his_api_controller.go 1.7MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. "encoding/json"
  8. "fmt"
  9. "gdyb/controllers"
  10. "gdyb/enums"
  11. "gdyb/models"
  12. "gdyb/service"
  13. "gdyb/utils"
  14. "github.com/astaxie/beego"
  15. "github.com/axgle/mahonia"
  16. "github.com/go-ole/go-ole/oleutil"
  17. "github.com/gorilla/websocket"
  18. "github.com/jinzhu/gorm"
  19. "github.com/shopspring/decimal"
  20. "io"
  21. "io/ioutil"
  22. "math"
  23. "math/rand"
  24. "net/http"
  25. "net/url"
  26. "os"
  27. "path/filepath"
  28. "regexp"
  29. "strconv"
  30. "strings"
  31. "syscall"
  32. "time"
  33. "unsafe"
  34. )
  35. type HisApiController struct {
  36. controllers.BaseAuthAPIController
  37. }
  38. func HisManagerApiRegistRouters() {
  39. //挂号
  40. beego.Router("/test/net", &HisApiController{}, "get:TestNet")
  41. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  42. //上传就诊信息-上传明细-结算
  43. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  44. //查询
  45. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  46. //对总账
  47. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  48. //对明细
  49. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  50. //退费,退明细
  51. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  52. //退号
  53. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  54. //退明细
  55. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  56. //上传就诊信息-上传明细-预结算
  57. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  58. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  59. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  60. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  61. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  62. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  63. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  64. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  65. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  66. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  67. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  68. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  69. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  70. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  71. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  72. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  73. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  74. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  75. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  76. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  77. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  78. beego.Router("/api/check", &HisApiController{}, "get:Check")
  79. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  80. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  81. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  82. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  83. beego.Router("/api/3204a", &HisApiController{}, "get:Post3204a")
  84. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  85. beego.Router("/api/8404", &HisApiController{}, "get:Post8404")
  86. beego.Router("/api/3204", &HisApiController{}, "get:Post3204")
  87. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  88. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  89. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  90. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  91. //beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  92. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  93. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  94. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  95. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  96. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  97. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  98. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  99. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  100. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  101. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  102. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  103. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  104. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  105. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  106. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  107. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  108. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  109. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  110. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  111. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  112. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  113. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  114. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  115. beego.Router("/api/CFYLJG012", &HisApiController{}, "get:GetCFYLJG12")
  116. beego.Router("/api/CFYLJG013", &HisApiController{}, "get:GetCFYLJG13")
  117. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  118. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  119. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  120. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  121. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  122. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  123. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  124. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  125. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  126. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  127. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  128. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  129. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  130. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  131. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  132. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  133. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  134. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  135. beego.Router("/api/3103", &HisApiController{}, "get:Get3103")
  136. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  137. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  138. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  139. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  140. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  141. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  142. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  143. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  144. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  145. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  146. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  147. //beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  148. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  149. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  150. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  151. //库盘和变更
  152. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  153. //删除库盘和变更
  154. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  155. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  156. //药品变更
  157. //beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  158. //beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  159. //beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  160. //beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  161. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  162. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  163. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  164. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  165. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  166. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  167. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  168. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  169. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  170. beego.Router("/api/changedrug/five", &HisApiController{}, "get:ChangeDrugFive")
  171. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  172. //beego.Router("/api/delete_xs_bg_three", &HisApiController{}, "get:DeleteXSandBGThree")
  173. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  174. beego.Router("/api/5101", &HisApiController{}, "get:Get5101")
  175. beego.Router("/api/5102", &HisApiController{}, "get:Get5102")
  176. }
  177. func (c *HisApiController) Get5101() {
  178. adminUser := c.GetAdminUserInfo()
  179. admin_user_id, _ := c.GetInt64("admin_user_id")
  180. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  181. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  182. if miConfig.MdtrtareaAdmvs == "341203" {
  183. fmt.Println(miConfig.SecretKey)
  184. var res models.Result9001Two
  185. 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 +
  186. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  187. resp, requestErr := http.Get(api)
  188. if requestErr != nil {
  189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  190. return
  191. }
  192. body, ioErr := ioutil.ReadAll(resp.Body)
  193. if ioErr != nil {
  194. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  196. return
  197. }
  198. var respJSON map[string]interface{}
  199. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  202. return
  203. }
  204. status := respJSON["data"].(map[string]interface{})["status"].(string)
  205. if status == "0" {
  206. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  207. c.ServeSuccessJSON(map[string]interface{}{
  208. "failed_code": -10,
  209. "msg": err_msg,
  210. })
  211. return
  212. }
  213. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  214. result, _ := json.Marshal(respJSON)
  215. fmt.Println("log")
  216. fmt.Println(string(result))
  217. if err := json.Unmarshal([]byte(result), &res); err != nil {
  218. utils.ErrorLog("解析失败:%v", err)
  219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  220. return
  221. }
  222. if res.Infcode == 0 {
  223. sign := models.HisSignIn{
  224. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  225. SignNo: res.Output.Signinoutb.SignNo,
  226. SignTime: "",
  227. Ctime: time.Now().Unix(),
  228. Mtime: time.Now().Unix(),
  229. Status: 1,
  230. InputLog: "",
  231. OutputLog: "",
  232. FixmedinsCode: miConfig.Code,
  233. }
  234. err := service.CreateSignIn(&sign)
  235. if err == nil {
  236. c.ServeSuccessJSON(map[string]interface{}{
  237. "msg": "签到成功",
  238. })
  239. }
  240. } else {
  241. c.ServeSuccessJSON(map[string]interface{}{
  242. "failed_code": -10,
  243. "msg": res.ErrMsg,
  244. })
  245. return
  246. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  247. //return
  248. }
  249. } else if miConfig.MdtrtareaAdmvs == "340699" {
  250. fmt.Println(miConfig.SecretKey)
  251. var res models.Result9001Two
  252. 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 +
  253. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  254. resp, requestErr := http.Get(api)
  255. if requestErr != nil {
  256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  257. return
  258. }
  259. body, ioErr := ioutil.ReadAll(resp.Body)
  260. if ioErr != nil {
  261. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  263. return
  264. }
  265. var respJSON map[string]interface{}
  266. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  269. return
  270. }
  271. status := respJSON["data"].(map[string]interface{})["status"].(string)
  272. if status == "0" {
  273. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  274. c.ServeSuccessJSON(map[string]interface{}{
  275. "failed_code": -10,
  276. "msg": err_msg,
  277. })
  278. return
  279. }
  280. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  281. result, _ := json.Marshal(respJSON)
  282. fmt.Println("log")
  283. fmt.Println(string(result))
  284. if err := json.Unmarshal([]byte(result), &res); err != nil {
  285. utils.ErrorLog("解析失败:%v", err)
  286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  287. return
  288. }
  289. if res.Infcode == 0 {
  290. sign := models.HisSignIn{
  291. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  292. SignNo: res.Output.Signinoutb.SignNo,
  293. SignTime: "",
  294. Ctime: time.Now().Unix(),
  295. Mtime: time.Now().Unix(),
  296. Status: 1,
  297. InputLog: "",
  298. OutputLog: "",
  299. FixmedinsCode: miConfig.Code,
  300. }
  301. err := service.CreateSignIn(&sign)
  302. if err == nil {
  303. c.ServeSuccessJSON(map[string]interface{}{
  304. "msg": "查询成功",
  305. })
  306. }
  307. } else {
  308. c.ServeSuccessJSON(map[string]interface{}{
  309. "failed_code": -10,
  310. "msg": res.ErrMsg,
  311. })
  312. return
  313. }
  314. }
  315. }
  316. func (c *HisApiController) Get5102() {
  317. adminUser := c.GetAdminUserInfo()
  318. admin_user_id, _ := c.GetInt64("admin_user_id")
  319. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  320. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  321. if miConfig.MdtrtareaAdmvs == "341203" {
  322. fmt.Println(miConfig.SecretKey)
  323. var res models.Result9001Two
  324. 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 +
  325. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  326. resp, requestErr := http.Get(api)
  327. if requestErr != nil {
  328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  329. return
  330. }
  331. body, ioErr := ioutil.ReadAll(resp.Body)
  332. if ioErr != nil {
  333. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  335. return
  336. }
  337. var respJSON map[string]interface{}
  338. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  339. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  341. return
  342. }
  343. status := respJSON["data"].(map[string]interface{})["status"].(string)
  344. if status == "0" {
  345. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  346. c.ServeSuccessJSON(map[string]interface{}{
  347. "failed_code": -10,
  348. "msg": err_msg,
  349. })
  350. return
  351. }
  352. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  353. result, _ := json.Marshal(respJSON)
  354. fmt.Println("log")
  355. fmt.Println(string(result))
  356. if err := json.Unmarshal([]byte(result), &res); err != nil {
  357. utils.ErrorLog("解析失败:%v", err)
  358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  359. return
  360. }
  361. if res.Infcode == 0 {
  362. sign := models.HisSignIn{
  363. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  364. SignNo: res.Output.Signinoutb.SignNo,
  365. SignTime: "",
  366. Ctime: time.Now().Unix(),
  367. Mtime: time.Now().Unix(),
  368. Status: 1,
  369. InputLog: "",
  370. OutputLog: "",
  371. FixmedinsCode: miConfig.Code,
  372. }
  373. err := service.CreateSignIn(&sign)
  374. if err == nil {
  375. c.ServeSuccessJSON(map[string]interface{}{
  376. "msg": "签到成功",
  377. })
  378. }
  379. } else {
  380. c.ServeSuccessJSON(map[string]interface{}{
  381. "failed_code": -10,
  382. "msg": res.ErrMsg,
  383. })
  384. return
  385. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  386. //return
  387. }
  388. } else if miConfig.MdtrtareaAdmvs == "340699" {
  389. fmt.Println(miConfig.SecretKey)
  390. var res models.Result9001Two
  391. 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 +
  392. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  393. resp, requestErr := http.Get(api)
  394. if requestErr != nil {
  395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  396. return
  397. }
  398. body, ioErr := ioutil.ReadAll(resp.Body)
  399. if ioErr != nil {
  400. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  402. return
  403. }
  404. var respJSON map[string]interface{}
  405. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  406. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  408. return
  409. }
  410. status := respJSON["data"].(map[string]interface{})["status"].(string)
  411. if status == "0" {
  412. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  413. c.ServeSuccessJSON(map[string]interface{}{
  414. "failed_code": -10,
  415. "msg": err_msg,
  416. })
  417. return
  418. }
  419. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  420. result, _ := json.Marshal(respJSON)
  421. fmt.Println("log")
  422. fmt.Println(string(result))
  423. if err := json.Unmarshal([]byte(result), &res); err != nil {
  424. utils.ErrorLog("解析失败:%v", err)
  425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  426. return
  427. }
  428. if res.Infcode == 0 {
  429. sign := models.HisSignIn{
  430. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  431. SignNo: res.Output.Signinoutb.SignNo,
  432. SignTime: "",
  433. Ctime: time.Now().Unix(),
  434. Mtime: time.Now().Unix(),
  435. Status: 1,
  436. InputLog: "",
  437. OutputLog: "",
  438. FixmedinsCode: miConfig.Code,
  439. }
  440. err := service.CreateSignIn(&sign)
  441. if err == nil {
  442. c.ServeSuccessJSON(map[string]interface{}{
  443. "msg": "查询成功",
  444. })
  445. }
  446. } else {
  447. c.ServeSuccessJSON(map[string]interface{}{
  448. "failed_code": -10,
  449. "msg": res.ErrMsg,
  450. })
  451. return
  452. }
  453. }
  454. }
  455. func (c *HisApiController) Get3201() {
  456. adminUser := c.GetAdminUserInfo()
  457. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  458. 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)
  459. var response Response
  460. if err := json.Unmarshal([]byte(result), &response); err != nil {
  461. fmt.Println("Error decoding JSON:", err)
  462. return
  463. }
  464. }
  465. func (c *HisApiController) TestNet() {
  466. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  467. //return
  468. c.ServeSuccessJSON(map[string]interface{}{
  469. "msg": "成功",
  470. })
  471. }
  472. func (c *HisApiController) Get3508() {
  473. admin_user_id, _ := c.GetInt64("admin_user_id")
  474. drug_id, _ := c.GetInt64("id")
  475. start_time := c.GetString("start_time")
  476. end_time := c.GetString("end_time")
  477. adminUser := c.GetAdminUserInfo()
  478. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  479. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  480. drug, _ := service.GetDrugByID(drug_id)
  481. var struct3508 models.Struct3508
  482. struct3508.OrgName = miConfig.OrgName
  483. struct3508.FixmedinsCode = miConfig.Code
  484. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  485. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  486. struct3508.AccessKey = miConfig.AccessKey
  487. struct3508.Opter = curRoles.UserName
  488. struct3508.RequestUrl = miConfig.Url
  489. struct3508.Url = miConfig.Url
  490. struct3508.AppId = miConfig.Cainfo
  491. struct3508.AppSecret = miConfig.AppSecret
  492. struct3508.Enckey = miConfig.EncKey
  493. struct3508.SignKey = miConfig.SignKey
  494. struct3508.SecretKey = miConfig.SecretKey
  495. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  496. struct3508.Begndate = start_time
  497. struct3508.Enddate = end_time
  498. struct3508.Enddate = end_time
  499. struct3508.Enddate = end_time
  500. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  501. result1, result2 := service.Gdyb3508(struct3508, struct3508.SecretKey)
  502. saveLog(result1, result2, "3508", "3508")
  503. var res models.Result3508
  504. var respJSON2 map[string]interface{}
  505. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  508. return
  509. }
  510. userJSONBytes2, _ := json.Marshal(respJSON2)
  511. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  512. utils.ErrorLog("解析失败:%v", err)
  513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  514. return
  515. }
  516. if res.Infcode == -1 {
  517. c.ServeSuccessJSON(map[string]interface{}{
  518. "failed_code": -10,
  519. "msg": res.ErrMsg,
  520. })
  521. } else {
  522. c.ServeSuccessJSON(map[string]interface{}{
  523. "info": res.Output,
  524. })
  525. }
  526. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  527. result1, result2, _ := service.FJyb3508(struct3508)
  528. saveLog(result1, result2, "3508", "3508")
  529. var res models.Result3508
  530. var respJSON2 map[string]interface{}
  531. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  532. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  534. return
  535. }
  536. userJSONBytes2, _ := json.Marshal(respJSON2)
  537. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  538. utils.ErrorLog("解析失败:%v", err)
  539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  540. return
  541. }
  542. if res.Infcode == -1 {
  543. c.ServeSuccessJSON(map[string]interface{}{
  544. "failed_code": -10,
  545. "msg": res.ErrMsg,
  546. })
  547. } else {
  548. c.ServeSuccessJSON(map[string]interface{}{
  549. "info": res.Output,
  550. })
  551. }
  552. }
  553. }
  554. func (c *HisApiController) Get3509() {
  555. admin_user_id, _ := c.GetInt64("admin_user_id")
  556. drug_id, _ := c.GetInt64("id")
  557. start_time := c.GetString("start_time")
  558. end_time := c.GetString("end_time")
  559. adminUser := c.GetAdminUserInfo()
  560. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  561. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  562. drug, _ := service.GetDrugByID(drug_id)
  563. var struct3508 models.Struct3509
  564. struct3508.OrgName = miConfig.OrgName
  565. struct3508.FixmedinsCode = miConfig.Code
  566. struct3508.AccessKey = miConfig.AccessKey
  567. struct3508.Opter = curRoles.UserName
  568. struct3508.RequestUrl = miConfig.Url
  569. struct3508.Url = miConfig.Url
  570. struct3508.AppId = miConfig.Cainfo
  571. struct3508.AppSecret = miConfig.AppSecret
  572. struct3508.Enckey = miConfig.EncKey
  573. struct3508.SignKey = miConfig.SignKey
  574. struct3508.SecretKey = miConfig.SecretKey
  575. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  576. struct3508.Begndate = start_time
  577. struct3508.Enddate = end_time
  578. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  579. result1, result2 := service.Gdyb3509(struct3508, struct3508.SecretKey)
  580. saveLog(result1, result2, "3509", "3509")
  581. var res models.Result3508
  582. var respJSON2 map[string]interface{}
  583. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  586. return
  587. }
  588. userJSONBytes2, _ := json.Marshal(respJSON2)
  589. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  590. utils.ErrorLog("解析失败:%v", err)
  591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  592. return
  593. }
  594. if res.Infcode == -1 {
  595. c.ServeSuccessJSON(map[string]interface{}{
  596. "failed_code": -10,
  597. "msg": res.ErrMsg,
  598. })
  599. } else {
  600. c.ServeSuccessJSON(map[string]interface{}{
  601. "info": res.Output,
  602. })
  603. }
  604. } else {
  605. result1, result2, _ := service.FJyb3509(struct3508)
  606. saveLog(result1, result2, "3509", "3509")
  607. var res models.Result3509
  608. var respJSON2 map[string]interface{}
  609. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  610. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  612. return
  613. }
  614. userJSONBytes2, _ := json.Marshal(respJSON2)
  615. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  616. utils.ErrorLog("解析失败:%v", err)
  617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  618. return
  619. }
  620. if res.Infcode == -1 {
  621. c.ServeSuccessJSON(map[string]interface{}{
  622. "failed_code": -10,
  623. "msg": res.ErrMsg,
  624. })
  625. } else {
  626. c.ServeSuccessJSON(map[string]interface{}{
  627. "info": res.Output,
  628. })
  629. }
  630. }
  631. }
  632. func (c *HisApiController) Get3510() {
  633. admin_user_id, _ := c.GetInt64("admin_user_id")
  634. drug_id, _ := c.GetInt64("id")
  635. start_time := c.GetString("start_time")
  636. end_time := c.GetString("end_time")
  637. adminUser := c.GetAdminUserInfo()
  638. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  639. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  640. drug, _ := service.GetDrugByID(drug_id)
  641. var struct3508 models.Struct3510
  642. struct3508.FixmedinsCode = miConfig.Code
  643. struct3508.OrgName = miConfig.OrgName
  644. struct3508.AccessKey = miConfig.AccessKey
  645. struct3508.Opter = curRoles.UserName
  646. struct3508.RequestUrl = miConfig.Url
  647. struct3508.Url = miConfig.Url
  648. struct3508.AppId = miConfig.Cainfo
  649. struct3508.AppSecret = miConfig.AppSecret
  650. struct3508.Enckey = miConfig.EncKey
  651. struct3508.SignKey = miConfig.SignKey
  652. struct3508.SecretKey = miConfig.SecretKey
  653. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  654. struct3508.Begndate = start_time
  655. struct3508.Enddate = end_time
  656. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  657. result1, result2 := service.Gdyb3510(struct3508, struct3508.SecretKey)
  658. saveLog(result1, result2, "3510", "3510")
  659. var res models.Result3510
  660. var respJSON2 map[string]interface{}
  661. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  662. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  664. return
  665. }
  666. userJSONBytes2, _ := json.Marshal(respJSON2)
  667. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  668. utils.ErrorLog("解析失败:%v", err)
  669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  670. return
  671. }
  672. if res.Infcode == -1 {
  673. c.ServeSuccessJSON(map[string]interface{}{
  674. "failed_code": -10,
  675. "msg": res.ErrMsg,
  676. })
  677. } else {
  678. c.ServeSuccessJSON(map[string]interface{}{
  679. "info": res.Output,
  680. })
  681. }
  682. } else {
  683. result1, result2, _ := service.FJyb3510(struct3508)
  684. saveLog(result1, result2, "3510", "3510")
  685. var res models.Result3510
  686. var respJSON2 map[string]interface{}
  687. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  688. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  690. return
  691. }
  692. userJSONBytes2, _ := json.Marshal(respJSON2)
  693. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  694. utils.ErrorLog("解析失败:%v", err)
  695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  696. return
  697. }
  698. if res.Infcode == -1 {
  699. c.ServeSuccessJSON(map[string]interface{}{
  700. "failed_code": -10,
  701. "msg": res.ErrMsg,
  702. })
  703. } else {
  704. c.ServeSuccessJSON(map[string]interface{}{
  705. "info": res.Output,
  706. })
  707. }
  708. }
  709. }
  710. func (c *HisApiController) Get3511() {
  711. admin_user_id, _ := c.GetInt64("admin_user_id")
  712. drug_id, _ := c.GetInt64("id")
  713. start_time := c.GetString("start_time")
  714. end_time := c.GetString("end_time")
  715. adminUser := c.GetAdminUserInfo()
  716. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  717. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  718. drug, _ := service.GetDrugByID(drug_id)
  719. var struct3508 models.Struct3511
  720. struct3508.FixmedinsCode = miConfig.Code
  721. struct3508.OrgName = miConfig.OrgName
  722. struct3508.AccessKey = miConfig.AccessKey
  723. struct3508.Opter = curRoles.UserName
  724. struct3508.RequestUrl = miConfig.Url
  725. struct3508.Url = miConfig.Url
  726. struct3508.AppId = miConfig.Cainfo
  727. struct3508.AppSecret = miConfig.AppSecret
  728. struct3508.Enckey = miConfig.EncKey
  729. struct3508.SignKey = miConfig.SignKey
  730. struct3508.SecretKey = miConfig.SecretKey
  731. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  732. struct3508.Begndate = start_time
  733. struct3508.Enddate = end_time
  734. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  735. result1, result2 := service.Gdyb3511(struct3508, struct3508.SecretKey)
  736. saveLog(result1, result2, "3511", "3511")
  737. var res models.Result3511
  738. var respJSON2 map[string]interface{}
  739. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  740. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  742. return
  743. }
  744. userJSONBytes2, _ := json.Marshal(respJSON2)
  745. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  746. utils.ErrorLog("解析失败:%v", err)
  747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  748. return
  749. }
  750. if res.Infcode == -1 {
  751. c.ServeSuccessJSON(map[string]interface{}{
  752. "failed_code": -10,
  753. "msg": res.ErrMsg,
  754. })
  755. } else {
  756. c.ServeSuccessJSON(map[string]interface{}{
  757. "info": res.Output,
  758. })
  759. }
  760. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  761. var res models.Result3511
  762. //安徽
  763. data := make(map[string]interface{})
  764. data["struct_3511s"] = struct3508
  765. client := &http.Client{}
  766. bytesData, _ := json.Marshal(data)
  767. var req *http.Request
  768. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3511", bytes.NewReader(bytesData))
  769. resp, _ := client.Do(req)
  770. defer resp.Body.Close()
  771. body, ioErr := ioutil.ReadAll(resp.Body)
  772. if ioErr != nil {
  773. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  774. }
  775. var respJSON map[string]interface{}
  776. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  777. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  779. return
  780. }
  781. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  782. result, _ := json.Marshal(respJSON)
  783. if err := json.Unmarshal([]byte(result), &res); err != nil {
  784. //utils.ErrorLog("解析失败:%v", err)
  785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  786. return
  787. }
  788. if res.Infcode == -1 {
  789. c.ServeSuccessJSON(map[string]interface{}{
  790. "failed_code": -10,
  791. "msg": res.ErrMsg,
  792. })
  793. } else {
  794. c.ServeSuccessJSON(map[string]interface{}{
  795. "info": res.Output,
  796. })
  797. }
  798. } else {
  799. result1, result2, _ := service.FJyb3511(struct3508)
  800. saveLog(result1, result2, "3511", "3511")
  801. var res models.Result3511
  802. var respJSON2 map[string]interface{}
  803. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  804. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  806. return
  807. }
  808. userJSONBytes2, _ := json.Marshal(respJSON2)
  809. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  810. utils.ErrorLog("解析失败:%v", err)
  811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  812. return
  813. }
  814. if res.Infcode == -1 {
  815. c.ServeSuccessJSON(map[string]interface{}{
  816. "failed_code": -10,
  817. "msg": res.ErrMsg,
  818. })
  819. } else {
  820. c.ServeSuccessJSON(map[string]interface{}{
  821. "info": res.Output,
  822. })
  823. }
  824. }
  825. }
  826. func (c *HisApiController) Get3512() {
  827. admin_user_id, _ := c.GetInt64("admin_user_id")
  828. drug_id, _ := c.GetInt64("id")
  829. start_time := c.GetString("start_time")
  830. end_time := c.GetString("end_time")
  831. adminUser := c.GetAdminUserInfo()
  832. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  833. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  834. drug, _ := service.GetDrugByIDTwo(drug_id, adminUser.CurrentOrgId)
  835. var infos models.Output2
  836. for _, item := range drug {
  837. var struct3508 models.Struct3512
  838. struct3508.FixmedinsCode = miConfig.Code
  839. struct3508.OrgName = miConfig.OrgName
  840. struct3508.AccessKey = miConfig.AccessKey
  841. struct3508.Opter = curRoles.UserName
  842. struct3508.RequestUrl = miConfig.Url
  843. struct3508.Url = miConfig.Url
  844. struct3508.AppId = miConfig.Cainfo
  845. struct3508.AppSecret = miConfig.AppSecret
  846. struct3508.Enckey = miConfig.EncKey
  847. struct3508.SignKey = miConfig.SignKey
  848. struct3508.SecretKey = miConfig.SecretKey
  849. struct3508.MedListCodg = item.MedicalInsuranceNumber
  850. struct3508.Begndate = start_time
  851. struct3508.Enddate = end_time
  852. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  853. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  854. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  855. result1, result2 := service.Gdyb3512(struct3508, struct3508.SecretKey)
  856. saveLog(result1, result2, "3512", "3512")
  857. var res models.Result3512
  858. var respJSON2 map[string]interface{}
  859. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  862. return
  863. }
  864. userJSONBytes2, _ := json.Marshal(respJSON2)
  865. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  866. utils.ErrorLog("解析失败:%v", err)
  867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  868. return
  869. }
  870. for _, item := range res.Output {
  871. if item.ValiFlag == "1" {
  872. infos = append(infos, item)
  873. }
  874. }
  875. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  876. result1, result2, _ := service.FJyb3512(struct3508)
  877. saveLog(result1, result2, "3512", "3512")
  878. var res models.Result3512
  879. var respJSON2 map[string]interface{}
  880. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  883. return
  884. }
  885. userJSONBytes2, _ := json.Marshal(respJSON2)
  886. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  887. utils.ErrorLog("解析失败:%v", err)
  888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  889. return
  890. }
  891. for _, item := range res.Output {
  892. if item.ValiFlag == "1" {
  893. infos = append(infos, item)
  894. }
  895. }
  896. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  897. var res models.Result3512
  898. //安徽
  899. data := make(map[string]interface{})
  900. data["struct_3512s"] = struct3508
  901. client := &http.Client{}
  902. bytesData, _ := json.Marshal(data)
  903. var req *http.Request
  904. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3512", bytes.NewReader(bytesData))
  905. resp, _ := client.Do(req)
  906. defer resp.Body.Close()
  907. body, ioErr := ioutil.ReadAll(resp.Body)
  908. if ioErr != nil {
  909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  910. }
  911. var respJSON map[string]interface{}
  912. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  913. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  915. return
  916. }
  917. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  918. result, _ := json.Marshal(respJSON)
  919. if err := json.Unmarshal([]byte(result), &res); err != nil {
  920. //utils.ErrorLog("解析失败:%v", err)
  921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  922. return
  923. }
  924. for _, item := range res.Output {
  925. if item.ValiFlag == "1" {
  926. infos = append(infos, item)
  927. }
  928. }
  929. }
  930. }
  931. c.ServeSuccessJSON(map[string]interface{}{
  932. "info": infos,
  933. })
  934. }
  935. func (c *HisApiController) Get3513() {
  936. admin_user_id, _ := c.GetInt64("admin_user_id")
  937. drug_id, _ := c.GetInt64("id")
  938. start_time := c.GetString("start_time")
  939. end_time := c.GetString("end_time")
  940. adminUser := c.GetAdminUserInfo()
  941. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  942. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  943. //drug, _ := service.GetDrugByID(drug_id)
  944. drug, _ := service.GetDrugByIDTwo(drug_id, adminUser.CurrentOrgId)
  945. var infos models.Output3
  946. for _, item := range drug {
  947. var struct3508 models.Struct3513
  948. struct3508.FixmedinsCode = miConfig.Code
  949. struct3508.OrgName = miConfig.OrgName
  950. struct3508.AccessKey = miConfig.AccessKey
  951. struct3508.Opter = curRoles.UserName
  952. struct3508.RequestUrl = miConfig.Url
  953. struct3508.Url = miConfig.Url
  954. struct3508.AppId = miConfig.Cainfo
  955. struct3508.AppSecret = miConfig.AppSecret
  956. struct3508.Enckey = miConfig.EncKey
  957. struct3508.SignKey = miConfig.SignKey
  958. struct3508.SecretKey = miConfig.SecretKey
  959. struct3508.MedListCodg = item.MedicalInsuranceNumber
  960. struct3508.Begndate = start_time
  961. struct3508.Enddate = end_time
  962. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  963. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  964. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  965. result1, result2 := service.Gdyb3513(struct3508, struct3508.SecretKey)
  966. saveLog(result1, result2, "3513", "3513")
  967. var res models.Result3513
  968. var respJSON2 map[string]interface{}
  969. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  970. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  972. return
  973. }
  974. userJSONBytes2, _ := json.Marshal(respJSON2)
  975. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  976. utils.ErrorLog("解析失败:%v", err)
  977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  978. return
  979. }
  980. infos = append(infos, res.Output...)
  981. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  982. result1, result2, _ := service.FJyb3513(struct3508)
  983. saveLog(result1, result2, "3513", "3513")
  984. var res models.Result3513
  985. var respJSON2 map[string]interface{}
  986. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  989. return
  990. }
  991. userJSONBytes2, _ := json.Marshal(respJSON2)
  992. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  993. utils.ErrorLog("解析失败:%v", err)
  994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  995. return
  996. }
  997. infos = append(infos, res.Output...)
  998. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  999. var res models.Result3513
  1000. //安徽
  1001. data := make(map[string]interface{})
  1002. data["struct_3513s"] = struct3508
  1003. client := &http.Client{}
  1004. bytesData, _ := json.Marshal(data)
  1005. var req *http.Request
  1006. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3513", bytes.NewReader(bytesData))
  1007. resp, _ := client.Do(req)
  1008. defer resp.Body.Close()
  1009. body, ioErr := ioutil.ReadAll(resp.Body)
  1010. if ioErr != nil {
  1011. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1012. }
  1013. var respJSON map[string]interface{}
  1014. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1017. return
  1018. }
  1019. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1020. result, _ := json.Marshal(respJSON)
  1021. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1022. //utils.ErrorLog("解析失败:%v", err)
  1023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1024. return
  1025. }
  1026. infos = append(infos, res.Output...)
  1027. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") { //
  1028. result1, result2 := service.JXyb3513(struct3508, struct3508.SecretKey, struct3508.AccessKey, struct3508.RequestUrl)
  1029. saveLog(result1, result2, "3513", "3513")
  1030. var res models.Result3513
  1031. var respJSON2 map[string]interface{}
  1032. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1033. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1035. return
  1036. }
  1037. userJSONBytes2, _ := json.Marshal(respJSON2)
  1038. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1039. utils.ErrorLog("解析失败:%v", err)
  1040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1041. return
  1042. }
  1043. infos = append(infos, res.Output...)
  1044. }
  1045. }
  1046. type Newinfo struct {
  1047. FixmedinsCode string
  1048. MedListCodg string
  1049. MedinsListCodg string
  1050. MedinsListName string
  1051. FixmedinsBchno string
  1052. MdtrtId string
  1053. MdtrtSetlType string
  1054. BkkpSn string
  1055. DrugTracCodg string
  1056. PsnNo string
  1057. PsnCertType string
  1058. Certno string
  1059. PsnName string
  1060. Memo string
  1061. TrdnFlag string
  1062. UpdtTime string
  1063. OpterName string
  1064. Rid string
  1065. CrteTime string
  1066. OptTime string
  1067. OpterId string
  1068. CrterName string
  1069. CrterId string
  1070. OptinsNo string
  1071. }
  1072. var Newinfos []Newinfo
  1073. for _, item := range infos {
  1074. var ni Newinfo
  1075. patient, _ := service.GetPatientByIDCard(item.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1076. //patient, _ := service.GetPatientByIDCard(item.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1077. numbers := strings.Split(item.FixmedinsBchno, "-")
  1078. flow := service.GetSaleDate(numbers[1])
  1079. ni.MdtrtId = item.MdtrtId
  1080. ni.UpdtTime = flow.SaleDate
  1081. ni.PsnName = patient.Name
  1082. ni.Certno = item.Certno
  1083. ni.MedinsListName = item.MedinsListName
  1084. ni.FixmedinsBchno = item.FixmedinsBchno
  1085. ni.DrugTracCodg = item.DrugTracCodg
  1086. ni.MedListCodg = patient.Name
  1087. Newinfos = append(Newinfos, ni)
  1088. }
  1089. c.ServeSuccessJSON(map[string]interface{}{
  1090. "info": Newinfos,
  1091. })
  1092. }
  1093. func (c *HisApiController) Get35081() {
  1094. admin_user_id, _ := c.GetInt64("admin_user_id")
  1095. drug_id, _ := c.GetInt64("id")
  1096. //start_time := c.GetString("start_time")
  1097. //end_time := c.GetString("end_time")
  1098. page, _ := c.GetInt("page")
  1099. adminUser := c.GetAdminUserInfo()
  1100. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1101. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1102. drug, _ := service.GetDrugByID(drug_id)
  1103. var struct3508 models.Struct35081
  1104. struct3508.FixmedinsCode = miConfig.Code
  1105. struct3508.OrgName = miConfig.OrgName
  1106. struct3508.AccessKey = miConfig.AccessKey
  1107. struct3508.Opter = curRoles.UserName
  1108. struct3508.RequestUrl = miConfig.Url
  1109. struct3508.Url = miConfig.Url
  1110. struct3508.AppId = miConfig.Cainfo
  1111. struct3508.AppSecret = miConfig.AppSecret
  1112. struct3508.Enckey = miConfig.EncKey
  1113. struct3508.SignKey = miConfig.SignKey
  1114. struct3508.SecretKey = miConfig.SecretKey
  1115. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  1116. struct3508.PageNum = page
  1117. struct3508.PageSize = 10
  1118. result1, result2, _ := service.FJyb35081(struct3508)
  1119. saveLog(result1, result2, "35081", "35081")
  1120. var res models.Result35081
  1121. var respJSON2 map[string]interface{}
  1122. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1123. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1125. return
  1126. }
  1127. userJSONBytes2, _ := json.Marshal(respJSON2)
  1128. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1129. utils.ErrorLog("解析失败:%v", err)
  1130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1131. return
  1132. }
  1133. if res.Infcode == -1 {
  1134. c.ServeSuccessJSON(map[string]interface{}{
  1135. "failed_code": -10,
  1136. "msg": res.ErrMsg,
  1137. })
  1138. } else {
  1139. c.ServeSuccessJSON(map[string]interface{}{
  1140. "info": res.Output,
  1141. })
  1142. }
  1143. }
  1144. func (c *HisApiController) Get35082() {
  1145. admin_user_id, _ := c.GetInt64("admin_user_id")
  1146. drug_id, _ := c.GetInt64("id")
  1147. //start_time := c.GetString("start_time")
  1148. //end_time := c.GetString("end_time")
  1149. page, _ := c.GetInt("page")
  1150. adminUser := c.GetAdminUserInfo()
  1151. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1152. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1153. drug, _ := service.GetDrugByID(drug_id)
  1154. var struct3508 models.Struct35082
  1155. struct3508.FixmedinsCode = miConfig.Code
  1156. struct3508.OrgName = miConfig.OrgName
  1157. struct3508.AccessKey = miConfig.AccessKey
  1158. struct3508.Opter = curRoles.UserName
  1159. struct3508.RequestUrl = miConfig.Url
  1160. struct3508.Url = miConfig.Url
  1161. struct3508.AppId = miConfig.Cainfo
  1162. struct3508.AppSecret = miConfig.AppSecret
  1163. struct3508.Enckey = miConfig.EncKey
  1164. struct3508.SignKey = miConfig.SignKey
  1165. struct3508.SecretKey = miConfig.SecretKey
  1166. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  1167. struct3508.PageNum = page
  1168. struct3508.PageSize = 10
  1169. result1, result2, _ := service.FJyb35082(struct3508)
  1170. saveLog(result1, result2, "35082", "35082")
  1171. var res models.Result35082
  1172. var respJSON2 map[string]interface{}
  1173. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1176. return
  1177. }
  1178. userJSONBytes2, _ := json.Marshal(respJSON2)
  1179. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1180. utils.ErrorLog("解析失败:%v", err)
  1181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1182. return
  1183. }
  1184. if res.Infcode == -1 {
  1185. c.ServeSuccessJSON(map[string]interface{}{
  1186. "failed_code": -10,
  1187. "msg": res.ErrMsg,
  1188. })
  1189. } else {
  1190. c.ServeSuccessJSON(map[string]interface{}{
  1191. "info": res.Output,
  1192. })
  1193. }
  1194. }
  1195. func IsDigit(s string) bool {
  1196. re := regexp.MustCompile("^[0-9]+$")
  1197. return re.MatchString(s)
  1198. }
  1199. func (c *HisApiController) FJ3501AND3502() {
  1200. ids := c.GetString("ids")
  1201. admin_user_id, _ := c.GetInt64("admin_user_id")
  1202. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1203. id_arr := strings.Split(ids, ",")
  1204. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1205. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1206. //规则判断
  1207. var errs []string
  1208. for _, drug := range drugs {
  1209. if drug.IsPc == 0 {
  1210. if len(drug.DrugCode) > 0 {
  1211. codes := strings.Split(drug.DrugCode, ",")
  1212. for _, code := range codes {
  1213. if len(code) > 0 {
  1214. if len(code) != 20 {
  1215. errs = append(errs, drug.BaseDrugLib.DrugName+" 溯源码"+code+"位数不是20位")
  1216. }
  1217. if IsDigit(code) == false {
  1218. errs = append(errs, drug.BaseDrugLib.DrugName+" 溯源码"+code+"不是纯数字")
  1219. }
  1220. }
  1221. }
  1222. }
  1223. }
  1224. }
  1225. if len(errs) > 0 {
  1226. c.ServeSuccessJSON(map[string]interface{}{
  1227. "failed_code": -10,
  1228. "msg": errs,
  1229. })
  1230. return
  1231. }
  1232. //库盘
  1233. for _, drug := range drugs {
  1234. if drug.IsPc == 0 {
  1235. var res2 ResultSix
  1236. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  1237. var struct3501 models.Struct3501
  1238. struct3501.Code = miConfig.Code
  1239. struct3501.OrgName = miConfig.OrgName
  1240. struct3501.AccessKey = miConfig.AccessKey
  1241. struct3501.Opter = roles.UserName
  1242. struct3501.RequestUrl = miConfig.Url
  1243. struct3501.Url = miConfig.Url
  1244. struct3501.AppId = miConfig.Cainfo
  1245. struct3501.AppSecret = miConfig.AppSecret
  1246. struct3501.Enckey = miConfig.EncKey
  1247. struct3501.SignKey = miConfig.SignKey
  1248. struct3501.SecretKey = miConfig.SecretKey
  1249. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  1250. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  1251. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  1252. struct3501.RxFlag = "1"
  1253. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  1254. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  1255. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1256. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1257. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  1258. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  1259. struct3501.FixmedinsBchno = number
  1260. struct3501.DrugTracCodg = drug.DrugCode
  1261. memo := make(map[string]interface{})
  1262. memo["pric"] = drug.Price
  1263. bytesData, _ := json.Marshal(memo)
  1264. struct3501.Memo = string(bytesData)
  1265. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  1266. result1, result2, _ := service.FJyb3501(struct3501)
  1267. saveLog(result1, result2, "3501", "3501")
  1268. //saveLog(result, requestLog, "2201", "挂号")
  1269. var respJSON2 map[string]interface{}
  1270. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1273. return
  1274. }
  1275. userJSONBytes2, _ := json.Marshal(respJSON2)
  1276. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1277. utils.ErrorLog("解析失败:%v", err)
  1278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1279. return
  1280. }
  1281. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  1282. data := make(map[string]interface{})
  1283. data["struct_3501s"] = struct3501
  1284. client := &http.Client{}
  1285. bytesData, _ := json.Marshal(data)
  1286. var req *http.Request
  1287. if miConfig.MdtrtareaAdmvs == "320830" {
  1288. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  1289. } else {
  1290. if miConfig.MdtrtareaAdmvs == "320921" {
  1291. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  1292. } else {
  1293. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  1294. }
  1295. }
  1296. resp, _ := client.Do(req)
  1297. defer resp.Body.Close()
  1298. body, ioErr := ioutil.ReadAll(resp.Body)
  1299. if ioErr != nil {
  1300. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1301. }
  1302. var respJSON map[string]interface{}
  1303. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1304. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1306. return
  1307. }
  1308. var resSix10265 ResultSix10265 //1101结果
  1309. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1310. result, _ := json.Marshal(respJSON)
  1311. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1312. utils.ErrorLog("解析失败:%v", err)
  1313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1314. return
  1315. }
  1316. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1317. res2.Output = resSix10265.Output
  1318. res2.ErrMsg = resSix10265.ErrMsg
  1319. res2.Cainfo = resSix10265.Cainfo
  1320. res2.WarnMsg = resSix10265.WarnMsg
  1321. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1322. res2.Infcode = infocode
  1323. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  1324. data := make(map[string]interface{})
  1325. data["struct_3501s"] = struct3501
  1326. client := &http.Client{}
  1327. bytesData, _ := json.Marshal(data)
  1328. var req *http.Request
  1329. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  1330. resp, _ := client.Do(req)
  1331. defer resp.Body.Close()
  1332. body, ioErr := ioutil.ReadAll(resp.Body)
  1333. if ioErr != nil {
  1334. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1335. }
  1336. var respJSON map[string]interface{}
  1337. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1338. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1340. return
  1341. }
  1342. var resSix10265 ResultSix10265 //1101结果
  1343. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1344. result, _ := json.Marshal(respJSON)
  1345. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1346. utils.ErrorLog("解析失败:%v", err)
  1347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1348. return
  1349. }
  1350. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1351. res2.Output = resSix10265.Output
  1352. res2.ErrMsg = resSix10265.ErrMsg
  1353. res2.Cainfo = resSix10265.Cainfo
  1354. res2.WarnMsg = resSix10265.WarnMsg
  1355. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1356. res2.Infcode = infocode
  1357. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  1358. data := make(map[string]interface{})
  1359. data["struct_3501s"] = struct3501
  1360. client := &http.Client{}
  1361. bytesData, _ := json.Marshal(data)
  1362. var req *http.Request
  1363. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  1364. resp, _ := client.Do(req)
  1365. defer resp.Body.Close()
  1366. body, ioErr := ioutil.ReadAll(resp.Body)
  1367. if ioErr != nil {
  1368. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1369. }
  1370. var respJSON map[string]interface{}
  1371. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1372. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1374. return
  1375. }
  1376. var resSix10265 ResultSix10265 //1101结果
  1377. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1378. result, _ := json.Marshal(respJSON)
  1379. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1380. utils.ErrorLog("解析失败:%v", err)
  1381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1382. return
  1383. }
  1384. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1385. res2.Output = resSix10265.Output
  1386. res2.ErrMsg = resSix10265.ErrMsg
  1387. res2.Cainfo = resSix10265.Cainfo
  1388. res2.WarnMsg = resSix10265.WarnMsg
  1389. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1390. res2.Infcode = infocode
  1391. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  1392. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  1393. saveLog(result1, result2, "3501", "3501")
  1394. //saveLog(result, requestLog, "2201", "挂号")
  1395. var respJSON2 map[string]interface{}
  1396. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1397. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1399. return
  1400. }
  1401. userJSONBytes2, _ := json.Marshal(respJSON2)
  1402. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1403. utils.ErrorLog("解析失败:%v", err)
  1404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1405. return
  1406. }
  1407. }
  1408. utils.ErrorLog("解析失败:%v", res2.Infcode)
  1409. if res2.Infcode != -1 {
  1410. drug.IsPc = 1
  1411. drug.Bchno = number
  1412. drug.PcDate = time.Now().Unix()
  1413. service.SaveW(drug)
  1414. //if err == nil {
  1415. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  1416. // var struct3502 models.Struct3502
  1417. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  1418. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  1419. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  1420. // struct3502.FixmedinsCode = miConfig.Code
  1421. // struct3502.Code = miConfig.Code
  1422. //
  1423. // struct3502.RxFlag = "0"
  1424. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  1425. // struct3502.OrgName = miConfig.OrgName
  1426. // struct3502.Opter = roles.UserName
  1427. // struct3502.AccessKey = miConfig.AccessKey
  1428. // struct3502.RequestUrl = miConfig.Url
  1429. // struct3502.SecretKey = miConfig.SecretKey
  1430. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1431. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1432. // struct3502.Url = miConfig.Url
  1433. // struct3502.AppId = miConfig.Cainfo
  1434. // struct3502.AppSecret = miConfig.AppSecret
  1435. // struct3502.Enckey = miConfig.EncKey
  1436. // struct3502.SignKey = miConfig.SignKey
  1437. // struct3502.SecretKey = miConfig.SecretKey
  1438. // struct3502.DrugTracCodg = drug.DrugCode
  1439. //
  1440. // struct3502.Memo = ""
  1441. // struct3502.InvChgType = "108"
  1442. // struct3502.FixmedinsBchno = bg_number
  1443. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  1444. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  1445. //
  1446. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  1447. // result11, result22, _ := service.FJyb3502(struct3502)
  1448. // saveLog(result11, result22, "3502", "3502")
  1449. //
  1450. // var respJSON3 map[string]interface{}
  1451. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1452. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1453. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1454. // return
  1455. // }
  1456. // userJSONBytes3, _ := json.Marshal(respJSON3)
  1457. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1458. // utils.ErrorLog("解析失败:%v", err)
  1459. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1460. // return
  1461. // }
  1462. //
  1463. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  1464. // data := make(map[string]interface{})
  1465. // data["struct_3502s"] = struct3502
  1466. // client := &http.Client{}
  1467. // bytesData, _ := json.Marshal(data)
  1468. // var req *http.Request
  1469. // if miConfig.MdtrtareaAdmvs == "320830" {
  1470. // req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3502", bytes.NewReader(bytesData))
  1471. // } else if miConfig.MdtrtareaAdmvs == "320921" {
  1472. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1473. // } else {
  1474. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1475. // }
  1476. //
  1477. // resp, _ := client.Do(req)
  1478. // defer resp.Body.Close()
  1479. // body, ioErr := ioutil.ReadAll(resp.Body)
  1480. // if ioErr != nil {
  1481. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1482. // }
  1483. // var respJSON map[string]interface{}
  1484. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1485. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1486. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1487. // return
  1488. // }
  1489. // var resSix10265 ResultSix10265 //1101结果
  1490. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1491. // result, _ := json.Marshal(respJSON)
  1492. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1493. // utils.ErrorLog("解析失败:%v", err)
  1494. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1495. // return
  1496. // }
  1497. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  1498. // res3.Output = resSix10265.Output
  1499. // res3.ErrMsg = resSix10265.ErrMsg
  1500. // res3.Cainfo = resSix10265.Cainfo
  1501. // res3.WarnMsg = resSix10265.WarnMsg
  1502. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1503. // res3.Infcode = infocode
  1504. //
  1505. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  1506. //
  1507. // data := make(map[string]interface{})
  1508. // data["struct_3502s"] = struct3502
  1509. // client := &http.Client{}
  1510. // bytesData, _ := json.Marshal(data)
  1511. // var req *http.Request
  1512. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  1513. // resp, _ := client.Do(req)
  1514. // defer resp.Body.Close()
  1515. // body, ioErr := ioutil.ReadAll(resp.Body)
  1516. // if ioErr != nil {
  1517. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1518. // }
  1519. // var respJSON map[string]interface{}
  1520. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1521. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1522. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1523. // return
  1524. // }
  1525. // var resSix10265 ResultSix10265 //1101结果
  1526. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1527. // result, _ := json.Marshal(respJSON)
  1528. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1529. // utils.ErrorLog("解析失败:%v", err)
  1530. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1531. // return
  1532. // }
  1533. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  1534. // res3.Output = resSix10265.Output
  1535. // res3.ErrMsg = resSix10265.ErrMsg
  1536. // res3.Cainfo = resSix10265.Cainfo
  1537. // res3.WarnMsg = resSix10265.WarnMsg
  1538. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1539. // res3.Infcode = infocode
  1540. //
  1541. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  1542. //
  1543. // data := make(map[string]interface{})
  1544. // data["struct_3501s"] = struct3501
  1545. // client := &http.Client{}
  1546. // bytesData, _ := json.Marshal(data)
  1547. // var req *http.Request
  1548. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  1549. // resp, _ := client.Do(req)
  1550. // defer resp.Body.Close()
  1551. // body, ioErr := ioutil.ReadAll(resp.Body)
  1552. // if ioErr != nil {
  1553. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1554. // }
  1555. // var respJSON map[string]interface{}
  1556. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1557. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1558. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1559. // return
  1560. // }
  1561. // var resSix10265 ResultSix10265 //1101结果
  1562. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1563. // result, _ := json.Marshal(respJSON)
  1564. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1565. // utils.ErrorLog("解析失败:%v", err)
  1566. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1567. // return
  1568. // }
  1569. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  1570. // res2.Output = resSix10265.Output
  1571. // res2.ErrMsg = resSix10265.ErrMsg
  1572. // res2.Cainfo = resSix10265.Cainfo
  1573. // res2.WarnMsg = resSix10265.WarnMsg
  1574. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1575. // res2.Infcode = infocode
  1576. //
  1577. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  1578. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  1579. // saveLog(result11, result22, "3502", "3502")
  1580. //
  1581. // var respJSON3 map[string]interface{}
  1582. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1583. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1584. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1585. // return
  1586. // }
  1587. // userJSONBytes3, _ := json.Marshal(respJSON3)
  1588. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1589. // utils.ErrorLog("解析失败:%v", err)
  1590. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1591. // return
  1592. // }
  1593. // }
  1594. // if res3.Infcode == -1 {
  1595. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  1596. // c.ServeSuccessJSON(map[string]interface{}{
  1597. // "failed_code": -10,
  1598. // "msg": res3.ErrMsg,
  1599. // })
  1600. // } else {
  1601. // drug.IsBg = 1
  1602. // drug.BgBchno = bg_number
  1603. // service.SaveW(drug)
  1604. // }
  1605. //}
  1606. //} else {
  1607. } else {
  1608. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  1609. }
  1610. }
  1611. //变更
  1612. }
  1613. if len(errs) == 0 {
  1614. c.ServeSuccessJSON(map[string]interface{}{
  1615. "msg": "盘存变更成功",
  1616. })
  1617. } else {
  1618. c.ServeSuccessJSON(map[string]interface{}{
  1619. "failed_code": -10,
  1620. "msg": errs,
  1621. })
  1622. }
  1623. }
  1624. func (c *HisApiController) DeletePCandBG() {
  1625. ids := c.GetString("ids")
  1626. id_arr := strings.Split(ids, ",")
  1627. admin_user_id, _ := c.GetInt64("admin_user_id")
  1628. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1629. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1630. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1631. var err []string
  1632. for _, item := range drugs {
  1633. if item.IsPc == 1 {
  1634. var res FJ3507Result
  1635. var struct3507 models.Struct3507
  1636. struct3507.FixmedinsBchno = item.Bchno
  1637. struct3507.InvDataType = "1"
  1638. struct3507.Opter = roles.UserName
  1639. struct3507.OrgName = miConfig.OrgName
  1640. struct3507.AccessKey = miConfig.AccessKey
  1641. struct3507.RequestUrl = miConfig.Url
  1642. struct3507.FixmedinsCode = miConfig.Code
  1643. struct3507.Code = miConfig.Code
  1644. struct3507.SecretKey = miConfig.SecretKey
  1645. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1646. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1647. struct3507.Url = miConfig.Url
  1648. struct3507.AppId = miConfig.Cainfo
  1649. struct3507.AppSecret = miConfig.AppSecret
  1650. struct3507.Enckey = miConfig.EncKey
  1651. struct3507.SignKey = miConfig.SignKey
  1652. struct3507.SecretKey = miConfig.SecretKey
  1653. if miConfig.MdtrtareaAdmvs == "350500" {
  1654. result, result1, _ := service.FJyb3507(struct3507)
  1655. saveLog(result, result1, "3507", "3507")
  1656. var respJSON2 map[string]interface{}
  1657. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1658. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1660. return
  1661. }
  1662. userJSONBytes2, _ := json.Marshal(respJSON2)
  1663. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1664. utils.ErrorLog("解析失败:%v", err)
  1665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1666. return
  1667. }
  1668. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  1669. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  1670. saveLog(result2, result1, "3507", "3507")
  1671. var respJSON2 map[string]interface{}
  1672. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1675. return
  1676. }
  1677. userJSONBytes2, _ := json.Marshal(respJSON2)
  1678. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1679. utils.ErrorLog("解析失败:%v", err)
  1680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1681. return
  1682. }
  1683. } else {
  1684. data := make(map[string]interface{})
  1685. data["struct_3507s"] = struct3507
  1686. client := &http.Client{}
  1687. bytesData, _ := json.Marshal(data)
  1688. var req *http.Request
  1689. if miConfig.MdtrtareaAdmvs == "320830" {
  1690. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1691. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1692. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1693. } else {
  1694. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1695. }
  1696. resp, _ := client.Do(req)
  1697. defer resp.Body.Close()
  1698. body, ioErr := ioutil.ReadAll(resp.Body)
  1699. if ioErr != nil {
  1700. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1701. }
  1702. var respJSON map[string]interface{}
  1703. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1706. return
  1707. }
  1708. var resSix10265 ResultSix10265 //1101结果
  1709. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1710. result, _ := json.Marshal(respJSON)
  1711. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1712. utils.ErrorLog("解析失败:%v", err)
  1713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1714. return
  1715. }
  1716. res.InfRefmsgid = resSix10265.InfRefmsgid
  1717. //res.Output = resSix10265.Output
  1718. res.ErrMsg = resSix10265.ErrMsg
  1719. res.Cainfo = resSix10265.Cainfo
  1720. res.WarnMsg = resSix10265.WarnMsg
  1721. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1722. res.Infcode = infocode
  1723. }
  1724. if res.Infcode == 0 {
  1725. item.IsPc = 0
  1726. service.SaveW(item)
  1727. } else {
  1728. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1729. }
  1730. }
  1731. }
  1732. if len(err) == 0 {
  1733. c.ServeSuccessJSON(map[string]interface{}{
  1734. "msg": "删除盘存变更成功",
  1735. })
  1736. } else {
  1737. c.ServeSuccessJSON(map[string]interface{}{
  1738. "failed_code": -10,
  1739. "msg": err,
  1740. })
  1741. }
  1742. }
  1743. func (c *HisApiController) DeleteXSandBG() {
  1744. ids := c.GetString("ids")
  1745. id_arr := strings.Split(ids, ",")
  1746. admin_user_id, _ := c.GetInt64("admin_user_id")
  1747. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1748. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1749. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1750. var err []string
  1751. for _, item := range flows {
  1752. if item.IsSale == 1 && item.IsChange == 1 {
  1753. var res FJ3507Result
  1754. var res2 FJ3507Result
  1755. var struct3507 models.Struct3507
  1756. struct3507.FixmedinsBchno = item.Bchno
  1757. struct3507.InvDataType = "4"
  1758. struct3507.Opter = roles.UserName
  1759. struct3507.OrgName = miConfig.OrgName
  1760. struct3507.AccessKey = miConfig.AccessKey
  1761. struct3507.RequestUrl = miConfig.Url
  1762. struct3507.FixmedinsCode = miConfig.Code
  1763. struct3507.SecretKey = miConfig.SecretKey
  1764. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1765. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1766. struct3507.Url = miConfig.Url
  1767. struct3507.AppId = miConfig.Cainfo
  1768. struct3507.AppSecret = miConfig.AppSecret
  1769. struct3507.Enckey = miConfig.EncKey
  1770. struct3507.SignKey = miConfig.SignKey
  1771. struct3507.SecretKey = miConfig.SecretKey
  1772. //result, result1, _ := service.FJyb3507(struct3507)
  1773. //saveLog(result, result1, "3507", "3507")
  1774. if miConfig.MdtrtareaAdmvs == "350500" {
  1775. result, result1, _ := service.FJyb3507(struct3507)
  1776. saveLog(result, result1, "3507", "3507")
  1777. var respJSON2 map[string]interface{}
  1778. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1781. return
  1782. }
  1783. userJSONBytes2, _ := json.Marshal(respJSON2)
  1784. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1785. utils.ErrorLog("解析失败:%v", err)
  1786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1787. return
  1788. }
  1789. } else {
  1790. data := make(map[string]interface{})
  1791. data["struct_3507s"] = struct3507
  1792. client := &http.Client{}
  1793. bytesData, _ := json.Marshal(data)
  1794. var req *http.Request
  1795. if miConfig.MdtrtareaAdmvs == "320830" {
  1796. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1797. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1798. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1799. } else {
  1800. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1801. }
  1802. resp, _ := client.Do(req)
  1803. defer resp.Body.Close()
  1804. body, ioErr := ioutil.ReadAll(resp.Body)
  1805. if ioErr != nil {
  1806. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1807. }
  1808. var respJSON map[string]interface{}
  1809. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1810. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1812. return
  1813. }
  1814. var resSix10265 ResultSix10265 //1101结果
  1815. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1816. result, _ := json.Marshal(respJSON)
  1817. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1818. utils.ErrorLog("解析失败:%v", err)
  1819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1820. return
  1821. }
  1822. res.InfRefmsgid = resSix10265.InfRefmsgid
  1823. //res.Output = resSix10265.Output
  1824. res.ErrMsg = resSix10265.ErrMsg
  1825. res.Cainfo = resSix10265.Cainfo
  1826. res.WarnMsg = resSix10265.WarnMsg
  1827. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1828. res.Infcode = infocode
  1829. }
  1830. if res.Infcode == 0 {
  1831. item.IsSale = 0
  1832. item.SaleDate = ""
  1833. item.Bchno = ""
  1834. err2 := service.SaveDF(item)
  1835. if err2 == nil {
  1836. var struct3507_2 models.Struct3507
  1837. struct3507_2.OrgName = miConfig.OrgName
  1838. struct3507_2.AccessKey = miConfig.AccessKey
  1839. struct3507_2.RequestUrl = miConfig.Url
  1840. struct3507_2.Opter = roles.UserName
  1841. struct3507_2.FixmedinsCode = miConfig.Code
  1842. struct3507_2.Code = miConfig.Code
  1843. struct3507_2.SecretKey = miConfig.SecretKey
  1844. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1845. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1846. struct3507_2.Url = miConfig.Url
  1847. struct3507_2.AppId = miConfig.Cainfo
  1848. struct3507_2.AppSecret = miConfig.AppSecret
  1849. struct3507_2.Enckey = miConfig.EncKey
  1850. struct3507_2.SignKey = miConfig.SignKey
  1851. struct3507_2.SecretKey = miConfig.SecretKey
  1852. struct3507_2.FixmedinsBchno = item.BgBchno
  1853. struct3507_2.InvDataType = "2"
  1854. if miConfig.MdtrtareaAdmvs == "350500" {
  1855. result11, result22, _ := service.FJyb3507(struct3507_2)
  1856. saveLog(result11, result22, "3507", "3507")
  1857. var respJSON3 map[string]interface{}
  1858. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1859. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1861. return
  1862. }
  1863. userJSONBytes3, _ := json.Marshal(respJSON3)
  1864. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1865. utils.ErrorLog("解析失败:%v", err)
  1866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1867. return
  1868. }
  1869. } else {
  1870. data := make(map[string]interface{})
  1871. data["struct_3507s"] = struct3507_2
  1872. client := &http.Client{}
  1873. bytesData, _ := json.Marshal(data)
  1874. var req *http.Request
  1875. if miConfig.MdtrtareaAdmvs == "320830" {
  1876. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1877. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1878. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1879. } else {
  1880. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1881. }
  1882. resp, _ := client.Do(req)
  1883. defer resp.Body.Close()
  1884. body, ioErr := ioutil.ReadAll(resp.Body)
  1885. if ioErr != nil {
  1886. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1887. }
  1888. var respJSON map[string]interface{}
  1889. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1890. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1892. return
  1893. }
  1894. var resSix10265 ResultSix10265 //1101结果
  1895. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1896. result, _ := json.Marshal(respJSON)
  1897. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1898. utils.ErrorLog("解析失败:%v", err)
  1899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1900. return
  1901. }
  1902. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1903. //res.Output = resSix10265.Output
  1904. res2.ErrMsg = resSix10265.ErrMsg
  1905. res2.Cainfo = resSix10265.Cainfo
  1906. res2.WarnMsg = resSix10265.WarnMsg
  1907. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1908. res2.Infcode = infocode
  1909. }
  1910. if res2.Infcode == 0 {
  1911. item.IsChange = 0
  1912. item.BgBchno = ""
  1913. service.SaveDF2(item)
  1914. } else {
  1915. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1916. }
  1917. }
  1918. } else {
  1919. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1920. }
  1921. }
  1922. if item.IsSale == 2 && item.IsChange == 1 {
  1923. var res FJ3507Result
  1924. var res2 FJ3507Result
  1925. var struct3507 models.Struct3507
  1926. struct3507.FixmedinsBchno = item.Bchno
  1927. struct3507.InvDataType = "4"
  1928. struct3507.Opter = roles.UserName
  1929. struct3507.OrgName = miConfig.OrgName
  1930. struct3507.AccessKey = miConfig.AccessKey
  1931. struct3507.RequestUrl = miConfig.Url
  1932. struct3507.FixmedinsCode = miConfig.Code
  1933. struct3507.Code = miConfig.Code
  1934. struct3507.SecretKey = miConfig.SecretKey
  1935. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1936. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1937. struct3507.Url = miConfig.Url
  1938. struct3507.AppId = miConfig.Cainfo
  1939. struct3507.AppSecret = miConfig.AppSecret
  1940. struct3507.Enckey = miConfig.EncKey
  1941. struct3507.SignKey = miConfig.SignKey
  1942. struct3507.SecretKey = miConfig.SecretKey
  1943. //result, result1, _ := service.FJyb3507(struct3507)
  1944. //saveLog(result, result1, "3507", "3507")
  1945. //
  1946. //var respJSON2 map[string]interface{}
  1947. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1948. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1949. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1950. // return
  1951. //}
  1952. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1953. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1954. // utils.ErrorLog("解析失败:%v", err)
  1955. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1956. // return
  1957. //}
  1958. if miConfig.MdtrtareaAdmvs == "350500" {
  1959. result, result1, _ := service.FJyb3507(struct3507)
  1960. saveLog(result, result1, "3507", "3507")
  1961. var respJSON2 map[string]interface{}
  1962. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1963. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1965. return
  1966. }
  1967. userJSONBytes2, _ := json.Marshal(respJSON2)
  1968. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1969. utils.ErrorLog("解析失败:%v", err)
  1970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1971. return
  1972. }
  1973. } else {
  1974. data := make(map[string]interface{})
  1975. data["struct_3507s"] = struct3507
  1976. client := &http.Client{}
  1977. bytesData, _ := json.Marshal(data)
  1978. var req *http.Request
  1979. if miConfig.MdtrtareaAdmvs == "320830" {
  1980. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1981. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1982. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1983. } else {
  1984. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1985. }
  1986. resp, _ := client.Do(req)
  1987. defer resp.Body.Close()
  1988. body, ioErr := ioutil.ReadAll(resp.Body)
  1989. if ioErr != nil {
  1990. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1991. }
  1992. var respJSON map[string]interface{}
  1993. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1994. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1996. return
  1997. }
  1998. var resSix10265 ResultSix10265 //1101结果
  1999. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2000. result, _ := json.Marshal(respJSON)
  2001. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2002. utils.ErrorLog("解析失败:%v", err)
  2003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2004. return
  2005. }
  2006. res.InfRefmsgid = resSix10265.InfRefmsgid
  2007. //res.Output = resSix10265.Output
  2008. res.ErrMsg = resSix10265.ErrMsg
  2009. res.Cainfo = resSix10265.Cainfo
  2010. res.WarnMsg = resSix10265.WarnMsg
  2011. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2012. res.Infcode = infocode
  2013. }
  2014. if res.Infcode == 0 {
  2015. item.IsSale = 0
  2016. item.SaleDate = ""
  2017. item.Bchno = ""
  2018. err2 := service.SaveDF(item)
  2019. if err2 == nil {
  2020. var struct3507_2 models.Struct3507
  2021. struct3507_2.OrgName = miConfig.OrgName
  2022. struct3507_2.AccessKey = miConfig.AccessKey
  2023. struct3507_2.RequestUrl = miConfig.Url
  2024. struct3507_2.Opter = roles.UserName
  2025. struct3507_2.FixmedinsCode = miConfig.Code
  2026. struct3507_2.Code = miConfig.Code
  2027. struct3507_2.SecretKey = miConfig.SecretKey
  2028. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2029. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2030. struct3507_2.Url = miConfig.Url
  2031. struct3507_2.AppId = miConfig.Cainfo
  2032. struct3507_2.AppSecret = miConfig.AppSecret
  2033. struct3507_2.Enckey = miConfig.EncKey
  2034. struct3507_2.SignKey = miConfig.SignKey
  2035. struct3507_2.SecretKey = miConfig.SecretKey
  2036. struct3507_2.FixmedinsBchno = item.BgBchno
  2037. struct3507_2.InvDataType = "2"
  2038. //result11, result22, _ := service.FJyb3507(struct3507_2)
  2039. //saveLog(result11, result22, "3507", "3507")
  2040. //var respJSON3 map[string]interface{}
  2041. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2042. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2043. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2044. // return
  2045. //}
  2046. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2047. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2048. // utils.ErrorLog("解析失败:%v", err)
  2049. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2050. // return
  2051. //}
  2052. if miConfig.MdtrtareaAdmvs == "350500" {
  2053. result11, result22, _ := service.FJyb3507(struct3507_2)
  2054. saveLog(result11, result22, "3507", "3507")
  2055. var respJSON3 map[string]interface{}
  2056. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2059. return
  2060. }
  2061. userJSONBytes3, _ := json.Marshal(respJSON3)
  2062. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2063. utils.ErrorLog("解析失败:%v", err)
  2064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2065. return
  2066. }
  2067. } else {
  2068. data := make(map[string]interface{})
  2069. data["struct_3507s"] = struct3507_2
  2070. client := &http.Client{}
  2071. bytesData, _ := json.Marshal(data)
  2072. var req *http.Request
  2073. if miConfig.MdtrtareaAdmvs == "320830" {
  2074. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2075. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2076. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2077. } else {
  2078. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2079. }
  2080. resp, _ := client.Do(req)
  2081. defer resp.Body.Close()
  2082. body, ioErr := ioutil.ReadAll(resp.Body)
  2083. if ioErr != nil {
  2084. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2085. }
  2086. var respJSON map[string]interface{}
  2087. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2088. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2090. return
  2091. }
  2092. var resSix10265 ResultSix10265 //1101结果
  2093. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2094. result, _ := json.Marshal(respJSON)
  2095. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2096. utils.ErrorLog("解析失败:%v", err)
  2097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2098. return
  2099. }
  2100. res2.InfRefmsgid = resSix10265.InfRefmsgid
  2101. //res.Output = resSix10265.Output
  2102. res2.ErrMsg = resSix10265.ErrMsg
  2103. res2.Cainfo = resSix10265.Cainfo
  2104. res2.WarnMsg = resSix10265.WarnMsg
  2105. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2106. res2.Infcode = infocode
  2107. }
  2108. if res2.Infcode == 0 {
  2109. item.IsChange = 0
  2110. item.BgBchno = ""
  2111. service.SaveDF2(item)
  2112. } else {
  2113. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2114. }
  2115. }
  2116. } else {
  2117. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2118. }
  2119. }
  2120. if item.IsSale == 1 && item.IsChange == 0 {
  2121. var res FJ3507Result
  2122. var struct3507 models.Struct3507
  2123. struct3507.FixmedinsBchno = item.Bchno
  2124. struct3507.InvDataType = "4"
  2125. struct3507.Opter = roles.UserName
  2126. struct3507.FixmedinsCode = miConfig.Code
  2127. struct3507.Code = miConfig.Code
  2128. struct3507.OrgName = miConfig.OrgName
  2129. struct3507.AccessKey = miConfig.AccessKey
  2130. struct3507.RequestUrl = miConfig.Url
  2131. struct3507.SecretKey = miConfig.SecretKey
  2132. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2133. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2134. struct3507.Url = miConfig.Url
  2135. struct3507.AppId = miConfig.Cainfo
  2136. struct3507.AppSecret = miConfig.AppSecret
  2137. struct3507.Enckey = miConfig.EncKey
  2138. struct3507.SignKey = miConfig.SignKey
  2139. struct3507.SecretKey = miConfig.SecretKey
  2140. //result, result1, _ := service.FJyb3507(struct3507)
  2141. //saveLog(result, result1, "3507", "3507")
  2142. //
  2143. //var respJSON3 map[string]interface{}
  2144. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2145. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2146. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2147. // return
  2148. //}
  2149. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2150. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2151. // utils.ErrorLog("解析失败:%v", err)
  2152. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2153. // return
  2154. //}
  2155. if miConfig.MdtrtareaAdmvs == "350500" {
  2156. result, result1, _ := service.FJyb3507(struct3507)
  2157. saveLog(result, result1, "3507", "3507")
  2158. var respJSON2 map[string]interface{}
  2159. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2160. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2162. return
  2163. }
  2164. userJSONBytes2, _ := json.Marshal(respJSON2)
  2165. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2166. utils.ErrorLog("解析失败:%v", err)
  2167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2168. return
  2169. }
  2170. } else {
  2171. data := make(map[string]interface{})
  2172. data["struct_3507s"] = struct3507
  2173. client := &http.Client{}
  2174. bytesData, _ := json.Marshal(data)
  2175. var req *http.Request
  2176. if miConfig.MdtrtareaAdmvs == "320830" {
  2177. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2178. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2179. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2180. } else {
  2181. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2182. }
  2183. resp, _ := client.Do(req)
  2184. defer resp.Body.Close()
  2185. body, ioErr := ioutil.ReadAll(resp.Body)
  2186. if ioErr != nil {
  2187. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2188. }
  2189. var respJSON map[string]interface{}
  2190. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2191. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2193. return
  2194. }
  2195. var resSix10265 ResultSix10265 //1101结果
  2196. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2197. result, _ := json.Marshal(respJSON)
  2198. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2199. utils.ErrorLog("解析失败:%v", err)
  2200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2201. return
  2202. }
  2203. res.InfRefmsgid = resSix10265.InfRefmsgid
  2204. //res.Output = resSix10265.Output
  2205. res.ErrMsg = resSix10265.ErrMsg
  2206. res.Cainfo = resSix10265.Cainfo
  2207. res.WarnMsg = resSix10265.WarnMsg
  2208. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2209. res.Infcode = infocode
  2210. }
  2211. if res.Infcode == 0 {
  2212. item.IsSale = 0
  2213. item.SaleDate = ""
  2214. service.SaveDF(item)
  2215. } else {
  2216. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2217. }
  2218. }
  2219. if item.IsSale == 2 && item.IsChange == 0 {
  2220. var res FJ3507Result
  2221. var struct3507 models.Struct3507
  2222. struct3507.FixmedinsBchno = item.Bchno
  2223. struct3507.InvDataType = "4"
  2224. struct3507.Opter = roles.UserName
  2225. struct3507.FixmedinsCode = miConfig.Code
  2226. struct3507.Code = miConfig.Code
  2227. struct3507.OrgName = miConfig.OrgName
  2228. struct3507.AccessKey = miConfig.AccessKey
  2229. struct3507.RequestUrl = miConfig.Url
  2230. struct3507.SecretKey = miConfig.SecretKey
  2231. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2232. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2233. struct3507.Url = miConfig.Url
  2234. struct3507.AppId = miConfig.Cainfo
  2235. struct3507.AppSecret = miConfig.AppSecret
  2236. struct3507.Enckey = miConfig.EncKey
  2237. struct3507.SignKey = miConfig.SignKey
  2238. struct3507.SecretKey = miConfig.SecretKey
  2239. //result, result1, _ := service.FJyb3507(struct3507)
  2240. //saveLog(result, result1, "3507", "3507")
  2241. //
  2242. //var respJSON3 map[string]interface{}
  2243. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2244. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2245. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2246. // return
  2247. //}
  2248. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2249. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2250. // utils.ErrorLog("解析失败:%v", err)
  2251. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2252. // return
  2253. //}
  2254. if miConfig.MdtrtareaAdmvs == "350500" {
  2255. result, result1, _ := service.FJyb3507(struct3507)
  2256. saveLog(result, result1, "3507", "3507")
  2257. var respJSON2 map[string]interface{}
  2258. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2261. return
  2262. }
  2263. userJSONBytes2, _ := json.Marshal(respJSON2)
  2264. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2265. utils.ErrorLog("解析失败:%v", err)
  2266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2267. return
  2268. }
  2269. } else {
  2270. data := make(map[string]interface{})
  2271. data["struct_3507s"] = struct3507
  2272. client := &http.Client{}
  2273. bytesData, _ := json.Marshal(data)
  2274. var req *http.Request
  2275. if miConfig.MdtrtareaAdmvs == "320830" {
  2276. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2277. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2278. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2279. } else {
  2280. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2281. }
  2282. resp, _ := client.Do(req)
  2283. defer resp.Body.Close()
  2284. body, ioErr := ioutil.ReadAll(resp.Body)
  2285. if ioErr != nil {
  2286. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2287. }
  2288. var respJSON map[string]interface{}
  2289. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2290. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2292. return
  2293. }
  2294. var resSix10265 ResultSix10265 //1101结果
  2295. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2296. result, _ := json.Marshal(respJSON)
  2297. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2298. utils.ErrorLog("解析失败:%v", err)
  2299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2300. return
  2301. }
  2302. res.InfRefmsgid = resSix10265.InfRefmsgid
  2303. //res.Output = resSix10265.Output
  2304. res.ErrMsg = resSix10265.ErrMsg
  2305. res.Cainfo = resSix10265.Cainfo
  2306. res.WarnMsg = resSix10265.WarnMsg
  2307. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2308. res.Infcode = infocode
  2309. }
  2310. if res.Infcode == 0 {
  2311. item.IsSale = 0
  2312. item.SaleDate = ""
  2313. item.Bchno = ""
  2314. service.SaveDF(item)
  2315. } else {
  2316. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2317. }
  2318. }
  2319. if item.IsSale == 0 && item.IsChange == 1 {
  2320. var res FJ3507Result
  2321. var struct3507 models.Struct3507
  2322. struct3507.FixmedinsBchno = item.BgBchno
  2323. struct3507.InvDataType = "2"
  2324. struct3507.Opter = roles.UserName
  2325. struct3507.FixmedinsCode = miConfig.Code
  2326. struct3507.Code = miConfig.Code
  2327. struct3507.OrgName = miConfig.OrgName
  2328. struct3507.AccessKey = miConfig.AccessKey
  2329. struct3507.RequestUrl = miConfig.Url
  2330. struct3507.SecretKey = miConfig.SecretKey
  2331. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2332. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2333. struct3507.Url = miConfig.Url
  2334. struct3507.AppId = miConfig.Cainfo
  2335. struct3507.AppSecret = miConfig.AppSecret
  2336. struct3507.Enckey = miConfig.EncKey
  2337. struct3507.SignKey = miConfig.SignKey
  2338. struct3507.SecretKey = miConfig.SecretKey
  2339. //result, result1, _ := service.FJyb3507(struct3507)
  2340. //saveLog(result, result1, "3507", "3507")
  2341. //
  2342. //var respJSON3 map[string]interface{}
  2343. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2344. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2345. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2346. // return
  2347. //}
  2348. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2349. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2350. // utils.ErrorLog("解析失败:%v", err)
  2351. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2352. // return
  2353. //}
  2354. if miConfig.MdtrtareaAdmvs == "350500" {
  2355. result, result1, _ := service.FJyb3507(struct3507)
  2356. saveLog(result, result1, "3507", "3507")
  2357. var respJSON2 map[string]interface{}
  2358. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2361. return
  2362. }
  2363. userJSONBytes2, _ := json.Marshal(respJSON2)
  2364. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2365. utils.ErrorLog("解析失败:%v", err)
  2366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2367. return
  2368. }
  2369. } else {
  2370. data := make(map[string]interface{})
  2371. data["struct_3507s"] = struct3507
  2372. client := &http.Client{}
  2373. bytesData, _ := json.Marshal(data)
  2374. var req *http.Request
  2375. if miConfig.MdtrtareaAdmvs == "320830" {
  2376. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2377. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2378. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2379. } else {
  2380. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2381. }
  2382. resp, _ := client.Do(req)
  2383. defer resp.Body.Close()
  2384. body, ioErr := ioutil.ReadAll(resp.Body)
  2385. if ioErr != nil {
  2386. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2387. }
  2388. var respJSON map[string]interface{}
  2389. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2390. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2392. return
  2393. }
  2394. var resSix10265 ResultSix10265 //1101结果
  2395. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2396. result, _ := json.Marshal(respJSON)
  2397. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2398. utils.ErrorLog("解析失败:%v", err)
  2399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2400. return
  2401. }
  2402. res.InfRefmsgid = resSix10265.InfRefmsgid
  2403. //res.Output = resSix10265.Output
  2404. res.ErrMsg = resSix10265.ErrMsg
  2405. res.Cainfo = resSix10265.Cainfo
  2406. res.WarnMsg = resSix10265.WarnMsg
  2407. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2408. res.Infcode = infocode
  2409. }
  2410. if res.Infcode == 0 {
  2411. item.IsChange = 0
  2412. item.BgBchno = ""
  2413. service.SaveDF2(item)
  2414. } else {
  2415. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2416. }
  2417. }
  2418. }
  2419. if len(err) == 0 {
  2420. c.ServeSuccessJSON(map[string]interface{}{
  2421. "msg": "删除销售变更成功",
  2422. })
  2423. } else {
  2424. c.ServeSuccessJSON(map[string]interface{}{
  2425. "failed_code": -10,
  2426. "msg": err,
  2427. })
  2428. }
  2429. }
  2430. //func (c *HisApiController) BatchFJ3501AND3502() {
  2431. // //ids := c.GetString("ids")
  2432. // start_time := c.GetString("start_time")
  2433. // end_time := c.GetString("end_time")
  2434. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2435. //
  2436. //
  2437. // timeLayout := "2006-01-02"
  2438. // loc, _ := time.LoadLocation("Local")
  2439. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2440. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2441. //
  2442. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2443. // //id_arr := strings.Split(ids, ",")
  2444. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2445. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2446. // //库盘
  2447. // var errs []string
  2448. // for _, drug := range drugs {
  2449. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2450. // var res2 ResultSix
  2451. // var res3 ResultSix
  2452. //
  2453. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2454. // var struct3501 models.Struct3501
  2455. // struct3501.Code = miConfig.Code
  2456. // struct3501.OrgName = miConfig.OrgName
  2457. // struct3501.AccessKey = miConfig.AccessKey
  2458. // struct3501.Opter = roles.UserName
  2459. // struct3501.RequestUrl = miConfig.Url
  2460. // struct3501.Url = miConfig.Url
  2461. // struct3501.AppId = miConfig.Cainfo
  2462. // struct3501.AppSecret = miConfig.AppSecret
  2463. // struct3501.Enckey = miConfig.EncKey
  2464. // struct3501.SignKey = miConfig.SignKey
  2465. // struct3501.SecretKey = miConfig.SecretKey
  2466. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2467. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2468. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2469. // struct3501.RxFlag = "1"
  2470. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2471. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2472. //
  2473. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2474. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2475. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2476. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2477. // struct3501.FixmedinsBchno = number
  2478. // struct3501.DrugTracCodg = drug.DrugCode
  2479. // memo := make(map[string]interface{})
  2480. // memo["pric"] = drug.Price
  2481. // bytesData, _ := json.Marshal(memo)
  2482. // struct3501.Memo = string(bytesData)
  2483. //
  2484. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2485. //
  2486. // result1, result2, _ := service.FJyb3501(struct3501)
  2487. // saveLog(result1, result2, "3501", "3501")
  2488. // //saveLog(result, requestLog, "2201", "挂号")
  2489. //
  2490. // var respJSON2 map[string]interface{}
  2491. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2492. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2493. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2494. // return
  2495. // }
  2496. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2497. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2498. // utils.ErrorLog("解析失败:%v", err)
  2499. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2500. // return
  2501. // }
  2502. //
  2503. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2504. // data := make(map[string]interface{})
  2505. // data["struct_3501s"] = struct3501
  2506. // client := &http.Client{}
  2507. // bytesData, _ := json.Marshal(data)
  2508. // var req *http.Request
  2509. // if miConfig.MdtrtareaAdmvs == "320921" {
  2510. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2511. // } else {
  2512. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2513. // }
  2514. //
  2515. // resp, _ := client.Do(req)
  2516. // defer resp.Body.Close()
  2517. // body, ioErr := ioutil.ReadAll(resp.Body)
  2518. // if ioErr != nil {
  2519. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2520. // }
  2521. // var respJSON map[string]interface{}
  2522. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2523. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2524. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2525. // return
  2526. // }
  2527. // var resSix10265 ResultSix10265 //1101结果
  2528. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2529. // result, _ := json.Marshal(respJSON)
  2530. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2531. // utils.ErrorLog("解析失败:%v", err)
  2532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2533. // return
  2534. // }
  2535. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2536. // res2.Output = resSix10265.Output
  2537. // res2.ErrMsg = resSix10265.ErrMsg
  2538. // res2.Cainfo = resSix10265.Cainfo
  2539. // res2.WarnMsg = resSix10265.WarnMsg
  2540. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2541. // res2.Infcode = infocode
  2542. //
  2543. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2544. // data := make(map[string]interface{})
  2545. // data["struct_3501s"] = struct3501
  2546. // client := &http.Client{}
  2547. // bytesData, _ := json.Marshal(data)
  2548. // var req *http.Request
  2549. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2550. // resp, _ := client.Do(req)
  2551. // defer resp.Body.Close()
  2552. // body, ioErr := ioutil.ReadAll(resp.Body)
  2553. // if ioErr != nil {
  2554. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2555. // }
  2556. // var respJSON map[string]interface{}
  2557. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2558. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2559. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2560. // return
  2561. // }
  2562. // var resSix10265 ResultSix10265 //1101结果
  2563. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2564. // result, _ := json.Marshal(respJSON)
  2565. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2566. // utils.ErrorLog("解析失败:%v", err)
  2567. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2568. // return
  2569. // }
  2570. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2571. // res2.Output = resSix10265.Output
  2572. // res2.ErrMsg = resSix10265.ErrMsg
  2573. // res2.Cainfo = resSix10265.Cainfo
  2574. // res2.WarnMsg = resSix10265.WarnMsg
  2575. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2576. // res2.Infcode = infocode
  2577. //
  2578. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2579. // data := make(map[string]interface{})
  2580. // data["struct_3501s"] = struct3501
  2581. // client := &http.Client{}
  2582. // bytesData, _ := json.Marshal(data)
  2583. // var req *http.Request
  2584. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2585. // resp, _ := client.Do(req)
  2586. // defer resp.Body.Close()
  2587. // body, ioErr := ioutil.ReadAll(resp.Body)
  2588. // if ioErr != nil {
  2589. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2590. // }
  2591. // var respJSON map[string]interface{}
  2592. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2593. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2594. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2595. // return
  2596. // }
  2597. // var resSix10265 ResultSix10265 //1101结果
  2598. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2599. // result, _ := json.Marshal(respJSON)
  2600. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2601. // utils.ErrorLog("解析失败:%v", err)
  2602. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2603. // return
  2604. // }
  2605. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2606. // res2.Output = resSix10265.Output
  2607. // res2.ErrMsg = resSix10265.ErrMsg
  2608. // res2.Cainfo = resSix10265.Cainfo
  2609. // res2.WarnMsg = resSix10265.WarnMsg
  2610. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2611. // res2.Infcode = infocode
  2612. //
  2613. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2614. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2615. // saveLog(result1, result2, "3501", "3501")
  2616. // //saveLog(result, requestLog, "2201", "挂号")
  2617. //
  2618. // var respJSON2 map[string]interface{}
  2619. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2620. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2621. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2622. // return
  2623. // }
  2624. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2625. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2626. // utils.ErrorLog("解析失败:%v", err)
  2627. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2628. // return
  2629. // }
  2630. //
  2631. // }
  2632. //
  2633. // if res2.Infcode != -1 {
  2634. // drug.IsPc = 1
  2635. // drug.Bchno = number
  2636. // drug.PcDate = time.Now().Unix()
  2637. // err := service.SaveW(drug)
  2638. // if err == nil {
  2639. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2640. // var struct3502 models.Struct3502
  2641. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2642. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2643. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2644. // struct3502.FixmedinsCode = miConfig.Code
  2645. // struct3502.Code = miConfig.Code
  2646. //
  2647. // struct3502.RxFlag = "0"
  2648. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2649. // struct3502.OrgName = miConfig.OrgName
  2650. // struct3502.Opter = roles.UserName
  2651. // struct3502.AccessKey = miConfig.AccessKey
  2652. // struct3502.RequestUrl = miConfig.Url
  2653. // struct3502.SecretKey = miConfig.SecretKey
  2654. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2655. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2656. // struct3502.Url = miConfig.Url
  2657. // struct3502.AppId = miConfig.Cainfo
  2658. // struct3502.AppSecret = miConfig.AppSecret
  2659. // struct3502.Enckey = miConfig.EncKey
  2660. // struct3502.SignKey = miConfig.SignKey
  2661. // struct3502.SecretKey = miConfig.SecretKey
  2662. // struct3502.DrugTracCodg = drug.DrugCode
  2663. //
  2664. // struct3502.Memo = ""
  2665. // struct3502.InvChgType = "108"
  2666. // struct3502.FixmedinsBchno = bg_number
  2667. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2668. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2669. //
  2670. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2671. // result11, result22, _ := service.FJyb3502(struct3502)
  2672. // saveLog(result11, result22, "3502", "3502")
  2673. //
  2674. // var respJSON3 map[string]interface{}
  2675. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2676. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2677. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2678. // return
  2679. // }
  2680. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2681. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2682. // utils.ErrorLog("解析失败:%v", err)
  2683. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2684. // return
  2685. // }
  2686. //
  2687. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2688. // data := make(map[string]interface{})
  2689. // data["struct_3502s"] = struct3502
  2690. // client := &http.Client{}
  2691. // bytesData, _ := json.Marshal(data)
  2692. // var req *http.Request
  2693. // if miConfig.MdtrtareaAdmvs == "320921" {
  2694. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2695. // } else {
  2696. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2697. // }
  2698. //
  2699. // resp, _ := client.Do(req)
  2700. // defer resp.Body.Close()
  2701. // body, ioErr := ioutil.ReadAll(resp.Body)
  2702. // if ioErr != nil {
  2703. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2704. // }
  2705. // var respJSON map[string]interface{}
  2706. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2707. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2708. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2709. // return
  2710. // }
  2711. // var resSix10265 ResultSix10265 //1101结果
  2712. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2713. // result, _ := json.Marshal(respJSON)
  2714. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2715. // utils.ErrorLog("解析失败:%v", err)
  2716. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2717. // return
  2718. // }
  2719. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2720. // res3.Output = resSix10265.Output
  2721. // res3.ErrMsg = resSix10265.ErrMsg
  2722. // res3.Cainfo = resSix10265.Cainfo
  2723. // res3.WarnMsg = resSix10265.WarnMsg
  2724. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2725. // res3.Infcode = infocode
  2726. //
  2727. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2728. //
  2729. // data := make(map[string]interface{})
  2730. // data["struct_3502s"] = struct3502
  2731. // client := &http.Client{}
  2732. // bytesData, _ := json.Marshal(data)
  2733. // var req *http.Request
  2734. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2735. // resp, _ := client.Do(req)
  2736. // defer resp.Body.Close()
  2737. // body, ioErr := ioutil.ReadAll(resp.Body)
  2738. // if ioErr != nil {
  2739. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2740. // }
  2741. // var respJSON map[string]interface{}
  2742. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2743. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2744. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2745. // return
  2746. // }
  2747. // var resSix10265 ResultSix10265 //1101结果
  2748. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2749. // result, _ := json.Marshal(respJSON)
  2750. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2751. // utils.ErrorLog("解析失败:%v", err)
  2752. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2753. // return
  2754. // }
  2755. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2756. // res3.Output = resSix10265.Output
  2757. // res3.ErrMsg = resSix10265.ErrMsg
  2758. // res3.Cainfo = resSix10265.Cainfo
  2759. // res3.WarnMsg = resSix10265.WarnMsg
  2760. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2761. // res3.Infcode = infocode
  2762. //
  2763. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2764. //
  2765. // data := make(map[string]interface{})
  2766. // data["struct_3501s"] = struct3501
  2767. // client := &http.Client{}
  2768. // bytesData, _ := json.Marshal(data)
  2769. // var req *http.Request
  2770. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2771. // resp, _ := client.Do(req)
  2772. // defer resp.Body.Close()
  2773. // body, ioErr := ioutil.ReadAll(resp.Body)
  2774. // if ioErr != nil {
  2775. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2776. // }
  2777. // var respJSON map[string]interface{}
  2778. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2779. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2780. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2781. // return
  2782. // }
  2783. // var resSix10265 ResultSix10265 //1101结果
  2784. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2785. // result, _ := json.Marshal(respJSON)
  2786. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2787. // utils.ErrorLog("解析失败:%v", err)
  2788. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2789. // return
  2790. // }
  2791. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2792. // res2.Output = resSix10265.Output
  2793. // res2.ErrMsg = resSix10265.ErrMsg
  2794. // res2.Cainfo = resSix10265.Cainfo
  2795. // res2.WarnMsg = resSix10265.WarnMsg
  2796. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2797. // res2.Infcode = infocode
  2798. //
  2799. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2800. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2801. // saveLog(result11, result22, "3502", "3502")
  2802. //
  2803. // var respJSON3 map[string]interface{}
  2804. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2805. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2806. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2807. // return
  2808. // }
  2809. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2810. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2811. // utils.ErrorLog("解析失败:%v", err)
  2812. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2813. // return
  2814. // }
  2815. // }
  2816. // if res3.Infcode == -1 {
  2817. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2818. // c.ServeSuccessJSON(map[string]interface{}{
  2819. // "failed_code": -10,
  2820. // "msg": res3.ErrMsg,
  2821. // })
  2822. // } else {
  2823. // drug.IsBg = 1
  2824. // drug.BgBchno = bg_number
  2825. // service.SaveW(drug)
  2826. // }
  2827. // }
  2828. // } else {
  2829. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2830. // }
  2831. // }
  2832. // //变更
  2833. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2834. // var res3 ResultSix
  2835. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2836. //
  2837. // var struct3502 models.Struct3502
  2838. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2839. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2840. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2841. // struct3502.FixmedinsCode = miConfig.Code
  2842. // struct3502.Code = miConfig.Code
  2843. //
  2844. // struct3502.Opter = roles.UserName
  2845. // struct3502.RxFlag = "0"
  2846. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2847. // struct3502.OrgName = miConfig.OrgName
  2848. // struct3502.AccessKey = miConfig.AccessKey
  2849. // struct3502.RequestUrl = miConfig.Url
  2850. // struct3502.SecretKey = miConfig.SecretKey
  2851. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2852. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2853. // struct3502.InvChgType = "108"
  2854. // struct3502.DrugTracCodg = drug.DrugCode
  2855. //
  2856. // struct3502.Url = miConfig.Url
  2857. // struct3502.AppId = miConfig.Cainfo
  2858. // struct3502.AppSecret = miConfig.AppSecret
  2859. // struct3502.Enckey = miConfig.EncKey
  2860. // struct3502.SignKey = miConfig.SignKey
  2861. // struct3502.SecretKey = miConfig.SecretKey
  2862. //
  2863. // struct3502.FixmedinsBchno = bg_number
  2864. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2865. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2866. //
  2867. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2868. // result1, result2, _ := service.FJyb3502(struct3502)
  2869. // saveLog(result1, result2, "3502", "3502")
  2870. // var respJSON3 map[string]interface{}
  2871. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2872. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2873. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2874. // return
  2875. // }
  2876. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2877. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2878. // utils.ErrorLog("解析失败:%v", err)
  2879. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2880. // return
  2881. // }
  2882. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2883. // data := make(map[string]interface{})
  2884. // data["struct_3502s"] = struct3502
  2885. // client := &http.Client{}
  2886. // bytesData, _ := json.Marshal(data)
  2887. // var req *http.Request
  2888. // if miConfig.MdtrtareaAdmvs == "320921" {
  2889. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2890. // } else {
  2891. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2892. // }
  2893. // resp, _ := client.Do(req)
  2894. // defer resp.Body.Close()
  2895. // body, ioErr := ioutil.ReadAll(resp.Body)
  2896. // if ioErr != nil {
  2897. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2898. // }
  2899. // var respJSON map[string]interface{}
  2900. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2901. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2902. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2903. // return
  2904. // }
  2905. // var resSix10265 ResultSix10265 //1101结果
  2906. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2907. // result, _ := json.Marshal(respJSON)
  2908. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2909. // utils.ErrorLog("解析失败:%v", err)
  2910. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2911. // return
  2912. // }
  2913. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2914. // res3.Output = resSix10265.Output
  2915. // res3.ErrMsg = resSix10265.ErrMsg
  2916. // res3.Cainfo = resSix10265.Cainfo
  2917. // res3.WarnMsg = resSix10265.WarnMsg
  2918. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2919. // res3.Infcode = infocode
  2920. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2921. //
  2922. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2923. //
  2924. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2925. //
  2926. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2927. //
  2928. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2929. // saveLog(result1, result2, "3501", "3501")
  2930. // //saveLog(result, requestLog, "2201", "挂号")
  2931. //
  2932. // var respJSON2 map[string]interface{}
  2933. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2934. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2935. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2936. // return
  2937. // }
  2938. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2939. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2940. // utils.ErrorLog("解析失败:%v", err)
  2941. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2942. // return
  2943. // }
  2944. //
  2945. // }
  2946. // if res3.Infcode == -1 {
  2947. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2948. // } else {
  2949. // drug.IsBg = 1
  2950. // drug.BgBchno = bg_number
  2951. // service.SaveW(drug)
  2952. // }
  2953. // }
  2954. // }
  2955. //
  2956. // if len(errs) == 0 {
  2957. // c.ServeSuccessJSON(map[string]interface{}{
  2958. // "msg": "盘存变更成功",
  2959. // })
  2960. // } else {
  2961. // c.ServeSuccessJSON(map[string]interface{}{
  2962. // "failed_code": -10,
  2963. // "msg": errs,
  2964. // })
  2965. // }
  2966. //}
  2967. func (c *HisApiController) DeleteXSandBGTwo() {
  2968. id, _ := c.GetInt64("id")
  2969. admin_user_id, _ := c.GetInt64("admin_user_id")
  2970. var errs []string
  2971. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  2972. //for _, item := range advicelist {
  2973. // flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  2974. // flows = append(flows, flow...)
  2975. //}
  2976. //roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2977. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2978. for _, item := range advicelist {
  2979. prescription := service.GetHisPrescriptionByID(item.PrescriptionId)
  2980. if prescription.OrderStatus != 2 {
  2981. // 将时间戳转换为time.Time类型
  2982. t := time.Unix(item.RecordDate, 0) // 注意第二个参数是纳秒,这里是0
  2983. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, item.PatientId)
  2984. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.AdviceName+"医嘱没结算无法撤销上传")
  2985. }
  2986. if len(item.DrugCode) > 0 {
  2987. t := time.Unix(item.RecordDate, 0) // 注意第二个参数是纳秒,这里是0
  2988. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, item.PatientId)
  2989. codes := strings.Split(item.DrugCode, ",")
  2990. for _, code := range codes {
  2991. if len(code) > 0 {
  2992. if len(code) != 20 {
  2993. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.AdviceName+" 溯源码"+code+"位数不是20位")
  2994. }
  2995. if IsDigit(code) == false {
  2996. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.AdviceName+" 溯源码"+code+"不是纯数字")
  2997. }
  2998. }
  2999. }
  3000. }
  3001. }
  3002. if len(errs) > 0 {
  3003. c.ServeSuccessJSON(map[string]interface{}{
  3004. "failed_code": -10,
  3005. "msg": errs,
  3006. })
  3007. return
  3008. }
  3009. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3010. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3011. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3012. for _, item := range advicelist {
  3013. flow, _ := service.GetNewDrugFlowInfoByPatient(item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3014. //Drug ,_ := service.GetDrugLibById( drug.DrugId)
  3015. prescription := service.GetHisPrescriptionByID(item.PrescriptionId)
  3016. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, flow, miConfig, roles, strconv.Itoa(int(item.ID)), item)
  3017. result111, result222 = CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, flow, miConfig, roles, flow.Bchno, item)
  3018. saveLog(result111, result222, "3506", "销售退货")
  3019. var res FJ3507Result
  3020. var res3507for10188 FJ3507ResultFor10188
  3021. //进行商品销售接口
  3022. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3023. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3024. var respJSON3 map[string]interface{}
  3025. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3026. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3028. return
  3029. }
  3030. userJSONBytes3, _ := json.Marshal(respJSON3)
  3031. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 || c.GetAdminUserInfo().CurrentOrgId == 10633 {
  3032. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3033. utils.ErrorLog("解析失败:%v", err)
  3034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3035. return
  3036. }
  3037. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3038. res.ErrMsg = res3507for10188.ErrMsg
  3039. res.Cainfo = res3507for10188.Cainfo
  3040. res.WarnMsg = res3507for10188.WarnMsg
  3041. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3042. res.Infcode = infocode
  3043. } else {
  3044. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3045. utils.ErrorLog("解析失败:%v", err)
  3046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3047. return
  3048. }
  3049. }
  3050. if res.Infcode == 0 {
  3051. service.SaveDoctoradviceStatus(item.ID, time.Now().Format("2006-01-02"))
  3052. } else {
  3053. errs = append(errs, item.AdviceName+",销售退货失败:"+res.ErrMsg)
  3054. }
  3055. }
  3056. c.ServeSuccessJSON(map[string]interface{}{
  3057. "msg": "销售退货成功",
  3058. })
  3059. }
  3060. // 删除
  3061. //func (c *HisApiController) DeleteXSandBGThree() {
  3062. // id, _ := c.GetInt64("id")
  3063. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3064. //
  3065. // advicelist, _ := service.FinddelHisAdviceDocAdvice(id)
  3066. // //var flows []*models.DrugFlow
  3067. // //for _, item := range advicelist {
  3068. // // flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3069. // // flows = append(flows, flow...)
  3070. // //}
  3071. //
  3072. // //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3073. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3074. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3075. //
  3076. // var err []string
  3077. // for _, item := range advicelist {
  3078. //
  3079. // var res FJ3507Result
  3080. //
  3081. // var struct3507 models.Struct3507
  3082. // struct3507.FixmedinsBchno = item.ID
  3083. // struct3507.InvDataType = "4"
  3084. // struct3507.Opter = roles.UserName
  3085. // struct3507.OrgName = miConfig.OrgName
  3086. // struct3507.AccessKey = miConfig.AccessKey
  3087. // struct3507.RequestUrl = miConfig.Url
  3088. // struct3507.FixmedinsCode = miConfig.Code
  3089. // struct3507.SecretKey = miConfig.SecretKey
  3090. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3091. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3092. // struct3507.Url = miConfig.Url
  3093. // struct3507.AppId = miConfig.Cainfo
  3094. // struct3507.AppSecret = miConfig.AppSecret
  3095. // struct3507.Enckey = miConfig.EncKey
  3096. // struct3507.SignKey = miConfig.SignKey
  3097. // struct3507.SecretKey = miConfig.SecretKey
  3098. //
  3099. // if miConfig.MdtrtareaAdmvs == "350500" {
  3100. // result, result1, _ := service.FJyb3507(struct3507)
  3101. // saveLog(result, result1, "3507", "3507")
  3102. // var respJSON2 map[string]interface{}
  3103. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3104. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3105. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3106. // return
  3107. // }
  3108. // userJSONBytes2, _ := json.Marshal(respJSON2)
  3109. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3110. // utils.ErrorLog("解析失败:%v", err)
  3111. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3112. // return
  3113. // }
  3114. // } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  3115. // data := make(map[string]interface{})
  3116. // data["struct_3507s"] = struct3507
  3117. // client := &http.Client{}
  3118. // bytesData, _ := json.Marshal(data)
  3119. // var req *http.Request
  3120. // if miConfig.MdtrtareaAdmvs == "320830" {
  3121. // req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  3122. // } else if miConfig.MdtrtareaAdmvs == "320921" {
  3123. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3124. // } else {
  3125. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3126. // }
  3127. //
  3128. // resp, _ := client.Do(req)
  3129. // defer resp.Body.Close()
  3130. // body, ioErr := ioutil.ReadAll(resp.Body)
  3131. // if ioErr != nil {
  3132. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3133. // }
  3134. // var respJSON map[string]interface{}
  3135. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3136. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3137. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3138. // return
  3139. // }
  3140. // var resSix10265 ResultSix10265 //1101结果
  3141. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3142. // result, _ := json.Marshal(respJSON)
  3143. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3144. // utils.ErrorLog("解析失败:%v", err)
  3145. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3146. // return
  3147. // }
  3148. // res.InfRefmsgid = resSix10265.InfRefmsgid
  3149. // //res.Output = resSix10265.Output
  3150. // res.ErrMsg = resSix10265.ErrMsg
  3151. // res.Cainfo = resSix10265.Cainfo
  3152. // res.WarnMsg = resSix10265.WarnMsg
  3153. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3154. // res.Infcode = infocode
  3155. // } else if miConfig.MdtrtareaAdmvs == "440100" {
  3156. // result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  3157. // saveLog(result2, result1, "3507", "3507")
  3158. // var respJSON2 map[string]interface{}
  3159. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3160. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3161. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3162. // return
  3163. // }
  3164. // userJSONBytes2, _ := json.Marshal(respJSON2)
  3165. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3166. // utils.ErrorLog("解析失败:%v", err)
  3167. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3168. // return
  3169. // }
  3170. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  3171. // result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  3172. // saveLog(result2, result1, "3507", "3507")
  3173. // var respJSON2 map[string]interface{}
  3174. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3175. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3176. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3177. // return
  3178. // }
  3179. // userJSONBytes2, _ := json.Marshal(respJSON2)
  3180. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3181. // utils.ErrorLog("解析失败:%v", err)
  3182. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3183. // return
  3184. // }
  3185. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  3186. // result1, result2 := service.Jxyb3507(struct3507)
  3187. // saveLog(result2, result1, "3507", "3507")
  3188. // var respJSON2 map[string]interface{}
  3189. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3190. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3191. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3192. // return
  3193. // }
  3194. // userJSONBytes2, _ := json.Marshal(respJSON2)
  3195. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3196. // utils.ErrorLog("解析失败:%v", err)
  3197. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3198. // return
  3199. // }
  3200. // } else if miConfig.MdtrtareaAdmvs == "340699" {
  3201. // result1, result2 := service.AHyb3507(struct3507)
  3202. // saveLog(result2, result1, "3507", "3507")
  3203. // var respJSON2 map[string]interface{}
  3204. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3205. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3206. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3207. // return
  3208. // }
  3209. // userJSONBytes2, _ := json.Marshal(respJSON2)
  3210. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3211. // utils.ErrorLog("解析失败:%v", err)
  3212. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3213. // return
  3214. // }
  3215. // } else if miConfig.MdtrtareaAdmvs == "150404" {
  3216. //
  3217. // data := make(map[string]interface{})
  3218. // data["struct_3507s"] = struct3507
  3219. // client := &http.Client{}
  3220. // bytesData, _ := json.Marshal(data)
  3221. // var req *http.Request
  3222. //
  3223. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  3224. //
  3225. // resp, _ := client.Do(req)
  3226. // defer resp.Body.Close()
  3227. // body, ioErr := ioutil.ReadAll(resp.Body)
  3228. // if ioErr != nil {
  3229. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3230. // }
  3231. // var respJSON map[string]interface{}
  3232. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3233. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3234. // }
  3235. //
  3236. // var resSix10265 ResultSix10265 //1101结果
  3237. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3238. // result, _ := json.Marshal(respJSON)
  3239. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3240. // utils.ErrorLog("解析失败:%v", err)
  3241. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3242. // return
  3243. // }
  3244. // res.InfRefmsgid = resSix10265.InfRefmsgid
  3245. // res.ErrMsg = resSix10265.ErrMsg
  3246. // res.Cainfo = resSix10265.Cainfo
  3247. // res.WarnMsg = resSix10265.WarnMsg
  3248. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3249. // res.Infcode = infocode
  3250. // }
  3251. //
  3252. // if res.Infcode == 0 {
  3253. // service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  3254. // item.IsSale = 0
  3255. // item.SaleDate = ""
  3256. // item.Bchno = ""
  3257. // service.SaveDF(item)
  3258. // } else {
  3259. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  3260. // }
  3261. // }
  3262. //
  3263. // c.ServeSuccessJSON(map[string]interface{}{
  3264. // "msg": "删除销售数据成功",
  3265. // })
  3266. //
  3267. //}
  3268. // 获取当天起止时间戳
  3269. func GetNowTime() (int64, int64) {
  3270. t := time.Now()
  3271. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  3272. timesamp := addTime.Unix()
  3273. return timesamp, timesamp + 86399
  3274. }
  3275. func (c *HisApiController) ChangeDrugfour() {
  3276. patient_id, _ := c.GetInt64("patient_id")
  3277. admin_user_id, _ := c.GetInt64("admin_user_id")
  3278. times := c.GetString("time", "")
  3279. timeLayout := "2006-01-02"
  3280. loc, _ := time.LoadLocation("Local")
  3281. var stime, etime int64
  3282. if times == "" {
  3283. stime, etime = GetNowTime()
  3284. } else {
  3285. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3286. stime = stmp.Unix()
  3287. etime = stime + 86399
  3288. }
  3289. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3290. //var flows []*models.DrugFlow
  3291. //for _, item := range advicelist {
  3292. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  3293. // flows = append(flows, flow...)
  3294. //}
  3295. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3296. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3297. var err []string
  3298. for _, item := range advicelist {
  3299. prescription := service.GetHisPrescriptionByID(item.PrescriptionId)
  3300. if prescription.OrderStatus == 2 {
  3301. var res FJ3507Result
  3302. var res3507for10188 FJ3507ResultFor10188
  3303. number := strconv.FormatInt(item.ID, 10)
  3304. //进行商品销售接口
  3305. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number, stime)
  3306. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3307. var respJSON3 map[string]interface{}
  3308. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3309. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3311. return
  3312. }
  3313. userJSONBytes3, _ := json.Marshal(respJSON3)
  3314. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 || c.GetAdminUserInfo().CurrentOrgId == 10633 {
  3315. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3316. utils.ErrorLog("解析失败:%v", err)
  3317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3318. return
  3319. }
  3320. //if res3507for10188.Infcode
  3321. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3322. //res.Output = resSix10265.Output
  3323. res.ErrMsg = res3507for10188.ErrMsg
  3324. res.Cainfo = res3507for10188.Cainfo
  3325. res.WarnMsg = res3507for10188.WarnMsg
  3326. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3327. res.Infcode = infocode
  3328. } else {
  3329. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3330. utils.ErrorLog("解析失败:%v", err)
  3331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3332. return
  3333. }
  3334. }
  3335. if res.Infcode == 0 {
  3336. service.SaveDoctoradviceStatus(item.ID, time.Now().Format("2006-01-02"))
  3337. } else {
  3338. err = append(err, item.AdviceName+",销售失败:"+res.ErrMsg)
  3339. }
  3340. } else { //还没结,提示用户去结算,并药品追溯上传
  3341. err = append(err, item.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3342. }
  3343. }
  3344. str := strings.Join(err, " ")
  3345. saveLog(str, str, "3505", "3505自动上传日志")
  3346. c.ServeSuccessJSON(map[string]interface{}{
  3347. "status": "1",
  3348. "msg": err,
  3349. })
  3350. }
  3351. func (c *HisApiController) ChangeDrugFive() {
  3352. id := c.GetString("id")
  3353. ids := strings.Split(id, ",")
  3354. admin_user_id, _ := c.GetInt64("admin_user_id")
  3355. var errs []string
  3356. //校验gui'ge
  3357. for _, value := range ids {
  3358. intValue, _ := strconv.ParseInt(value, 10, 64)
  3359. //file := strconv.FormatInt(int64(num), 10)
  3360. advicelist, _ := service.FindHisAdviceDocAdvice(intValue)
  3361. //for _, item := range advicelist {
  3362. // flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3363. // flows = append(flows, flow...)
  3364. //}
  3365. //roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3366. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3367. for _, item := range advicelist {
  3368. prescription := service.GetHisPrescriptionByID(item.PrescriptionId)
  3369. if prescription.OrderStatus != 2 {
  3370. // 将时间戳转换为time.Time类型
  3371. t := time.Unix(item.RecordDate, 0) // 注意第二个参数是纳秒,这里是0
  3372. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, item.PatientId)
  3373. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.AdviceName+"医嘱没结算无法上传")
  3374. }
  3375. if len(item.DrugCode) > 0 {
  3376. t := time.Unix(item.RecordDate, 0) // 注意第二个参数是纳秒,这里是0
  3377. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, item.PatientId)
  3378. codes := strings.Split(item.DrugCode, ",")
  3379. for _, code := range codes {
  3380. if len(code) > 0 {
  3381. if len(code) != 20 {
  3382. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.AdviceName+" 溯源码"+code+"位数不是20位")
  3383. }
  3384. if IsDigit(code) == false {
  3385. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.AdviceName+" 溯源码"+code+"不是纯数字")
  3386. }
  3387. }
  3388. }
  3389. }
  3390. }
  3391. }
  3392. utils.ErrorLog("接口返回数据解析JSON失败: %v", errs)
  3393. if len(errs) > 0 {
  3394. c.ServeSuccessJSON(map[string]interface{}{
  3395. "failed_code": -10,
  3396. "msg": errs,
  3397. })
  3398. return
  3399. }
  3400. for _, value := range ids {
  3401. intValue, _ := strconv.ParseInt(value, 10, 64)
  3402. //file := strconv.FormatInt(int64(num), 10)
  3403. advicelist, _ := service.FindHisAdviceDocAdvice(intValue)
  3404. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3405. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3406. for _, item := range advicelist {
  3407. prescription := service.GetHisPrescriptionByID(item.PrescriptionId)
  3408. if prescription.OrderStatus == 2 {
  3409. var res FJ3507Result
  3410. var res3507for10188 FJ3507ResultFor10188
  3411. number := strconv.FormatInt(item.ID, 10)
  3412. //进行商品销售接口
  3413. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number, item.RecordDate)
  3414. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3415. var respJSON3 map[string]interface{}
  3416. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3417. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3419. return
  3420. }
  3421. userJSONBytes3, _ := json.Marshal(respJSON3)
  3422. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 || c.GetAdminUserInfo().CurrentOrgId == 10633 {
  3423. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3424. utils.ErrorLog("解析失败:%v", err)
  3425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3426. return
  3427. }
  3428. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3429. res.ErrMsg = res3507for10188.ErrMsg
  3430. res.Cainfo = res3507for10188.Cainfo
  3431. res.WarnMsg = res3507for10188.WarnMsg
  3432. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3433. res.Infcode = infocode
  3434. } else {
  3435. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3436. utils.ErrorLog("解析失败:%v", err)
  3437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3438. return
  3439. }
  3440. }
  3441. if res.Infcode == 0 {
  3442. service.SaveDoctoradviceStatus(item.ID, time.Now().Format("2006-01-02"))
  3443. } else {
  3444. errs = append(errs, item.AdviceName+",销售失败:"+res.ErrMsg)
  3445. }
  3446. } else { //还没结,提示用户去结算,并药品追溯上传
  3447. errs = append(errs, item.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3448. }
  3449. }
  3450. str := strings.Join(errs, " ")
  3451. saveLog(str, str, "3505", "3505自动上传日志")
  3452. }
  3453. c.ServeSuccessJSON(map[string]interface{}{
  3454. "status": "1",
  3455. "msg": errs,
  3456. })
  3457. }
  3458. //func (c *HisApiController) ChangeDrugfour() {
  3459. // patient_id, _ := c.GetInt64("patient_id")
  3460. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3461. // //id_arr := strings.Split(ids, ",")
  3462. // times := c.GetString("time", "")
  3463. // timeLayout := "2006-01-02"
  3464. // loc, _ := time.LoadLocation("Local")
  3465. // var stime, etime int64
  3466. // if times == "" {
  3467. // stime, etime = GetNowTime()
  3468. // } else {
  3469. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3470. // stime = stmp.Unix()
  3471. // etime = stime + 86399
  3472. // }
  3473. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3474. // var flows []*models.DrugFlow
  3475. // for _, item := range advicelist {
  3476. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3477. // flows = append(flows, flow...)
  3478. // }
  3479. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3480. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3481. // var err []string
  3482. //
  3483. // for _, item := range flows {
  3484. // var res3 ResultSix
  3485. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3486. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3487. // if prescription.OrderStatus == 2 {
  3488. // //已经结算
  3489. // //判断是否已经销售
  3490. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3491. // //是否已经变更 1是 0否
  3492. // if item.IsChange == 0 { //没变更,进行变更操作
  3493. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3494. //
  3495. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3496. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3497. // var respJSON3 map[string]interface{}
  3498. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3499. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3500. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3501. // return
  3502. // }
  3503. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3504. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3505. // utils.ErrorLog("解析失败:%v", err)
  3506. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3507. // return
  3508. // }
  3509. // if res3.Infcode == 0 {
  3510. // item.IsChange = 1
  3511. // item.BgBchno = bg_number
  3512. // service.SaveDF2(item)
  3513. // } else {
  3514. //
  3515. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3516. // }
  3517. // }
  3518. // } else { //没销售,
  3519. // var res FJ3507Result
  3520. // var res3507for10188 FJ3507ResultFor10188
  3521. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3522. //
  3523. // //进行商品销售接口
  3524. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3525. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3526. // var respJSON3 map[string]interface{}
  3527. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3528. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3529. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3530. // return
  3531. // }
  3532. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3533. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3534. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3535. // utils.ErrorLog("解析失败:%v", err)
  3536. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3537. // return
  3538. // }
  3539. // //if res3507for10188.Infcode
  3540. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3541. // //res.Output = resSix10265.Output
  3542. // res.ErrMsg = res3507for10188.ErrMsg
  3543. // res.Cainfo = res3507for10188.Cainfo
  3544. // res.WarnMsg = res3507for10188.WarnMsg
  3545. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3546. // res.Infcode = infocode
  3547. // } else {
  3548. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3549. // utils.ErrorLog("解析失败:%v", err)
  3550. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3551. // return
  3552. // }
  3553. //
  3554. // }
  3555. // if res.Infcode == 0 {
  3556. // item.IsSale = 1
  3557. // item.Bchno = number
  3558. // item.SaleDate = time.Now().Format("2006-01-02")
  3559. //
  3560. // err5 := service.SaveDF(item)
  3561. // if err5 == nil {
  3562. // if item.IsChange == 0 { //没变更,进行变更操作
  3563. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3564. //
  3565. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3566. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3567. //
  3568. // var respJSON3 map[string]interface{}
  3569. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3570. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3571. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3572. // return
  3573. // }
  3574. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3575. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3576. // utils.ErrorLog("解析失败:%v", err)
  3577. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3578. // return
  3579. // }
  3580. // //if res3507for10188.Infcode
  3581. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3582. // //res.Output = resSix10265.Output
  3583. // res3.ErrMsg = res3507for10188.ErrMsg
  3584. // res3.Cainfo = res3507for10188.Cainfo
  3585. // res3.WarnMsg = res3507for10188.WarnMsg
  3586. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3587. // res3.Infcode = infocode
  3588. // } else {
  3589. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3590. // utils.ErrorLog("解析失败:%v", err)
  3591. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3592. // return
  3593. // }
  3594. // }
  3595. // if res3.Infcode == 0 {
  3596. // item.IsChange = 1
  3597. // item.BgBchno = bg_number
  3598. // service.SaveDF2(item)
  3599. // } else {
  3600. //
  3601. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3602. // }
  3603. // }
  3604. // }
  3605. // } else {
  3606. //
  3607. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3608. // }
  3609. // }
  3610. //
  3611. // } else { //还没结,提示用户去结算,并药品追溯上传
  3612. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3613. // }
  3614. // }
  3615. // }
  3616. // if len(err) == 0 {
  3617. // c.ServeSuccessJSON(map[string]interface{}{
  3618. // "msg": "销售变更成功",
  3619. // })
  3620. // } else {
  3621. // c.ServeSuccessJSON(map[string]interface{}{
  3622. // "failed_code": -10,
  3623. // "msg": err,
  3624. // })
  3625. // }
  3626. //}
  3627. //func (c *HisApiController) ChangeDrug() {
  3628. // ids := c.GetString("ids")
  3629. // id_arr := strings.Split(ids, ",")
  3630. // flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3631. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3632. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3633. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3634. // var err []string
  3635. // for _, item := range flows {
  3636. // var res3 ResultSix
  3637. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3638. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3639. // if prescription.OrderStatus == 2 {
  3640. // //已经结算
  3641. // //判断是否已经销售
  3642. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3643. // //是否已经变更 1是 0否
  3644. // if item.IsChange == 0 { //没变更,进行变更操作
  3645. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3646. //
  3647. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3648. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3649. // var respJSON3 map[string]interface{}
  3650. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3651. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3652. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3653. // return
  3654. // }
  3655. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3656. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3657. // utils.ErrorLog("解析失败:%v", err)
  3658. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3659. // return
  3660. // }
  3661. // if res3.Infcode == 0 {
  3662. // item.IsChange = 1
  3663. // item.BgBchno = bg_number
  3664. // service.SaveDF2(item)
  3665. // } else {
  3666. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3667. // }
  3668. // }
  3669. // } else { //没销售,
  3670. // var res FJ3507Result
  3671. // var res3507for10188 FJ3507ResultFor10188
  3672. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3673. //
  3674. // //进行商品销售接口
  3675. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3676. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3677. // var respJSON3 map[string]interface{}
  3678. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3679. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3680. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3681. // return
  3682. // }
  3683. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3684. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3685. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3686. // utils.ErrorLog("解析失败:%v", err)
  3687. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3688. // return
  3689. // }
  3690. // //if res3507for10188.Infcode
  3691. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3692. // //res.Output = resSix10265.Output
  3693. // res.ErrMsg = res3507for10188.ErrMsg
  3694. // res.Cainfo = res3507for10188.Cainfo
  3695. // res.WarnMsg = res3507for10188.WarnMsg
  3696. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3697. // res.Infcode = infocode
  3698. // } else {
  3699. //
  3700. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3701. // utils.ErrorLog("解析失败:%v", err)
  3702. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3703. // return
  3704. // }
  3705. //
  3706. // }
  3707. //
  3708. // if res.Infcode == 0 {
  3709. // item.IsSale = 1
  3710. // item.Bchno = number
  3711. // item.SaleDate = time.Now().Format("2006-01-02")
  3712. //
  3713. // err5 := service.SaveDF(item)
  3714. // if err5 == nil {
  3715. // if item.IsChange == 0 { //没变更,进行变更操作
  3716. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3717. //
  3718. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3719. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3720. //
  3721. // var respJSON3 map[string]interface{}
  3722. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3723. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3724. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3725. // return
  3726. // }
  3727. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3728. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3729. // utils.ErrorLog("解析失败:%v", err)
  3730. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3731. // return
  3732. // }
  3733. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3734. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3735. // utils.ErrorLog("解析失败:%v", err)
  3736. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3737. // return
  3738. // }
  3739. // //if res3507for10188.Infcode
  3740. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3741. // //res.Output = resSix10265.Output
  3742. // res3.ErrMsg = res3507for10188.ErrMsg
  3743. // res3.Cainfo = res3507for10188.Cainfo
  3744. // res3.WarnMsg = res3507for10188.WarnMsg
  3745. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3746. // res3.Infcode = infocode
  3747. // } else {
  3748. //
  3749. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3750. // utils.ErrorLog("解析失败:%v", err)
  3751. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3752. // return
  3753. // }
  3754. //
  3755. // }
  3756. //
  3757. // if res3.Infcode == 0 {
  3758. // item.IsChange = 1
  3759. // item.BgBchno = bg_number
  3760. // service.SaveDF2(item)
  3761. // } else {
  3762. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3763. // }
  3764. // }
  3765. // }
  3766. // } else {
  3767. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3768. // }
  3769. // }
  3770. //
  3771. // } else { //还没结算
  3772. // var res3507for10188 FJ3507ResultFor10188
  3773. //
  3774. // if item.IsChange == 0 { //没变更,进行变更操作
  3775. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3776. //
  3777. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3778. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3779. //
  3780. // var respJSON3 map[string]interface{}
  3781. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3782. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3783. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3784. // return
  3785. // }
  3786. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3787. //
  3788. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3789. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3790. // utils.ErrorLog("解析失败:%v", err)
  3791. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3792. // return
  3793. // }
  3794. // //if res3507for10188.Infcode
  3795. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3796. // //res.Output = resSix10265.Output
  3797. // res3.ErrMsg = res3507for10188.ErrMsg
  3798. // res3.Cainfo = res3507for10188.Cainfo
  3799. // res3.WarnMsg = res3507for10188.WarnMsg
  3800. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3801. // res3.Infcode = infocode
  3802. // } else {
  3803. //
  3804. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3805. // utils.ErrorLog("解析失败:%v", err)
  3806. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3807. // return
  3808. // }
  3809. //
  3810. // }
  3811. //
  3812. // if res3.Infcode == 0 {
  3813. // item.IsChange = 1
  3814. // item.BgBchno = bg_number
  3815. // service.SaveDF2(item)
  3816. // } else {
  3817. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3818. // }
  3819. // }
  3820. // }
  3821. // } else if item.ConsumableType == 7 {
  3822. // var res3507for10188 FJ3507ResultFor10188
  3823. //
  3824. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3825. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3826. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3827. // //判断是否已经销售
  3828. // if item.IsSale == 2 { //是否已经销售,1是 0否
  3829. // //是否已经变更 1是 0否
  3830. // if item.IsChange == 0 { //没变更,进行变更操作
  3831. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3832. //
  3833. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3834. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3835. //
  3836. // var respJSON3 map[string]interface{}
  3837. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3838. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3839. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3840. // return
  3841. // }
  3842. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3843. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3844. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3845. // utils.ErrorLog("解析失败:%v", err)
  3846. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3847. // return
  3848. // }
  3849. // //if res3507for10188.Infcode
  3850. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3851. // //res.Output = resSix10265.Output
  3852. // res3.ErrMsg = res3507for10188.ErrMsg
  3853. // res3.Cainfo = res3507for10188.Cainfo
  3854. // res3.WarnMsg = res3507for10188.WarnMsg
  3855. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3856. // res3.Infcode = infocode
  3857. // } else {
  3858. //
  3859. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3860. // utils.ErrorLog("解析失败:%v", err)
  3861. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3862. // return
  3863. // }
  3864. //
  3865. // }
  3866. // if res3.Infcode == 0 {
  3867. // item.IsChange = 1
  3868. // item.BgBchno = bg_number
  3869. // service.SaveDF2(item)
  3870. // } else {
  3871. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3872. // }
  3873. // }
  3874. // } else { //没销售,
  3875. // //进行商品销售退货接口
  3876. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3877. //
  3878. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3879. // saveLog(result111, result222, "3506", "销售退货")
  3880. // var res7 FJ3507Result
  3881. //
  3882. // //进行商品销售接口
  3883. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3884. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3885. // var respJSON3 map[string]interface{}
  3886. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3887. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3888. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3889. // return
  3890. // }
  3891. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3892. //
  3893. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3894. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3895. // utils.ErrorLog("解析失败:%v", err)
  3896. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3897. // return
  3898. // }
  3899. // //if res3507for10188.Infcode
  3900. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3901. // //res.Output = resSix10265.Output
  3902. // res7.ErrMsg = res3507for10188.ErrMsg
  3903. // res7.Cainfo = res3507for10188.Cainfo
  3904. // res7.WarnMsg = res3507for10188.WarnMsg
  3905. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3906. // res7.Infcode = infocode
  3907. // } else {
  3908. //
  3909. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3910. // utils.ErrorLog("解析失败:%v", err)
  3911. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3912. // return
  3913. // }
  3914. //
  3915. // }
  3916. // if res7.Infcode == 0 {
  3917. // item.IsSale = 2
  3918. // item.SaleDate = item.SaleDate
  3919. // item.Bchno = number
  3920. // service.SaveDF(item)
  3921. // if item.IsChange == 0 { //没变更,进行变更操作
  3922. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3923. //
  3924. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3925. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3926. //
  3927. // var respJSON3 map[string]interface{}
  3928. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3929. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3930. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3931. // return
  3932. // }
  3933. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3934. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3935. // // utils.ErrorLog("解析失败:%v", err)
  3936. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3937. // // return
  3938. // //}
  3939. //
  3940. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3941. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3942. // utils.ErrorLog("解析失败:%v", err)
  3943. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3944. // return
  3945. // }
  3946. // //if res3507for10188.Infcode
  3947. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3948. // //res.Output = resSix10265.Output
  3949. // res3.ErrMsg = res3507for10188.ErrMsg
  3950. // res3.Cainfo = res3507for10188.Cainfo
  3951. // res3.WarnMsg = res3507for10188.WarnMsg
  3952. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3953. // res3.Infcode = infocode
  3954. // } else {
  3955. //
  3956. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3957. // utils.ErrorLog("解析失败:%v", err)
  3958. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3959. // return
  3960. // }
  3961. //
  3962. // }
  3963. // if res3.Infcode == 0 {
  3964. // item.IsChange = 1
  3965. // item.BgBchno = bg_number
  3966. // service.SaveDF2(item)
  3967. // } else {
  3968. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3969. // }
  3970. // }
  3971. // } else {
  3972. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3973. // }
  3974. // }
  3975. // } else { //还没结算
  3976. // if item.IsChange == 0 { //没变更,进行变更操作
  3977. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3978. //
  3979. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3980. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3981. //
  3982. // var respJSON3 map[string]interface{}
  3983. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3984. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3985. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3986. // return
  3987. // }
  3988. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3989. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3990. // // utils.ErrorLog("解析失败:%v", err)
  3991. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3992. // // return
  3993. // //}
  3994. //
  3995. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3996. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3997. // utils.ErrorLog("解析失败:%v", err)
  3998. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3999. // return
  4000. // }
  4001. // //if res3507for10188.Infcode
  4002. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4003. // //res.Output = resSix10265.Output
  4004. // res3.ErrMsg = res3507for10188.ErrMsg
  4005. // res3.Cainfo = res3507for10188.Cainfo
  4006. // res3.WarnMsg = res3507for10188.WarnMsg
  4007. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4008. // res3.Infcode = infocode
  4009. // } else {
  4010. //
  4011. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4012. // utils.ErrorLog("解析失败:%v", err)
  4013. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4014. // return
  4015. // }
  4016. //
  4017. // }
  4018. // if res3.Infcode == 0 {
  4019. // item.IsChange = 1
  4020. // item.BgBchno = bg_number
  4021. // service.SaveDF2(item)
  4022. // } else {
  4023. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4024. // }
  4025. // }
  4026. // }
  4027. // }
  4028. // }
  4029. // if len(err) == 0 {
  4030. // c.ServeSuccessJSON(map[string]interface{}{
  4031. // "msg": "销售变更成功",
  4032. // })
  4033. // } else {
  4034. // c.ServeSuccessJSON(map[string]interface{}{
  4035. // "failed_code": -10,
  4036. // "msg": err,
  4037. // })
  4038. // }
  4039. //}
  4040. //func (c *HisApiController) ChangeDrugtwo() {
  4041. //
  4042. // //ids := c.GetString("ids")
  4043. // //id_arr := strings.Split(ids, ",")
  4044. // flows, _ := service.GetNewDrugFlowInfothree123()
  4045. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4046. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4047. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4048. // var err []string
  4049. // for _, item := range flows {
  4050. // var res3 ResultSix
  4051. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4052. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4053. // if prescription.OrderStatus == 2 {
  4054. // //已经结算
  4055. // //判断是否已经销售
  4056. // //if item.IsSale == 1 { //是否已经销售,1是 0否
  4057. // // //是否已经变更 1是 0否
  4058. // // if item.IsChange == 0 { //没变更,进行变更操作
  4059. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4060. // //
  4061. // // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4062. // // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4063. // // var respJSON3 map[string]interface{}
  4064. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4065. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4066. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4067. // // return
  4068. // // }
  4069. // // userJSONBytes3, _ := json.Marshal(respJSON3)
  4070. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4071. // // utils.ErrorLog("解析失败:%v", err)
  4072. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4073. // // return
  4074. // // }
  4075. // // if res3.Infcode == 0 {
  4076. // // item.IsChange = 1
  4077. // // item.BgBchno = bg_number
  4078. // // service.SaveDF2(item)
  4079. // // } else {
  4080. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4081. // // }
  4082. // // }
  4083. // //}
  4084. // //else
  4085. // { //没销售,
  4086. // var res FJ3507Result
  4087. // var res3507for10188 FJ3507ResultFor10188
  4088. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4089. //
  4090. // //进行商品销售接口
  4091. // result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4092. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4093. // var respJSON3 map[string]interface{}
  4094. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4095. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4096. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4097. // return
  4098. // }
  4099. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4100. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4101. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4102. // utils.ErrorLog("解析失败:%v", err)
  4103. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4104. // return
  4105. // }
  4106. // //if res3507for10188.Infcode
  4107. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  4108. // //res.Output = resSix10265.Output
  4109. // res.ErrMsg = res3507for10188.ErrMsg
  4110. // res.Cainfo = res3507for10188.Cainfo
  4111. // res.WarnMsg = res3507for10188.WarnMsg
  4112. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4113. // res.Infcode = infocode
  4114. // } else {
  4115. //
  4116. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4117. // utils.ErrorLog("解析失败:%v", err)
  4118. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4119. // return
  4120. // }
  4121. //
  4122. // }
  4123. //
  4124. // if res.Infcode == 0 {
  4125. // item.IsSale = 1
  4126. // item.Bchno = number
  4127. // item.SaleDate = time.Now().Format("2006-01-02")
  4128. //
  4129. // service.SaveDF(item)
  4130. // //if err5 == nil {
  4131. // // if item.IsChange == 0 { //没变更,进行变更操作
  4132. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4133. // //
  4134. // // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4135. // // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4136. // //
  4137. // // var respJSON3 map[string]interface{}
  4138. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4139. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4140. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4141. // // return
  4142. // // }
  4143. // //
  4144. // // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4145. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4146. // // utils.ErrorLog("解析失败:%v", err)
  4147. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4148. // // return
  4149. // // }
  4150. // // //if res3507for10188.Infcode
  4151. // // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4152. // // //res.Output = resSix10265.Output
  4153. // // res3.ErrMsg = res3507for10188.ErrMsg
  4154. // // res3.Cainfo = res3507for10188.Cainfo
  4155. // // res3.WarnMsg = res3507for10188.WarnMsg
  4156. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4157. // // res3.Infcode = infocode
  4158. // // } else {
  4159. // //
  4160. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4161. // // utils.ErrorLog("解析失败:%v", err)
  4162. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4163. // // return
  4164. // // }
  4165. // //
  4166. // // }
  4167. // //
  4168. // // if res3.Infcode == 0 {
  4169. // // item.IsChange = 1
  4170. // // item.BgBchno = bg_number
  4171. // // service.SaveDF2(item)
  4172. // // } else {
  4173. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4174. // // }
  4175. // // }
  4176. // //}
  4177. // } else {
  4178. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4179. // }
  4180. // }
  4181. //
  4182. // } else { //还没结算
  4183. // var res3507for10188 FJ3507ResultFor10188
  4184. //
  4185. // if item.IsChange == 0 { //没变更,进行变更操作
  4186. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4187. //
  4188. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4189. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4190. //
  4191. // var respJSON3 map[string]interface{}
  4192. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4193. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4195. // return
  4196. // }
  4197. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4198. //
  4199. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4200. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4201. // utils.ErrorLog("解析失败:%v", err)
  4202. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4203. // return
  4204. // }
  4205. // //if res3507for10188.Infcode
  4206. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4207. // //res.Output = resSix10265.Output
  4208. // res3.ErrMsg = res3507for10188.ErrMsg
  4209. // res3.Cainfo = res3507for10188.Cainfo
  4210. // res3.WarnMsg = res3507for10188.WarnMsg
  4211. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4212. // res3.Infcode = infocode
  4213. // } else {
  4214. //
  4215. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4216. // utils.ErrorLog("解析失败:%v", err)
  4217. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4218. // return
  4219. // }
  4220. //
  4221. // }
  4222. //
  4223. // if res3.Infcode == 0 {
  4224. // item.IsChange = 1
  4225. // item.BgBchno = bg_number
  4226. // service.SaveDF2(item)
  4227. // } else {
  4228. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4229. // }
  4230. // }
  4231. // }
  4232. // }
  4233. // //if item.ConsumableType == 7 {
  4234. // // var res3507for10188 FJ3507ResultFor10188
  4235. // //
  4236. // // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4237. // // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4238. // // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4239. // // //判断是否已经销售
  4240. // // if item.IsSale == 2 { //是否已经销售,1是 0否
  4241. // // //是否已经变更 1是 0否
  4242. // // if item.IsChange == 0 { //没变更,进行变更操作
  4243. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4244. // //
  4245. // // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4246. // // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4247. // //
  4248. // // var respJSON3 map[string]interface{}
  4249. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4250. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4251. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4252. // // return
  4253. // // }
  4254. // // userJSONBytes3, _ := json.Marshal(respJSON3)
  4255. // // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4256. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4257. // // utils.ErrorLog("解析失败:%v", err)
  4258. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4259. // // return
  4260. // // }
  4261. // // //if res3507for10188.Infcode
  4262. // // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4263. // // //res.Output = resSix10265.Output
  4264. // // res3.ErrMsg = res3507for10188.ErrMsg
  4265. // // res3.Cainfo = res3507for10188.Cainfo
  4266. // // res3.WarnMsg = res3507for10188.WarnMsg
  4267. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4268. // // res3.Infcode = infocode
  4269. // // } else {
  4270. // //
  4271. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4272. // // utils.ErrorLog("解析失败:%v", err)
  4273. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4274. // // return
  4275. // // }
  4276. // //
  4277. // // }
  4278. // // if res3.Infcode == 0 {
  4279. // // item.IsChange = 1
  4280. // // item.BgBchno = bg_number
  4281. // // service.SaveDF2(item)
  4282. // // } else {
  4283. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4284. // // }
  4285. // // }
  4286. // // } else { //没销售,
  4287. // // //进行商品销售退货接口
  4288. // // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4289. // //
  4290. // // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4291. // // saveLog(result111, result222, "3506", "销售退货")
  4292. // // var res7 FJ3507Result
  4293. // //
  4294. // // //进行商品销售接口
  4295. // // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4296. // // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4297. // // var respJSON3 map[string]interface{}
  4298. // // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4299. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4300. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4301. // // return
  4302. // // }
  4303. // // userJSONBytes3, _ := json.Marshal(respJSON3)
  4304. // //
  4305. // // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4306. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4307. // // utils.ErrorLog("解析失败:%v", err)
  4308. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4309. // // return
  4310. // // }
  4311. // // //if res3507for10188.Infcode
  4312. // // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4313. // // //res.Output = resSix10265.Output
  4314. // // res7.ErrMsg = res3507for10188.ErrMsg
  4315. // // res7.Cainfo = res3507for10188.Cainfo
  4316. // // res7.WarnMsg = res3507for10188.WarnMsg
  4317. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4318. // // res7.Infcode = infocode
  4319. // // } else {
  4320. // //
  4321. // // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4322. // // utils.ErrorLog("解析失败:%v", err)
  4323. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4324. // // return
  4325. // // }
  4326. // //
  4327. // // }
  4328. // // if res7.Infcode == 0 {
  4329. // // item.IsSale = 2
  4330. // // item.SaleDate = item.SaleDate
  4331. // // item.Bchno = number
  4332. // // service.SaveDF(item)
  4333. // // if item.IsChange == 0 { //没变更,进行变更操作
  4334. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4335. // //
  4336. // // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4337. // // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4338. // //
  4339. // // var respJSON3 map[string]interface{}
  4340. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4341. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4342. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4343. // // return
  4344. // // }
  4345. // // userJSONBytes3, _ := json.Marshal(respJSON3)
  4346. // // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4347. // // // utils.ErrorLog("解析失败:%v", err)
  4348. // // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4349. // // // return
  4350. // // //}
  4351. // //
  4352. // // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4353. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4354. // // utils.ErrorLog("解析失败:%v", err)
  4355. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4356. // // return
  4357. // // }
  4358. // // //if res3507for10188.Infcode
  4359. // // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4360. // // //res.Output = resSix10265.Output
  4361. // // res3.ErrMsg = res3507for10188.ErrMsg
  4362. // // res3.Cainfo = res3507for10188.Cainfo
  4363. // // res3.WarnMsg = res3507for10188.WarnMsg
  4364. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4365. // // res3.Infcode = infocode
  4366. // // } else {
  4367. // //
  4368. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4369. // // utils.ErrorLog("解析失败:%v", err)
  4370. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4371. // // return
  4372. // // }
  4373. // //
  4374. // // }
  4375. // // if res3.Infcode == 0 {
  4376. // // item.IsChange = 1
  4377. // // item.BgBchno = bg_number
  4378. // // service.SaveDF2(item)
  4379. // // } else {
  4380. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4381. // // }
  4382. // // }
  4383. // // } else {
  4384. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4385. // // }
  4386. // // }
  4387. // // } else { //还没结算
  4388. // // if item.IsChange == 0 { //没变更,进行变更操作
  4389. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4390. // //
  4391. // // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4392. // // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4393. // //
  4394. // // var respJSON3 map[string]interface{}
  4395. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4396. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4397. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4398. // // return
  4399. // // }
  4400. // // userJSONBytes3, _ := json.Marshal(respJSON3)
  4401. // // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4402. // // // utils.ErrorLog("解析失败:%v", err)
  4403. // // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4404. // // // return
  4405. // // //}
  4406. // //
  4407. // // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4408. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4409. // // utils.ErrorLog("解析失败:%v", err)
  4410. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4411. // // return
  4412. // // }
  4413. // // //if res3507for10188.Infcode
  4414. // // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4415. // // //res.Output = resSix10265.Output
  4416. // // res3.ErrMsg = res3507for10188.ErrMsg
  4417. // // res3.Cainfo = res3507for10188.Cainfo
  4418. // // res3.WarnMsg = res3507for10188.WarnMsg
  4419. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4420. // // res3.Infcode = infocode
  4421. // // } else {
  4422. // //
  4423. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4424. // // utils.ErrorLog("解析失败:%v", err)
  4425. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4426. // // return
  4427. // // }
  4428. // //
  4429. // // }
  4430. // // if res3.Infcode == 0 {
  4431. // // item.IsChange = 1
  4432. // // item.BgBchno = bg_number
  4433. // // service.SaveDF2(item)
  4434. // // } else {
  4435. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4436. // // }
  4437. // // }
  4438. // // }
  4439. // //}
  4440. // }
  4441. // if len(err) == 0 {
  4442. // c.ServeSuccessJSON(map[string]interface{}{
  4443. // "msg": "销售变更成功",
  4444. // })
  4445. // } else {
  4446. // c.ServeSuccessJSON(map[string]interface{}{
  4447. // "failed_code": -10,
  4448. // "msg": err,
  4449. // })
  4450. // }
  4451. //}
  4452. //
  4453. //func (c *HisApiController) ChangeDrugthree() {
  4454. //
  4455. // //ids := c.GetString("ids")
  4456. // //id_arr := strings.Split(ids, ",")
  4457. // flows, _ := service.GetNewDrugFlowInfothree()
  4458. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4459. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4460. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4461. // var err []string
  4462. // for _, item := range flows {
  4463. // var res3 ResultSix
  4464. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4465. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4466. // if prescription.OrderStatus == 2 {
  4467. // //已经结算
  4468. // //判断是否已经销售
  4469. // if item.IsSale == 1 { //是否已经销售,1是 0否
  4470. // //是否已经变更 1是 0否
  4471. // if item.IsChange == 0 { //没变更,进行变更操作
  4472. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4473. //
  4474. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4475. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4476. // var respJSON3 map[string]interface{}
  4477. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4478. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4479. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4480. // return
  4481. // }
  4482. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4483. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4484. // utils.ErrorLog("解析失败:%v", err)
  4485. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4486. // return
  4487. // }
  4488. // if res3.Infcode == 0 {
  4489. // item.IsChange = 1
  4490. // item.BgBchno = bg_number
  4491. // service.SaveDF2(item)
  4492. // } else {
  4493. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4494. // }
  4495. // }
  4496. // } else { //没销售,
  4497. // var res FJ3507Result
  4498. // var res3507for10188 FJ3507ResultFor10188
  4499. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4500. //
  4501. // //进行商品销售接口
  4502. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4503. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4504. // var respJSON3 map[string]interface{}
  4505. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4506. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4507. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4508. // return
  4509. // }
  4510. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4511. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4512. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4513. // utils.ErrorLog("解析失败:%v", err)
  4514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4515. // return
  4516. // }
  4517. // //if res3507for10188.Infcode
  4518. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  4519. // //res.Output = resSix10265.Output
  4520. // res.ErrMsg = res3507for10188.ErrMsg
  4521. // res.Cainfo = res3507for10188.Cainfo
  4522. // res.WarnMsg = res3507for10188.WarnMsg
  4523. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4524. // res.Infcode = infocode
  4525. // } else {
  4526. //
  4527. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4528. // utils.ErrorLog("解析失败:%v", err)
  4529. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4530. // return
  4531. // }
  4532. //
  4533. // }
  4534. //
  4535. // if res.Infcode == 0 {
  4536. // item.IsSale = 1
  4537. // item.Bchno = number
  4538. // item.SaleDate = time.Now().Format("2006-01-02")
  4539. //
  4540. // err5 := service.SaveDF(item)
  4541. // if err5 == nil {
  4542. // if item.IsChange == 0 { //没变更,进行变更操作
  4543. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4544. //
  4545. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4546. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4547. //
  4548. // var respJSON3 map[string]interface{}
  4549. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4550. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4551. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4552. // return
  4553. // }
  4554. //
  4555. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4556. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4557. // utils.ErrorLog("解析失败:%v", err)
  4558. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4559. // return
  4560. // }
  4561. // //if res3507for10188.Infcode
  4562. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4563. // //res.Output = resSix10265.Output
  4564. // res3.ErrMsg = res3507for10188.ErrMsg
  4565. // res3.Cainfo = res3507for10188.Cainfo
  4566. // res3.WarnMsg = res3507for10188.WarnMsg
  4567. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4568. // res3.Infcode = infocode
  4569. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4570. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4571. // utils.ErrorLog("解析失败:%v", err)
  4572. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4573. // return
  4574. // }
  4575. // //if res3507for10188.Infcode
  4576. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4577. // //res.Output = resSix10265.Output
  4578. // res3.ErrMsg = res3507for10188.ErrMsg
  4579. // res3.Cainfo = res3507for10188.Cainfo
  4580. // res3.WarnMsg = res3507for10188.WarnMsg
  4581. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4582. // res3.Infcode = infocode
  4583. //
  4584. // } else {
  4585. //
  4586. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4587. // utils.ErrorLog("解析失败:%v", err)
  4588. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4589. // return
  4590. // }
  4591. //
  4592. // }
  4593. //
  4594. // if res3.Infcode == 0 {
  4595. // item.IsChange = 1
  4596. // item.BgBchno = bg_number
  4597. // service.SaveDF2(item)
  4598. // } else {
  4599. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4600. // }
  4601. // }
  4602. // }
  4603. // } else {
  4604. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4605. // }
  4606. // }
  4607. //
  4608. // } else { //还没结算
  4609. // var res3507for10188 FJ3507ResultFor10188
  4610. //
  4611. // if item.IsChange == 0 { //没变更,进行变更操作
  4612. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4613. //
  4614. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4615. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4616. //
  4617. // var respJSON3 map[string]interface{}
  4618. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4619. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4620. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4621. // return
  4622. // }
  4623. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4624. //
  4625. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4626. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4627. // utils.ErrorLog("解析失败:%v", err)
  4628. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4629. // return
  4630. // }
  4631. // //if res3507for10188.Infcode
  4632. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4633. // //res.Output = resSix10265.Output
  4634. // res3.ErrMsg = res3507for10188.ErrMsg
  4635. // res3.Cainfo = res3507for10188.Cainfo
  4636. // res3.WarnMsg = res3507for10188.WarnMsg
  4637. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4638. // res3.Infcode = infocode
  4639. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4640. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4641. // utils.ErrorLog("解析失败:%v", err)
  4642. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4643. // return
  4644. // }
  4645. // //if res3507for10188.Infcode
  4646. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4647. // //res.Output = resSix10265.Output
  4648. // res3.ErrMsg = res3507for10188.ErrMsg
  4649. // res3.Cainfo = res3507for10188.Cainfo
  4650. // res3.WarnMsg = res3507for10188.WarnMsg
  4651. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4652. // res3.Infcode = infocode
  4653. //
  4654. // } else {
  4655. //
  4656. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4657. // utils.ErrorLog("解析失败:%v", err)
  4658. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4659. // return
  4660. // }
  4661. //
  4662. // }
  4663. //
  4664. // if res3.Infcode == 0 {
  4665. // item.IsChange = 1
  4666. // item.BgBchno = bg_number
  4667. // service.SaveDF2(item)
  4668. // } else {
  4669. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4670. // }
  4671. // }
  4672. // }
  4673. // } else if item.ConsumableType == 7 {
  4674. // var res3507for10188 FJ3507ResultFor10188
  4675. //
  4676. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4677. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4678. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4679. // //判断是否已经销售
  4680. // if item.IsSale == 2 { //是否已经销售,1是 0否
  4681. // //是否已经变更 1是 0否
  4682. // if item.IsChange == 0 { //没变更,进行变更操作
  4683. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4684. //
  4685. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4686. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4687. //
  4688. // var respJSON3 map[string]interface{}
  4689. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4690. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4691. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4692. // return
  4693. // }
  4694. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4695. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4696. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4697. // utils.ErrorLog("解析失败:%v", err)
  4698. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4699. // return
  4700. // }
  4701. // //if res3507for10188.Infcode
  4702. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4703. // //res.Output = resSix10265.Output
  4704. // res3.ErrMsg = res3507for10188.ErrMsg
  4705. // res3.Cainfo = res3507for10188.Cainfo
  4706. // res3.WarnMsg = res3507for10188.WarnMsg
  4707. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4708. // res3.Infcode = infocode
  4709. // } else {
  4710. //
  4711. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4712. // utils.ErrorLog("解析失败:%v", err)
  4713. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4714. // return
  4715. // }
  4716. //
  4717. // }
  4718. // if res3.Infcode == 0 {
  4719. // item.IsChange = 1
  4720. // item.BgBchno = bg_number
  4721. // service.SaveDF2(item)
  4722. // } else {
  4723. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4724. // }
  4725. // }
  4726. // } else { //没销售,
  4727. // //进行商品销售退货接口
  4728. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4729. //
  4730. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4731. // saveLog(result111, result222, "3506", "销售退货")
  4732. // var res7 FJ3507Result
  4733. //
  4734. // //进行商品销售接口
  4735. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4736. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4737. // var respJSON3 map[string]interface{}
  4738. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4739. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4740. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4741. // return
  4742. // }
  4743. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4744. //
  4745. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4746. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4747. // utils.ErrorLog("解析失败:%v", err)
  4748. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4749. // return
  4750. // }
  4751. // //if res3507for10188.Infcode
  4752. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4753. // //res.Output = resSix10265.Output
  4754. // res7.ErrMsg = res3507for10188.ErrMsg
  4755. // res7.Cainfo = res3507for10188.Cainfo
  4756. // res7.WarnMsg = res3507for10188.WarnMsg
  4757. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4758. // res7.Infcode = infocode
  4759. // } else {
  4760. //
  4761. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4762. // utils.ErrorLog("解析失败:%v", err)
  4763. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4764. // return
  4765. // }
  4766. //
  4767. // }
  4768. // if res7.Infcode == 0 {
  4769. // item.IsSale = 2
  4770. // item.SaleDate = item.SaleDate
  4771. // item.Bchno = number
  4772. // service.SaveDF(item)
  4773. // if item.IsChange == 0 { //没变更,进行变更操作
  4774. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4775. //
  4776. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4777. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4778. //
  4779. // var respJSON3 map[string]interface{}
  4780. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4781. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4782. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4783. // return
  4784. // }
  4785. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4786. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4787. // // utils.ErrorLog("解析失败:%v", err)
  4788. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4789. // // return
  4790. // //}
  4791. //
  4792. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4793. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4794. // utils.ErrorLog("解析失败:%v", err)
  4795. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4796. // return
  4797. // }
  4798. // //if res3507for10188.Infcode
  4799. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4800. // //res.Output = resSix10265.Output
  4801. // res3.ErrMsg = res3507for10188.ErrMsg
  4802. // res3.Cainfo = res3507for10188.Cainfo
  4803. // res3.WarnMsg = res3507for10188.WarnMsg
  4804. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4805. // res3.Infcode = infocode
  4806. // } else {
  4807. //
  4808. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4809. // utils.ErrorLog("解析失败:%v", err)
  4810. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4811. // return
  4812. // }
  4813. //
  4814. // }
  4815. // if res3.Infcode == 0 {
  4816. // item.IsChange = 1
  4817. // item.BgBchno = bg_number
  4818. // service.SaveDF2(item)
  4819. // } else {
  4820. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4821. // }
  4822. // }
  4823. // } else {
  4824. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4825. // }
  4826. // }
  4827. // } else { //还没结算
  4828. // if item.IsChange == 0 { //没变更,进行变更操作
  4829. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4830. //
  4831. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4832. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4833. //
  4834. // var respJSON3 map[string]interface{}
  4835. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4836. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4837. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4838. // return
  4839. // }
  4840. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4841. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4842. // // utils.ErrorLog("解析失败:%v", err)
  4843. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4844. // // return
  4845. // //}
  4846. //
  4847. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4848. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4849. // utils.ErrorLog("解析失败:%v", err)
  4850. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4851. // return
  4852. // }
  4853. // //if res3507for10188.Infcode
  4854. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4855. // //res.Output = resSix10265.Output
  4856. // res3.ErrMsg = res3507for10188.ErrMsg
  4857. // res3.Cainfo = res3507for10188.Cainfo
  4858. // res3.WarnMsg = res3507for10188.WarnMsg
  4859. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4860. // res3.Infcode = infocode
  4861. // } else {
  4862. //
  4863. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4864. // utils.ErrorLog("解析失败:%v", err)
  4865. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4866. // return
  4867. // }
  4868. //
  4869. // }
  4870. // if res3.Infcode == 0 {
  4871. // item.IsChange = 1
  4872. // item.BgBchno = bg_number
  4873. // service.SaveDF2(item)
  4874. // } else {
  4875. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4876. // }
  4877. // }
  4878. // }
  4879. // }
  4880. // }
  4881. // if len(err) == 0 {
  4882. // c.ServeSuccessJSON(map[string]interface{}{
  4883. // "msg": "销售变更成功",
  4884. // })
  4885. // } else {
  4886. // c.ServeSuccessJSON(map[string]interface{}{
  4887. // "failed_code": -10,
  4888. // "msg": err,
  4889. // })
  4890. // }
  4891. //}
  4892. //func (c *HisApiController) ChangeDrugTen() {
  4893. // start_time_str := c.GetString("start_time")
  4894. // end_time_str := c.GetString("end_time")
  4895. // //ids := c.GetString("ids")
  4896. // //id_arr := strings.Split(ids, ",")
  4897. // timeLayout := "2006-01-02"
  4898. // loc, _ := time.LoadLocation("Local")
  4899. // theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4900. //
  4901. // recordStartTime := theStartTime.Unix()
  4902. //
  4903. // theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4904. //
  4905. // recordEndTime := theEndTime.Unix()
  4906. //
  4907. // //timestamp := int64(1729612800)
  4908. // flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4909. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4910. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4911. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4912. // var err []string
  4913. // for _, item := range flows {
  4914. // var res3 ResultSix
  4915. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4916. // if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4917. // continue
  4918. // }
  4919. // if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4920. // continue
  4921. // }
  4922. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4923. //
  4924. // if prescription.OrderStatus == 2 {
  4925. // //已经结算
  4926. // //判断 是否已经销售
  4927. // //if item.IsSale == 1 { //是否已经销售,1是 0否
  4928. // ////是否已经变更 1是 0否
  4929. // //if item.IsChange == 0 { //没变更,进行变更操作
  4930. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4931. // //
  4932. // // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4933. // // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4934. // // var respJSON3 map[string]interface{}
  4935. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4936. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4937. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4938. // // return
  4939. // // }
  4940. // // userJSONBytes3, _ := json.Marshal(respJSON3)
  4941. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4942. // // utils.ErrorLog("解析失败:%v", err)
  4943. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4944. // // return
  4945. // // }
  4946. // // if res3.Infcode == 0 {
  4947. // // item.IsChange = 1
  4948. // // item.BgBchno = bg_number
  4949. // // service.SaveDF2(item)
  4950. // // } else {
  4951. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4952. // // }
  4953. // //}
  4954. //
  4955. // //} else
  4956. // if item.IsSale == 0 { //没销售,
  4957. // var res FJ3507Result
  4958. // var res3507for10188 FJ3507ResultFor10188
  4959. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4960. //
  4961. // //进行商品销售接口
  4962. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4963. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4964. // var respJSON3 map[string]interface{}
  4965. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4966. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4967. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4968. // return
  4969. // }
  4970. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4971. // if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 || c.GetAdminUserInfo().CurrentOrgId == 10633 {
  4972. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4973. // utils.ErrorLog("解析失败:%v", err)
  4974. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4975. // return
  4976. // }
  4977. // //if res3507for10188.Infcode
  4978. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  4979. // //res.Output = resSix10265.Output
  4980. // res.ErrMsg = res3507for10188.ErrMsg
  4981. // res.Cainfo = res3507for10188.Cainfo
  4982. // res.WarnMsg = res3507for10188.WarnMsg
  4983. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4984. // res.Infcode = infocode
  4985. // } else if c.GetAdminUserInfo().CurrentOrgId == 10480 {
  4986. //
  4987. // } else {
  4988. //
  4989. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4990. // utils.ErrorLog("解析失败:%v", err)
  4991. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4992. // return
  4993. // }
  4994. //
  4995. // }
  4996. //
  4997. // if res.Infcode == 0 {
  4998. // item.IsSale = 1
  4999. // item.Bchno = number
  5000. // item.SaleDate = time.Now().Format("2006-01-02")
  5001. // service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  5002. //
  5003. // err5 := service.SaveDF(item)
  5004. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  5005. // //if err5 == nil {
  5006. // //
  5007. // // if item.IsChange == 1 { //没变更,进行变更操作
  5008. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5009. // //
  5010. // // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  5011. // // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  5012. // //
  5013. // // var respJSON3 map[string]interface{}
  5014. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5015. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5016. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5017. // // return
  5018. // // }
  5019. // //
  5020. // // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  5021. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5022. // // utils.ErrorLog("解析失败:%v", err)
  5023. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5024. // // return
  5025. // // }
  5026. // // //if res3507for10188.Infcode
  5027. // // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5028. // // //res.Output = resSix10265.Output
  5029. // // res3.ErrMsg = res3507for10188.ErrMsg
  5030. // // res3.Cainfo = res3507for10188.Cainfo
  5031. // // res3.WarnMsg = res3507for10188.WarnMsg
  5032. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5033. // // res3.Infcode = infocode
  5034. // // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5035. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5036. // // utils.ErrorLog("解析失败:%v", err)
  5037. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5038. // // return
  5039. // // }
  5040. // // //if res3507for10188.Infcode
  5041. // // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5042. // // //res.Output = resSix10265.Output
  5043. // // res3.ErrMsg = res3507for10188.ErrMsg
  5044. // // res3.Cainfo = res3507for10188.Cainfo
  5045. // // res3.WarnMsg = res3507for10188.WarnMsg
  5046. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5047. // // res3.Infcode = infocode
  5048. // //
  5049. // // } else {
  5050. // //
  5051. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5052. // // utils.ErrorLog("解析失败:%v", err)
  5053. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5054. // // return
  5055. // // }
  5056. // //
  5057. // // }
  5058. // //
  5059. // // if res3.Infcode == 0 {
  5060. // // item.IsChange = 1
  5061. // // item.BgBchno = bg_number
  5062. // // service.SaveDF2(item)
  5063. // // return
  5064. // // } else {
  5065. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5066. // // }
  5067. // // }
  5068. // //}
  5069. // } else {
  5070. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  5071. // }
  5072. // }
  5073. //
  5074. // }
  5075. // } else if item.ConsumableType == 7 {
  5076. // var res3507for10188 FJ3507ResultFor10188
  5077. //
  5078. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  5079. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  5080. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  5081. // //判断是否已经销售
  5082. // if item.IsSale == 2 { //是否已经销售,1是 0否
  5083. // //是否已经变更 1是 0否
  5084. // if item.IsChange == 0 { //没变更,进行变更操作
  5085. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5086. //
  5087. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5088. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5089. //
  5090. // var respJSON3 map[string]interface{}
  5091. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5092. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5093. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5094. // return
  5095. // }
  5096. // userJSONBytes3, _ := json.Marshal(respJSON3)
  5097. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5098. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5099. // utils.ErrorLog("解析失败:%v", err)
  5100. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5101. // return
  5102. // }
  5103. // //if res3507for10188.Infcode
  5104. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5105. // //res.Output = resSix10265.Output
  5106. // res3.ErrMsg = res3507for10188.ErrMsg
  5107. // res3.Cainfo = res3507for10188.Cainfo
  5108. // res3.WarnMsg = res3507for10188.WarnMsg
  5109. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5110. // res3.Infcode = infocode
  5111. // } else {
  5112. //
  5113. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5114. // utils.ErrorLog("解析失败:%v", err)
  5115. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5116. // return
  5117. // }
  5118. //
  5119. // }
  5120. // if res3.Infcode == 0 {
  5121. // item.IsChange = 1
  5122. // item.BgBchno = bg_number
  5123. // service.SaveDF2(item)
  5124. // } else {
  5125. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5126. // }
  5127. // }
  5128. // } else { //没销售,
  5129. // //进行商品销售退货接口
  5130. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  5131. //
  5132. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  5133. // saveLog(result111, result222, "3506", "销售退货")
  5134. // var res7 FJ3507Result
  5135. //
  5136. // //进行商品销售接口
  5137. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  5138. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  5139. // var respJSON3 map[string]interface{}
  5140. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  5141. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5142. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5143. // return
  5144. // }
  5145. // userJSONBytes3, _ := json.Marshal(respJSON3)
  5146. //
  5147. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5148. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5149. // utils.ErrorLog("解析失败:%v", err)
  5150. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5151. // return
  5152. // }
  5153. // //if res3507for10188.Infcode
  5154. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  5155. // //res.Output = resSix10265.Output
  5156. // res7.ErrMsg = res3507for10188.ErrMsg
  5157. // res7.Cainfo = res3507for10188.Cainfo
  5158. // res7.WarnMsg = res3507for10188.WarnMsg
  5159. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5160. // res7.Infcode = infocode
  5161. // } else {
  5162. //
  5163. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  5164. // utils.ErrorLog("解析失败:%v", err)
  5165. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5166. // return
  5167. // }
  5168. //
  5169. // }
  5170. // if res7.Infcode == 0 {
  5171. // item.IsSale = 2
  5172. // item.SaleDate = item.SaleDate
  5173. // item.Bchno = number
  5174. // service.SaveDF(item)
  5175. // if item.IsChange == 0 { //没变更,进行变更操作
  5176. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5177. //
  5178. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5179. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5180. //
  5181. // var respJSON3 map[string]interface{}
  5182. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5183. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5184. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5185. // return
  5186. // }
  5187. // userJSONBytes3, _ := json.Marshal(respJSON3)
  5188. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5189. // // utils.ErrorLog("解析失败:%v", err)
  5190. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5191. // // return
  5192. // //}
  5193. //
  5194. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5195. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5196. // utils.ErrorLog("解析失败:%v", err)
  5197. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5198. // return
  5199. // }
  5200. // //if res3507for10188.Infcode
  5201. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5202. // //res.Output = resSix10265.Output
  5203. // res3.ErrMsg = res3507for10188.ErrMsg
  5204. // res3.Cainfo = res3507for10188.Cainfo
  5205. // res3.WarnMsg = res3507for10188.WarnMsg
  5206. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5207. // res3.Infcode = infocode
  5208. // } else {
  5209. //
  5210. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5211. // utils.ErrorLog("解析失败:%v", err)
  5212. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5213. // return
  5214. // }
  5215. //
  5216. // }
  5217. // if res3.Infcode == 0 {
  5218. // item.IsChange = 1
  5219. // item.BgBchno = bg_number
  5220. // service.SaveDF2(item)
  5221. // } else {
  5222. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5223. // }
  5224. // }
  5225. // } else {
  5226. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  5227. // }
  5228. // }
  5229. // } else { //还没结算
  5230. // if item.IsChange == 0 { //没变更,进行变更操作
  5231. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5232. //
  5233. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5234. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5235. //
  5236. // var respJSON3 map[string]interface{}
  5237. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5238. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5239. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5240. // return
  5241. // }
  5242. // userJSONBytes3, _ := json.Marshal(respJSON3)
  5243. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5244. // // utils.ErrorLog("解析失败:%v", err)
  5245. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5246. // // return
  5247. // //}
  5248. //
  5249. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5250. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5251. // utils.ErrorLog("解析失败:%v", err)
  5252. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5253. // return
  5254. // }
  5255. // //if res3507for10188.Infcode
  5256. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5257. // //res.Output = resSix10265.Output
  5258. // res3.ErrMsg = res3507for10188.ErrMsg
  5259. // res3.Cainfo = res3507for10188.Cainfo
  5260. // res3.WarnMsg = res3507for10188.WarnMsg
  5261. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5262. // res3.Infcode = infocode
  5263. // } else {
  5264. //
  5265. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5266. // utils.ErrorLog("解析失败:%v", err)
  5267. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5268. // return
  5269. // }
  5270. //
  5271. // }
  5272. // if res3.Infcode == 0 {
  5273. // item.IsChange = 1
  5274. // item.BgBchno = bg_number
  5275. // service.SaveDF2(item)
  5276. // } else {
  5277. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5278. // }
  5279. // }
  5280. // }
  5281. // }
  5282. // }
  5283. // if len(err) == 0 {
  5284. // c.ServeSuccessJSON(map[string]interface{}{
  5285. // "msg": "销售变更成功",
  5286. // })
  5287. // } else {
  5288. // c.ServeSuccessJSON(map[string]interface{}{
  5289. // "failed_code": -10,
  5290. // "msg": err,
  5291. // })
  5292. // }
  5293. //}
  5294. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5295. var struct3502 models.Struct3502
  5296. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5297. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5298. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5299. struct3502.FixmedinsCode = miConfig.Code
  5300. struct3502.Code = miConfig.Code
  5301. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5302. struct3502.Opter = role.UserName
  5303. struct3502.RxFlag = "1"
  5304. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  5305. struct3502.OrgName = miConfig.OrgName
  5306. struct3502.AccessKey = miConfig.AccessKey
  5307. struct3502.RequestUrl = miConfig.Url
  5308. struct3502.SecretKey = miConfig.SecretKey
  5309. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5310. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5311. struct3502.Url = miConfig.Url
  5312. struct3502.AppId = miConfig.Cainfo
  5313. struct3502.AppSecret = miConfig.AppSecret
  5314. struct3502.Enckey = miConfig.EncKey
  5315. struct3502.SignKey = miConfig.SignKey
  5316. struct3502.SecretKey = miConfig.SecretKey
  5317. struct3502.InvChgType = chgType
  5318. struct3502.FixmedinsBchno = number
  5319. struct3502.Cnt = strconv.FormatInt(count, 10)
  5320. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  5321. //result1, result2, _ := service.FJyb3502(struct3502)
  5322. if miConfig.MdtrtareaAdmvs == "350500" {
  5323. result1, result2, _ := service.FJyb3502(struct3502)
  5324. //saveLog(result1, result2, "3502", "3502")
  5325. return result1, result2
  5326. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5327. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  5328. return result1, result2
  5329. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5330. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  5331. return result1, result2
  5332. } else {
  5333. data := make(map[string]interface{})
  5334. data["struct_3502s"] = struct3502
  5335. client := &http.Client{}
  5336. bytesData, _ := json.Marshal(data)
  5337. var req *http.Request
  5338. if miConfig.MdtrtareaAdmvs == "320830" {
  5339. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3502", bytes.NewReader(bytesData))
  5340. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5341. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5342. } else {
  5343. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5344. }
  5345. resp, _ := client.Do(req)
  5346. defer resp.Body.Close()
  5347. body, ioErr := ioutil.ReadAll(resp.Body)
  5348. if ioErr != nil {
  5349. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5350. }
  5351. var respJSON map[string]interface{}
  5352. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5353. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5354. }
  5355. //var resSix10265 ResultSix10265 //1101结果
  5356. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5357. result, _ := json.Marshal(respJSON)
  5358. return string(result), ""
  5359. }
  5360. }
  5361. 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) {
  5362. flow, _ := service.GetNewDrugFlowInfoByPatient(drug.DrugId, stime, org_id)
  5363. Drug, _ := service.GetDrugLibById(drug.DrugId)
  5364. var struct3505 models.Struct3505
  5365. struct3505.MedListCodg = Drug.MedicalInsuranceNumber
  5366. struct3505.FixmedinsHilistId = Drug.MedicalInsuranceNumber
  5367. struct3505.FixmedinsHilistName = Drug.DrugName
  5368. struct3505.FixmedinsBchno = number
  5369. struct3505.Opter = role.UserName
  5370. struct3505.Bchno = "---"
  5371. struct3505.FixmedinsCode = miConfig.Code
  5372. struct3505.Code = miConfig.Code
  5373. struct3505.FinlTrnsPric = strconv.FormatFloat(drug.Price, 'f', -1, 64)
  5374. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5375. struct3505.PrscDrName = roles.UserName
  5376. if org_id == 10191 {
  5377. struct3505.PharName = "刘水山"
  5378. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5379. }
  5380. if org_id == 10188 {
  5381. struct3505.PharName = "李汉清"
  5382. struct3505.PharPracCertNo = "30220200932022010034"
  5383. }
  5384. if org_id == 10217 {
  5385. struct3505.PharName = "张敏"
  5386. struct3505.PharPracCertNo = "30220230432090100108"
  5387. }
  5388. if org_id == 10318 {
  5389. struct3505.PharName = "邹刘阳"
  5390. struct3505.PharPracCertNo = "210441200001378"
  5391. }
  5392. if org_id == 10402 {
  5393. struct3505.PharName = "刘韶健"
  5394. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5395. }
  5396. if org_id == 9919 {
  5397. struct3505.PharName = "周君权"
  5398. struct3505.PharPracCertNo = "089644396094401375"
  5399. }
  5400. if org_id == 10644 {
  5401. struct3505.PharName = "陈金娣"
  5402. struct3505.PharPracCertNo = "20181441500320100066"
  5403. }
  5404. if org_id == 10567 {
  5405. struct3505.PharName = "范小兰"
  5406. struct3505.PharPracCertNo = "0200102079485"
  5407. }
  5408. if org_id == 10721 {
  5409. struct3505.PharName = "孙莉侠"
  5410. struct3505.PharPracCertNo = "060399"
  5411. }
  5412. if org_id == 10726 {
  5413. struct3505.PharName = "彭建福"
  5414. struct3505.PharPracCertNo = "D445281006261"
  5415. }
  5416. if org_id == 10697 {
  5417. struct3505.PharName = "陶海兰"
  5418. struct3505.PharPracCertNo = "0010933"
  5419. }
  5420. if org_id == 10265 {
  5421. struct3505.PharName = "李彩星"
  5422. struct3505.PharPracCertNo = "20171110600110100019"
  5423. }
  5424. if org_id == 10028 {
  5425. struct3505.PharName = "曾细平"
  5426. struct3505.PharPracCertNo = "D440307022134"
  5427. }
  5428. if org_id == 10138 {
  5429. struct3505.PharName = "彭斯遥"
  5430. struct3505.PharPracCertNo = "30220200943042010052"
  5431. }
  5432. if org_id == 10278 {
  5433. struct3505.PharName = "彭斯遥"
  5434. struct3505.PharPracCertNo = "30220200943042010052"
  5435. }
  5436. if org_id == 10610 {
  5437. struct3505.PharName = "彭斯遥"
  5438. struct3505.PharPracCertNo = "30220200943042010052"
  5439. }
  5440. if org_id == 10537 {
  5441. struct3505.PharName = "彭斯遥"
  5442. struct3505.PharPracCertNo = "30220200943042010052"
  5443. }
  5444. if org_id == 9504 {
  5445. struct3505.PharName = "资美红"
  5446. struct3505.PharPracCertNo = "D440904006635"
  5447. }
  5448. if org_id == 10480 {
  5449. struct3505.PharName = "陈思"
  5450. struct3505.PharPracCertNo = "30220240434110010470"
  5451. }
  5452. if org_id == 10653 {
  5453. struct3505.PharName = "邓树英"
  5454. struct3505.PharPracCertNo = "201910026440004734"
  5455. }
  5456. if org_id == 10571 {
  5457. struct3505.PharName = "廖志平"
  5458. struct3505.PharPracCertNo = "0136425"
  5459. }
  5460. if org_id == 10387 {
  5461. struct3505.PharName = "易圣"
  5462. struct3505.PharPracCertNo = "D430726002209"
  5463. }
  5464. if org_id == 10633 {
  5465. struct3505.PharName = "王敏"
  5466. struct3505.PharPracCertNo = "342222199107214042"
  5467. }
  5468. if org_id == 9478 {
  5469. struct3505.PharName = "祁仲钰"
  5470. struct3505.PharPracCertNo = "D440111043488"
  5471. }
  5472. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5473. struct3505.SetlId = order.SetlId
  5474. struct3505.MdtrtSn = order.MdtrtId
  5475. struct3505.ManuLotnum = flow.BatchNumber
  5476. struct3505.ManuDate = time.Unix(flow.ProductDate, 0).Format("2006-01-02")
  5477. struct3505.ExpyEnd = time.Unix(flow.ExpireDate, 0).Format("2006-01-02")
  5478. struct3505.RxFlag = "1"
  5479. if drug.PrescribingNumberUnit != drug.BaseDrugLib.MinUnit {
  5480. struct3505.TrdnFlag = "0"
  5481. } else {
  5482. struct3505.TrdnFlag = "1"
  5483. }
  5484. if drug.ZeroFlag == 1 {
  5485. struct3505.TrdnFlag = "1"
  5486. }
  5487. if drug.ZeroFlag == 2 {
  5488. struct3505.TrdnFlag = "0"
  5489. }
  5490. if org_id == 10610 || org_id == 10278 || org_id == 10138 || org_id == 10537 || org_id == 10028 || org_id == 10191 || org_id == 9478 {
  5491. if Drug.IsZeroFlag == 1 {
  5492. struct3505.TrdnFlag = "1"
  5493. }
  5494. if Drug.IsZeroFlag == 2 {
  5495. struct3505.TrdnFlag = "0"
  5496. }
  5497. }
  5498. struct3505.RtalDocno = order.Number
  5499. struct3505.PsnCertType = "01"
  5500. struct3505.CertNo = order.Certno
  5501. struct3505.PsnNo = order.PsnNo
  5502. struct3505.PsnName = order.PsnName
  5503. struct3505.Url = miConfig.Url
  5504. struct3505.AppId = miConfig.Cainfo
  5505. struct3505.AppSecret = miConfig.AppSecret
  5506. struct3505.Enckey = miConfig.EncKey
  5507. struct3505.SignKey = miConfig.SignKey
  5508. struct3505.SecretKey = miConfig.SecretKey
  5509. strValue := fmt.Sprintf("%.2f", drug.PrescribingNumber)
  5510. struct3505.SelRetnCnt = strValue
  5511. struct3505.SelRetnTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5512. struct3505.SelRetnOpterName = role.UserName
  5513. if order.IsMedicineInsurance == 1 {
  5514. struct3505.MdtrtSetlType = "1"
  5515. } else {
  5516. struct3505.MdtrtSetlType = "2"
  5517. }
  5518. struct3505.OrgName = miConfig.OrgName
  5519. struct3505.AccessKey = miConfig.AccessKey
  5520. struct3505.RequestUrl = miConfig.Url
  5521. struct3505.SecretKey = miConfig.SecretKey
  5522. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5523. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5524. struct3505.Cainfo = miConfig.Cainfo
  5525. struct3505.DrugTracCodg = drug.DrugCode
  5526. if miConfig.MdtrtareaAdmvs == "350500" {
  5527. result1, result2, _ := service.FJyb3505(struct3505)
  5528. return result1, result2
  5529. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5530. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5531. return result1, result2
  5532. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5533. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5534. return result1, result2
  5535. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5536. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5537. return result1, result2
  5538. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "360") {
  5539. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5540. return result1, result2
  5541. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5542. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5543. return result1, result2
  5544. } else if miConfig.MdtrtareaAdmvs == "150404" {
  5545. data := make(map[string]interface{})
  5546. data["struct_3505s"] = struct3505
  5547. client := &http.Client{}
  5548. bytesData, _ := json.Marshal(data)
  5549. var req *http.Request
  5550. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  5551. resp, _ := client.Do(req)
  5552. defer resp.Body.Close()
  5553. body, ioErr := ioutil.ReadAll(resp.Body)
  5554. if ioErr != nil {
  5555. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5556. }
  5557. var respJSON map[string]interface{}
  5558. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5559. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5560. }
  5561. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5562. result, _ := json.Marshal(respJSON)
  5563. return string(result), ""
  5564. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5565. data := make(map[string]interface{})
  5566. data["struct_3505s"] = struct3505
  5567. client := &http.Client{}
  5568. bytesData, _ := json.Marshal(data)
  5569. var req *http.Request
  5570. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3505", bytes.NewReader(bytesData))
  5571. resp, _ := client.Do(req)
  5572. defer resp.Body.Close()
  5573. body, ioErr := ioutil.ReadAll(resp.Body)
  5574. if ioErr != nil {
  5575. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5576. }
  5577. var respJSON map[string]interface{}
  5578. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5579. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5580. }
  5581. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5582. if status == "0" {
  5583. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5584. utils.ErrorLog("接口返回数据读取失败: %v", err_msg)
  5585. }
  5586. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5587. result, _ := json.Marshal(respJSON)
  5588. return string(result), ""
  5589. } else if miConfig.MdtrtareaAdmvs == "430800" {
  5590. result1, result2 := service.Hnyb3505(struct3505)
  5591. return result1, result2
  5592. } else {
  5593. data := make(map[string]interface{})
  5594. data["struct_3505s"] = struct3505
  5595. client := &http.Client{}
  5596. bytesData, _ := json.Marshal(data)
  5597. var req *http.Request
  5598. if miConfig.MdtrtareaAdmvs == "320830" {
  5599. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3505", bytes.NewReader(bytesData))
  5600. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5601. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5602. } else {
  5603. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5604. }
  5605. resp, _ := client.Do(req)
  5606. defer resp.Body.Close()
  5607. body, ioErr := ioutil.ReadAll(resp.Body)
  5608. if ioErr != nil {
  5609. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5610. }
  5611. var respJSON map[string]interface{}
  5612. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5613. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5614. }
  5615. //var resSix10265 ResultSix10265 //1101结果
  5616. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5617. result, _ := json.Marshal(respJSON)
  5618. return string(result), ""
  5619. }
  5620. }
  5621. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5622. var struct3505 models.Struct3505
  5623. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5624. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5625. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5626. struct3505.FixmedinsBchno = number
  5627. struct3505.Opter = role.UserName
  5628. struct3505.FixmedinsCode = miConfig.Code
  5629. struct3505.Code = miConfig.Code
  5630. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5631. struct3505.PrscDrName = roles.UserName
  5632. if org_id == 10191 {
  5633. struct3505.PharName = "刘水山"
  5634. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5635. }
  5636. if org_id == 10188 {
  5637. struct3505.PharName = "李汉清"
  5638. struct3505.PharPracCertNo = "30220200932022010034"
  5639. }
  5640. if org_id == 10217 {
  5641. struct3505.PharName = "张敏"
  5642. struct3505.PharPracCertNo = "30220230432090100108"
  5643. }
  5644. if org_id == 10318 {
  5645. struct3505.PharName = "邹刘阳"
  5646. struct3505.PharPracCertNo = "210441200001378"
  5647. }
  5648. if org_id == 10402 {
  5649. struct3505.PharName = "刘韶健"
  5650. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5651. }
  5652. if org_id == 9919 {
  5653. struct3505.PharName = "周君权"
  5654. struct3505.PharPracCertNo = "089644396094401375"
  5655. }
  5656. if org_id == 10644 {
  5657. struct3505.PharName = "陈金娣"
  5658. struct3505.PharPracCertNo = "20181441500320100066"
  5659. }
  5660. if org_id == 10567 {
  5661. struct3505.PharName = "范小兰"
  5662. struct3505.PharPracCertNo = "0200102079485"
  5663. }
  5664. if org_id == 10721 {
  5665. struct3505.PharName = "孙莉侠"
  5666. struct3505.PharPracCertNo = "060399"
  5667. }
  5668. if org_id == 10726 {
  5669. struct3505.PharName = "彭建福"
  5670. struct3505.PharPracCertNo = "D445281006261"
  5671. }
  5672. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5673. struct3505.SetlId = order.SetlId
  5674. struct3505.MdtrtSn = order.MdtrtId
  5675. struct3505.ManuLotnum = drug.Number
  5676. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5677. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5678. struct3505.RxFlag = "1"
  5679. struct3505.TrdnFlag = "0"
  5680. struct3505.RtalDocno = order.Number
  5681. struct3505.PsnCertType = "01"
  5682. struct3505.CertNo = order.Certno
  5683. struct3505.PsnNo = order.PsnNo
  5684. struct3505.PsnName = order.PsnName
  5685. struct3505.Url = miConfig.Url
  5686. struct3505.AppId = miConfig.Cainfo
  5687. struct3505.AppSecret = miConfig.AppSecret
  5688. struct3505.Enckey = miConfig.EncKey
  5689. struct3505.SignKey = miConfig.SignKey
  5690. struct3505.SecretKey = miConfig.SecretKey
  5691. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5692. struct3505.SelRetnCnt = strValue
  5693. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5694. struct3505.SelRetnOpterName = role.UserName
  5695. if order.IsMedicineInsurance == 1 {
  5696. struct3505.MdtrtSetlType = "1"
  5697. } else {
  5698. struct3505.MdtrtSetlType = "2"
  5699. }
  5700. struct3505.OrgName = miConfig.OrgName
  5701. struct3505.AccessKey = miConfig.AccessKey
  5702. struct3505.RequestUrl = miConfig.Url
  5703. struct3505.SecretKey = miConfig.SecretKey
  5704. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5705. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5706. struct3505.Cainfo = miConfig.Cainfo
  5707. struct3505.DrugTracCodg = drug.DrugCode
  5708. if miConfig.MdtrtareaAdmvs == "350500" {
  5709. result1, result2, _ := service.FJyb3505(struct3505)
  5710. return result1, result2
  5711. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5712. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5713. return result1, result2
  5714. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5715. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5716. return result1, result2
  5717. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5718. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5719. return result1, result2
  5720. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5721. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5722. return result1, result2
  5723. } else {
  5724. data := make(map[string]interface{})
  5725. data["struct_3505s"] = struct3505
  5726. client := &http.Client{}
  5727. bytesData, _ := json.Marshal(data)
  5728. var req *http.Request
  5729. if miConfig.MdtrtareaAdmvs == "320830" {
  5730. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3505", bytes.NewReader(bytesData))
  5731. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5732. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5733. } else {
  5734. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5735. }
  5736. resp, _ := client.Do(req)
  5737. defer resp.Body.Close()
  5738. body, ioErr := ioutil.ReadAll(resp.Body)
  5739. if ioErr != nil {
  5740. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5741. }
  5742. var respJSON map[string]interface{}
  5743. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5744. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5745. }
  5746. //var resSix10265 ResultSix10265 //1101结果
  5747. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5748. result, _ := json.Marshal(respJSON)
  5749. return string(result), ""
  5750. }
  5751. }
  5752. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, role models.UserAdminRole, number string, doc *models.HisDoctorAdviceInfo) (string, string) {
  5753. var struct3506 models.Struct3506
  5754. struct3506.MedListCodg = doc.BaseDrugLib.MedicalInsuranceNumber
  5755. struct3506.FixmedinsHilistId = doc.BaseDrugLib.MedicalInsuranceNumber
  5756. struct3506.FixmedinsHilistName = doc.BaseDrugLib.DrugName
  5757. struct3506.FixmedinsCode = miConfig.Code
  5758. struct3506.Code = miConfig.Code
  5759. struct3506.FixmedinsBchno = number
  5760. struct3506.Opter = role.UserName
  5761. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5762. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5763. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5764. struct3506.MdtrtSn = order.MdtrtId
  5765. struct3506.ExpyEnd = ""
  5766. struct3506.RxFlag = "0"
  5767. if doc.PrescribingNumberUnit != doc.BaseDrugLib.MinUnit {
  5768. struct3506.TrdnFlag = "0"
  5769. } else {
  5770. struct3506.TrdnFlag = "1"
  5771. }
  5772. if org_id == 10610 || org_id == 10278 || org_id == 10138 || org_id == 10537 || org_id == 10028 || org_id == 10191 || org_id == 9478 {
  5773. if doc.BaseDrugLib.IsZeroFlag == 1 {
  5774. struct3506.TrdnFlag = "1"
  5775. }
  5776. if doc.BaseDrugLib.IsZeroFlag == 2 {
  5777. struct3506.TrdnFlag = "0"
  5778. }
  5779. }
  5780. struct3506.TrdnFlag = "1"
  5781. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5782. struct3506.SelRetnCnt = strValue
  5783. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5784. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5785. struct3506.SelRetnOpterName = role.UserName
  5786. struct3506.OrgName = miConfig.OrgName
  5787. struct3506.AccessKey = miConfig.AccessKey
  5788. struct3506.RequestUrl = miConfig.Url
  5789. struct3506.SecretKey = miConfig.SecretKey
  5790. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5791. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5792. struct3506.Url = miConfig.Url
  5793. struct3506.AppId = miConfig.Cainfo
  5794. struct3506.AppSecret = miConfig.AppSecret
  5795. struct3506.Enckey = miConfig.EncKey
  5796. struct3506.SignKey = miConfig.SignKey
  5797. struct3506.SecretKey = miConfig.SecretKey
  5798. struct3506.DrugTracCodg = drug.DrugCode
  5799. if miConfig.MdtrtareaAdmvs == "350500" {
  5800. result1, result2, _ := service.FJyb3506(struct3506)
  5801. return result1, result2
  5802. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5803. result1, result2 := service.Gzyb3506(struct3506, struct3506.SecretKey)
  5804. return result1, result2
  5805. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5806. result1, result2 := service.Gdyb3506(struct3506, struct3506.SecretKey)
  5807. return result1, result2
  5808. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5809. result1, result2 := service.JXyb3506(struct3506, struct3506.SecretKey, struct3506.AccessKey, struct3506.RequestUrl)
  5810. return result1, result2
  5811. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "360") {
  5812. result1, result2 := service.JXyb3506(struct3506, struct3506.SecretKey, struct3506.AccessKey, struct3506.RequestUrl)
  5813. return result1, result2
  5814. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5815. result1, result2 := service.AHyb3506(struct3506, struct3506.SecretKey, struct3506.RequestUrl)
  5816. return result1, result2
  5817. } else if miConfig.MdtrtareaAdmvs == "150404" {
  5818. data := make(map[string]interface{})
  5819. data["struct_3506s"] = struct3506
  5820. client := &http.Client{}
  5821. bytesData, _ := json.Marshal(data)
  5822. var req *http.Request
  5823. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3506", bytes.NewReader(bytesData))
  5824. resp, _ := client.Do(req)
  5825. defer resp.Body.Close()
  5826. body, ioErr := ioutil.ReadAll(resp.Body)
  5827. if ioErr != nil {
  5828. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5829. }
  5830. var respJSON map[string]interface{}
  5831. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5832. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5833. }
  5834. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5835. result, _ := json.Marshal(respJSON)
  5836. return string(result), ""
  5837. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5838. data := make(map[string]interface{})
  5839. data["struct_3506s"] = struct3506
  5840. client := &http.Client{}
  5841. bytesData, _ := json.Marshal(data)
  5842. var req *http.Request
  5843. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3506", bytes.NewReader(bytesData))
  5844. resp, _ := client.Do(req)
  5845. defer resp.Body.Close()
  5846. body, ioErr := ioutil.ReadAll(resp.Body)
  5847. if ioErr != nil {
  5848. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5849. }
  5850. var respJSON map[string]interface{}
  5851. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5852. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5853. }
  5854. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5855. if status == "0" {
  5856. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5857. utils.ErrorLog("接口返回数据读取失败: %v", err_msg)
  5858. }
  5859. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5860. result, _ := json.Marshal(respJSON)
  5861. return string(result), ""
  5862. } else if miConfig.MdtrtareaAdmvs == "430800" {
  5863. result1, result2 := service.Hnyb3506(struct3506)
  5864. return result1, result2
  5865. } else {
  5866. data := make(map[string]interface{})
  5867. data["struct_3506s"] = struct3506
  5868. client := &http.Client{}
  5869. bytesData, _ := json.Marshal(data)
  5870. var req *http.Request
  5871. if miConfig.MdtrtareaAdmvs == "320830" {
  5872. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3506", bytes.NewReader(bytesData))
  5873. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5874. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5875. } else {
  5876. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5877. }
  5878. resp, _ := client.Do(req)
  5879. defer resp.Body.Close()
  5880. body, ioErr := ioutil.ReadAll(resp.Body)
  5881. if ioErr != nil {
  5882. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5883. }
  5884. var respJSON map[string]interface{}
  5885. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5886. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5887. }
  5888. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5889. result, _ := json.Marshal(respJSON)
  5890. return string(result), ""
  5891. }
  5892. }
  5893. func (c *HisApiController) Get1318() {
  5894. adminUser := c.GetAdminUserInfo()
  5895. admin_user_id, _ := c.GetInt64("admin_user_id")
  5896. code := c.GetString("code")
  5897. code = ""
  5898. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5899. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5900. api := ""
  5901. if miConfig.MdtrtareaAdmvs == "320830" {
  5902. api = miConfig.AppSecret + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5903. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5904. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5905. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5906. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5907. } else {
  5908. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5909. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5910. }
  5911. resp, requestErr := http.Get(api)
  5912. if requestErr != nil {
  5913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5914. return
  5915. }
  5916. body, ioErr := ioutil.ReadAll(resp.Body)
  5917. if ioErr != nil {
  5918. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5920. return
  5921. }
  5922. var respJSON map[string]interface{}
  5923. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5924. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5926. return
  5927. }
  5928. //var res Result2406
  5929. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5930. result, _ := json.Marshal(respJSON)
  5931. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5932. utils.ErrorLog("解析失败:%v", err)
  5933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5934. return
  5935. }
  5936. if res.Infcode == "0" {
  5937. c.ServeSuccessJSON(map[string]interface{}{
  5938. "result": "",
  5939. })
  5940. } else {
  5941. c.ServeSuccessJSON(map[string]interface{}{
  5942. "failed_code": -10,
  5943. "msg": res.ErrMsg,
  5944. })
  5945. */return
  5946. //}
  5947. }
  5948. func (c *HisApiController) Get2503() {
  5949. adminUser := c.GetAdminUserInfo()
  5950. admin_user_id, _ := c.GetInt64("admin_user_id")
  5951. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5952. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5953. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5954. }
  5955. func (c *HisApiController) Get2406() {
  5956. id, _ := c.GetInt64("id")
  5957. record_time := c.GetString("record_time")
  5958. his_patient_id, _ := c.GetInt64("his_patient_id")
  5959. admin_user_id, _ := c.GetInt64("admin_user_id")
  5960. diagnosis_id := c.GetString("diagnosis")
  5961. timeLayout := "2006-01-02"
  5962. loc, _ := time.LoadLocation("Local")
  5963. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5964. if err != nil {
  5965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5966. return
  5967. }
  5968. recordDateTime := theTime.Unix()
  5969. adminUser := c.GetAdminUserInfo()
  5970. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5971. var config []*models.HisXtDiagnoseConfig
  5972. for _, item := range diagnosis_ids {
  5973. id, _ := strconv.ParseInt(item, 10, 64)
  5974. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5975. config = append(config, &diagnosisConfig)
  5976. }
  5977. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5978. fmt.Println(his_patient_id)
  5979. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5980. //timestamp := time.Now().Unix()
  5981. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5982. var patientPrescription models.HisPrescriptionInfo
  5983. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5984. if patientPrescription.ID == 0 {
  5985. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5986. }
  5987. var res2 Result2406
  5988. if miConfig.MdtrtareaAdmvs == "341203" {
  5989. data := make(map[string]interface{})
  5990. client := &http.Client{}
  5991. data["psn_no"] = his.PsnNo
  5992. data["mdtrt_id"] = his.Number
  5993. data["operator"] = roles.UserName
  5994. data["cert_no"] = his.IdCardNo
  5995. data["org_name"] = miConfig.OrgName
  5996. data["psn_name"] = his.Name
  5997. data["ipt_otp_no"] = his.IptOtpNo
  5998. data["ipt_psn_sp_flag_type"] = "0901"
  5999. data["ipt_psn_sp_flag"] = "1"
  6000. data["fixmedins_code"] = miConfig.Code
  6001. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6002. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6003. data["url"] = miConfig.Url
  6004. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  6005. bytesData, _ := json.Marshal(data)
  6006. var req *http.Request
  6007. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  6008. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  6009. resp, _ := client.Do(req)
  6010. defer resp.Body.Close()
  6011. body, ioErr := ioutil.ReadAll(resp.Body)
  6012. if ioErr != nil {
  6013. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6015. return
  6016. }
  6017. var respJSON map[string]interface{}
  6018. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6019. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6021. return
  6022. }
  6023. status := respJSON["data"].(map[string]interface{})["status"].(string)
  6024. if status == "0" {
  6025. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  6026. c.ServeSuccessJSON(map[string]interface{}{
  6027. "failed_code": -10,
  6028. "msg": err_msg,
  6029. })
  6030. return
  6031. }
  6032. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6033. userJSONBytes, _ := json.Marshal(respJSON)
  6034. fmt.Println("log")
  6035. fmt.Println(string(userJSONBytes))
  6036. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6037. utils.ErrorLog("解析失败:%v", err)
  6038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6039. return
  6040. }
  6041. } else if miConfig.MdtrtareaAdmvs == "340699" {
  6042. data := make(map[string]interface{})
  6043. client := &http.Client{}
  6044. data["psn_no"] = his.PsnNo
  6045. data["mdtrt_id"] = his.Number
  6046. data["operator"] = roles.UserName
  6047. data["cert_no"] = his.IdCardNo
  6048. data["org_name"] = miConfig.OrgName
  6049. data["psn_name"] = his.Name
  6050. data["ipt_otp_no"] = his.IptOtpNo
  6051. data["ipt_psn_sp_flag_type"] = "0901"
  6052. data["ipt_psn_sp_flag"] = "1"
  6053. data["fixmedins_code"] = miConfig.Code
  6054. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6055. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6056. data["url"] = miConfig.Url
  6057. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  6058. bytesData, _ := json.Marshal(data)
  6059. var req *http.Request
  6060. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  6061. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  6062. resp, _ := client.Do(req)
  6063. defer resp.Body.Close()
  6064. body, ioErr := ioutil.ReadAll(resp.Body)
  6065. if ioErr != nil {
  6066. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6068. return
  6069. }
  6070. var respJSON map[string]interface{}
  6071. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6074. return
  6075. }
  6076. status := respJSON["data"].(map[string]interface{})["status"].(string)
  6077. if status == "0" {
  6078. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  6079. c.ServeSuccessJSON(map[string]interface{}{
  6080. "failed_code": -10,
  6081. "msg": err_msg,
  6082. })
  6083. return
  6084. }
  6085. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6086. userJSONBytes, _ := json.Marshal(respJSON)
  6087. fmt.Println("log")
  6088. fmt.Println(string(userJSONBytes))
  6089. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6090. utils.ErrorLog("解析失败:%v", err)
  6091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6092. return
  6093. }
  6094. }
  6095. if res2.Infcode != 0 {
  6096. adminUser := c.GetAdminUserInfo()
  6097. errlog := &models.HisOrderError{
  6098. UserOrgId: adminUser.CurrentOrgId,
  6099. Ctime: time.Now().Unix(),
  6100. Mtime: time.Now().Unix(),
  6101. ErrMsg: res2.ErrMsg,
  6102. Status: 1,
  6103. PatientId: id,
  6104. RecordTime: recordDateTime,
  6105. Stage: 3,
  6106. }
  6107. service.CreateErrMsgLog(errlog)
  6108. c.ServeSuccessJSON(map[string]interface{}{
  6109. "failed_code": -10,
  6110. "msg": res2.ErrMsg,
  6111. })
  6112. return
  6113. } else {
  6114. c.ServeSuccessJSON(map[string]interface{}{
  6115. "msg": "上传成功",
  6116. })
  6117. return
  6118. }
  6119. }
  6120. func (c *HisApiController) Get4105() {
  6121. }
  6122. func (c *HisApiController) Post5302() {
  6123. patient_id, _ := c.GetInt64("id")
  6124. admin_user_id, _ := c.GetInt64("admin_user_id")
  6125. p, _ := service.GetHisPatientById(patient_id)
  6126. adminUser := c.GetAdminUserInfo()
  6127. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6128. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6129. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  6130. }
  6131. func (c *HisApiController) Get4104() {
  6132. }
  6133. type Output struct {
  6134. CertNo string `json:"certno"`
  6135. PsnName string `json:"psn_name"`
  6136. CardNo string `json:"card_no"`
  6137. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6138. CardSN string `json:"card_sn"`
  6139. PsnCertType string `json:"psn_cert_type"`
  6140. MdtrtCertNo string `json:"mdtrt_cert_no"`
  6141. MdtrtCertType string `json:"mdtrt_cert_type"`
  6142. QRCode string `json:"qrCode"`
  6143. EcToken string `json:"ecToken"`
  6144. }
  6145. type AHResponse struct {
  6146. Body AHBody `json:"body"`
  6147. Code int `json:"code"`
  6148. CSBCode int `json:"csbCode"`
  6149. Message string `json:"message"`
  6150. RequestID string `json:"requestId"`
  6151. State struct{} `json:"state"`
  6152. }
  6153. type AHBody struct {
  6154. ErrMsg string `json:"err_msg"`
  6155. InfRefMsgID string `json:"inf_refmsgid"`
  6156. InfCode int `json:"infcode"`
  6157. Output struct {
  6158. Result []struct {
  6159. BasMednFlag string `json:"bas_medn_flag"`
  6160. ChldMedcFlag string `json:"chld_medc_flag"`
  6161. ChrgitmLv string `json:"chrgitm_lv"`
  6162. Cnt float64 `json:"cnt"`
  6163. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  6164. DrtReimFlag string `json:"drt_reim_flag"`
  6165. FeedetlSn string `json:"feedetl_sn"`
  6166. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6167. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  6168. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6169. ListSpItemFlag string `json:"list_sp_item_flag"`
  6170. LmtUsedFlag string `json:"lmt_used_flag"`
  6171. MedChrgitmType string `json:"med_chrgitm_type"`
  6172. Memo string `json:"memo"`
  6173. OverlmtAmt float64 `json:"overlmt_amt"`
  6174. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6175. Pric float64 `json:"pric"`
  6176. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  6177. SelfpayProp float64 `json:"selfpay_prop"`
  6178. } `json:"result"`
  6179. } `json:"output"`
  6180. }
  6181. type Response struct {
  6182. Output Output `json:"output"`
  6183. Infcode int `json:"infcode"`
  6184. InfRefMsgID string `json:"inf_refmsgid"`
  6185. RefMsgTime string `json:"refmsg_time"`
  6186. RespondTime string `json:"respond_time"`
  6187. ErrMsg string `json:"err_msg"`
  6188. WarnMsg string `json:"warn_msg"`
  6189. SignType string `json:"signtype"`
  6190. CAInfo string `json:"cainfo"`
  6191. }
  6192. func (c *HisApiController) Getquerydata() {
  6193. query_type, _ := c.GetInt64("type")
  6194. refd_setl_flag := c.GetString("refd_setl_flag")
  6195. med_type := c.GetString("med_type")
  6196. //admin_user_id,_ := c.GetInt64("admin_user_id")
  6197. cert_no := c.GetString("cert_no")
  6198. psn_no := c.GetString("psn_no")
  6199. start_time := c.GetString("start_time")
  6200. end_time := c.GetString("end_time")
  6201. page, _ := c.GetInt64("page")
  6202. limit, _ := c.GetInt64("limit")
  6203. var bp models.BusinessParams5262
  6204. bp.RefdSetlFlag = refd_setl_flag
  6205. bp.MedType = med_type
  6206. bp.Certno = cert_no
  6207. bp.Psnno = psn_no
  6208. bp.QBegntime = start_time
  6209. bp.QEndtime = end_time
  6210. if query_type == 1 { //本地
  6211. Post5262(c, bp, page, limit)
  6212. } else { //异地
  6213. Post5267(c, bp, page, limit)
  6214. }
  6215. }
  6216. func (c *HisApiController) Drugscheck() {
  6217. admin_user_id, _ := c.GetInt64("admin_user_id")
  6218. adminUser := c.GetAdminUserInfo()
  6219. var queryResult []QueryResult
  6220. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  6221. for _, item := range drugs {
  6222. result := QueryResult{
  6223. ID: item.ID,
  6224. Name: item.DrugName,
  6225. Code: item.MedicalInsuranceNumber,
  6226. List_type_code: "101",
  6227. }
  6228. queryResult = append(queryResult, result)
  6229. }
  6230. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6231. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6232. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6233. for _, item := range queryResult {
  6234. 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)
  6235. }
  6236. }
  6237. func (c *HisApiController) Goodcheck() {
  6238. admin_user_id, _ := c.GetInt64("admin_user_id")
  6239. adminUser := c.GetAdminUserInfo()
  6240. var queryResult []QueryResult
  6241. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  6242. for _, item := range goods {
  6243. result := QueryResult{
  6244. ID: item.ID,
  6245. Name: item.GoodName,
  6246. Code: item.SocialSecurityDirectoryCode,
  6247. List_type_code: "301",
  6248. }
  6249. queryResult = append(queryResult, result)
  6250. }
  6251. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6252. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6253. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6254. for _, item := range queryResult {
  6255. 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)
  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. }
  6258. }
  6259. func (c *HisApiController) Projectcheck() {
  6260. admin_user_id, _ := c.GetInt64("admin_user_id")
  6261. adminUser := c.GetAdminUserInfo()
  6262. var queryResult []QueryResult
  6263. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  6264. for _, item := range projects {
  6265. result := QueryResult{
  6266. ID: item.ID,
  6267. Name: item.ProjectName,
  6268. Code: item.MedicalCode,
  6269. List_type_code: "201",
  6270. }
  6271. queryResult = append(queryResult, result)
  6272. }
  6273. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6274. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6275. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6276. for _, item := range queryResult {
  6277. 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)
  6278. }
  6279. }
  6280. //func (c *HisApiController)CancleDia(){
  6281. //
  6282. // id, _ := c.GetInt64("id")
  6283. // record_time := c.GetString("record_time")
  6284. // his_patient_id, _ := c.GetInt64("his_patient_id")
  6285. //
  6286. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6287. //
  6288. // diagnosis_id := c.GetString("diagnosis")
  6289. // sick_type, _ := c.GetInt64("sick_type")
  6290. // reg_type, _ := c.GetInt64("p_type")
  6291. // begin_time := c.GetString("begin_time")
  6292. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  6293. //
  6294. //
  6295. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  6296. //
  6297. // fmt.Println(acct_used_flag)
  6298. //
  6299. //
  6300. // timeLayout := "2006-01-02"
  6301. // loc, _ := time.LoadLocation("Local")
  6302. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6303. // if err != nil {
  6304. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6305. // return
  6306. // }
  6307. // recordDateTime := theTime.Unix()
  6308. // adminUser := c.GetAdminUserInfo()
  6309. //
  6310. //
  6311. //
  6312. //
  6313. //
  6314. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6315. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6316. // var patientPrescription models.HisPrescriptionInfo
  6317. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6318. // if patientPrescription.ID == 0 {
  6319. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6320. // }
  6321. // //if patientPrescription.Do
  6322. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6323. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6324. //
  6325. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6326. //
  6327. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  6328. //
  6329. // var config []*models.HisXtDiagnoseConfig
  6330. // for _, item := range diagnosis_ids {
  6331. // id, _ := strconv.ParseInt(item, 10, 64)
  6332. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  6333. // config = append(config, &diagnosisConfig)
  6334. // }
  6335. //
  6336. // sickConfig, _ := service.FindSickById(sick_type)
  6337. //
  6338. //
  6339. // data := make(map[string]interface{})
  6340. // client := &http.Client{}
  6341. // data["psn_no"] = his.PsnNo
  6342. // data["mdtrt_id"] = his.Number
  6343. // data["doctor"] = roles.UserName
  6344. // data["department"] = department.Name
  6345. // data["org_name"] = miConfig.OrgName
  6346. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  6347. // data["doctor_id"] = doctor_info.DoctorNumber
  6348. // data["new_doctor_name"] = doctor_info.UserName
  6349. // data["fixmedins_code"] = miConfig.Code
  6350. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6351. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6352. // data["secret_key"] = miConfig.SecretKey
  6353. // data["sick_code"] = sickConfig.CountryCode
  6354. // data["sick_name"] = sickConfig.ClassName
  6355. // data["url"] = miConfig.Url
  6356. // data["ak"] = miConfig.AccessKey
  6357. // data["begin_time"] = begin_time
  6358. // data["cainfo"] = miConfig.Cainfo
  6359. // data["is_vaild"] = "0"
  6360. //
  6361. // data["dept"] = strconv.FormatInt(department.ID, 10)
  6362. // data["config"] = config
  6363. // bytesData, _ := json.Marshal(data)
  6364. //
  6365. // var req *http.Request
  6366. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  6367. // resp, _ := client.Do(req)
  6368. // defer resp.Body.Close()
  6369. // body, ioErr := ioutil.ReadAll(resp.Body)
  6370. // if ioErr != nil {
  6371. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6372. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6373. // return
  6374. // }
  6375. // var respJSON map[string]interface{}
  6376. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6377. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6378. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6379. // return
  6380. // }
  6381. //
  6382. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6383. // userJSONBytes, _ := json.Marshal(respJSON)
  6384. // fmt.Println("log")
  6385. // fmt.Println(string(userJSONBytes))
  6386. //
  6387. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  6388. // utils.ErrorLog("解析失败:%v", err)
  6389. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6390. // return
  6391. // }
  6392. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  6393. // res2.Output = ressix10265.Output
  6394. // res2.ErrMsg = ressix10265.ErrMsg
  6395. // res2.Cainfo = ressix10265.Cainfo
  6396. // res2.WarnMsg = ressix10265.WarnMsg
  6397. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  6398. // res2.Infcode = infocode
  6399. //
  6400. //}
  6401. func (c *HisApiController) Get4102() {
  6402. order_id, _ := c.GetInt64("order_id")
  6403. admin_user_id, _ := c.GetInt64("admin_user_id")
  6404. stas_type := c.GetString("stas_type")
  6405. order, _ := service.GetHisOrderByIDTwo(order_id)
  6406. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6407. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6408. var pp models.PublicParams
  6409. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6410. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6411. pp.FixmedinsName = miConfig.OrgName
  6412. pp.FixmedinsCode = miConfig.Code
  6413. pp.RequestUrl = miConfig.Url
  6414. pp.Cainfo = miConfig.Cainfo
  6415. pp.SecretKey = miConfig.SecretKey
  6416. pp.AccessKey = miConfig.AccessKey
  6417. pp.OpterName = curRoles.UserName
  6418. if miConfig.MdtrtareaAdmvs == "350500" {
  6419. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6420. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  6421. saveLog(result, request, "4102", "清单确认")
  6422. var dat map[string]interface{}
  6423. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6424. fmt.Println(dat)
  6425. } else {
  6426. fmt.Println(err)
  6427. }
  6428. var empty ResultFourteen
  6429. userJSONBytes, _ := json.Marshal(dat)
  6430. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6431. utils.ErrorLog("解析失败:%v", err)
  6432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6433. return
  6434. }
  6435. if empty.Infcode == 0 {
  6436. c.ServeSuccessJSON(map[string]interface{}{
  6437. "msg": "确认成功",
  6438. })
  6439. return
  6440. }
  6441. } else {
  6442. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6443. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  6444. result3, request3 := service.Jxyb4105(pp)
  6445. saveLog(result, request, "4102", "清单确认")
  6446. saveLog(result2, request2, "4103", "清单确认")
  6447. saveLog(result3, request3, "4105", "清单统计")
  6448. var dat map[string]interface{}
  6449. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6450. fmt.Println(dat)
  6451. } else {
  6452. fmt.Println(err)
  6453. }
  6454. var empty ResultFourteen
  6455. userJSONBytes, _ := json.Marshal(dat)
  6456. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6457. utils.ErrorLog("解析失败:%v", err)
  6458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6459. return
  6460. }
  6461. if empty.Infcode == 0 {
  6462. c.ServeSuccessJSON(map[string]interface{}{
  6463. "msg": "确认成功",
  6464. })
  6465. return
  6466. }
  6467. }
  6468. }
  6469. // 对账权限查询
  6470. func (c *HisApiController) Get3260() {
  6471. admin_user_id, _ := c.GetInt64("admin_user_id")
  6472. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6473. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6474. var api string
  6475. var res models.JSResult3260
  6476. if miConfig.MdtrtareaAdmvs == "320830" {
  6477. api = miConfig.AppSecret + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6478. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6479. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6480. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6481. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6482. } else {
  6483. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6484. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6485. }
  6486. resp, requestErr := http.Get(api)
  6487. if requestErr != nil {
  6488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6489. return
  6490. }
  6491. body, ioErr := ioutil.ReadAll(resp.Body)
  6492. if ioErr != nil {
  6493. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6495. return
  6496. }
  6497. var respJSON map[string]interface{}
  6498. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6499. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6501. return
  6502. }
  6503. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6504. result, _ := json.Marshal(respJSON)
  6505. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6506. utils.ErrorLog("解析失败:%v", err)
  6507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6508. return
  6509. }
  6510. if res.Infcode == "0" {
  6511. c.ServeSuccessJSON(map[string]interface{}{
  6512. "result": res.Output.Data,
  6513. })
  6514. } else {
  6515. c.ServeSuccessJSON(map[string]interface{}{
  6516. "failed_code": -10,
  6517. "msg": res.ErrMsg,
  6518. })
  6519. return
  6520. }
  6521. }
  6522. func (c *HisApiController) Get3261() {
  6523. admin_user_id, _ := c.GetInt64("admin_user_id")
  6524. //month := c.GetString("month")
  6525. startTime := c.GetString("start_time")
  6526. //endTime, _ := c.GetString("end_time")
  6527. times := strings.Split(startTime, "-")
  6528. stmt_mon := times[0] + times[1]
  6529. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6530. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6531. var api string
  6532. var res models.JSResult3261
  6533. //var res10265 Result5301For10265
  6534. if miConfig.MdtrtareaAdmvs == "320830" {
  6535. api = miConfig.AppSecret + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6536. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6537. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6538. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6539. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6540. } else {
  6541. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6542. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6543. }
  6544. resp, requestErr := http.Get(api)
  6545. if requestErr != nil {
  6546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6547. return
  6548. }
  6549. body, ioErr := ioutil.ReadAll(resp.Body)
  6550. if ioErr != nil {
  6551. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6553. return
  6554. }
  6555. var respJSON map[string]interface{}
  6556. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6557. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6559. return
  6560. }
  6561. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6562. result, _ := json.Marshal(respJSON)
  6563. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6564. utils.ErrorLog("解析失败:%v", err)
  6565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6566. return
  6567. }
  6568. if res.Infcode == "0" {
  6569. c.ServeSuccessJSON(map[string]interface{}{
  6570. "result": res.Output,
  6571. })
  6572. } else {
  6573. c.ServeSuccessJSON(map[string]interface{}{
  6574. "failed_code": -10,
  6575. "msg": res.ErrMsg,
  6576. })
  6577. return
  6578. }
  6579. }
  6580. type TempFun struct {
  6581. FundKey string
  6582. FundCode string
  6583. }
  6584. func (c *HisApiController) Get3262() {
  6585. admin_user_id, _ := c.GetInt64("admin_user_id")
  6586. startTime := c.GetString("start_time")
  6587. endTime := c.GetString("end_time")
  6588. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6589. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6590. //timeLayout := "2006-01-02"
  6591. //loc, _ := time.LoadLocation("Local")
  6592. //var theStartTIme int64
  6593. //if len(startTime) > 0 {
  6594. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  6595. // if err != nil {
  6596. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6597. // return
  6598. // }
  6599. // theStartTIme = theTime.Unix()
  6600. //}
  6601. //var theEndtTIme int64
  6602. //if len(endTime) > 0 {
  6603. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  6604. // if err != nil {
  6605. // utils.ErrorLog(err.Error())
  6606. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6607. // return
  6608. // }
  6609. // theEndtTIme = theTime.Unix()
  6610. //}
  6611. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6612. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6613. for _, team := range datas {
  6614. fmt.Println(team.PsnTime)
  6615. for _, team_two := range datas_two {
  6616. fmt.Println(team_two.PsnTime)
  6617. if team.FundKey == team_two.FundKey {
  6618. fmt.Println(team_two.PsnTime)
  6619. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  6620. fmt.Println(team.PsnTime)
  6621. }
  6622. }
  6623. }
  6624. fmt.Println("1111")
  6625. fmt.Println(datas)
  6626. fmt.Println("1111")
  6627. var twos []models.FixMonRecDetailFileInTwo
  6628. for _, team := range datas {
  6629. var two models.FixMonRecDetailFileInTwo
  6630. two.MedType = team.MedType
  6631. two.Insutype = team.Insutype
  6632. two.PsnType = team.PsnType
  6633. two.MedType = team.MedType
  6634. two.FixBlngAdmdvs = "999999"
  6635. two.InsuAdmdvs = "555555"
  6636. two.PsnTime = team.PsnTime
  6637. two.PsnCnt = team.PsnCnt
  6638. two.FundKey = team.FundKey
  6639. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6640. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6641. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6642. two.MedfeeSumAmt = ms
  6643. two.InscpAmt = ia
  6644. two.FundPaySumAmt = fps
  6645. twos = append(twos, two)
  6646. }
  6647. //startTime := c.GetString("start_time")
  6648. //endTime, _ := c.GetString("end_time")
  6649. times := strings.Split(startTime, "-")
  6650. stmt_mon := times[0] + times[1]
  6651. var funs []models.FundDetail
  6652. for _, item := range datas {
  6653. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6654. funs = append(funs, fun...)
  6655. }
  6656. var funInfos []models.Fund
  6657. //for _, item := range funs {
  6658. // var rf []models.FundInfo
  6659. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6660. // for _, subitem := range rf {
  6661. // var fund models.Fund
  6662. // fund.FundCode = subitem.FundPayType
  6663. // fund.FundName = subitem.FundPayTypeName
  6664. // fund.FundAmt = subitem.FundPayAmt
  6665. // fund.FundKey = item.FundKey
  6666. // fund.InsuAdmdvs = "555555"
  6667. // fund.FixBlngAdmdvs = "999999"
  6668. // funInfos = append(funInfos, fund)
  6669. // }
  6670. //}
  6671. var tempFuns []TempFun
  6672. for _, funInfo := range funInfos {
  6673. var tempFun TempFun
  6674. tempFun.FundKey = funInfo.FundKey
  6675. tempFun.FundCode = funInfo.FundCode
  6676. tempFuns = append(tempFuns, tempFun)
  6677. }
  6678. tempFuns = RemoveRepeatedFunElement(tempFuns)
  6679. fmt.Println(tempFuns)
  6680. var funInfosTwo []models.Fund
  6681. decimal.DivisionPrecision = 2
  6682. for _, item := range tempFuns {
  6683. var fund models.Fund
  6684. for _, subItem := range funInfos {
  6685. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  6686. fund.FundKey = subItem.FundKey
  6687. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6688. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6689. fund.FundName = subItem.FundName
  6690. fund.FundCode = subItem.FundCode
  6691. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6692. }
  6693. }
  6694. funInfosTwo = append(funInfosTwo, fund)
  6695. }
  6696. fmt.Println("funInfosTwo")
  6697. fmt.Println(funInfosTwo)
  6698. var upld_btch string
  6699. var empty models.JSResultEmpty
  6700. data := make(map[string]interface{})
  6701. data["org_name"] = miConfig.OrgName
  6702. data["doctor"] = curRoles.UserName
  6703. data["doctor_name"] = curRoles.UserName
  6704. data["fixmedins_code"] = miConfig.Code
  6705. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6706. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6707. data["secret_key"] = miConfig.SecretKey
  6708. data["url"] = miConfig.Url
  6709. data["ak"] = miConfig.AccessKey
  6710. data["cainfo"] = miConfig.Cainfo
  6711. data["datas"] = twos
  6712. data["fund"] = funInfosTwo
  6713. fmt.Println(twos)
  6714. month := time.Unix(1557042972, 0).Format("1")
  6715. year := time.Now().Format("2006")
  6716. month = time.Now().Format("01")
  6717. day := time.Now().Format("02")
  6718. hour := time.Now().Format("15")
  6719. min := time.Now().Format("04")
  6720. sec := time.Now().Format("05")
  6721. fix_fill_date := year + month + day + hour + min + sec
  6722. data["fix_fill_dept"] = miConfig.OrgName
  6723. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6724. data["fix_fill_psn"] = curRoles.UserName
  6725. data["fix_fill_date"] = fix_fill_date
  6726. data["stmt_loc"] = "2"
  6727. data["setl_mon"] = stmt_mon
  6728. upld_btch = "0"
  6729. data["upld_btch"] = upld_btch
  6730. //fmt.Println(data)
  6731. client := &http.Client{}
  6732. bytesData, _ := json.Marshal(data)
  6733. var req *http.Request
  6734. if miConfig.MdtrtareaAdmvs == "320830" {
  6735. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3262", bytes.NewReader(bytesData))
  6736. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6737. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6738. } else {
  6739. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6740. }
  6741. resp, _ := client.Do(req)
  6742. defer resp.Body.Close()
  6743. body, ioErr := ioutil.ReadAll(resp.Body)
  6744. if ioErr != nil {
  6745. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6747. }
  6748. var respJSON map[string]interface{}
  6749. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6750. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6752. }
  6753. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6754. //fmt.Println(respJSON)
  6755. result, _ := json.Marshal(respJSON)
  6756. //fmt.Println(result)
  6757. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6758. utils.ErrorLog("解析失败:%v", err)
  6759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6760. }
  6761. if empty.Infcode != "0" {
  6762. c.ServeSuccessJSON(map[string]interface{}{
  6763. "failed_code": -10,
  6764. "msg": empty.ErrMsg,
  6765. })
  6766. return
  6767. } else {
  6768. c.ServeSuccessJSON(map[string]interface{}{
  6769. "msg": "上传成功",
  6770. })
  6771. return
  6772. }
  6773. }
  6774. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6775. newArr = make([]TempFun, 0)
  6776. for i := 0; i < len(arr); i++ {
  6777. repeat := false
  6778. for j := i + 1; j < len(arr); j++ {
  6779. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6780. repeat = true
  6781. break
  6782. }
  6783. }
  6784. if !repeat {
  6785. newArr = append(newArr, arr[i])
  6786. }
  6787. }
  6788. return
  6789. }
  6790. func (c *HisApiController) Get3263() {
  6791. admin_user_id, _ := c.GetInt64("admin_user_id")
  6792. startTime := c.GetString("start_time")
  6793. //endTime, _ := c.GetString("end_time")
  6794. times := strings.Split(startTime, "-")
  6795. setl_mon := times[0] + times[1]
  6796. upld_btch := "0"
  6797. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6798. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6799. var result3263 models.JSResult3263
  6800. data := make(map[string]interface{})
  6801. data["org_name"] = miConfig.OrgName
  6802. data["doctor"] = curRoles.UserName
  6803. data["doctor_name"] = curRoles.UserName
  6804. data["fixmedins_code"] = miConfig.Code
  6805. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6806. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6807. data["secret_key"] = miConfig.SecretKey
  6808. data["url"] = miConfig.Url
  6809. data["ak"] = miConfig.AccessKey
  6810. data["cainfo"] = miConfig.Cainfo
  6811. data["setl_mon"] = setl_mon
  6812. data["stmt_loc"] = "2"
  6813. data["upld_btch"] = upld_btch
  6814. client := &http.Client{}
  6815. bytesData, _ := json.Marshal(data)
  6816. var req *http.Request
  6817. if miConfig.MdtrtareaAdmvs == "320830" {
  6818. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData))
  6819. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6820. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6821. } else {
  6822. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6823. }
  6824. resp, _ := client.Do(req)
  6825. defer resp.Body.Close()
  6826. body, ioErr := ioutil.ReadAll(resp.Body)
  6827. if ioErr != nil {
  6828. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6830. }
  6831. var respJSON map[string]interface{}
  6832. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6835. }
  6836. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6837. fmt.Println(respJSON)
  6838. result, _ := json.Marshal(respJSON)
  6839. fmt.Println(result)
  6840. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6841. utils.ErrorLog("解析失败:%v", err)
  6842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6843. }
  6844. if result3263.Infcode != "0" {
  6845. c.ServeSuccessJSON(map[string]interface{}{
  6846. "failed_code": -10,
  6847. "msg": result3263.ErrMsg,
  6848. })
  6849. return
  6850. } else {
  6851. c.ServeSuccessJSON(map[string]interface{}{
  6852. "list": result3263.Output,
  6853. })
  6854. return
  6855. }
  6856. }
  6857. func (c *HisApiController) Get3264() {
  6858. admin_user_id, _ := c.GetInt64("admin_user_id")
  6859. startTime := c.GetString("start_time")
  6860. //endTime, _ := c.GetString("end_time")
  6861. times := strings.Split(startTime, "-")
  6862. setl_mon := times[0] + times[1]
  6863. upld_btch := "0"
  6864. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6865. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6866. //solidify_id := []
  6867. var result3263 models.JSResult3263
  6868. data := make(map[string]interface{})
  6869. data["org_name"] = miConfig.OrgName
  6870. data["doctor"] = curRoles.UserName
  6871. data["doctor_name"] = curRoles.UserName
  6872. data["fixmedins_code"] = miConfig.Code
  6873. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6874. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6875. data["secret_key"] = miConfig.SecretKey
  6876. data["url"] = miConfig.Url
  6877. data["ak"] = miConfig.AccessKey
  6878. data["cainfo"] = miConfig.Cainfo
  6879. data["setl_mon"] = setl_mon
  6880. data["stmt_loc"] = "2"
  6881. data["upld_btch"] = upld_btch
  6882. client := &http.Client{}
  6883. bytesData, _ := json.Marshal(data)
  6884. var req3263 *http.Request
  6885. if miConfig.MdtrtareaAdmvs == "320830" {
  6886. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData))
  6887. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6888. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6889. } else {
  6890. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6891. }
  6892. resp, _ := client.Do(req3263)
  6893. defer resp.Body.Close()
  6894. body, ioErr := ioutil.ReadAll(resp.Body)
  6895. if ioErr != nil {
  6896. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6898. }
  6899. var respJSON3263 map[string]interface{}
  6900. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6903. }
  6904. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6905. fmt.Println(respJSON3263)
  6906. result, _ := json.Marshal(respJSON3263)
  6907. fmt.Println(result)
  6908. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6909. utils.ErrorLog("解析失败:%v", err)
  6910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6911. }
  6912. var ids []string
  6913. for _, item := range result3263.Output {
  6914. ids = append(ids, item.SolidifyID)
  6915. }
  6916. var empty models.JSResultEmpty
  6917. data2 := make(map[string]interface{})
  6918. data2["org_name"] = miConfig.OrgName
  6919. data2["doctor"] = curRoles.UserName
  6920. data2["doctor_name"] = curRoles.UserName
  6921. data2["fixmedins_code"] = miConfig.Code
  6922. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6923. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6924. data2["secret_key"] = miConfig.SecretKey
  6925. data2["url"] = miConfig.Url
  6926. data2["ak"] = miConfig.AccessKey
  6927. data2["cainfo"] = miConfig.Cainfo
  6928. data2["setl_mon"] = setl_mon
  6929. data2["stmt_loc"] = "2"
  6930. data2["upld_btch"] = upld_btch
  6931. data2["solidify_id"] = ids
  6932. client2 := &http.Client{}
  6933. bytesData2, _ := json.Marshal(data2)
  6934. var req *http.Request
  6935. if miConfig.MdtrtareaAdmvs == "320830" {
  6936. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3264", bytes.NewReader(bytesData))
  6937. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6938. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6939. } else {
  6940. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6941. }
  6942. resp2, _ := client2.Do(req)
  6943. defer resp.Body.Close()
  6944. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6945. if ioErr2 != nil {
  6946. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6948. }
  6949. var respJSON map[string]interface{}
  6950. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6953. }
  6954. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6955. fmt.Println(respJSON)
  6956. result2, _ := json.Marshal(respJSON)
  6957. fmt.Println(result2)
  6958. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6959. utils.ErrorLog("解析失败:%v", err)
  6960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6961. }
  6962. if empty.Infcode != "0" {
  6963. c.ServeSuccessJSON(map[string]interface{}{
  6964. "failed_code": -10,
  6965. "msg": empty.ErrMsg,
  6966. })
  6967. return
  6968. } else {
  6969. c.ServeSuccessJSON(map[string]interface{}{
  6970. "msg": "",
  6971. })
  6972. return
  6973. }
  6974. }
  6975. func (c *HisApiController) Get3265() {
  6976. admin_user_id, _ := c.GetInt64("admin_user_id")
  6977. startTime := c.GetString("start_time")
  6978. //endTime, _ := c.GetString("end_time")
  6979. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6980. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6981. times := strings.Split(startTime, "-")
  6982. setl_mon := times[0] + times[1]
  6983. var upld_btch string
  6984. upld_btch = "0"
  6985. //var empty models.JSResultEmpty
  6986. var result3265 models.JSResult3264
  6987. var result3263 models.JSResult3263
  6988. data2 := make(map[string]interface{})
  6989. data2["org_name"] = miConfig.OrgName
  6990. data2["doctor"] = curRoles.UserName
  6991. data2["doctor_name"] = curRoles.UserName
  6992. data2["fixmedins_code"] = miConfig.Code
  6993. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6994. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6995. data2["secret_key"] = miConfig.SecretKey
  6996. data2["url"] = miConfig.Url
  6997. data2["ak"] = miConfig.AccessKey
  6998. data2["cainfo"] = miConfig.Cainfo
  6999. data2["setl_mon"] = setl_mon
  7000. data2["stmt_loc"] = "2"
  7001. data2["upld_btch"] = upld_btch
  7002. client2 := &http.Client{}
  7003. bytesData2, _ := json.Marshal(data2)
  7004. var req3263 *http.Request
  7005. if miConfig.MdtrtareaAdmvs == "320830" {
  7006. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData2))
  7007. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7008. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  7009. } else {
  7010. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  7011. }
  7012. resp2, _ := client2.Do(req3263)
  7013. defer resp2.Body.Close()
  7014. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7015. if ioErr2 != nil {
  7016. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7018. }
  7019. var respJSON3263 map[string]interface{}
  7020. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7021. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7023. }
  7024. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7025. fmt.Println(respJSON3263)
  7026. result2, _ := json.Marshal(respJSON3263)
  7027. fmt.Println(result2)
  7028. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7029. utils.ErrorLog("解析失败:%v", err)
  7030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7031. }
  7032. var ids []string
  7033. for _, item := range result3263.Output {
  7034. ids = append(ids, item.SolidifyID)
  7035. }
  7036. data := make(map[string]interface{})
  7037. data["org_name"] = miConfig.OrgName
  7038. data["doctor"] = curRoles.UserName
  7039. data["doctor_name"] = curRoles.UserName
  7040. data["fixmedins_code"] = miConfig.Code
  7041. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7042. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7043. data["secret_key"] = miConfig.SecretKey
  7044. data["url"] = miConfig.Url
  7045. data["ak"] = miConfig.AccessKey
  7046. data["cainfo"] = miConfig.Cainfo
  7047. data["setl_mon"] = setl_mon
  7048. data["solidify_id"] = ids
  7049. month := time.Unix(1557042972, 0).Format("1")
  7050. year := time.Now().Format("2006")
  7051. month = time.Now().Format("01")
  7052. day := time.Now().Format("02")
  7053. hour := time.Now().Format("15")
  7054. min := time.Now().Format("04")
  7055. sec := time.Now().Format("05")
  7056. fix_fill_date := year + month + day + hour + min + sec
  7057. data["fix_fill_dept"] = miConfig.OrgName
  7058. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7059. data["fix_fill_psn"] = curRoles.UserName
  7060. data["fix_fill_date"] = fix_fill_date
  7061. data["stmt_loc"] = "2"
  7062. data["upld_btch"] = upld_btch
  7063. client := &http.Client{}
  7064. bytesData, _ := json.Marshal(data)
  7065. var req *http.Request
  7066. if miConfig.MdtrtareaAdmvs == "320830" {
  7067. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3265", bytes.NewReader(bytesData2))
  7068. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7069. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  7070. } else {
  7071. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  7072. }
  7073. resp, _ := client.Do(req)
  7074. defer resp.Body.Close()
  7075. body, ioErr := ioutil.ReadAll(resp.Body)
  7076. if ioErr != nil {
  7077. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7079. }
  7080. var respJSON map[string]interface{}
  7081. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7082. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7084. }
  7085. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7086. fmt.Println(respJSON)
  7087. result, _ := json.Marshal(respJSON)
  7088. fmt.Println(result)
  7089. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7090. utils.ErrorLog("解析失败:%v", err)
  7091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7092. }
  7093. if result3265.Infcode != "0" {
  7094. c.ServeSuccessJSON(map[string]interface{}{
  7095. "failed_code": -10,
  7096. "msg": result3265.ErrMsg,
  7097. })
  7098. return
  7099. } else {
  7100. c.ServeSuccessJSON(map[string]interface{}{
  7101. "info": result3265.Output,
  7102. })
  7103. return
  7104. }
  7105. }
  7106. func (c *HisApiController) Get3266() {
  7107. admin_user_id, _ := c.GetInt64("admin_user_id")
  7108. startTime := c.GetString("start_time")
  7109. //endTime, _ := c.GetString("end_time")
  7110. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7111. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7112. times := strings.Split(startTime, "-")
  7113. stmt_mon := times[0] + times[1]
  7114. var upld_btch string
  7115. //var empty models.JSResultEmpty
  7116. var result3265 models.JSResult3264
  7117. data := make(map[string]interface{})
  7118. data["org_name"] = miConfig.OrgName
  7119. data["doctor"] = curRoles.UserName
  7120. data["doctor_name"] = curRoles.UserName
  7121. data["fixmedins_code"] = miConfig.Code
  7122. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7123. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7124. data["secret_key"] = miConfig.SecretKey
  7125. data["url"] = miConfig.Url
  7126. data["ak"] = miConfig.AccessKey
  7127. data["cainfo"] = miConfig.Cainfo
  7128. data["setl_mon"] = stmt_mon
  7129. month := time.Unix(1557042972, 0).Format("1")
  7130. year := time.Now().Format("2006")
  7131. month = time.Now().Format("01")
  7132. day := time.Now().Format("02")
  7133. hour := time.Now().Format("15")
  7134. min := time.Now().Format("04")
  7135. sec := time.Now().Format("05")
  7136. fix_fill_date := year + month + day + hour + min + sec
  7137. data["fix_fill_dept"] = miConfig.OrgName
  7138. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7139. data["fix_fill_psn"] = curRoles.UserName
  7140. data["fix_fill_date"] = fix_fill_date
  7141. data["stmt_loc"] = "2"
  7142. upld_btch = "0"
  7143. data["upld_btch"] = upld_btch
  7144. client := &http.Client{}
  7145. bytesData, _ := json.Marshal(data)
  7146. var req *http.Request
  7147. if miConfig.MdtrtareaAdmvs == "320830" {
  7148. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3266", bytes.NewReader(bytesData))
  7149. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7150. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  7151. } else {
  7152. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  7153. }
  7154. resp, _ := client.Do(req)
  7155. defer resp.Body.Close()
  7156. body, ioErr := ioutil.ReadAll(resp.Body)
  7157. if ioErr != nil {
  7158. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7160. }
  7161. var respJSON map[string]interface{}
  7162. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7163. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7165. }
  7166. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7167. fmt.Println(respJSON)
  7168. result, _ := json.Marshal(respJSON)
  7169. fmt.Println(result)
  7170. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7171. utils.ErrorLog("解析失败:%v", err)
  7172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7173. }
  7174. if result3265.Infcode != "0" {
  7175. c.ServeSuccessJSON(map[string]interface{}{
  7176. "failed_code": -10,
  7177. "msg": result3265.ErrMsg,
  7178. })
  7179. return
  7180. } else {
  7181. c.ServeSuccessJSON(map[string]interface{}{
  7182. "info": result3265.Output,
  7183. })
  7184. return
  7185. }
  7186. }
  7187. func (c *HisApiController) Get3267() {
  7188. admin_user_id, _ := c.GetInt64("admin_user_id")
  7189. startTime := c.GetString("start_time")
  7190. //endTime, _ := c.GetString("end_time")
  7191. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7192. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7193. times := strings.Split(startTime, "-")
  7194. setl_mon := times[0] + times[1]
  7195. var upld_btch string
  7196. //var empty models.JSResultEmpty
  7197. var result3265 models.JSResult3264
  7198. upld_btch = "0"
  7199. data := make(map[string]interface{})
  7200. data["org_name"] = miConfig.OrgName
  7201. data["doctor"] = curRoles.UserName
  7202. data["doctor_name"] = curRoles.UserName
  7203. data["fixmedins_code"] = miConfig.Code
  7204. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7205. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7206. data["secret_key"] = miConfig.SecretKey
  7207. data["url"] = miConfig.Url
  7208. data["ak"] = miConfig.AccessKey
  7209. data["cainfo"] = miConfig.Cainfo
  7210. data["setl_mon"] = setl_mon
  7211. data["stmt_loc"] = "2"
  7212. data["upld_btch"] = upld_btch
  7213. client := &http.Client{}
  7214. bytesData, _ := json.Marshal(data)
  7215. var req *http.Request
  7216. if miConfig.MdtrtareaAdmvs == "320830" {
  7217. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3267", bytes.NewReader(bytesData))
  7218. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7219. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7220. } else {
  7221. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7222. }
  7223. resp, _ := client.Do(req)
  7224. defer resp.Body.Close()
  7225. body, ioErr := ioutil.ReadAll(resp.Body)
  7226. if ioErr != nil {
  7227. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7229. }
  7230. var respJSON map[string]interface{}
  7231. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7232. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7234. }
  7235. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7236. fmt.Println(respJSON)
  7237. result, _ := json.Marshal(respJSON)
  7238. fmt.Println(result)
  7239. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7240. utils.ErrorLog("解析失败:%v", err)
  7241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7242. }
  7243. if result3265.Infcode != "0" {
  7244. c.ServeSuccessJSON(map[string]interface{}{
  7245. "failed_code": -10,
  7246. "msg": result3265.ErrMsg,
  7247. })
  7248. return
  7249. } else {
  7250. c.ServeSuccessJSON(map[string]interface{}{
  7251. "info": result3265.Output.Data,
  7252. })
  7253. return
  7254. }
  7255. }
  7256. func (c *HisApiController) Get3268() {
  7257. admin_user_id, _ := c.GetInt64("admin_user_id")
  7258. startTime := c.GetString("start_time")
  7259. endTime := c.GetString("end_time")
  7260. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7261. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7262. times := strings.Split(startTime, "-")
  7263. setl_mon := times[0] + times[1]
  7264. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  7265. var twos []models.FixMonRecDetailFileInTwo
  7266. var funs []models.FundDetail
  7267. for _, item := range datas {
  7268. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  7269. funs = append(funs, fun...)
  7270. }
  7271. var funInfos []models.Fund
  7272. //for _, item := range funs {
  7273. // var rf []models.FundInfo
  7274. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  7275. // for _, subitem := range rf {
  7276. // var fund models.Fund
  7277. // fund.FundCode = subitem.FundPayType
  7278. // fund.FundName = subitem.FundPayTypeName
  7279. // fund.FundAmt = subitem.FundPayAmt
  7280. // fund.FundKey = item.FundKey
  7281. // fund.InsuAdmdvs = "555555"
  7282. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  7283. // funInfos = append(funInfos, fund)
  7284. // }
  7285. //}
  7286. for _, team := range datas {
  7287. var two models.FixMonRecDetailFileInTwo
  7288. two.SetlDate = time.Now().Format("2006-01-02")
  7289. two.MedType = team.MedType
  7290. two.Insutype = team.Insutype
  7291. two.PsnType = team.PsnType
  7292. two.MedType = team.MedType
  7293. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  7294. two.InsuAdmdvs = team.InsuAdmdvs
  7295. two.PsnTime = team.PsnTime
  7296. two.PsnCnt = team.PsnCnt
  7297. two.FundKey = team.FundKey
  7298. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  7299. fps, _ := strconv.ParseFloat(team.Fund, 64)
  7300. ia, _ := strconv.ParseFloat(team.Amt, 64)
  7301. two.MedfeeSumAmt = ms
  7302. two.InscpAmt = ia
  7303. two.FundPaySumAmt = fps
  7304. twos = append(twos, two)
  7305. }
  7306. var upld_btch string
  7307. upld_btch = "0"
  7308. var empty models.JSResultEmpty
  7309. data := make(map[string]interface{})
  7310. data["org_name"] = miConfig.OrgName
  7311. data["doctor"] = curRoles.UserName
  7312. data["doctor_name"] = curRoles.UserName
  7313. data["fixmedins_code"] = miConfig.Code
  7314. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7315. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7316. data["secret_key"] = miConfig.SecretKey
  7317. data["url"] = miConfig.Url
  7318. data["ak"] = miConfig.AccessKey
  7319. data["cainfo"] = miConfig.Cainfo
  7320. data["datas"] = twos
  7321. data["fund"] = funInfos
  7322. data["setl_mon"] = setl_mon
  7323. month := time.Unix(1557042972, 0).Format("1")
  7324. year := time.Now().Format("2006")
  7325. month = time.Now().Format("01")
  7326. day := time.Now().Format("02")
  7327. hour := time.Now().Format("15")
  7328. min := time.Now().Format("04")
  7329. sec := time.Now().Format("05")
  7330. fix_fill_date := year + month + day + hour + min + sec
  7331. data["fix_fill_dept"] = miConfig.OrgName
  7332. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7333. data["fix_fill_psn"] = curRoles.UserName
  7334. data["fix_fill_date"] = fix_fill_date
  7335. data["stmt_loc"] = "2"
  7336. data["upld_btch"] = upld_btch
  7337. client := &http.Client{}
  7338. bytesData, _ := json.Marshal(data)
  7339. var req *http.Request
  7340. if miConfig.MdtrtareaAdmvs == "320830" {
  7341. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3268", bytes.NewReader(bytesData))
  7342. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7343. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7344. } else {
  7345. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7346. }
  7347. resp, _ := client.Do(req)
  7348. defer resp.Body.Close()
  7349. body, ioErr := ioutil.ReadAll(resp.Body)
  7350. if ioErr != nil {
  7351. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7353. }
  7354. var respJSON map[string]interface{}
  7355. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7356. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7358. }
  7359. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7360. fmt.Println(respJSON)
  7361. result, _ := json.Marshal(respJSON)
  7362. fmt.Println(result)
  7363. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  7364. utils.ErrorLog("解析失败:%v", err)
  7365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7366. }
  7367. if empty.Infcode != "0" {
  7368. c.ServeSuccessJSON(map[string]interface{}{
  7369. "failed_code": -10,
  7370. "msg": empty.ErrMsg,
  7371. })
  7372. return
  7373. } else {
  7374. c.ServeSuccessJSON(map[string]interface{}{
  7375. "msg": "上传成功",
  7376. })
  7377. return
  7378. }
  7379. }
  7380. func (c *HisApiController) Get3269() {
  7381. admin_user_id, _ := c.GetInt64("admin_user_id")
  7382. startTime := c.GetString("start_time")
  7383. //endTime, _ := c.GetString("end_time")
  7384. times := strings.Split(startTime, "-")
  7385. setl_mon := times[0] + times[1]
  7386. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7387. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7388. var result3263 models.JSResult3263
  7389. data := make(map[string]interface{})
  7390. data["org_name"] = miConfig.OrgName
  7391. data["doctor"] = curRoles.UserName
  7392. data["doctor_name"] = curRoles.UserName
  7393. data["fixmedins_code"] = miConfig.Code
  7394. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7395. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7396. data["secret_key"] = miConfig.SecretKey
  7397. data["url"] = miConfig.Url
  7398. data["ak"] = miConfig.AccessKey
  7399. data["cainfo"] = miConfig.Cainfo
  7400. data["setl_mon"] = setl_mon
  7401. data["stmt_loc"] = "2"
  7402. client := &http.Client{}
  7403. bytesData, _ := json.Marshal(data)
  7404. var req *http.Request
  7405. if miConfig.MdtrtareaAdmvs == "320830" {
  7406. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData))
  7407. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7408. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7409. } else {
  7410. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7411. }
  7412. resp, _ := client.Do(req)
  7413. defer resp.Body.Close()
  7414. body, ioErr := ioutil.ReadAll(resp.Body)
  7415. if ioErr != nil {
  7416. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7418. }
  7419. var respJSON map[string]interface{}
  7420. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7421. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7423. }
  7424. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7425. fmt.Println(respJSON)
  7426. result, _ := json.Marshal(respJSON)
  7427. fmt.Println(result)
  7428. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  7429. utils.ErrorLog("解析失败:%v", err)
  7430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7431. }
  7432. if result3263.Infcode != "0" {
  7433. c.ServeSuccessJSON(map[string]interface{}{
  7434. "failed_code": -10,
  7435. "msg": result3263.ErrMsg,
  7436. })
  7437. return
  7438. } else {
  7439. c.ServeSuccessJSON(map[string]interface{}{
  7440. "msg": "上传成功",
  7441. })
  7442. return
  7443. }
  7444. }
  7445. func (c *HisApiController) Get3270() {
  7446. admin_user_id, _ := c.GetInt64("admin_user_id")
  7447. startTime := c.GetString("start_time")
  7448. //endTime, _ := c.GetString("end_time")
  7449. times := strings.Split(startTime, "-")
  7450. setl_mon := times[0] + times[1]
  7451. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7452. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7453. var result3263 models.JSResult3263
  7454. data2 := make(map[string]interface{})
  7455. data2["org_name"] = miConfig.OrgName
  7456. data2["doctor"] = curRoles.UserName
  7457. data2["doctor_name"] = curRoles.UserName
  7458. data2["fixmedins_code"] = miConfig.Code
  7459. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7460. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7461. data2["secret_key"] = miConfig.SecretKey
  7462. data2["url"] = miConfig.Url
  7463. data2["ak"] = miConfig.AccessKey
  7464. data2["cainfo"] = miConfig.Cainfo
  7465. data2["setl_mon"] = setl_mon
  7466. data2["stmt_loc"] = "2"
  7467. client2 := &http.Client{}
  7468. bytesData2, _ := json.Marshal(data2)
  7469. var req3263 *http.Request
  7470. if miConfig.MdtrtareaAdmvs == "320830" {
  7471. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData2))
  7472. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7473. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7474. } else {
  7475. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7476. }
  7477. resp2, _ := client2.Do(req3263)
  7478. defer resp2.Body.Close()
  7479. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7480. if ioErr2 != nil {
  7481. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7483. }
  7484. var respJSON3263 map[string]interface{}
  7485. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7486. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7488. }
  7489. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7490. fmt.Println(respJSON3263)
  7491. result2, _ := json.Marshal(respJSON3263)
  7492. fmt.Println(result2)
  7493. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7494. utils.ErrorLog("解析失败:%v", err)
  7495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7496. }
  7497. var ids []string
  7498. for _, item := range result3263.Output {
  7499. ids = append(ids, item.SolidifyID)
  7500. }
  7501. var result3264 models.JSResult3264
  7502. data := make(map[string]interface{})
  7503. data["org_name"] = miConfig.OrgName
  7504. data["doctor"] = curRoles.UserName
  7505. data["doctor_name"] = curRoles.UserName
  7506. data["fixmedins_code"] = miConfig.Code
  7507. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7508. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7509. data["secret_key"] = miConfig.SecretKey
  7510. data["url"] = miConfig.Url
  7511. data["ak"] = miConfig.AccessKey
  7512. data["cainfo"] = miConfig.Cainfo
  7513. data["setl_mon"] = setl_mon
  7514. data["stmt_loc"] = "2"
  7515. data["solidify_id"] = ids
  7516. client := &http.Client{}
  7517. bytesData, _ := json.Marshal(data)
  7518. var req *http.Request
  7519. if miConfig.MdtrtareaAdmvs == "320830" {
  7520. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3270", bytes.NewReader(bytesData))
  7521. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7522. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7523. } else {
  7524. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7525. }
  7526. resp, _ := client.Do(req)
  7527. defer resp.Body.Close()
  7528. body, ioErr := ioutil.ReadAll(resp.Body)
  7529. if ioErr != nil {
  7530. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7532. }
  7533. var respJSON map[string]interface{}
  7534. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7535. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7537. }
  7538. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7539. fmt.Println(respJSON)
  7540. result, _ := json.Marshal(respJSON)
  7541. fmt.Println(result)
  7542. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  7543. utils.ErrorLog("解析失败:%v", err)
  7544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7545. }
  7546. if result3264.Infcode != "0" {
  7547. c.ServeSuccessJSON(map[string]interface{}{
  7548. "failed_code": -10,
  7549. "msg": result3264.ErrMsg,
  7550. })
  7551. return
  7552. } else {
  7553. c.ServeSuccessJSON(map[string]interface{}{
  7554. "info": result3264.Output,
  7555. })
  7556. return
  7557. }
  7558. }
  7559. func (c *HisApiController) Get3271() {
  7560. admin_user_id, _ := c.GetInt64("admin_user_id")
  7561. startTime := c.GetString("start_time")
  7562. //endTime, _ := c.GetString("end_time")
  7563. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7564. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7565. times := strings.Split(startTime, "-")
  7566. setl_mon := times[0] + times[1]
  7567. //var empty models.JSResultEmpty
  7568. var result3265 models.JSResult3264
  7569. var result3263 models.JSResult3263
  7570. data2 := make(map[string]interface{})
  7571. data2["org_name"] = miConfig.OrgName
  7572. data2["doctor"] = curRoles.UserName
  7573. data2["doctor_name"] = curRoles.UserName
  7574. data2["fixmedins_code"] = miConfig.Code
  7575. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7576. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7577. data2["secret_key"] = miConfig.SecretKey
  7578. data2["url"] = miConfig.Url
  7579. data2["ak"] = miConfig.AccessKey
  7580. data2["cainfo"] = miConfig.Cainfo
  7581. data2["setl_mon"] = setl_mon
  7582. data2["stmt_loc"] = "2"
  7583. client2 := &http.Client{}
  7584. bytesData2, _ := json.Marshal(data2)
  7585. var req3263 *http.Request
  7586. if miConfig.MdtrtareaAdmvs == "320830" {
  7587. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData2))
  7588. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7589. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7590. } else {
  7591. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7592. }
  7593. resp2, _ := client2.Do(req3263)
  7594. defer resp2.Body.Close()
  7595. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7596. if ioErr2 != nil {
  7597. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7599. }
  7600. var respJSON3263 map[string]interface{}
  7601. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7602. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7604. }
  7605. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7606. fmt.Println(respJSON3263)
  7607. result2, _ := json.Marshal(respJSON3263)
  7608. fmt.Println(result2)
  7609. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7610. utils.ErrorLog("解析失败:%v", err)
  7611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7612. }
  7613. var ids []string
  7614. for _, item := range result3263.Output {
  7615. ids = append(ids, item.SolidifyID)
  7616. }
  7617. data := make(map[string]interface{})
  7618. data["org_name"] = miConfig.OrgName
  7619. data["doctor"] = curRoles.UserName
  7620. data["doctor_name"] = curRoles.UserName
  7621. data["fixmedins_code"] = miConfig.Code
  7622. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7623. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7624. data["secret_key"] = miConfig.SecretKey
  7625. data["url"] = miConfig.Url
  7626. data["ak"] = miConfig.AccessKey
  7627. data["cainfo"] = miConfig.Cainfo
  7628. data["setl_mon"] = setl_mon
  7629. data["solidify_id"] = ids
  7630. month := time.Unix(1557042972, 0).Format("1")
  7631. year := time.Now().Format("2006")
  7632. month = time.Now().Format("01")
  7633. day := time.Now().Format("02")
  7634. hour := time.Now().Format("15")
  7635. min := time.Now().Format("04")
  7636. sec := time.Now().Format("05")
  7637. fix_fill_date := year + month + day + hour + min + sec
  7638. data["fix_fill_dept"] = miConfig.OrgName
  7639. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7640. data["fix_fill_psn"] = curRoles.UserName
  7641. data["fix_fill_date"] = fix_fill_date
  7642. data["stmt_loc"] = "2"
  7643. client := &http.Client{}
  7644. bytesData, _ := json.Marshal(data)
  7645. var req *http.Request
  7646. if miConfig.MdtrtareaAdmvs == "320830" {
  7647. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3271", bytes.NewReader(bytesData2))
  7648. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7649. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7650. } else {
  7651. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7652. }
  7653. resp, _ := client.Do(req)
  7654. defer resp.Body.Close()
  7655. body, ioErr := ioutil.ReadAll(resp.Body)
  7656. if ioErr != nil {
  7657. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7659. }
  7660. var respJSON map[string]interface{}
  7661. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7662. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7664. }
  7665. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7666. fmt.Println(respJSON)
  7667. result, _ := json.Marshal(respJSON)
  7668. fmt.Println(result)
  7669. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7670. utils.ErrorLog("解析失败:%v", err)
  7671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7672. }
  7673. if result3265.Infcode != "0" {
  7674. c.ServeSuccessJSON(map[string]interface{}{
  7675. "failed_code": -10,
  7676. "msg": result3265.ErrMsg,
  7677. })
  7678. return
  7679. } else {
  7680. c.ServeSuccessJSON(map[string]interface{}{
  7681. "info": result3265.Output.Data,
  7682. })
  7683. return
  7684. }
  7685. }
  7686. func (c *HisApiController) Get3272() {
  7687. admin_user_id, _ := c.GetInt64("admin_user_id")
  7688. startTime := c.GetString("start_time")
  7689. //endTime, _ := c.GetString("end_time")
  7690. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7691. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7692. times := strings.Split(startTime, "-")
  7693. setl_mon := times[0] + times[1]
  7694. var upld_btch string
  7695. //var empty models.JSResultEmpty
  7696. var result3265 models.JSResult3264
  7697. data := make(map[string]interface{})
  7698. data["org_name"] = miConfig.OrgName
  7699. data["doctor"] = curRoles.UserName
  7700. data["doctor_name"] = curRoles.UserName
  7701. data["fixmedins_code"] = miConfig.Code
  7702. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7703. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7704. data["secret_key"] = miConfig.SecretKey
  7705. data["url"] = miConfig.Url
  7706. data["ak"] = miConfig.AccessKey
  7707. data["cainfo"] = miConfig.Cainfo
  7708. data["setl_mon"] = setl_mon
  7709. month := time.Unix(1557042972, 0).Format("1")
  7710. year := time.Now().Format("2006")
  7711. month = time.Now().Format("01")
  7712. day := time.Now().Format("02")
  7713. hour := time.Now().Format("15")
  7714. min := time.Now().Format("04")
  7715. sec := time.Now().Format("05")
  7716. fix_fill_date := year + month + day + hour + min + sec
  7717. data["fix_fill_dept"] = miConfig.OrgName
  7718. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7719. data["fix_fill_psn"] = curRoles.UserName
  7720. data["fix_fill_date"] = fix_fill_date
  7721. data["stmt_loc"] = "2"
  7722. data["upld_btch"] = upld_btch
  7723. client := &http.Client{}
  7724. bytesData, _ := json.Marshal(data)
  7725. var req *http.Request
  7726. if miConfig.MdtrtareaAdmvs == "320830" {
  7727. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3272", bytes.NewReader(bytesData))
  7728. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7729. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7730. } else {
  7731. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7732. }
  7733. resp, _ := client.Do(req)
  7734. defer resp.Body.Close()
  7735. body, ioErr := ioutil.ReadAll(resp.Body)
  7736. if ioErr != nil {
  7737. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7739. }
  7740. var respJSON map[string]interface{}
  7741. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7742. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7744. }
  7745. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7746. fmt.Println(respJSON)
  7747. result, _ := json.Marshal(respJSON)
  7748. fmt.Println(result)
  7749. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7750. utils.ErrorLog("解析失败:%v", err)
  7751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7752. }
  7753. if result3265.Infcode != "0" {
  7754. c.ServeSuccessJSON(map[string]interface{}{
  7755. "failed_code": -10,
  7756. "msg": result3265.ErrMsg,
  7757. })
  7758. return
  7759. } else {
  7760. c.ServeSuccessJSON(map[string]interface{}{
  7761. "info": result3265.Output,
  7762. })
  7763. return
  7764. }
  7765. }
  7766. func (c *HisApiController) Get3273() {
  7767. admin_user_id, _ := c.GetInt64("admin_user_id")
  7768. startTime := c.GetString("start_time")
  7769. //endTime, _ := c.GetString("end_time")
  7770. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7771. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7772. times := strings.Split(startTime, "-")
  7773. setl_mon := times[0] + times[1]
  7774. var result3265 models.JSResult3264
  7775. data := make(map[string]interface{})
  7776. data["org_name"] = miConfig.OrgName
  7777. data["doctor"] = curRoles.UserName
  7778. data["doctor_name"] = curRoles.UserName
  7779. data["fixmedins_code"] = miConfig.Code
  7780. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7781. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7782. data["secret_key"] = miConfig.SecretKey
  7783. data["url"] = miConfig.Url
  7784. data["ak"] = miConfig.AccessKey
  7785. data["cainfo"] = miConfig.Cainfo
  7786. data["setl_mon"] = setl_mon
  7787. data["stmt_loc"] = "2"
  7788. client := &http.Client{}
  7789. bytesData, _ := json.Marshal(data)
  7790. var req *http.Request
  7791. if miConfig.MdtrtareaAdmvs == "320921" {
  7792. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7793. } else {
  7794. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7795. }
  7796. resp, _ := client.Do(req)
  7797. defer resp.Body.Close()
  7798. body, ioErr := ioutil.ReadAll(resp.Body)
  7799. if ioErr != nil {
  7800. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7802. }
  7803. var respJSON map[string]interface{}
  7804. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7805. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7807. }
  7808. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7809. fmt.Println(respJSON)
  7810. result, _ := json.Marshal(respJSON)
  7811. fmt.Println(result)
  7812. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7813. utils.ErrorLog("解析失败:%v", err)
  7814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7815. }
  7816. if result3265.Infcode != "0" {
  7817. c.ServeSuccessJSON(map[string]interface{}{
  7818. "failed_code": -10,
  7819. "msg": result3265.ErrMsg,
  7820. })
  7821. return
  7822. } else {
  7823. c.ServeSuccessJSON(map[string]interface{}{
  7824. "info": result3265.Output.Data,
  7825. })
  7826. return
  7827. }
  7828. }
  7829. func (c *HisApiController) Get3274() {
  7830. //if miConfig.MdtrtareaAdmvs == "320921" {
  7831. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7832. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7833. // "&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
  7834. //
  7835. //} else {
  7836. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7837. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7838. // "&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
  7839. //
  7840. //}
  7841. }
  7842. func (c *HisApiController) Get3275() {
  7843. //if miConfig.MdtrtareaAdmvs == "320921" {
  7844. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7845. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7846. // "&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
  7847. //
  7848. //} else {
  7849. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7850. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7851. // "&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
  7852. //
  7853. //}
  7854. }
  7855. func (c *HisApiController) Get3276() {
  7856. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7857. //month := c.GetString("month")
  7858. //
  7859. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7860. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7861. //var api string
  7862. //var res Result5301
  7863. //
  7864. //if miConfig.MdtrtareaAdmvs == "320921" {
  7865. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7866. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7867. //} else {
  7868. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7869. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7870. //}
  7871. //
  7872. //resp, requestErr := http.Get(api)
  7873. //if requestErr != nil {
  7874. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7875. // return
  7876. //}
  7877. //
  7878. //body, ioErr := ioutil.ReadAll(resp.Body)
  7879. //if ioErr != nil {
  7880. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7881. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7882. // return
  7883. //}
  7884. //var respJSON map[string]interface{}
  7885. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7886. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7887. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7888. // return
  7889. //}
  7890. //
  7891. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7892. //result, _ := json.Marshal(respJSON)
  7893. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7894. // utils.ErrorLog("解析失败:%v", err)
  7895. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7896. // return
  7897. //}
  7898. }
  7899. func (c *HisApiController) Get3277() {
  7900. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7901. //month := c.GetString("month")
  7902. //
  7903. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7904. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7905. //var api string
  7906. //var res Result5301
  7907. //
  7908. //if miConfig.MdtrtareaAdmvs == "320921" {
  7909. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7910. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7911. //} else {
  7912. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7913. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7914. //}
  7915. //
  7916. //resp, requestErr := http.Get(api)
  7917. //if requestErr != nil {
  7918. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7919. // return
  7920. //}
  7921. //
  7922. //body, ioErr := ioutil.ReadAll(resp.Body)
  7923. //if ioErr != nil {
  7924. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7925. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7926. // return
  7927. //}
  7928. //var respJSON map[string]interface{}
  7929. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7930. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7931. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7932. // return
  7933. //}
  7934. //
  7935. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7936. //result, _ := json.Marshal(respJSON)
  7937. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7938. // utils.ErrorLog("解析失败:%v", err)
  7939. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7940. // return
  7941. //}
  7942. }
  7943. func (c *HisApiController) GetCFYLJG001() {
  7944. admin_user_id, _ := c.GetInt64("admin_user_id")
  7945. patient_id, _ := c.GetInt64("patient_id")
  7946. his_patient_id, _ := c.GetInt64("his_patient_id")
  7947. record_time := c.GetString("record_time")
  7948. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7949. psn, _ := service.GetPsnByPatientId(patient_id)
  7950. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7951. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7952. var cFYLJG001 models.CFYLJG001
  7953. timeLayout := "2006-01-02"
  7954. loc, _ := time.LoadLocation("Local")
  7955. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7956. if err != nil {
  7957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7958. return
  7959. }
  7960. recordDateTime := theTime.Unix()
  7961. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7962. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7963. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7964. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7965. //dept, _ := service.GetDepartMentDetail(info.Departments)
  7966. for _, item := range prescriptions {
  7967. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7968. if his.IdCardType == 1 {
  7969. bas := strings.Split(psn.CardInfo, "|")
  7970. basNumber := bas[1]
  7971. fmt.Println(basNumber)
  7972. card_sn := bas[3]
  7973. card_no := bas[2]
  7974. cFYLJG001.MdtrtCertType = "03"
  7975. cFYLJG001.CardSn = card_sn
  7976. cFYLJG001.MdtrtCertNo = card_no
  7977. cFYLJG001.EcToken = ""
  7978. cFYLJG001.AuthNo = ""
  7979. } else if his.IdCardType == 2 {
  7980. cFYLJG001.MdtrtCertType = "02"
  7981. cFYLJG001.CardSn = ""
  7982. cFYLJG001.MdtrtCertNo = his.IdCardNo
  7983. cFYLJG001.EcToken = ""
  7984. cFYLJG001.AuthNo = ""
  7985. } else if his.IdCardType == 4 {
  7986. cFYLJG001.MdtrtCertType = "01"
  7987. cFYLJG001.CardSn = ""
  7988. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7989. cFYLJG001.EcToken = psn.VerifyNumber
  7990. cFYLJG001.AuthNo = ""
  7991. }
  7992. cFYLJG001.BizTypeCode = "01"
  7993. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7994. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7995. cFYLJG001.RxTypeCode = "1"
  7996. tempTime := time.Unix(item.PreTime, 0)
  7997. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7998. cFYLJG001.PrscTime = timeFormatOne
  7999. var count float64
  8000. if item.Type == 1 {
  8001. for _, sumItem := range item.HisDoctorAdviceInfo {
  8002. count = count + sumItem.PrescribingNumber
  8003. }
  8004. }
  8005. cFYLJG001.RxDrugCnt = count
  8006. cFYLJG001.ValiDays = "2"
  8007. ts := time.Unix(item.PreTime, 0)
  8008. record_time2 := ts.AddDate(0, 0, int(2)).Unix()
  8009. tempTime3 := time.Unix(record_time2, 0)
  8010. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  8011. cFYLJG001.ValiEndTime = timeFormat3
  8012. cFYLJG001.RxCotnFlag = "0"
  8013. for _, subItem := range item.HisDoctorAdviceInfo {
  8014. var drug models.RxDrug
  8015. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  8016. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  8017. drug.RxItemTypeCode = "11"
  8018. drug.DrugDosform = "剂" //TODO
  8019. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  8020. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  8021. }
  8022. drug.MedcWayDscr = subItem.DeliveryWay
  8023. tempTime2 := time.Unix(subItem.StartTime, 0)
  8024. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8025. drug.MedcBegntime = timeFormatTwo
  8026. if subItem.Day > 0 {
  8027. ts := time.Unix(subItem.StartTime, 0)
  8028. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  8029. tempTime4 := time.Unix(record_time, 0)
  8030. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  8031. drug.MedcEndtime = timeFormat5
  8032. } else {
  8033. tempTime2 := time.Unix(subItem.StartTime, 0)
  8034. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8035. drug.MedcEndtime = timeFormatTwo
  8036. }
  8037. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  8038. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  8039. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  8040. drug.DrugCnt = subItem.PrescribingNumber
  8041. drug.DrugDosunt = subItem.PrescribingNumberUnit
  8042. drug.DrugGenname = subItem.AdviceName
  8043. drug.MedcWayCodg = subItem.DeliveryWay
  8044. //drug.DrugTotlcnt = subItem.PrescribingNumber
  8045. drug.SinDoscnt = subItem.SingleDose
  8046. drug.SinDosunt = subItem.SingleDoseUnit
  8047. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  8048. drug.UsedFrquName = subItem.ExecutionFrequency
  8049. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  8050. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  8051. drug.HospApprFlag = "1"
  8052. cFYLJG001.List = append(cFYLJG001.List, drug)
  8053. }
  8054. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  8055. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.OrgName
  8056. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  8057. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  8058. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  8059. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  8060. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  8061. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  8062. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  8063. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  8064. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  8065. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  8066. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  8067. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  8068. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  8069. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  8070. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  8071. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  8072. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  8073. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  8074. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  8075. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  8076. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  8077. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  8078. tempTime2 := time.Now().Unix()
  8079. tempTime6 := time.Unix(tempTime2, 0)
  8080. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  8081. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  8082. cFYLJG001.Mdtrtinfo.DiseCodg = ""
  8083. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  8084. cFYLJG001.Mdtrtinfo.MaindiagCode = "I10.x00x002"
  8085. cFYLJG001.Mdtrtinfo.MaindiagName = "高血压"
  8086. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  8087. var config []*models.HisXtDiagnoseConfig
  8088. for _, item := range diagnosis_ids {
  8089. id, _ := strconv.ParseInt(item, 10, 64)
  8090. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8091. config = append(config, &diagnosisConfig)
  8092. }
  8093. for index, subitem := range config {
  8094. if index == 0 {
  8095. var dia models.DiseInfo
  8096. dia.DiagType = "1"
  8097. dia.MaindiagFlag = "1"
  8098. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8099. dia.DiagCode = subitem.CountryCode
  8100. dia.DiagName = subitem.ClassName
  8101. dia.DiagDept = "肾内科"
  8102. dia.DiagDrNo = doctor.DoctorNumber
  8103. dia.DiagDrName = doctor.UserName
  8104. tempTime3 := time.Unix(item.PreTime, 0)
  8105. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  8106. dia.DiagTime = timeFormatTwo
  8107. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  8108. } else {
  8109. var dia models.DiseInfo
  8110. dia.DiagType = "1"
  8111. dia.MaindiagFlag = "0"
  8112. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8113. dia.DiagCode = subitem.CountryCode
  8114. dia.DiagName = subitem.ClassName
  8115. dia.DiagDept = "肾内科"
  8116. dia.DiagDrNo = doctor.DoctorNumber
  8117. dia.DiagDrName = doctor.UserName
  8118. tempTime3 := time.Unix(item.PreTime, 0)
  8119. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  8120. dia.DiagTime = timeFormatTwo
  8121. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  8122. }
  8123. }
  8124. if miConfig.MdtrtareaAdmvs == "340699" {
  8125. result, request := service.GetAHCFYLJG001("http://10.66.149.64:8080/epc/api", cFYLJG001, his.Insutype)
  8126. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  8127. var res ResultCFYLJG001AH
  8128. var respJSON2 map[string]interface{}
  8129. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8130. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8132. return
  8133. }
  8134. userJSONBytes2, _ := json.Marshal(respJSON2)
  8135. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8136. utils.ErrorLog("解析失败:%v", err)
  8137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8138. return
  8139. }
  8140. var flow models.HisPrescriptionFlow
  8141. flow.Ctime = time.Now().Unix()
  8142. flow.SignDigest = ""
  8143. flow.RxTraceCode = res.RxTraceCode
  8144. flow.HiRxno = res.HiRxno
  8145. flow.MID = his.Number
  8146. flow.Status = 1
  8147. flow.DCode = doctor_info.DoctorNumber
  8148. flow.OriginalRxFile = ""
  8149. flow.OriginalValue = ""
  8150. flow.SignCertDn = ""
  8151. flow.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  8152. flow.SignCertSn = ""
  8153. flow.Mtime = time.Now().Unix()
  8154. service.Createflow(&flow)
  8155. c.ServeSuccessJSON(map[string]interface{}{
  8156. "msg": "上传成功",
  8157. })
  8158. } else {
  8159. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  8160. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  8161. var res ResultCFYLJG001
  8162. var respJSON2 map[string]interface{}
  8163. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8166. return
  8167. }
  8168. userJSONBytes2, _ := json.Marshal(respJSON2)
  8169. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8170. utils.ErrorLog("解析失败:%v", err)
  8171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8172. return
  8173. }
  8174. if res.Infcode == -1 {
  8175. c.ServeSuccessJSON(map[string]interface{}{
  8176. "failed_code": -10,
  8177. "msg": res.ErrMsg,
  8178. })
  8179. return
  8180. } else {
  8181. var flow models.HisPrescriptionFlow
  8182. flow.Ctime = time.Now().Unix()
  8183. flow.SignDigest = ""
  8184. flow.RxTraceCode = res.Output.RxTraceCode
  8185. flow.HiRxno = res.Output.HiRxno
  8186. flow.MID = his.Number
  8187. flow.Status = 1
  8188. flow.DCode = doctor_info.DoctorNumber
  8189. flow.OriginalRxFile = ""
  8190. flow.OriginalValue = ""
  8191. flow.SignCertDn = ""
  8192. flow.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  8193. flow.SignCertSn = ""
  8194. flow.Mtime = time.Now().Unix()
  8195. service.Createflow(&flow)
  8196. c.ServeSuccessJSON(map[string]interface{}{
  8197. "msg": "上传成功",
  8198. })
  8199. }
  8200. }
  8201. }
  8202. }
  8203. func (c *HisApiController) GetCFYLJG12() {
  8204. admin_user_id, _ := c.GetInt64("admin_user_id")
  8205. his_patient_id, _ := c.GetInt64("his_patient_id")
  8206. record_time := c.GetString("record_time")
  8207. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8208. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8209. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8210. flow, _ := service.Getflowtwo(his.Number)
  8211. patient_id, _ := c.GetInt64("patient_id")
  8212. timeLayout := "2006-01-02"
  8213. loc, _ := time.LoadLocation("Local")
  8214. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8215. if err != nil {
  8216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8217. return
  8218. }
  8219. recordDateTime := theTime.Unix()
  8220. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8221. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8222. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8223. dept, _ := service.GetDepartMentDetail(info.Departments)
  8224. inputData := make(map[string]interface{})
  8225. inputData["rxTraceCode"] = flow.RxTraceCode
  8226. inputData["hiRxno"] = flow.HiRxno
  8227. inputData["mdtrtId"] = flow.MID
  8228. inputData["patnName"] = his.PsnName
  8229. inputData["psnCertType"] = his.PsnCertType
  8230. inputData["certno"] = his.Certno
  8231. inputData["fixmedinsName"] = miConfig.OrgName
  8232. inputData["fixmedinsCode"] = miConfig.Code
  8233. inputData["drCode"] = doctor_info.DoctorNumber
  8234. inputData["prscDrName"] = doctor_info.UserName
  8235. inputData["pharDeptName"] = dept.Name
  8236. inputData["pharDeptCode"] = dept.Number
  8237. inputData["pharProfttlCodg"] = ""
  8238. inputData["pharProfttlName"] = ""
  8239. inputData["pharCode"] = "HY340621000425"
  8240. inputData["pharCertType"] = "01"
  8241. inputData["pharCertno"] = ""
  8242. inputData["pharName"] = "孙莉侠"
  8243. inputData["pharPracCertNo"] = ""
  8244. tempTime2 := time.Unix(info.Ctime, 0)
  8245. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8246. inputData["pharChkTime"] = timeFormatTwo
  8247. bytesData, _ := json.Marshal(inputData)
  8248. fmt.Println(string(bytesData))
  8249. encoded := base64.StdEncoding.EncodeToString(bytesData)
  8250. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  8251. if err != nil {
  8252. fmt.Println("Error reading PDF file:", err)
  8253. return
  8254. }
  8255. // 将 PDF 文件内容进行 Base64 编码
  8256. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  8257. fmt.Println(err)
  8258. if miConfig.MdtrtareaAdmvs == "340699" {
  8259. data := make(map[string]interface{})
  8260. data["rx_encoded"] = rx_encoded
  8261. data["code"] = miConfig.Code
  8262. data["url"] = "http://10.66.149.64:8080/epc/api"
  8263. data["encoded"] = encoded
  8264. client := &http.Client{}
  8265. bytesData, _ := json.Marshal(data)
  8266. var req *http.Request
  8267. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/02", bytes.NewReader(bytesData))
  8268. resp, _ := client.Do(req)
  8269. defer resp.Body.Close()
  8270. body, ioErr := ioutil.ReadAll(resp.Body)
  8271. if ioErr != nil {
  8272. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8273. }
  8274. var respJSON map[string]interface{}
  8275. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8276. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8278. return
  8279. }
  8280. var resSix10265 ResultSix10265 //1101结果
  8281. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8282. result, _ := json.Marshal(respJSON)
  8283. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  8284. utils.ErrorLog("解析失败:%v", err)
  8285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8286. return
  8287. }
  8288. utils.ErrorLog("接口返回数据解析JSON失败: %v", result)
  8289. //saveLog(result, "", "GetCFYLJG002", "GetCFYLJG002")
  8290. } else {
  8291. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8292. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  8293. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8294. var res2 AhResult002
  8295. var respJSON2 map[string]interface{}
  8296. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8297. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8299. return
  8300. }
  8301. userJSONBytes2, _ := json.Marshal(respJSON2)
  8302. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8303. utils.ErrorLog("解析失败:%v", err)
  8304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8305. return
  8306. }
  8307. flow.Ctime = time.Now().Unix()
  8308. flow.SignDigest = res2.SignDigest
  8309. flow.RxFile = res2.RxFile
  8310. flow.MID = his.Number
  8311. flow.Status = 1
  8312. flow.DCode = doctor_info.DoctorNumber
  8313. flow.OriginalRxFile = rx_encoded
  8314. flow.OriginalValue = encoded
  8315. flow.SignCertDn = res2.SignCertDn
  8316. flow.SignCertSn = res2.SignCertSn
  8317. flow.Mtime = time.Now().Unix()
  8318. service.Saveflow(flow)
  8319. c.ServeSuccessJSON(map[string]interface{}{
  8320. "msg": "预签名成功",
  8321. })
  8322. }
  8323. }
  8324. func (c *HisApiController) GetCFYLJG13() {
  8325. admin_user_id, _ := c.GetInt64("admin_user_id")
  8326. his_patient_id, _ := c.GetInt64("his_patient_id")
  8327. record_time := c.GetString("record_time")
  8328. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8329. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8330. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8331. flow, _ := service.Getflowtwo(his.Number)
  8332. patient_id, _ := c.GetInt64("patient_id")
  8333. timeLayout := "2006-01-02"
  8334. loc, _ := time.LoadLocation("Local")
  8335. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8336. if err != nil {
  8337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8338. return
  8339. }
  8340. recordDateTime := theTime.Unix()
  8341. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8342. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8343. dept, _ := service.GetDepartMentDetail(info.Departments)
  8344. var cFYLJG003 models.CFYLJG003
  8345. cFYLJG003.RxTraceCode = flow.RxTraceCode
  8346. cFYLJG003.HiRxno = flow.HiRxno
  8347. cFYLJG003.MdtrtID = flow.MID
  8348. cFYLJG003.PatnName = his.Name
  8349. cFYLJG003.Certno = his.Certno
  8350. cFYLJG003.FixmedinsName = miConfig.OrgName
  8351. cFYLJG003.FixmedinsCode = miConfig.Code
  8352. cFYLJG003.DrCode = doctor_info.DoctorNumber
  8353. cFYLJG003.PrscDrName = doctor_info.UserName
  8354. cFYLJG003.PharDeptName = dept.Name
  8355. cFYLJG003.PharDeptCode = dept.Number
  8356. if c.GetAdminUserInfo().CurrentOrgId == 10721 {
  8357. cFYLJG003.PharName = "孙莉侠"
  8358. cFYLJG003.PharPracCertNo = "060399"
  8359. cFYLJG003.PharCode = "HY340621000425"
  8360. cFYLJG003.PharCertType = "01"
  8361. cFYLJG003.PharCertno = ""
  8362. } else {
  8363. cFYLJG003.PharName = "彭斯遥"
  8364. cFYLJG003.PharPracCertNo = "30220200943042010052"
  8365. cFYLJG003.PharCode = "HY440309002107"
  8366. cFYLJG003.PharCertType = "01"
  8367. cFYLJG003.PharCertno = "430482199408260023"
  8368. }
  8369. cFYLJG003.PsnCertType = "01"
  8370. cFYLJG003.RxFile = flow.RxFile
  8371. cFYLJG003.SignDigest = flow.SignDigest
  8372. cFYLJG003.FixmedinsCode = miConfig.Code
  8373. cFYLJG003.PsnCertType = "01"
  8374. cFYLJG003.PharProfttlCodg = dept.Name
  8375. tempTime2 := time.Unix(info.Ctime, 0)
  8376. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8377. cFYLJG003.PharChkTime = timeFormatTwo
  8378. if miConfig.MdtrtareaAdmvs == "340699" {
  8379. data := make(map[string]interface{})
  8380. data["url"] = "http://10.66.149.64:8080/epc/api"
  8381. data["13"] = cFYLJG003
  8382. client := &http.Client{}
  8383. bytesData, _ := json.Marshal(data)
  8384. var req *http.Request
  8385. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/03", bytes.NewReader(bytesData))
  8386. resp, _ := client.Do(req)
  8387. defer resp.Body.Close()
  8388. body, ioErr := ioutil.ReadAll(resp.Body)
  8389. if ioErr != nil {
  8390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8391. }
  8392. var respJSON map[string]interface{}
  8393. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8396. return
  8397. }
  8398. var resSix10265 ResultSix10265 //1101结果
  8399. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8400. result, _ := json.Marshal(respJSON)
  8401. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  8402. utils.ErrorLog("解析失败:%v", err)
  8403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8404. return
  8405. }
  8406. utils.ErrorLog("接口返回数据解析JSON失败: %v", result)
  8407. //saveLog(result, "", "GetCFYLJG013", "GetCFYLJG013")
  8408. } else {
  8409. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8410. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  8411. var res ResultCFYLJG003
  8412. var respJSON2 map[string]interface{}
  8413. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8414. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8416. return
  8417. }
  8418. userJSONBytes2, _ := json.Marshal(respJSON2)
  8419. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8420. utils.ErrorLog("解析失败:%v", err)
  8421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8422. return
  8423. }
  8424. if res.Infcode == -1 {
  8425. c.ServeSuccessJSON(map[string]interface{}{
  8426. "failed_code": -10,
  8427. "msg": res.ErrMsg,
  8428. })
  8429. return
  8430. } else {
  8431. c.ServeSuccessJSON(map[string]interface{}{
  8432. "info": res.Output,
  8433. })
  8434. }
  8435. }
  8436. }
  8437. func (c *HisApiController) GetCFYLJG002() {
  8438. admin_user_id, _ := c.GetInt64("admin_user_id")
  8439. his_patient_id, _ := c.GetInt64("his_patient_id")
  8440. record_time := c.GetString("record_time")
  8441. admin_user_id = 3626
  8442. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8443. //id, _ := c.GetInt64("id")
  8444. admin_user_id = 3626
  8445. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8446. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8447. flow, _ := service.Getflowtwo(his.Number)
  8448. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8449. //record_time := c.GetString("record_time")
  8450. patient_id, _ := c.GetInt64("patient_id")
  8451. //patient_id = 23834
  8452. //record_time = "2023-09-18"
  8453. timeLayout := "2006-01-02"
  8454. loc, _ := time.LoadLocation("Local")
  8455. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8456. if err != nil {
  8457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8458. return
  8459. }
  8460. recordDateTime := theTime.Unix()
  8461. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8462. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8463. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8464. dept, _ := service.GetDepartMentDetail(info.Departments)
  8465. inputData := make(map[string]interface{})
  8466. inputData["rxTraceCode"] = flow.RxTraceCode
  8467. inputData["hiRxno"] = flow.HiRxno
  8468. inputData["mdtrtId"] = flow.MID
  8469. inputData["patnName"] = his.PsnName
  8470. inputData["psnCertType"] = his.PsnCertType
  8471. inputData["certno"] = his.Certno
  8472. inputData["fixmedinsName"] = miConfig.OrgName
  8473. inputData["fixmedinsCode"] = miConfig.Code
  8474. inputData["drCode"] = doctor_info.DoctorNumber
  8475. inputData["prscDrName"] = doctor_info.UserName
  8476. inputData["pharDeptName"] = dept.Name
  8477. inputData["pharDeptCode"] = dept.Number
  8478. inputData["pharProfttlCodg"] = ""
  8479. inputData["pharProfttlName"] = ""
  8480. inputData["pharCode"] = "HY340621000425"
  8481. inputData["pharCertType"] = "01"
  8482. inputData["pharCertno"] = ""
  8483. inputData["pharName"] = "孙莉侠"
  8484. inputData["pharPracCertNo"] = "060399"
  8485. tempTime2 := time.Unix(info.Ctime, 0)
  8486. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8487. inputData["pharChkTime"] = timeFormatTwo
  8488. bytesData, _ := json.Marshal(inputData)
  8489. fmt.Println(string(bytesData))
  8490. encoded := base64.StdEncoding.EncodeToString(bytesData)
  8491. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  8492. if err != nil {
  8493. fmt.Println("Error reading PDF file:", err)
  8494. return
  8495. }
  8496. // 将 PDF 文件内容进行 Base64 编码
  8497. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  8498. fmt.Println(err)
  8499. if miConfig.MdtrtareaAdmvs == "340699" {
  8500. result, request := service.GetAHCFYLJG002(miConfig.Code, "http://10.66.149.64:8080/epc/api", encoded, rx_encoded, "")
  8501. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8502. var res2 AhResult002
  8503. var respJSON2 map[string]interface{}
  8504. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8507. return
  8508. }
  8509. userJSONBytes2, _ := json.Marshal(respJSON2)
  8510. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8511. utils.ErrorLog("解析失败:%v", err)
  8512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8513. return
  8514. }
  8515. flow.Ctime = time.Now().Unix()
  8516. flow.SignDigest = res2.SignDigest
  8517. flow.RxFile = res2.RxFile
  8518. flow.MID = his.Number
  8519. flow.Status = 1
  8520. flow.DCode = doctor_info.DoctorNumber
  8521. flow.OriginalRxFile = rx_encoded
  8522. flow.OriginalValue = encoded
  8523. flow.SignCertDn = res2.SignCertDn
  8524. flow.SignCertSn = res2.SignCertSn
  8525. flow.Mtime = time.Now().Unix()
  8526. service.Saveflow(flow)
  8527. c.ServeSuccessJSON(map[string]interface{}{
  8528. "msg": "预签名成功",
  8529. })
  8530. } else {
  8531. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8532. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  8533. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8534. var res2 Result002
  8535. var respJSON2 map[string]interface{}
  8536. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8539. return
  8540. }
  8541. userJSONBytes2, _ := json.Marshal(respJSON2)
  8542. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8543. utils.ErrorLog("解析失败:%v", err)
  8544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8545. return
  8546. }
  8547. if res2.Infcode == 0 {
  8548. flow.Ctime = time.Now().Unix()
  8549. flow.SignDigest = res2.Output.SignDigest
  8550. flow.RxFile = res2.Output.RxFile
  8551. flow.MID = his.Number
  8552. flow.Status = 1
  8553. flow.DCode = doctor_info.DoctorNumber
  8554. flow.OriginalRxFile = rx_encoded
  8555. flow.OriginalValue = encoded
  8556. flow.SignCertDn = res2.Output.SignCertDn
  8557. flow.SignCertSn = res2.Output.SignCertSn
  8558. flow.Mtime = time.Now().Unix()
  8559. service.Saveflow(flow)
  8560. c.ServeSuccessJSON(map[string]interface{}{
  8561. "msg": "预签名成功",
  8562. })
  8563. } else {
  8564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8565. return
  8566. }
  8567. }
  8568. }
  8569. func (c *HisApiController) GetCFYLJG003() {
  8570. admin_user_id, _ := c.GetInt64("admin_user_id")
  8571. his_patient_id, _ := c.GetInt64("his_patient_id")
  8572. record_time := c.GetString("record_time")
  8573. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8574. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8575. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8576. flow, _ := service.Getflowtwo(his.Number)
  8577. patient_id, _ := c.GetInt64("patient_id")
  8578. timeLayout := "2006-01-02"
  8579. loc, _ := time.LoadLocation("Local")
  8580. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8581. if err != nil {
  8582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8583. return
  8584. }
  8585. recordDateTime := theTime.Unix()
  8586. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8587. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8588. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8589. dept, _ := service.GetDepartMentDetail(info.Departments)
  8590. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  8591. var cFYLJG003 models.CFYLJG003
  8592. cFYLJG003.RxTraceCode = flow.RxTraceCode
  8593. cFYLJG003.HiRxno = flow.HiRxno
  8594. cFYLJG003.MdtrtID = flow.MID
  8595. cFYLJG003.PatnName = his.PsnName
  8596. cFYLJG003.Certno = his.Certno
  8597. cFYLJG003.FixmedinsName = miConfig.OrgName
  8598. cFYLJG003.FixmedinsCode = miConfig.Code
  8599. cFYLJG003.DrCode = doctor_info.DoctorNumber
  8600. cFYLJG003.PrscDrName = doctor_info.UserName
  8601. cFYLJG003.PharDeptName = dept.Name
  8602. cFYLJG003.PharDeptCode = dept.Number
  8603. if c.GetAdminUserInfo().CurrentOrgId == 10721 {
  8604. cFYLJG003.PharName = "孙莉侠"
  8605. cFYLJG003.PharPracCertNo = "060399"
  8606. cFYLJG003.PharCode = "HY340621000425"
  8607. cFYLJG003.PharCertType = "01"
  8608. cFYLJG003.PharCertno = ""
  8609. } else {
  8610. cFYLJG003.PharName = "彭斯遥"
  8611. cFYLJG003.PharPracCertNo = "30220200943042010052"
  8612. cFYLJG003.PharCode = "HY440309002107"
  8613. cFYLJG003.PharCertType = "01"
  8614. cFYLJG003.PharCertno = "430482199408260023"
  8615. }
  8616. cFYLJG003.RxFile = flow.RxFile
  8617. cFYLJG003.SignDigest = flow.SignDigest
  8618. cFYLJG003.FixmedinsCode = miConfig.Code
  8619. cFYLJG003.PsnCertType = his.PsnCertType
  8620. tempTime2 := time.Unix(info.Ctime, 0)
  8621. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8622. cFYLJG003.PharChkTime = timeFormatTwo
  8623. if miConfig.MdtrtareaAdmvs == "340699" {
  8624. result, request := service.GetAHCFYLJG003("http://10.66.149.64:8080/epc/api", cFYLJG003)
  8625. saveLog(result, request, "GetAHCFYLJG003", "GetAHCFYLJG003")
  8626. var res AHResult003
  8627. var respJSON2 map[string]interface{}
  8628. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8629. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8631. return
  8632. }
  8633. userJSONBytes2, _ := json.Marshal(respJSON2)
  8634. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8635. utils.ErrorLog("解析失败:%v", err)
  8636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8637. return
  8638. }
  8639. {
  8640. c.ServeSuccessJSON(map[string]interface{}{
  8641. "info": res,
  8642. })
  8643. }
  8644. } else {
  8645. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8646. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  8647. var res ResultCFYLJG003
  8648. var respJSON2 map[string]interface{}
  8649. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8650. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8652. return
  8653. }
  8654. userJSONBytes2, _ := json.Marshal(respJSON2)
  8655. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8656. utils.ErrorLog("解析失败:%v", err)
  8657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8658. return
  8659. }
  8660. if res.Infcode == -1 {
  8661. c.ServeSuccessJSON(map[string]interface{}{
  8662. "failed_code": -10,
  8663. "msg": res.ErrMsg,
  8664. })
  8665. return
  8666. } else {
  8667. c.ServeSuccessJSON(map[string]interface{}{
  8668. "info": res.Output,
  8669. })
  8670. }
  8671. }
  8672. }
  8673. func (c *HisApiController) GetCFYLJG004() {
  8674. admin_user_id, _ := c.GetInt64("admin_user_id")
  8675. his_patient_id, _ := c.GetInt64("his_patient_id")
  8676. record_time := c.GetString("record_time")
  8677. admin_user_id = 3626
  8678. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8679. //id, _ := c.GetInt64("id")
  8680. admin_user_id = 3626
  8681. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8682. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8683. flow, _ := service.Getflowtwo(his.Number)
  8684. //id = 3
  8685. patient_id, _ := c.GetInt64("patient_id")
  8686. //patient_id = 23834
  8687. //record_time = "2023-09-18"
  8688. timeLayout := "2006-01-02"
  8689. loc, _ := time.LoadLocation("Local")
  8690. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8691. if err != nil {
  8692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8693. return
  8694. }
  8695. recordDateTime := theTime.Unix()
  8696. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8697. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8698. var cFYLJG004 models.CFYLJG004
  8699. cFYLJG004.HiRxno = flow.HiRxno
  8700. cFYLJG004.FixmedinsCode = miConfig.Code
  8701. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  8702. cFYLJG004.UndoDrCertType = "01"
  8703. cFYLJG004.UndoRea = "撤销处方"
  8704. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  8705. cFYLJG004.UndoDrName = doctor_info.UserName
  8706. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  8707. if miConfig.MdtrtareaAdmvs == "340699" {
  8708. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8709. //result, request := service.GetAHCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8710. //saveLog(result, request, "GetAHCFYLJG004", "GetAHCFYLJG004")
  8711. } else {
  8712. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  8713. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  8714. var res ResultCFYLJG004
  8715. var respJSON2 map[string]interface{}
  8716. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8717. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8719. return
  8720. }
  8721. userJSONBytes2, _ := json.Marshal(respJSON2)
  8722. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8723. utils.ErrorLog("解析失败:%v", err)
  8724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8725. return
  8726. }
  8727. if res.Infcode == -1 {
  8728. c.ServeSuccessJSON(map[string]interface{}{
  8729. "failed_code": -10,
  8730. "msg": res.ErrMsg,
  8731. })
  8732. return
  8733. } else {
  8734. flow.Status = 0
  8735. service.Saveflow(flow)
  8736. c.ServeSuccessJSON(map[string]interface{}{
  8737. "msg": "撤销成功",
  8738. })
  8739. return
  8740. }
  8741. }
  8742. }
  8743. func (c *HisApiController) GetCFYLJG005() {
  8744. admin_user_id, _ := c.GetInt64("admin_user_id")
  8745. his_patient_id, _ := c.GetInt64("his_patient_id")
  8746. //record_time := c.GetString("record_time")
  8747. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8748. //id, _ := c.GetInt64("id")
  8749. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8750. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8751. flow, _ := service.Getflowtwo(his.Number)
  8752. //id = 3
  8753. var cFYLJG005 models.CFYLJG005
  8754. //patient_id, _ := c.GetInt64("patient_id")
  8755. cFYLJG005.HiRxno = flow.HiRxno
  8756. cFYLJG005.MdtrtID = flow.MID
  8757. cFYLJG005.EcToken = ""
  8758. cFYLJG005.PsnName = his.Name
  8759. cFYLJG005.PsnCertType = "01"
  8760. cFYLJG005.Certno = his.IdCardNo
  8761. if miConfig.MdtrtareaAdmvs == "340699" {
  8762. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8763. result, request := service.GetAHCFYLJG005(miConfig.Code, cFYLJG005)
  8764. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8765. } else {
  8766. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  8767. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8768. var res ResultCFYLJG005
  8769. var respJSON2 map[string]interface{}
  8770. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8771. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8773. return
  8774. }
  8775. userJSONBytes2, _ := json.Marshal(respJSON2)
  8776. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8777. utils.ErrorLog("解析失败:%v", err)
  8778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8779. return
  8780. }
  8781. if res.Infcode == -1 {
  8782. c.ServeSuccessJSON(map[string]interface{}{
  8783. "failed_code": -10,
  8784. "msg": res.ErrMsg,
  8785. })
  8786. return
  8787. } else {
  8788. c.ServeSuccessJSON(map[string]interface{}{
  8789. "info": res.Output,
  8790. })
  8791. return
  8792. }
  8793. }
  8794. }
  8795. func (c *HisApiController) GetCFYLJG006() {
  8796. admin_user_id, _ := c.GetInt64("admin_user_id")
  8797. his_patient_id, _ := c.GetInt64("his_patient_id")
  8798. admin_user_id = 3626
  8799. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8800. //id, _ := c.GetInt64("id")
  8801. admin_user_id = 3626
  8802. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8803. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8804. flow, _ := service.Getflowtwo(his.Number)
  8805. //id = 3
  8806. patient_id, _ := c.GetInt64("patient_id")
  8807. var cFYLJG006 models.CFYLJG006
  8808. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8809. cFYLJG006.HiRxno = flow.HiRxno
  8810. cFYLJG006.MdtrtID = flow.MID
  8811. cFYLJG006.PsnName = patient.Name
  8812. cFYLJG006.PsnCertType = "01"
  8813. cFYLJG006.Certno = patient.IdCardNo
  8814. if miConfig.MdtrtareaAdmvs == "340699" {
  8815. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8816. //result, request := service.GetAHCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8817. //saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8818. } else {
  8819. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8820. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8821. var res ResultCFYLJG006
  8822. var respJSON2 map[string]interface{}
  8823. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8826. return
  8827. }
  8828. userJSONBytes2, _ := json.Marshal(respJSON2)
  8829. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8830. utils.ErrorLog("解析失败:%v", err)
  8831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8832. return
  8833. }
  8834. if res.Infcode == -1 {
  8835. c.ServeSuccessJSON(map[string]interface{}{
  8836. "failed_code": -10,
  8837. "msg": res.ErrMsg,
  8838. })
  8839. return
  8840. } else {
  8841. c.ServeSuccessJSON(map[string]interface{}{
  8842. "info": res.Output,
  8843. })
  8844. return
  8845. }
  8846. }
  8847. }
  8848. func (c *HisApiController) GetCFYLJG007() {
  8849. admin_user_id, _ := c.GetInt64("admin_user_id")
  8850. his_patient_id, _ := c.GetInt64("his_patient_id")
  8851. admin_user_id = 3626
  8852. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8853. //id, _ := c.GetInt64("id")
  8854. admin_user_id = 3626
  8855. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8856. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8857. flow, _ := service.Getflowtwo(his.Number)
  8858. //id = 3
  8859. patient_id, _ := c.GetInt64("patient_id")
  8860. var cFYLJG007 models.CFYLJG007
  8861. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8862. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8863. cFYLJG007.HiRxno = flow.HiRxno
  8864. cFYLJG007.MdtrtID = flow.MID
  8865. cFYLJG007.PsnNo = his.PsnNo
  8866. cFYLJG007.PsnCertType = "01"
  8867. cFYLJG007.Certno = patient.IdCardNo
  8868. cFYLJG007.PsnName = patient.Name
  8869. if miConfig.MdtrtareaAdmvs == "340699" {
  8870. //result, request := service.GetAHCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8871. //saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8872. } else {
  8873. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8874. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8875. var res ResultCFYLJG007
  8876. var respJSON2 map[string]interface{}
  8877. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8878. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8880. return
  8881. }
  8882. userJSONBytes2, _ := json.Marshal(respJSON2)
  8883. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8884. utils.ErrorLog("解析失败:%v", err)
  8885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8886. return
  8887. }
  8888. if res.Infcode == -1 {
  8889. c.ServeSuccessJSON(map[string]interface{}{
  8890. "failed_code": -10,
  8891. "msg": res.ErrMsg,
  8892. })
  8893. return
  8894. } else {
  8895. c.ServeSuccessJSON(map[string]interface{}{
  8896. "info": res,
  8897. })
  8898. return
  8899. }
  8900. }
  8901. }
  8902. func (c *HisApiController) GetCFYLJG008() {
  8903. admin_user_id, _ := c.GetInt64("admin_user_id")
  8904. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8905. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8906. var cFYLJG008 models.CFYLJG008
  8907. //id, _ := c.GetInt64("id")
  8908. patient_id, _ := c.GetInt64("patient_id")
  8909. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8910. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8911. //id = 3
  8912. //flow, _ := service.Getflow(id)
  8913. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8914. //
  8915. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8916. //patient_id, _ := c.GetInt64("patient_id")
  8917. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8918. record_time := c.GetString("record_time")
  8919. admin_user_id = 3626
  8920. patient_id = 19424
  8921. //his_patient_id = 263947
  8922. record_time = "2023-08-29"
  8923. timeLayout := "2006-01-02"
  8924. loc, _ := time.LoadLocation("Local")
  8925. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8926. if err != nil {
  8927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8928. return
  8929. }
  8930. recordDateTime := theTime.Unix()
  8931. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8932. cFYLJG008.FixmedinsName = ""
  8933. cFYLJG008.Lat = ""
  8934. cFYLJG008.Lng = ""
  8935. cFYLJG008.OrderType = "1"
  8936. cFYLJG008.PoolareaNo = ""
  8937. cFYLJG008.Lng = ""
  8938. cFYLJG008.PageNum = 1
  8939. cFYLJG008.PageSize = 10
  8940. var MPI models.MedinsProdInvChgDDTO
  8941. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8942. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8943. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8944. if miConfig.MdtrtareaAdmvs == "340699" {
  8945. //result, request := service.GetAHCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8946. //saveLog(result, request, "GetAHCFYLJG008", "GetAHCFYLJG008")
  8947. } else {
  8948. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8949. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8950. var res ResultCFYLJG008
  8951. var respJSON2 map[string]interface{}
  8952. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8953. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8955. return
  8956. }
  8957. userJSONBytes2, _ := json.Marshal(respJSON2)
  8958. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8959. utils.ErrorLog("解析失败:%v", err)
  8960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8961. return
  8962. }
  8963. if res.Infcode == -1 {
  8964. c.ServeSuccessJSON(map[string]interface{}{
  8965. "failed_code": -10,
  8966. "msg": res.ErrMsg,
  8967. })
  8968. return
  8969. } else {
  8970. c.ServeSuccessJSON(map[string]interface{}{
  8971. "info": res.Output,
  8972. })
  8973. return
  8974. }
  8975. }
  8976. }
  8977. func (c *HisApiController) GetBL4201A() {
  8978. order_id, _ := c.GetInt64("order_id")
  8979. admin_user_id, _ := c.GetInt64("admin_user_id")
  8980. order, _ := service.GetHisOrderByIDTwo(order_id)
  8981. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8982. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8983. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8984. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8985. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8986. department, _ := service.GetDepartMentDetail(his.Departments)
  8987. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8988. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8989. if order.ID == 0 {
  8990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8991. return
  8992. }
  8993. var struct4201A models.Struct4201A
  8994. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8995. for _, items := range order_info {
  8996. memo := make(map[string]interface{})
  8997. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8998. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8999. fsiOPFLD.MedType = "14"
  9000. fsiOPFLD.BkkpSn = items.FeedetlSn
  9001. fsiOPFLD.FixmedinsCode = miConfig.Code
  9002. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9003. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9004. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9005. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9006. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9007. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9008. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9009. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9010. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9011. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9012. fsiOPFLD.BilgDeptName = department.Name
  9013. fsiOPFLD.BilgDeptCodg = department.Number
  9014. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9015. fsiOPFLD.BilgDrName = doctor.UserName
  9016. fsiOPFLD.MedChrgitmType = "09"
  9017. memo["hosp_appr_flag"] = "1"
  9018. memo["invoice_no"] = order.MdtrtId
  9019. memo["memo"] = "自费"
  9020. bytesData, _ := json.Marshal(memo)
  9021. fsiOPFLD.Memo = string(bytesData)
  9022. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9023. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9024. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9025. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9026. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9027. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9028. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9029. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9030. fsiOPFLD.BilgDeptName = department.Name
  9031. fsiOPFLD.BilgDeptCodg = department.Number
  9032. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9033. fsiOPFLD.BilgDrName = doctor.UserName
  9034. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9035. case 0:
  9036. break
  9037. case 1:
  9038. fsiOPFLD.MedChrgitmType = "14"
  9039. break
  9040. case 2:
  9041. fsiOPFLD.MedChrgitmType = "05"
  9042. break
  9043. case 3:
  9044. fsiOPFLD.MedChrgitmType = "03"
  9045. break
  9046. case 4:
  9047. fsiOPFLD.MedChrgitmType = "03"
  9048. break
  9049. case 5:
  9050. fsiOPFLD.MedChrgitmType = "08"
  9051. break
  9052. case 6:
  9053. fsiOPFLD.MedChrgitmType = "14"
  9054. break
  9055. case 7:
  9056. fsiOPFLD.MedChrgitmType = "14"
  9057. break
  9058. case 8:
  9059. fsiOPFLD.MedChrgitmType = "03"
  9060. break
  9061. case 9:
  9062. fsiOPFLD.MedChrgitmType = "14"
  9063. break
  9064. case 10:
  9065. fsiOPFLD.MedChrgitmType = "14"
  9066. break
  9067. case 11:
  9068. fsiOPFLD.MedChrgitmType = "06"
  9069. break
  9070. case 12:
  9071. fsiOPFLD.MedChrgitmType = "12"
  9072. break
  9073. case 13:
  9074. fsiOPFLD.MedChrgitmType = "01"
  9075. break
  9076. case 14:
  9077. fsiOPFLD.MedChrgitmType = "04"
  9078. break
  9079. case 15:
  9080. fsiOPFLD.MedChrgitmType = "14"
  9081. break
  9082. }
  9083. memo["hosp_appr_flag"] = "1"
  9084. memo["invoice_no"] = order.MdtrtId
  9085. memo["memo"] = "自费"
  9086. bytesData, _ := json.Marshal(memo)
  9087. fsiOPFLD.Memo = string(bytesData)
  9088. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9089. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9090. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9091. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9092. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9093. fsiOPFLD.BilgDeptName = department.Name
  9094. fsiOPFLD.BilgDeptCodg = department.Number
  9095. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9096. fsiOPFLD.BilgDrName = doctor.UserName
  9097. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9098. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9099. fsiOPFLD.MedChrgitmType = "08"
  9100. memo["hosp_appr_flag"] = "1"
  9101. memo["invoice_no"] = order.MdtrtId
  9102. memo["memo"] = "自费"
  9103. bytesData, _ := json.Marshal(memo)
  9104. fsiOPFLD.Memo = string(bytesData)
  9105. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9106. }
  9107. }
  9108. }
  9109. for _, items := range order_info_two {
  9110. memo := make(map[string]interface{})
  9111. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9112. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9113. fsiOPFLD.MedType = "14"
  9114. fsiOPFLD.BkkpSn = items.FeedetlSn
  9115. fsiOPFLD.FixmedinsCode = miConfig.Code
  9116. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9117. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9118. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9119. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9120. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9121. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9122. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9123. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9124. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9125. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9126. fsiOPFLD.BilgDeptName = department.Name
  9127. fsiOPFLD.BilgDeptCodg = department.Number
  9128. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9129. fsiOPFLD.BilgDrName = doctor.UserName
  9130. fsiOPFLD.MedChrgitmType = "09"
  9131. memo["hosp_appr_flag"] = "1"
  9132. memo["invoice_no"] = order.MdtrtId
  9133. memo["memo"] = "自费"
  9134. bytesData, _ := json.Marshal(memo)
  9135. fsiOPFLD.Memo = string(bytesData)
  9136. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9137. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9138. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9139. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9140. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9141. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9142. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9143. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9144. fsiOPFLD.BilgDeptName = department.Name
  9145. fsiOPFLD.BilgDeptCodg = department.Number
  9146. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9147. fsiOPFLD.BilgDrName = doctor.UserName
  9148. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9149. case 0:
  9150. break
  9151. case 1:
  9152. fsiOPFLD.MedChrgitmType = "14"
  9153. break
  9154. case 2:
  9155. fsiOPFLD.MedChrgitmType = "05"
  9156. break
  9157. case 3:
  9158. fsiOPFLD.MedChrgitmType = "03"
  9159. break
  9160. case 4:
  9161. fsiOPFLD.MedChrgitmType = "03"
  9162. break
  9163. case 5:
  9164. fsiOPFLD.MedChrgitmType = "08"
  9165. break
  9166. case 6:
  9167. fsiOPFLD.MedChrgitmType = "14"
  9168. break
  9169. case 7:
  9170. fsiOPFLD.MedChrgitmType = "14"
  9171. break
  9172. case 8:
  9173. fsiOPFLD.MedChrgitmType = "03"
  9174. break
  9175. case 9:
  9176. fsiOPFLD.MedChrgitmType = "14"
  9177. break
  9178. case 10:
  9179. fsiOPFLD.MedChrgitmType = "14"
  9180. break
  9181. case 11:
  9182. fsiOPFLD.MedChrgitmType = "06"
  9183. break
  9184. case 12:
  9185. fsiOPFLD.MedChrgitmType = "12"
  9186. break
  9187. case 13:
  9188. fsiOPFLD.MedChrgitmType = "01"
  9189. break
  9190. case 14:
  9191. fsiOPFLD.MedChrgitmType = "04"
  9192. break
  9193. case 15:
  9194. fsiOPFLD.MedChrgitmType = "14"
  9195. break
  9196. }
  9197. memo["hosp_appr_flag"] = "1"
  9198. memo["invoice_no"] = order.MdtrtId
  9199. memo["memo"] = "自费"
  9200. bytesData, _ := json.Marshal(memo)
  9201. fsiOPFLD.Memo = string(bytesData)
  9202. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9203. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9204. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9205. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9206. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9207. fsiOPFLD.BilgDeptName = department.Name
  9208. fsiOPFLD.BilgDeptCodg = department.Number
  9209. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9210. fsiOPFLD.BilgDrName = doctor.UserName
  9211. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9212. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9213. fsiOPFLD.MedChrgitmType = "08"
  9214. memo["hosp_appr_flag"] = "1"
  9215. memo["invoice_no"] = order.MdtrtId
  9216. memo["memo"] = "自费"
  9217. bytesData, _ := json.Marshal(memo)
  9218. fsiOPFLD.Memo = string(bytesData)
  9219. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9220. }
  9221. }
  9222. }
  9223. fmt.Println(fsiOPFLDs)
  9224. struct4201A.Fopfd = fsiOPFLDs
  9225. fmt.Println(struct4201A.Fopfd)
  9226. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  9227. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  9228. var res2 ResultSix
  9229. var respJSON2 map[string]interface{}
  9230. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9231. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9233. return
  9234. }
  9235. userJSONBytes2, _ := json.Marshal(respJSON2)
  9236. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9237. utils.ErrorLog("解析失败:%v", err)
  9238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9239. return
  9240. }
  9241. if res2.Infcode != 0 {
  9242. c.ServeSuccessJSON(map[string]interface{}{
  9243. "failed_code": -10,
  9244. "msg": res2.ErrMsg,
  9245. })
  9246. return
  9247. } else {
  9248. order.IsUploadOrderInfo = 1
  9249. service.UpdateOrder(order)
  9250. c.ServeSuccessJSON(map[string]interface{}{
  9251. "msg": "上传成功",
  9252. })
  9253. }
  9254. }
  9255. func (c *HisApiController) Get3103() {
  9256. admin_user_id, _ := c.GetInt64("admin_user_id")
  9257. warm_type, _ := c.GetInt64("warm_type")
  9258. fk_state, _ := c.GetInt64("fk_state")
  9259. warm_ids := c.GetString("warm_ids")
  9260. desc := c.GetString("desc")
  9261. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9262. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9263. result, requestLog := service.Gdyb3103(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, warm_type, warm_ids, fk_state, desc)
  9264. saveLog(result, requestLog, "3103", "反馈")
  9265. var res2 ResultSix3103
  9266. var respJSON2 map[string]interface{}
  9267. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9270. return
  9271. }
  9272. userJSONBytes2, _ := json.Marshal(respJSON2)
  9273. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9274. utils.ErrorLog("解析失败:%v", err)
  9275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9276. return
  9277. }
  9278. if res2.Infcode != 0 {
  9279. c.ServeSuccessJSON(map[string]interface{}{
  9280. "failed_code": -10,
  9281. "msg": res2.ErrMsg,
  9282. })
  9283. return
  9284. } else {
  9285. c.ServeSuccessJSON(map[string]interface{}{
  9286. "msg": "反馈成功",
  9287. })
  9288. return
  9289. }
  9290. }
  9291. func (c *HisApiController) Get4201A() {
  9292. order_id, _ := c.GetInt64("order_id")
  9293. admin_user_id, _ := c.GetInt64("admin_user_id")
  9294. order, _ := service.GetHisOrderByIDTwo(order_id)
  9295. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9296. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  9297. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  9298. //order_info = append(order_info, order_info_two...)
  9299. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9300. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9301. department, _ := service.GetDepartMentDetail(his.Departments)
  9302. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9303. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9304. if order.ID == 0 {
  9305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9306. return
  9307. }
  9308. var struct4201A models.Struct4201A
  9309. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9310. for _, items := range order_info {
  9311. memo := make(map[string]interface{})
  9312. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9313. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9314. fsiOPFLD.MedType = "14"
  9315. fsiOPFLD.BkkpSn = items.FeedetlSn
  9316. fsiOPFLD.FixmedinsCode = miConfig.Code
  9317. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9318. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9319. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9320. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9321. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9322. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9323. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9324. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9325. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9326. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9327. fsiOPFLD.BilgDeptName = department.Name
  9328. fsiOPFLD.BilgDeptCodg = department.Number
  9329. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9330. fsiOPFLD.BilgDrName = doctor.UserName
  9331. fsiOPFLD.MedChrgitmType = "09"
  9332. memo["hosp_appr_flag"] = "1"
  9333. memo["invoice_no"] = order.MdtrtId
  9334. memo["memo"] = "自费"
  9335. bytesData, _ := json.Marshal(memo)
  9336. fsiOPFLD.Memo = string(bytesData)
  9337. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9338. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9339. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9340. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9341. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9342. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9343. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9344. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9345. fsiOPFLD.BilgDeptName = department.Name
  9346. fsiOPFLD.BilgDeptCodg = department.Number
  9347. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9348. fsiOPFLD.BilgDrName = doctor.UserName
  9349. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9350. case 0:
  9351. break
  9352. case 1:
  9353. fsiOPFLD.MedChrgitmType = "14"
  9354. break
  9355. case 2:
  9356. fsiOPFLD.MedChrgitmType = "05"
  9357. break
  9358. case 3:
  9359. fsiOPFLD.MedChrgitmType = "03"
  9360. break
  9361. case 4:
  9362. fsiOPFLD.MedChrgitmType = "03"
  9363. break
  9364. case 5:
  9365. fsiOPFLD.MedChrgitmType = "08"
  9366. break
  9367. case 6:
  9368. fsiOPFLD.MedChrgitmType = "14"
  9369. break
  9370. case 7:
  9371. fsiOPFLD.MedChrgitmType = "14"
  9372. break
  9373. case 8:
  9374. fsiOPFLD.MedChrgitmType = "03"
  9375. break
  9376. case 9:
  9377. fsiOPFLD.MedChrgitmType = "14"
  9378. break
  9379. case 10:
  9380. fsiOPFLD.MedChrgitmType = "14"
  9381. break
  9382. case 11:
  9383. fsiOPFLD.MedChrgitmType = "06"
  9384. break
  9385. case 12:
  9386. fsiOPFLD.MedChrgitmType = "12"
  9387. break
  9388. case 13:
  9389. fsiOPFLD.MedChrgitmType = "01"
  9390. break
  9391. case 14:
  9392. fsiOPFLD.MedChrgitmType = "04"
  9393. break
  9394. case 15:
  9395. fsiOPFLD.MedChrgitmType = "14"
  9396. break
  9397. }
  9398. memo["hosp_appr_flag"] = "1"
  9399. memo["invoice_no"] = order.MdtrtId
  9400. memo["memo"] = "自费"
  9401. bytesData, _ := json.Marshal(memo)
  9402. fsiOPFLD.Memo = string(bytesData)
  9403. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9404. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9405. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9406. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9407. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9408. fsiOPFLD.BilgDeptName = department.Name
  9409. fsiOPFLD.BilgDeptCodg = department.Number
  9410. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9411. fsiOPFLD.BilgDrName = doctor.UserName
  9412. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9413. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9414. fsiOPFLD.MedChrgitmType = "08"
  9415. memo["hosp_appr_flag"] = "1"
  9416. memo["invoice_no"] = order.MdtrtId
  9417. memo["memo"] = "自费"
  9418. bytesData, _ := json.Marshal(memo)
  9419. fsiOPFLD.Memo = string(bytesData)
  9420. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9421. }
  9422. }
  9423. }
  9424. for _, items := range order_info_two {
  9425. memo := make(map[string]interface{})
  9426. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9427. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9428. fsiOPFLD.MedType = "14"
  9429. fsiOPFLD.BkkpSn = items.FeedetlSn
  9430. fsiOPFLD.FixmedinsCode = miConfig.Code
  9431. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9432. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9433. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9434. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9435. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9436. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9437. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9438. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9439. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9440. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9441. fsiOPFLD.BilgDeptName = department.Name
  9442. fsiOPFLD.BilgDeptCodg = department.Number
  9443. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9444. fsiOPFLD.BilgDrName = doctor.UserName
  9445. fsiOPFLD.MedChrgitmType = "09"
  9446. memo["hosp_appr_flag"] = "1"
  9447. memo["invoice_no"] = order.MdtrtId
  9448. memo["memo"] = "自费"
  9449. bytesData, _ := json.Marshal(memo)
  9450. fsiOPFLD.Memo = string(bytesData)
  9451. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9452. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9453. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9454. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9455. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9456. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9457. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9458. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9459. fsiOPFLD.BilgDeptName = department.Name
  9460. fsiOPFLD.BilgDeptCodg = department.Number
  9461. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9462. fsiOPFLD.BilgDrName = doctor.UserName
  9463. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9464. case 0:
  9465. break
  9466. case 1:
  9467. fsiOPFLD.MedChrgitmType = "14"
  9468. break
  9469. case 2:
  9470. fsiOPFLD.MedChrgitmType = "05"
  9471. break
  9472. case 3:
  9473. fsiOPFLD.MedChrgitmType = "03"
  9474. break
  9475. case 4:
  9476. fsiOPFLD.MedChrgitmType = "03"
  9477. break
  9478. case 5:
  9479. fsiOPFLD.MedChrgitmType = "08"
  9480. break
  9481. case 6:
  9482. fsiOPFLD.MedChrgitmType = "14"
  9483. break
  9484. case 7:
  9485. fsiOPFLD.MedChrgitmType = "14"
  9486. break
  9487. case 8:
  9488. fsiOPFLD.MedChrgitmType = "03"
  9489. break
  9490. case 9:
  9491. fsiOPFLD.MedChrgitmType = "14"
  9492. break
  9493. case 10:
  9494. fsiOPFLD.MedChrgitmType = "14"
  9495. break
  9496. case 11:
  9497. fsiOPFLD.MedChrgitmType = "06"
  9498. break
  9499. case 12:
  9500. fsiOPFLD.MedChrgitmType = "12"
  9501. break
  9502. case 13:
  9503. fsiOPFLD.MedChrgitmType = "01"
  9504. break
  9505. case 14:
  9506. fsiOPFLD.MedChrgitmType = "04"
  9507. break
  9508. case 15:
  9509. fsiOPFLD.MedChrgitmType = "14"
  9510. break
  9511. }
  9512. memo["hosp_appr_flag"] = "1"
  9513. memo["invoice_no"] = order.MdtrtId
  9514. memo["memo"] = "自费"
  9515. bytesData, _ := json.Marshal(memo)
  9516. fsiOPFLD.Memo = string(bytesData)
  9517. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9518. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9519. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9520. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9521. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9522. fsiOPFLD.BilgDeptName = department.Name
  9523. fsiOPFLD.BilgDeptCodg = department.Number
  9524. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9525. fsiOPFLD.BilgDrName = doctor.UserName
  9526. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9527. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9528. fsiOPFLD.MedChrgitmType = "08"
  9529. memo["hosp_appr_flag"] = "1"
  9530. memo["invoice_no"] = order.MdtrtId
  9531. memo["memo"] = "自费"
  9532. bytesData, _ := json.Marshal(memo)
  9533. fsiOPFLD.Memo = string(bytesData)
  9534. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9535. }
  9536. }
  9537. }
  9538. fmt.Println(fsiOPFLDs)
  9539. struct4201A.Fopfd = fsiOPFLDs
  9540. fmt.Println(struct4201A.Fopfd)
  9541. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  9542. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  9543. var res2 ResultSix
  9544. var respJSON2 map[string]interface{}
  9545. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9548. return
  9549. }
  9550. userJSONBytes2, _ := json.Marshal(respJSON2)
  9551. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9552. utils.ErrorLog("解析失败:%v", err)
  9553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9554. return
  9555. }
  9556. if res2.Infcode != 0 {
  9557. c.ServeSuccessJSON(map[string]interface{}{
  9558. "failed_code": -10,
  9559. "msg": res2.ErrMsg,
  9560. })
  9561. return
  9562. } else {
  9563. order.IsUploadOrderInfo = 1
  9564. service.UpdateOrder(order)
  9565. c.ServeSuccessJSON(map[string]interface{}{
  9566. "msg": "上传成功",
  9567. })
  9568. }
  9569. }
  9570. func (c *HisApiController) Get4202() {
  9571. order_id, _ := c.GetInt64("order_id")
  9572. admin_user_id, _ := c.GetInt64("admin_user_id")
  9573. order, _ := service.GetHisOrderByIDTwo(order_id)
  9574. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9575. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9576. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9577. if order.ID == 0 {
  9578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9579. return
  9580. }
  9581. var struct4202 models.Struct4202
  9582. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9583. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9584. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9585. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9586. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9587. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9588. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  9589. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  9590. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9591. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9592. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9593. var config []*models.HisXtDiagnoseConfig
  9594. for _, item := range diagnosis_ids {
  9595. id, _ := strconv.ParseInt(item, 10, 64)
  9596. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9597. config = append(config, &diagnosisConfig)
  9598. }
  9599. var tempDiaginfos []models.OwnPayPatnDiagListD
  9600. for index, item := range config {
  9601. if index == 0 {
  9602. var tempDiaginfo models.OwnPayPatnDiagListD
  9603. tempDiaginfo.InoutDiagType = "1"
  9604. tempDiaginfo.DiagCode = item.CountryCode
  9605. tempDiaginfo.DiagName = item.CountryContentName
  9606. tempDiaginfo.DiagType = "1"
  9607. tempDiaginfo.DiagSrtNo = "1"
  9608. tempDiaginfo.MaindiagFlag = "1"
  9609. tempDiaginfo.ValiFlag = "1"
  9610. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9611. } else {
  9612. var tempDiaginfo models.OwnPayPatnDiagListD
  9613. tempDiaginfo.DiagCode = item.CountryCode
  9614. tempDiaginfo.DiagName = item.CountryContentName
  9615. tempDiaginfo.DiagType = "2"
  9616. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9617. tempDiaginfo.MaindiagFlag = "0"
  9618. tempDiaginfo.ValiFlag = "1"
  9619. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9620. }
  9621. }
  9622. struct4202.ODiagListD = tempDiaginfos
  9623. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  9624. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  9625. var res2 ResultSix
  9626. var respJSON2 map[string]interface{}
  9627. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9630. return
  9631. }
  9632. userJSONBytes2, _ := json.Marshal(respJSON2)
  9633. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9634. utils.ErrorLog("解析失败:%v", err)
  9635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9636. return
  9637. }
  9638. if res2.Infcode != 0 {
  9639. c.ServeSuccessJSON(map[string]interface{}{
  9640. "failed_code": -10,
  9641. "msg": res2.ErrMsg,
  9642. })
  9643. return
  9644. } else {
  9645. order.IsUploadDiagnose = 1
  9646. service.UpdateOrder(order)
  9647. c.ServeSuccessJSON(map[string]interface{}{
  9648. "msg": "上传成功",
  9649. })
  9650. }
  9651. }
  9652. func (c *HisApiController) Get4203() {
  9653. admin_user_id, _ := c.GetInt64("admin_user_id")
  9654. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9655. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9656. order_id, _ := c.GetInt64("order_id")
  9657. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9658. number := ""
  9659. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9660. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9661. if his.ID == 0 {
  9662. number = hospital.Number
  9663. } else {
  9664. number = his.Number
  9665. }
  9666. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  9667. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  9668. var res2 ResultSix
  9669. var respJSON2 map[string]interface{}
  9670. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9673. return
  9674. }
  9675. userJSONBytes2, _ := json.Marshal(respJSON2)
  9676. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9677. utils.ErrorLog("解析失败:%v", err)
  9678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9679. return
  9680. }
  9681. if res2.Infcode != 0 {
  9682. c.ServeSuccessJSON(map[string]interface{}{
  9683. "failed_code": -10,
  9684. "msg": res2.ErrMsg,
  9685. })
  9686. return
  9687. } else {
  9688. order.IsUploadSuccess = 1
  9689. service.UpdateOrderTwo(order)
  9690. c.ServeSuccessJSON(map[string]interface{}{
  9691. "msg": "上传成功",
  9692. })
  9693. }
  9694. }
  9695. func (c *HisApiController) Get4205() {
  9696. order_id, _ := c.GetInt64("order_id")
  9697. admin_user_id, _ := c.GetInt64("admin_user_id")
  9698. fapiao_code := c.GetString("fapiao_code")
  9699. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9700. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9701. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9702. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9703. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  9704. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9705. //order_info = append(order_info, order_info_two...)
  9706. department, _ := service.GetDepartMentDetail(his.Departments)
  9707. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9708. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9709. if order.ID == 0 {
  9710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9711. return
  9712. }
  9713. var struct4201A models.Struct4201A
  9714. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9715. for _, items := range order_info {
  9716. memo := make(map[string]interface{})
  9717. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9718. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9719. fsiOPFLD.MedType = pre.MedType
  9720. fsiOPFLD.FixmedinsCode = miConfig.Code
  9721. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9722. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9723. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9724. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.Cnt*items.Pric)
  9725. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9726. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.StartTime, 0).Format("2006-01-02 15:04:05")
  9727. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9728. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  9729. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9730. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9731. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9732. fsiOPFLD.BilgDeptName = department.Name
  9733. fsiOPFLD.BilgDeptCodg = department.Number
  9734. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9735. fsiOPFLD.BilgDrName = doctor.UserName
  9736. fsiOPFLD.MedChrgitmType = "09"
  9737. memo["hosp_appr_flag"] = "1"
  9738. memo["invoice_no"] = fapiao_code
  9739. memo["memo"] = "自费"
  9740. bytesData, _ := json.Marshal(memo)
  9741. fsiOPFLD.Memo = string(bytesData)
  9742. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9743. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9744. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9745. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9746. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.StartTime, 0).Format("2006-01-02 15:04:05")
  9747. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9748. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9749. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9750. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9751. fsiOPFLD.BilgDeptName = department.Name
  9752. fsiOPFLD.BilgDeptCodg = department.Number
  9753. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9754. fsiOPFLD.BilgDrName = doctor.UserName
  9755. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9756. case 0:
  9757. break
  9758. case 1:
  9759. fsiOPFLD.MedChrgitmType = "14"
  9760. break
  9761. case 2:
  9762. fsiOPFLD.MedChrgitmType = "05"
  9763. break
  9764. case 3:
  9765. fsiOPFLD.MedChrgitmType = "03"
  9766. break
  9767. case 4:
  9768. fsiOPFLD.MedChrgitmType = "03"
  9769. break
  9770. case 5:
  9771. fsiOPFLD.MedChrgitmType = "08"
  9772. break
  9773. case 6:
  9774. fsiOPFLD.MedChrgitmType = "14"
  9775. break
  9776. case 7:
  9777. fsiOPFLD.MedChrgitmType = "14"
  9778. break
  9779. case 8:
  9780. fsiOPFLD.MedChrgitmType = "03"
  9781. break
  9782. case 9:
  9783. fsiOPFLD.MedChrgitmType = "14"
  9784. break
  9785. case 10:
  9786. fsiOPFLD.MedChrgitmType = "14"
  9787. break
  9788. case 11:
  9789. fsiOPFLD.MedChrgitmType = "06"
  9790. break
  9791. case 12:
  9792. fsiOPFLD.MedChrgitmType = "12"
  9793. break
  9794. case 13:
  9795. fsiOPFLD.MedChrgitmType = "01"
  9796. break
  9797. case 14:
  9798. fsiOPFLD.MedChrgitmType = "04"
  9799. break
  9800. case 15:
  9801. fsiOPFLD.MedChrgitmType = "14"
  9802. break
  9803. }
  9804. memo["hosp_appr_flag"] = "1"
  9805. memo["invoice_no"] = fapiao_code
  9806. memo["memo"] = "自费"
  9807. bytesData, _ := json.Marshal(memo)
  9808. fsiOPFLD.Memo = string(bytesData)
  9809. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9810. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9811. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9812. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9813. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9814. fsiOPFLD.BilgDeptName = department.Name
  9815. fsiOPFLD.BilgDeptCodg = department.Number
  9816. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9817. fsiOPFLD.BilgDrName = doctor.UserName
  9818. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9819. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9820. fsiOPFLD.MedChrgitmType = "08"
  9821. memo["hosp_appr_flag"] = "1"
  9822. memo["invoice_no"] = fapiao_code
  9823. memo["memo"] = "自费"
  9824. bytesData, _ := json.Marshal(memo)
  9825. fsiOPFLD.Memo = string(bytesData)
  9826. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9827. }
  9828. }
  9829. }
  9830. for _, items := range order_info_two {
  9831. memo := make(map[string]interface{})
  9832. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9833. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9834. fsiOPFLD.MedType = pre.MedType
  9835. fsiOPFLD.BkkpSn = items.FeedetlSn
  9836. fsiOPFLD.FixmedinsCode = miConfig.Code
  9837. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9838. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9839. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9840. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.Cnt*items.Pric)
  9841. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9842. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9843. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9844. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9845. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9846. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9847. fsiOPFLD.BilgDeptName = department.Name
  9848. fsiOPFLD.BilgDeptCodg = department.Number
  9849. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9850. fsiOPFLD.BilgDrName = doctor.UserName
  9851. fsiOPFLD.MedChrgitmType = "09"
  9852. memo["hosp_appr_flag"] = "1"
  9853. memo["invoice_no"] = fapiao_code
  9854. memo["memo"] = "自费"
  9855. bytesData, _ := json.Marshal(memo)
  9856. fsiOPFLD.Memo = string(bytesData)
  9857. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9858. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9859. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9860. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9861. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9862. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9863. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9864. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9865. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9866. fsiOPFLD.BilgDeptName = department.Name
  9867. fsiOPFLD.BilgDeptCodg = department.Number
  9868. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9869. fsiOPFLD.BilgDrName = doctor.UserName
  9870. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9871. case 0:
  9872. break
  9873. case 1:
  9874. fsiOPFLD.MedChrgitmType = "14"
  9875. break
  9876. case 2:
  9877. fsiOPFLD.MedChrgitmType = "05"
  9878. break
  9879. case 3:
  9880. fsiOPFLD.MedChrgitmType = "03"
  9881. break
  9882. case 4:
  9883. fsiOPFLD.MedChrgitmType = "03"
  9884. break
  9885. case 5:
  9886. fsiOPFLD.MedChrgitmType = "08"
  9887. break
  9888. case 6:
  9889. fsiOPFLD.MedChrgitmType = "14"
  9890. break
  9891. case 7:
  9892. fsiOPFLD.MedChrgitmType = "14"
  9893. break
  9894. case 8:
  9895. fsiOPFLD.MedChrgitmType = "03"
  9896. break
  9897. case 9:
  9898. fsiOPFLD.MedChrgitmType = "14"
  9899. break
  9900. case 10:
  9901. fsiOPFLD.MedChrgitmType = "14"
  9902. break
  9903. case 11:
  9904. fsiOPFLD.MedChrgitmType = "06"
  9905. break
  9906. case 12:
  9907. fsiOPFLD.MedChrgitmType = "12"
  9908. break
  9909. case 13:
  9910. fsiOPFLD.MedChrgitmType = "01"
  9911. break
  9912. case 14:
  9913. fsiOPFLD.MedChrgitmType = "04"
  9914. break
  9915. case 15:
  9916. fsiOPFLD.MedChrgitmType = "14"
  9917. break
  9918. }
  9919. memo["hosp_appr_flag"] = "1"
  9920. memo["invoice_no"] = fapiao_code
  9921. memo["memo"] = "自费"
  9922. bytesData, _ := json.Marshal(memo)
  9923. fsiOPFLD.Memo = string(bytesData)
  9924. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9925. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9926. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9927. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9928. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9929. fsiOPFLD.BilgDeptName = department.Name
  9930. fsiOPFLD.BilgDeptCodg = department.Number
  9931. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9932. fsiOPFLD.BilgDrName = doctor.UserName
  9933. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9934. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9935. fsiOPFLD.MedChrgitmType = "08"
  9936. memo["hosp_appr_flag"] = "1"
  9937. memo["invoice_no"] = fapiao_code
  9938. memo["memo"] = "自费"
  9939. bytesData, _ := json.Marshal(memo)
  9940. fsiOPFLD.Memo = string(bytesData)
  9941. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9942. }
  9943. }
  9944. }
  9945. fmt.Println(fsiOPFLDs)
  9946. struct4201A.Fopfd = fsiOPFLDs
  9947. fmt.Println(struct4201A.Fopfd)
  9948. var struct4202 models.Struct4202
  9949. timeLayout := "2006-01-02 15:04:05"
  9950. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9951. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9952. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9953. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9954. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9955. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9956. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9957. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9958. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9959. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9960. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9961. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9962. var config []*models.HisXtDiagnoseConfig
  9963. for _, item := range diagnosis_ids {
  9964. id, _ := strconv.ParseInt(item, 10, 64)
  9965. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9966. config = append(config, &diagnosisConfig)
  9967. }
  9968. var tempDiaginfos []models.OwnPayPatnDiagListD
  9969. for index, item := range config {
  9970. if index == 0 {
  9971. var tempDiaginfo models.OwnPayPatnDiagListD
  9972. tempDiaginfo.InoutDiagType = "1"
  9973. tempDiaginfo.DiagCode = item.CountryCode
  9974. tempDiaginfo.DiagName = item.CountryContentName
  9975. tempDiaginfo.DiagType = "1"
  9976. tempDiaginfo.DiagSrtNo = "1"
  9977. tempDiaginfo.MaindiagFlag = "1"
  9978. tempDiaginfo.ValiFlag = "1"
  9979. tempDiaginfo.DiagDrName = doctor.UserName
  9980. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9981. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9982. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9983. } else {
  9984. var tempDiaginfo models.OwnPayPatnDiagListD
  9985. tempDiaginfo.DiagCode = item.CountryCode
  9986. tempDiaginfo.DiagName = item.CountryContentName
  9987. tempDiaginfo.DiagType = "2"
  9988. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9989. tempDiaginfo.MaindiagFlag = "0"
  9990. tempDiaginfo.ValiFlag = "1"
  9991. tempDiaginfo.DiagDrName = doctor.UserName
  9992. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9993. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9994. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9995. }
  9996. }
  9997. struct4202.ODiagListD = tempDiaginfos
  9998. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  9999. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  10000. var res2 ResultSix
  10001. var respJSON2 map[string]interface{}
  10002. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10003. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10005. return
  10006. }
  10007. userJSONBytes2, _ := json.Marshal(respJSON2)
  10008. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10009. utils.ErrorLog("解析失败:%v", err)
  10010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10011. return
  10012. }
  10013. if res2.Infcode != 0 {
  10014. c.ServeSuccessJSON(map[string]interface{}{
  10015. "failed_code": -10,
  10016. "msg": res2.ErrMsg,
  10017. })
  10018. return
  10019. } else {
  10020. order.IsUploadDiagnose = 1
  10021. order.IsUploadOrderInfo = 1
  10022. service.UpdateOrderTwo(order)
  10023. c.ServeSuccessJSON(map[string]interface{}{
  10024. "msg": "上传成功",
  10025. })
  10026. }
  10027. }
  10028. func (c *HisApiController) Get4207() {
  10029. admin_user_id, _ := c.GetInt64("admin_user_id")
  10030. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10031. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10032. order_id, _ := c.GetInt64("order_id")
  10033. order, _ := service.GetHisOrderByIDTwo(order_id)
  10034. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  10035. var struct4207 models.Struct4207
  10036. struct4207.PageNum = "1"
  10037. struct4207.PageSize = "1000"
  10038. struct4207.FixmedinsCode = miConfig.Code
  10039. struct4207.FixmedinsMdtrtID = order.Number
  10040. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  10041. saveLog(result, requestLog, "4207", "查询")
  10042. var res2 ResultSix
  10043. var respJSON2 map[string]interface{}
  10044. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10045. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10047. return
  10048. }
  10049. userJSONBytes2, _ := json.Marshal(respJSON2)
  10050. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10051. utils.ErrorLog("解析失败:%v", err)
  10052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10053. return
  10054. }
  10055. if res2.Infcode != 0 {
  10056. c.ServeSuccessJSON(map[string]interface{}{
  10057. "failed_code": -10,
  10058. "msg": res2.ErrMsg,
  10059. })
  10060. return
  10061. } else {
  10062. c.ServeSuccessJSON(map[string]interface{}{
  10063. "msg": "查询成功",
  10064. })
  10065. }
  10066. }
  10067. func (c *HisApiController) Get4208() {
  10068. admin_user_id, _ := c.GetInt64("admin_user_id")
  10069. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10070. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10071. order_id, _ := c.GetInt64("order_id")
  10072. order, _ := service.GetHisOrderByIDTwo(order_id)
  10073. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  10074. var struct4208 models.Struct4208
  10075. struct4208.PageNum = "1"
  10076. struct4208.PageSize = "1000"
  10077. struct4208.PsnCertType = "01"
  10078. struct4208.Certno = his.Certno
  10079. struct4208.MedType = order.MedType
  10080. struct4208.PsnName = his.Name
  10081. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  10082. saveLog(result, requestLog, "4208", "查询")
  10083. var res2 ResultSix
  10084. var respJSON2 map[string]interface{}
  10085. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10086. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10088. return
  10089. }
  10090. userJSONBytes2, _ := json.Marshal(respJSON2)
  10091. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10092. utils.ErrorLog("解析失败:%v", err)
  10093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10094. return
  10095. }
  10096. if res2.Infcode != 0 {
  10097. c.ServeSuccessJSON(map[string]interface{}{
  10098. "failed_code": -10,
  10099. "msg": res2.ErrMsg,
  10100. })
  10101. return
  10102. } else {
  10103. c.ServeSuccessJSON(map[string]interface{}{
  10104. "msg": "查询成功",
  10105. })
  10106. }
  10107. }
  10108. func (c *HisApiController) Get4209() {
  10109. admin_user_id, _ := c.GetInt64("admin_user_id")
  10110. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10111. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10112. order_id, _ := c.GetInt64("order_id")
  10113. order, _ := service.GetHisOrderByIDTwo(order_id)
  10114. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  10115. var struct4209 models.Struct4209
  10116. struct4209.FixmedinsMdtrtID = order.Number
  10117. struct4209.FixmedinsCode = miConfig.Code
  10118. struct4209.PageSize = "1000"
  10119. struct4209.PageNum = "1"
  10120. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  10121. saveLog(result, requestLog, "4209", "查询")
  10122. var res2 ResultSix
  10123. var respJSON2 map[string]interface{}
  10124. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10127. return
  10128. }
  10129. userJSONBytes2, _ := json.Marshal(respJSON2)
  10130. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10131. utils.ErrorLog("解析失败:%v", err)
  10132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10133. return
  10134. }
  10135. if res2.Infcode != 0 {
  10136. c.ServeSuccessJSON(map[string]interface{}{
  10137. "failed_code": -10,
  10138. "msg": res2.ErrMsg,
  10139. })
  10140. return
  10141. } else {
  10142. c.ServeSuccessJSON(map[string]interface{}{
  10143. "msg": "查询成功",
  10144. })
  10145. }
  10146. }
  10147. type Result3101 struct {
  10148. Infcode string `json:"infcode"`
  10149. InfRefmsgid string `json:"inf_refmsgid"`
  10150. RefmsgTime string `json:"refmsg_time"`
  10151. RespondTime string `json:"respond_time"`
  10152. Enctype string `json:"enctype"`
  10153. Signtype string `json:"signtype"`
  10154. ErrMsg string `json:"err_msg"`
  10155. Output struct {
  10156. Result []struct {
  10157. JudgeResultDetailDtos []struct {
  10158. VolaItemType string `json:"vola_item_type"`
  10159. MdtrtID string `json:"mdtrt_id"`
  10160. JrdID string `json:"jrd_id"`
  10161. PatnID string `json:"patn_id"`
  10162. RxID string `json:"rx_id"`
  10163. VolaAmt interface{} `json:"vola_amt"`
  10164. } `json:"judge_result_detail_dtos"`
  10165. RuleID string `json:"rule_id"`
  10166. VolaEvid string `json:"vola_evid"`
  10167. MdtrtID string `json:"mdtrt_id"`
  10168. RuleName string `json:"rule_name"`
  10169. VolaAmtStas string `json:"vola_amt_stas"`
  10170. JrID string `json:"jr_id"`
  10171. PatnID string `json:"patn_id"`
  10172. SevDeg string `json:"sev_deg"`
  10173. VolaAmt float64 `json:"vola_amt"`
  10174. VolaBhvrType string `json:"vola_bhvr_type"`
  10175. VolaCont string `json:"vola_cont"`
  10176. } `json:"result"`
  10177. } `json:"output"`
  10178. }
  10179. type Resultgd3101 struct {
  10180. Infcode int64 `json:"infcode"`
  10181. InfRefmsgid string `json:"inf_refmsgid"`
  10182. RefmsgTime string `json:"refmsg_time"`
  10183. RespondTime string `json:"respond_time"`
  10184. Enctype string `json:"enctype"`
  10185. Signtype string `json:"signtype"`
  10186. ErrMsg string `json:"err_msg"`
  10187. Output struct {
  10188. Result []struct {
  10189. JudgeResultDetailDtos []struct {
  10190. VolaItemType string `json:"vola_item_type"`
  10191. MdtrtID string `json:"mdtrt_id"`
  10192. JrdID string `json:"jrd_id"`
  10193. PatnID string `json:"patn_id"`
  10194. RxID string `json:"rx_id"`
  10195. VolaAmt interface{} `json:"vola_amt"`
  10196. } `json:"judge_result_detail_dtos"`
  10197. RuleID string `json:"rule_id"`
  10198. VolaEvid string `json:"vola_evid"`
  10199. MdtrtID string `json:"mdtrt_id"`
  10200. RuleName string `json:"rule_name"`
  10201. VolaAmtStas string `json:"vola_amt_stas"`
  10202. JrID string `json:"jr_id"`
  10203. PatnID string `json:"patn_id"`
  10204. SevDeg string `json:"sev_deg"`
  10205. VolaAmt float64 `json:"vola_amt"`
  10206. VolaBhvrType string `json:"vola_bhvr_type"`
  10207. VolaCont string `json:"vola_cont"`
  10208. } `json:"result"`
  10209. } `json:"output"`
  10210. }
  10211. func (c *HisApiController) ReadEleToken() {
  10212. admin_user_id, _ := c.GetInt64("admin_user_id")
  10213. his_patient_id, _ := c.GetInt64("his_patient_id")
  10214. adminUser := c.GetAdminUserInfo()
  10215. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10216. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10217. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10218. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  10219. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10220. if len(tokens) > 0 {
  10221. c.ServeSuccessJSON(map[string]interface{}{
  10222. "msg": "读取成功",
  10223. })
  10224. } else {
  10225. c.ServeSuccessJSON(map[string]interface{}{
  10226. "failed_code": -10,
  10227. "msg": "读取失败",
  10228. })
  10229. }
  10230. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10231. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10232. if len(tokens) > 0 {
  10233. c.ServeSuccessJSON(map[string]interface{}{
  10234. "msg": "读取成功",
  10235. })
  10236. } else {
  10237. c.ServeSuccessJSON(map[string]interface{}{
  10238. "failed_code": -10,
  10239. "msg": "读取失败",
  10240. })
  10241. }
  10242. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10243. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10244. if len(tokens) > 0 {
  10245. c.ServeSuccessJSON(map[string]interface{}{
  10246. "msg": "读取成功",
  10247. })
  10248. } else {
  10249. c.ServeSuccessJSON(map[string]interface{}{
  10250. "failed_code": -10,
  10251. "msg": "读取失败",
  10252. })
  10253. }
  10254. } else if miConfig.MdtrtareaAdmvs == "150404" {
  10255. var api string
  10256. 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 +
  10257. "&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"
  10258. resp, requestErr := http.Get(api)
  10259. if requestErr != nil {
  10260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10261. }
  10262. body, ioErr := ioutil.ReadAll(resp.Body)
  10263. if ioErr != nil {
  10264. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10266. }
  10267. var respJSON map[string]interface{}
  10268. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10271. return
  10272. }
  10273. var status string
  10274. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10275. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10276. var token string
  10277. var res ResultTwo //1101结果
  10278. var res10265 ResultTwo10265 //1101结果
  10279. if status == "0" { //读卡成功
  10280. var card_info string //卡信息
  10281. var busi_card_info string
  10282. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10283. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10284. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10285. fmt.Println(card_info)
  10286. fmt.Println(busi_card_info)
  10287. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10288. result, _ := json.Marshal(respJSON)
  10289. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10290. utils.ErrorLog("解析失败:%v", err)
  10291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10292. return
  10293. }
  10294. res.ErrMsg = res10265.ErrMsg
  10295. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10296. res.Infcode = infocode
  10297. res.Output = res10265.Output
  10298. res.InfRefmsgid = res10265.InfRefmsgid
  10299. if res.Infcode == 0 {
  10300. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10301. if err == gorm.ErrRecordNotFound {
  10302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10303. return
  10304. } else if err != nil {
  10305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10306. return
  10307. } else {
  10308. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10309. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10310. infoStr := string(Iinfos)
  10311. idetinfoStr := string(Idetinfos)
  10312. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  10313. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  10314. psn := &models.HisPsn{
  10315. PsnNo: res.Output.Baseinfo.PsnNo,
  10316. PatientId: patient.ID,
  10317. Certno: res.Output.Baseinfo.Certno,
  10318. Gend: res.Output.Baseinfo.Gend,
  10319. Naty: res.Output.Baseinfo.Naty,
  10320. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10321. PsnName: res.Output.Baseinfo.PsnName,
  10322. Age: float64(age),
  10323. Brdy: b,
  10324. Idetinfo: idetinfoStr,
  10325. Insuinfo: infoStr,
  10326. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10327. CardInfo: card_info,
  10328. VerifyNumber: token,
  10329. IdCardType: 4,
  10330. }
  10331. var rf []*ResultFive
  10332. json.Unmarshal([]byte(infoStr), &rf)
  10333. var insutypes []*ResultFive
  10334. var insutype string
  10335. var is390 int = 0
  10336. var is310 int = 0
  10337. for _, item := range rf {
  10338. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10339. insutypes = append(insutypes, item)
  10340. }
  10341. }
  10342. if len(insutypes) == 1 {
  10343. insutype = insutypes[0].Insutype
  10344. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10345. } else {
  10346. for _, i := range insutypes {
  10347. if i.Insutype == "390" {
  10348. is390 = 1
  10349. }
  10350. if i.Insutype == "310" {
  10351. is310 = 1
  10352. }
  10353. }
  10354. }
  10355. if is390 == 1 {
  10356. insutype = "390"
  10357. }
  10358. if is310 == 1 {
  10359. insutype = "310"
  10360. }
  10361. if len(insutypes) == 0 {
  10362. insutype = "310"
  10363. }
  10364. service.CreateHisPsn(psn)
  10365. c.ServeSuccessJSON(map[string]interface{}{
  10366. "patient": patient,
  10367. "number": token,
  10368. "insutype": insutype,
  10369. })
  10370. }
  10371. } else {
  10372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10373. return
  10374. }
  10375. } else { //读卡失败
  10376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10377. return
  10378. }
  10379. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10380. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  10381. if len(errMsg) == 0 {
  10382. type ELeData struct {
  10383. Data struct {
  10384. IdNo string `json:"idNo"`
  10385. IdType string `json:"idType"`
  10386. UserName string `json:"userName"`
  10387. EcToken string `json:"ecToken"`
  10388. InsuOrg string `json:"insuOrg"`
  10389. Gender string `json:"gender"`
  10390. Birthday string `json:"birthday"`
  10391. Nationality string `json:"nationality"`
  10392. Email string `json:"email"`
  10393. Extra string `json:"extra"`
  10394. } `json:"data"`
  10395. Code int `json:"code"`
  10396. Message string `json:"message"`
  10397. }
  10398. var ele ELeData
  10399. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10400. if err != nil {
  10401. utils.ErrorLog("解析失败:%v", err)
  10402. }
  10403. token := ele.Data.EcToken
  10404. if len(token) > 0 {
  10405. psn := &models.HisPsn{
  10406. PsnNo: his.PsnNo,
  10407. Age: 0,
  10408. PatientId: his.PatientId,
  10409. Certno: his.Certno,
  10410. Brdy: his.Brdy,
  10411. Gend: his.Gend,
  10412. Naty: his.Naty,
  10413. PsnCertType: his.PsnCertType,
  10414. PsnName: his.PsnName,
  10415. Idetinfo: his.Idetinfo,
  10416. Insuinfo: his.Iinfo,
  10417. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10418. CardInfo: outPutInfo,
  10419. VerifyNumber: token,
  10420. }
  10421. service.CreateHisPsn(psn)
  10422. }
  10423. if len(token) > 0 {
  10424. c.ServeSuccessJSON(map[string]interface{}{
  10425. "msg": "读取成功",
  10426. })
  10427. } else {
  10428. c.ServeSuccessJSON(map[string]interface{}{
  10429. "failed_code": -10,
  10430. "msg": "读取失败",
  10431. })
  10432. }
  10433. }
  10434. } else if miConfig.MdtrtareaAdmvs == "360302" {
  10435. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10436. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10437. type ELeData struct {
  10438. Data struct {
  10439. IdNo string `json:"idNo"`
  10440. IdType string `json:"idType"`
  10441. UserName string `json:"userName"`
  10442. EcToken string `json:"ecToken"`
  10443. InsuOrg string `json:"insuOrg"`
  10444. Gender string `json:"gender"`
  10445. Birthday string `json:"birthday"`
  10446. Nationality string `json:"nationality"`
  10447. Email string `json:"email"`
  10448. Extra string `json:"extra"`
  10449. } `json:"data"`
  10450. Code int `json:"code"`
  10451. Message string `json:"message"`
  10452. }
  10453. var ele ELeData
  10454. err := json.Unmarshal([]byte(result), &ele)
  10455. if err != nil {
  10456. utils.ErrorLog("解析失败:%v", err)
  10457. }
  10458. token := ele.Data.EcToken
  10459. token = Remove0000(token)
  10460. fmt.Println(ele.Data.UserName)
  10461. 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)
  10462. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10463. var res ResultTwo
  10464. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10465. utils.ErrorLog("解析失败:%v", err)
  10466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10467. return
  10468. }
  10469. if res.Infcode == 0 {
  10470. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10471. if err == gorm.ErrRecordNotFound {
  10472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10473. return
  10474. } else if err != nil {
  10475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10476. return
  10477. } else {
  10478. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10479. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10480. infoStr := string(Iinfos)
  10481. idetinfoStr := string(Idetinfos)
  10482. psn := &models.HisPsn{
  10483. PsnNo: res.Output.Baseinfo.PsnNo,
  10484. PatientId: patient.ID,
  10485. Certno: res.Output.Baseinfo.Certno,
  10486. Gend: res.Output.Baseinfo.Gend,
  10487. Naty: res.Output.Baseinfo.Naty,
  10488. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10489. PsnName: res.Output.Baseinfo.PsnName,
  10490. Idetinfo: idetinfoStr,
  10491. Insuinfo: infoStr,
  10492. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10493. CardInfo: "",
  10494. VerifyNumber: token,
  10495. }
  10496. service.CreateHisPsn(psn)
  10497. c.ServeSuccessJSON(map[string]interface{}{
  10498. "patient": patient,
  10499. "number": token,
  10500. })
  10501. }
  10502. } else {
  10503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10504. return
  10505. }
  10506. } else if miConfig.MdtrtareaAdmvs == "361025" {
  10507. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10508. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10509. type ELeData struct {
  10510. Data struct {
  10511. IdNo string `json:"idNo"`
  10512. IdType string `json:"idType"`
  10513. UserName string `json:"userName"`
  10514. EcToken string `json:"ecToken"`
  10515. InsuOrg string `json:"insuOrg"`
  10516. Gender string `json:"gender"`
  10517. Birthday string `json:"birthday"`
  10518. Nationality string `json:"nationality"`
  10519. Email string `json:"email"`
  10520. Extra string `json:"extra"`
  10521. } `json:"data"`
  10522. Code int `json:"code"`
  10523. Message string `json:"message"`
  10524. }
  10525. var ele ELeData
  10526. err := json.Unmarshal([]byte(result), &ele)
  10527. if err != nil {
  10528. utils.ErrorLog("解析失败:%v", err)
  10529. }
  10530. token := ele.Data.EcToken
  10531. token = Remove0000(token)
  10532. fmt.Println(ele.Data.UserName)
  10533. 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)
  10534. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10535. var res ResultTwo
  10536. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10537. utils.ErrorLog("解析失败:%v", err)
  10538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10539. return
  10540. }
  10541. if res.Infcode == 0 {
  10542. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10543. if err == gorm.ErrRecordNotFound {
  10544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10545. return
  10546. } else if err != nil {
  10547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10548. return
  10549. } else {
  10550. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10551. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10552. infoStr := string(Iinfos)
  10553. idetinfoStr := string(Idetinfos)
  10554. psn := &models.HisPsn{
  10555. PsnNo: res.Output.Baseinfo.PsnNo,
  10556. PatientId: patient.ID,
  10557. Certno: res.Output.Baseinfo.Certno,
  10558. Gend: res.Output.Baseinfo.Gend,
  10559. Naty: res.Output.Baseinfo.Naty,
  10560. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10561. PsnName: res.Output.Baseinfo.PsnName,
  10562. Idetinfo: idetinfoStr,
  10563. Insuinfo: infoStr,
  10564. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10565. CardInfo: "",
  10566. VerifyNumber: token,
  10567. }
  10568. service.CreateHisPsn(psn)
  10569. c.ServeSuccessJSON(map[string]interface{}{
  10570. "patient": patient,
  10571. "number": token,
  10572. })
  10573. }
  10574. } else {
  10575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10576. return
  10577. }
  10578. } else if miConfig.MdtrtareaAdmvs == "360100" {
  10579. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10580. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10581. type ELeData struct {
  10582. Data struct {
  10583. IdNo string `json:"idNo"`
  10584. IdType string `json:"idType"`
  10585. UserName string `json:"userName"`
  10586. EcToken string `json:"ecToken"`
  10587. InsuOrg string `json:"insuOrg"`
  10588. Gender string `json:"gender"`
  10589. Birthday string `json:"birthday"`
  10590. Nationality string `json:"nationality"`
  10591. Email string `json:"email"`
  10592. Extra string `json:"extra"`
  10593. } `json:"data"`
  10594. Code int `json:"code"`
  10595. Message string `json:"message"`
  10596. }
  10597. var ele ELeData
  10598. err := json.Unmarshal([]byte(result), &ele)
  10599. if err != nil {
  10600. utils.ErrorLog("解析失败:%v", err)
  10601. }
  10602. token := ele.Data.EcToken
  10603. token = Remove0000(token)
  10604. fmt.Println(ele.Data.UserName)
  10605. 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)
  10606. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10607. var res ResultTwo
  10608. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10609. utils.ErrorLog("解析失败:%v", err)
  10610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10611. return
  10612. }
  10613. if res.Infcode == 0 {
  10614. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10615. if err == gorm.ErrRecordNotFound {
  10616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10617. return
  10618. } else if err != nil {
  10619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10620. return
  10621. } else {
  10622. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10623. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10624. infoStr := string(Iinfos)
  10625. idetinfoStr := string(Idetinfos)
  10626. psn := &models.HisPsn{
  10627. PsnNo: res.Output.Baseinfo.PsnNo,
  10628. PatientId: patient.ID,
  10629. Certno: res.Output.Baseinfo.Certno,
  10630. Gend: res.Output.Baseinfo.Gend,
  10631. Naty: res.Output.Baseinfo.Naty,
  10632. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10633. PsnName: res.Output.Baseinfo.PsnName,
  10634. Idetinfo: idetinfoStr,
  10635. Insuinfo: infoStr,
  10636. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10637. CardInfo: "",
  10638. VerifyNumber: token,
  10639. }
  10640. service.CreateHisPsn(psn)
  10641. c.ServeSuccessJSON(map[string]interface{}{
  10642. "patient": patient,
  10643. "number": token,
  10644. })
  10645. }
  10646. } else {
  10647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10648. return
  10649. }
  10650. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10651. //if initFlag == 0 {
  10652. //c.TestGetJiangXiBasBaseInit()
  10653. //}
  10654. //if initEleFlag == 0 {
  10655. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10656. //}
  10657. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  10658. utils.ErrorLog("解析失败:%v", json_result)
  10659. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10660. type ELeData struct {
  10661. Data struct {
  10662. IdNo string `json:"idNo"`
  10663. IdType string `json:"idType"`
  10664. UserName string `json:"userName"`
  10665. EcToken string `json:"ecToken"`
  10666. InsuOrg string `json:"insuOrg"`
  10667. Gender string `json:"gender"`
  10668. Birthday string `json:"birthday"`
  10669. Nationality string `json:"nationality"`
  10670. Email string `json:"email"`
  10671. Extra string `json:"extra"`
  10672. } `json:"data"`
  10673. Code int `json:"code"`
  10674. Message string `json:"message"`
  10675. }
  10676. var ele ELeData
  10677. err := json.Unmarshal([]byte(json_result), &ele)
  10678. if err != nil {
  10679. utils.ErrorLog("解析失败:%v", err)
  10680. }
  10681. token := ele.Data.EcToken
  10682. token = Remove0000(token)
  10683. //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)
  10684. 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)
  10685. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  10686. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10687. var res ResultTwo
  10688. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10689. utils.ErrorLog("解析失败:%v", err)
  10690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10691. return
  10692. }
  10693. if res.Infcode == 0 {
  10694. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10695. if err == gorm.ErrRecordNotFound {
  10696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10697. return
  10698. } else if err != nil {
  10699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10700. return
  10701. } else {
  10702. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10703. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10704. infoStr := string(Iinfos)
  10705. idetinfoStr := string(Idetinfos)
  10706. psn := &models.HisPsn{
  10707. PsnNo: res.Output.Baseinfo.PsnNo,
  10708. PatientId: patient.ID,
  10709. Certno: res.Output.Baseinfo.Certno,
  10710. Gend: res.Output.Baseinfo.Gend,
  10711. Naty: res.Output.Baseinfo.Naty,
  10712. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10713. PsnName: res.Output.Baseinfo.PsnName,
  10714. Idetinfo: idetinfoStr,
  10715. Insuinfo: infoStr,
  10716. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10717. CardInfo: "",
  10718. VerifyNumber: token,
  10719. InsuplcAdmdvs: ele.Data.InsuOrg,
  10720. }
  10721. service.CreateHisPsn(psn)
  10722. c.ServeSuccessJSON(map[string]interface{}{
  10723. "patient": patient,
  10724. "number": token,
  10725. })
  10726. }
  10727. } else {
  10728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10729. return
  10730. }
  10731. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10732. res := c.GetoleInfo()
  10733. if res.Infcode == 0 {
  10734. var result string
  10735. if res.Output.MdtrtCertType == "01" {
  10736. 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)
  10737. } else if res.Output.MdtrtCertType == "02" {
  10738. 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)
  10739. } else if res.Output.MdtrtCertType == "03" {
  10740. 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)
  10741. }
  10742. var dat map[string]interface{}
  10743. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10744. fmt.Println(dat)
  10745. } else {
  10746. fmt.Println(err)
  10747. }
  10748. userJSONBytes, _ := json.Marshal(dat)
  10749. var res2 ResultTwo
  10750. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10751. utils.ErrorLog("解析失败:%v", err)
  10752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10753. return
  10754. }
  10755. if res2.Infcode == 0 {
  10756. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10757. if err == gorm.ErrRecordNotFound {
  10758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10759. return
  10760. } else if err != nil {
  10761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10762. return
  10763. } else {
  10764. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10765. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10766. infoStr := string(Iinfos)
  10767. idetinfoStr := string(Idetinfos)
  10768. var rf []*ResultFive
  10769. json.Unmarshal([]byte(infoStr), &rf)
  10770. var insutypes []*ResultFive
  10771. var insutype string
  10772. var is390 int = 0
  10773. var is310 int = 0
  10774. //var insuplc_admdvs string
  10775. for _, item := range rf {
  10776. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10777. insutypes = append(insutypes, item)
  10778. }
  10779. }
  10780. if len(insutypes) == 1 {
  10781. insutype = insutypes[0].Insutype
  10782. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10783. } else {
  10784. for _, i := range insutypes {
  10785. if i.Insutype == "390" {
  10786. is390 = 1
  10787. }
  10788. if i.Insutype == "310" {
  10789. is310 = 1
  10790. }
  10791. }
  10792. }
  10793. if is390 == 1 {
  10794. insutype = "390"
  10795. }
  10796. if is310 == 1 {
  10797. insutype = "310"
  10798. }
  10799. if len(insutypes) == 0 {
  10800. insutype = "310"
  10801. }
  10802. psn := &models.HisPsn{
  10803. PsnNo: res2.Output.Baseinfo.PsnNo,
  10804. PatientId: patient.ID,
  10805. Certno: res2.Output.Baseinfo.Certno,
  10806. Gend: res2.Output.Baseinfo.Gend,
  10807. Naty: res2.Output.Baseinfo.Naty,
  10808. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10809. PsnName: res2.Output.Baseinfo.PsnName,
  10810. Idetinfo: idetinfoStr,
  10811. Insuinfo: infoStr,
  10812. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10813. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10814. VerifyNumber: res.Output.EcToken,
  10815. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10816. }
  10817. service.CreateHisPsn(psn)
  10818. c.ServeSuccessJSON(map[string]interface{}{
  10819. "patient": patient,
  10820. "number": res.Output.CardNo,
  10821. "insutype": insutype,
  10822. })
  10823. }
  10824. } else {
  10825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10826. return
  10827. }
  10828. } else {
  10829. c.ServeSuccessJSON(map[string]interface{}{
  10830. "failed_code": -10,
  10831. "msg": res.ErrMsg,
  10832. })
  10833. }
  10834. } else {
  10835. //if initFlag == 0 {
  10836. // c.TestGetBasBaseInit()
  10837. //}
  10838. //token := c.GetEleBaseInfo()
  10839. //token = Remove0000(token)
  10840. type ELeData struct {
  10841. Code string `json:"code"`
  10842. Data struct {
  10843. Aac002 string `json:"aac002"`
  10844. Aaz500 string `json:"aaz500"`
  10845. ActCardNo string `json:"actCardNo"`
  10846. Bab520 string `json:"bab520"`
  10847. Bkz543 string `json:"bkz543"`
  10848. BusinessType string `json:"businessType"`
  10849. CertfCodg string `json:"certfCodg"`
  10850. EcIndexNo string `json:"ecIndexNo"`
  10851. EcToken string `json:"ecToken"`
  10852. ID0000 string `json:"id0000"`
  10853. IDNo string `json:"idNo"`
  10854. IDType string `json:"idType"`
  10855. Idcode string `json:"idcode"`
  10856. IdentityToken string `json:"identity_token"`
  10857. InsuOrg string `json:"insuOrg"`
  10858. OfficeID string `json:"officeId"`
  10859. OfficeName string `json:"officeName"`
  10860. OperatorID string `json:"operatorId"`
  10861. OperatorName string `json:"operatorName"`
  10862. OrgID string `json:"orgId"`
  10863. UserName string `json:"userName"`
  10864. } `json:"data"`
  10865. Infno interface{} `json:"infno"`
  10866. Message string `json:"message"`
  10867. OrgID string `json:"orgId"`
  10868. TransType string `json:"transType"`
  10869. }
  10870. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10871. fmt.Println(result)
  10872. outPutInfo := Remove0000(result)
  10873. fmt.Println(outPutInfo)
  10874. var ele ELeData
  10875. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10876. if err != nil {
  10877. utils.ErrorLog("解析失败:%v", err)
  10878. }
  10879. token := ele.Data.EcToken
  10880. var result2 string
  10881. var requestLog2 string
  10882. if len(token) > 0 {
  10883. if strings.Contains(ele.Data.IDNo, "HKG") {
  10884. 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)
  10885. } else {
  10886. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  10887. }
  10888. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10889. var res ResultTwo
  10890. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10891. utils.ErrorLog("解析失败:%v", err)
  10892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10893. return
  10894. }
  10895. if res.Infcode == 0 {
  10896. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10897. if err == gorm.ErrRecordNotFound {
  10898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10899. return
  10900. } else if err != nil {
  10901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10902. return
  10903. } else {
  10904. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10905. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10906. infoStr := string(Iinfos)
  10907. idetinfoStr := string(Idetinfos)
  10908. psn := &models.HisPsn{
  10909. PsnNo: res.Output.Baseinfo.PsnNo,
  10910. PatientId: patient.ID,
  10911. Certno: res.Output.Baseinfo.Certno,
  10912. Gend: res.Output.Baseinfo.Gend,
  10913. Naty: res.Output.Baseinfo.Naty,
  10914. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10915. PsnName: res.Output.Baseinfo.PsnName,
  10916. Idetinfo: idetinfoStr,
  10917. Insuinfo: infoStr,
  10918. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10919. CardInfo: "",
  10920. VerifyNumber: token,
  10921. }
  10922. service.CreateHisPsn(psn)
  10923. c.ServeSuccessJSON(map[string]interface{}{
  10924. "msg": "读取成功",
  10925. })
  10926. }
  10927. } else {
  10928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10929. return
  10930. }
  10931. } else {
  10932. c.ServeSuccessJSON(map[string]interface{}{
  10933. "failed_code": -10,
  10934. "msg": "读取失败",
  10935. })
  10936. }
  10937. }
  10938. }
  10939. func (c *HisApiController) ReadEleFace() {
  10940. admin_user_id, _ := c.GetInt64("admin_user_id")
  10941. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10942. adminUser := c.GetAdminUserInfo()
  10943. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10944. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10945. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10946. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  10947. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10948. if len(tokens) > 0 {
  10949. c.ServeSuccessJSON(map[string]interface{}{
  10950. "msg": "读取成功",
  10951. })
  10952. } else {
  10953. c.ServeSuccessJSON(map[string]interface{}{
  10954. "failed_code": -10,
  10955. "msg": "读取失败",
  10956. })
  10957. }
  10958. }
  10959. }
  10960. func timestampToBirthdayString(timestamp int64) string {
  10961. // 将时间戳转换为 time.Time
  10962. t := time.Unix(timestamp, 0)
  10963. // 格式化时间为生日字符串,例如 "2006-01-02"
  10964. birthday := t.Format("2006-01-02")
  10965. return birthday
  10966. }
  10967. func (c *HisApiController) Get9001() {
  10968. adminUser := c.GetAdminUserInfo()
  10969. admin_user_id, _ := c.GetInt64("admin_user_id")
  10970. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10971. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10972. if miConfig.MdtrtareaAdmvs == "350500" {
  10973. service.GetFjAuthorizationInfo(miConfig.Code)
  10974. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10975. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10976. var dat map[string]interface{}
  10977. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10978. fmt.Println(dat)
  10979. } else {
  10980. fmt.Println(err)
  10981. }
  10982. userJSONBytes, _ := json.Marshal(dat)
  10983. var res models.Result9001
  10984. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10985. utils.ErrorLog("解析失败:%v", err)
  10986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10987. return
  10988. }
  10989. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10990. fmt.Println(miConfig.SecretKey)
  10991. var res models.Result9001Two
  10992. 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 +
  10993. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10994. resp, requestErr := http.Get(api)
  10995. if requestErr != nil {
  10996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10997. return
  10998. }
  10999. body, ioErr := ioutil.ReadAll(resp.Body)
  11000. if ioErr != nil {
  11001. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11003. return
  11004. }
  11005. var respJSON map[string]interface{}
  11006. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11009. return
  11010. }
  11011. status := respJSON["data"].(map[string]interface{})["status"].(string)
  11012. if status == "0" {
  11013. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  11014. c.ServeSuccessJSON(map[string]interface{}{
  11015. "failed_code": -10,
  11016. "msg": err_msg,
  11017. })
  11018. return
  11019. }
  11020. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11021. result, _ := json.Marshal(respJSON)
  11022. fmt.Println("log")
  11023. fmt.Println(string(result))
  11024. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11025. utils.ErrorLog("解析失败:%v", err)
  11026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11027. return
  11028. }
  11029. if res.Infcode == 0 {
  11030. sign := models.HisSignIn{
  11031. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11032. SignNo: res.Output.Signinoutb.SignNo,
  11033. SignTime: "",
  11034. Ctime: time.Now().Unix(),
  11035. Mtime: time.Now().Unix(),
  11036. Status: 1,
  11037. InputLog: "",
  11038. OutputLog: "",
  11039. FixmedinsCode: miConfig.Code,
  11040. }
  11041. err := service.CreateSignIn(&sign)
  11042. if err == nil {
  11043. c.ServeSuccessJSON(map[string]interface{}{
  11044. "msg": "签到成功",
  11045. })
  11046. }
  11047. } else {
  11048. c.ServeSuccessJSON(map[string]interface{}{
  11049. "failed_code": -10,
  11050. "msg": res.ErrMsg,
  11051. })
  11052. return
  11053. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11054. //return
  11055. }
  11056. } else if miConfig.MdtrtareaAdmvs == "340699" {
  11057. fmt.Println(miConfig.SecretKey)
  11058. var res models.Result9001Two
  11059. 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 +
  11060. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  11061. resp, requestErr := http.Get(api)
  11062. if requestErr != nil {
  11063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11064. return
  11065. }
  11066. body, ioErr := ioutil.ReadAll(resp.Body)
  11067. if ioErr != nil {
  11068. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11070. return
  11071. }
  11072. var respJSON map[string]interface{}
  11073. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11074. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11076. return
  11077. }
  11078. status := respJSON["data"].(map[string]interface{})["status"].(string)
  11079. if status == "0" {
  11080. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  11081. c.ServeSuccessJSON(map[string]interface{}{
  11082. "failed_code": -10,
  11083. "msg": err_msg,
  11084. })
  11085. return
  11086. }
  11087. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11088. result, _ := json.Marshal(respJSON)
  11089. fmt.Println("log")
  11090. fmt.Println(string(result))
  11091. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11092. utils.ErrorLog("解析失败:%v", err)
  11093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11094. return
  11095. }
  11096. if res.Infcode == 0 {
  11097. sign := models.HisSignIn{
  11098. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11099. SignNo: res.Output.Signinoutb.SignNo,
  11100. SignTime: "",
  11101. Ctime: time.Now().Unix(),
  11102. Mtime: time.Now().Unix(),
  11103. Status: 1,
  11104. InputLog: "",
  11105. OutputLog: "",
  11106. FixmedinsCode: miConfig.Code,
  11107. }
  11108. err := service.CreateSignIn(&sign)
  11109. if err == nil {
  11110. c.ServeSuccessJSON(map[string]interface{}{
  11111. "msg": "签到成功",
  11112. })
  11113. }
  11114. } else {
  11115. c.ServeSuccessJSON(map[string]interface{}{
  11116. "failed_code": -10,
  11117. "msg": res.ErrMsg,
  11118. })
  11119. return
  11120. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11121. //return
  11122. }
  11123. } else {
  11124. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  11125. var dat map[string]interface{}
  11126. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11127. fmt.Println(dat)
  11128. } else {
  11129. fmt.Println(err)
  11130. }
  11131. userJSONBytes, _ := json.Marshal(dat)
  11132. var res models.Result9001
  11133. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11134. utils.ErrorLog("解析失败:%v", err)
  11135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11136. return
  11137. }
  11138. if res.Infcode == 0 {
  11139. sign := models.HisSignIn{
  11140. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11141. SignNo: res.Output.Signinoutb.SignNo,
  11142. SignTime: res.Output.Signinoutb.SignTime,
  11143. Ctime: time.Now().Unix(),
  11144. Mtime: time.Now().Unix(),
  11145. Status: 1,
  11146. InputLog: "",
  11147. OutputLog: "",
  11148. FixmedinsCode: miConfig.Code,
  11149. }
  11150. err := service.CreateSignIn(&sign)
  11151. if err == nil {
  11152. c.ServeSuccessJSON(map[string]interface{}{
  11153. "msg": "签到成功",
  11154. })
  11155. }
  11156. }
  11157. }
  11158. }
  11159. 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) {
  11160. var res Result3101
  11161. adminUser := c.GetAdminUserInfo()
  11162. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11163. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11164. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11165. //record_time := c.GetString("record_time")
  11166. //trig_scen := c.GetString("trig_scen")
  11167. timeLayout := "2006-01-02"
  11168. loc, _ := time.LoadLocation("Local")
  11169. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11170. if err != nil {
  11171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11172. return res
  11173. }
  11174. recordDateTime := theTime.Unix()
  11175. var patientPrescription models.HisPrescriptionInfo
  11176. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11177. //if patientPrescription.ID == 0 {
  11178. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11179. //}
  11180. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11181. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11182. //
  11183. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11184. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11185. var pp models.PublicParams
  11186. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11187. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11188. pp.FixmedinsName = miConfig.OrgName
  11189. pp.FixmedinsCode = miConfig.Code
  11190. pp.RequestUrl = miConfig.Url
  11191. pp.Cainfo = miConfig.Cainfo
  11192. pp.SecretKey = miConfig.SecretKey
  11193. pp.AccessKey = miConfig.AccessKey
  11194. pp.OpterName = roles.UserName
  11195. var config []*models.HisXtDiagnoseConfig
  11196. for _, item := range diagnosis_ids {
  11197. id, _ := strconv.ParseInt(item, 10, 64)
  11198. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11199. config = append(config, &diagnosisConfig)
  11200. }
  11201. var pd models.PatientDtos
  11202. pd.PatnID = his.PsnNo
  11203. pd.PatnName = his.Name
  11204. pd.Gend = his.Gend
  11205. pd.Brdy = his.Brdy
  11206. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11207. pd.CurrMdtrtID = his.Number
  11208. var fed models.FsiEncounterDtos
  11209. fed.MdtrtID = his.Number
  11210. fed.MedinsID = miConfig.Code
  11211. fed.MedinsName = miConfig.OrgName
  11212. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11213. fed.MedMdtrtType = "1"
  11214. fed.MedinsType = "1"
  11215. fed.MedinsLv = "11"
  11216. tm := time.Unix(his.RecordDate, 0)
  11217. s_tm := tm.Format("2006-01-02 15:04:05")
  11218. fed.AdmDate = s_tm
  11219. fed.DscgDate = s_tm
  11220. fed.DscgMainDiseCodg = config[0].CountryCode
  11221. fed.DscgMainDiseName = config[0].CountryContentName
  11222. //诊断信息
  11223. var fdds []*models.FsiDiagnoseDtos
  11224. for index, item := range config {
  11225. if index == 0 {
  11226. var fdd models.FsiDiagnoseDtos
  11227. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11228. fdd.InoutDiseType = "1"
  11229. fdd.MaindiseFlag = "1"
  11230. fdd.DiseDate = s_tm
  11231. fdd.DiasSrtNo = "1"
  11232. fdd.DiseName = item.CountryContentName
  11233. fdd.DiseCodg = item.CountryCode
  11234. fdds = append(fdds, &fdd)
  11235. } else {
  11236. var fdd models.FsiDiagnoseDtos
  11237. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11238. fdd.InoutDiseType = "1"
  11239. fdd.MaindiseFlag = "1"
  11240. fdd.DiseDate = s_tm
  11241. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11242. fdd.DiseName = item.CountryContentName
  11243. fdd.DiseCodg = item.CountryCode
  11244. fdds = append(fdds, &fdd)
  11245. }
  11246. }
  11247. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11248. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11249. fed.AdmDeptName = de.Name
  11250. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11251. fed.DscgDeptName = de.Name
  11252. fed.MedMdtrtType = "1"
  11253. fed.MedType = "11"
  11254. //if his.Insutype == "390" {
  11255. // fed.MedType = "1402"
  11256. //} else {
  11257. // fed.MedType = "9933"
  11258. //}
  11259. var orders []*models.FsiOrderDtos
  11260. if trig_scen == "2" {
  11261. //处方医嘱信息
  11262. for _, item := range prescriptions {
  11263. for _, subItem := range item.HisDoctorAdviceInfo {
  11264. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11265. var order models.FsiOrderDtos
  11266. order.RxID = strconv.FormatInt(item.ID, 10)
  11267. order.Rxno = strconv.FormatInt(item.ID, 10)
  11268. order.LongDrordFlag = "0"
  11269. order.HilistType = "1"
  11270. order.ChrgType = "1"
  11271. order.DrordBhvr = "-"
  11272. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11273. order.HosplistName = subItem.BaseDrugLib.DrugName
  11274. order.HilistLv = "1"
  11275. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11276. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11277. order.HosplistName = subItem.BaseDrugLib.DrugName
  11278. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11279. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11280. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11281. order.OwnpayAmt = ""
  11282. order.SelfpayAmt = ""
  11283. order.Spec = ""
  11284. order.SpecUnt = ""
  11285. order.DrordBegnDate = s_tm
  11286. order.DrordStopDate = ""
  11287. order.DrordDrCodg = doctor_info.DoctorNumber
  11288. order.DrordDeptName = department.Name
  11289. order.DrordDeptCodg = department.Number
  11290. order.DrordDrName = doctor_info.UserName
  11291. order.DrordDrProfttl = "234"
  11292. order.CurrDrordFlag = "1"
  11293. orders = append(orders, &order)
  11294. }
  11295. }
  11296. for _, subItem := range item.HisPrescriptionProject {
  11297. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11298. var order models.FsiOrderDtos
  11299. order.RxID = strconv.FormatInt(item.ID, 10)
  11300. order.Rxno = strconv.FormatInt(item.ID, 10)
  11301. order.LongDrordFlag = "0"
  11302. order.HilistType = "1"
  11303. order.ChrgType = "1"
  11304. order.DrordBhvr = "-"
  11305. order.HilistCode = subItem.HisProject.MedicalCode
  11306. order.HosplistName = subItem.HisProject.ProjectName
  11307. order.HilistLv = "1"
  11308. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11309. order.HosplistCode = subItem.HisProject.MedicalCode
  11310. order.HosplistName = subItem.HisProject.ProjectName
  11311. order.Cnt = subItem.Count
  11312. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11313. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11314. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11315. order.OwnpayAmt = ""
  11316. order.SelfpayAmt = ""
  11317. order.Spec = ""
  11318. order.SpecUnt = ""
  11319. order.DrordBegnDate = s_tm
  11320. order.DrordStopDate = ""
  11321. order.DrordDrCodg = doctor_info.DoctorNumber
  11322. order.DrordDeptName = department.Name
  11323. order.DrordDeptCodg = department.Number
  11324. order.DrordDrName = doctor_info.UserName
  11325. order.DrordDrProfttl = "234"
  11326. order.CurrDrordFlag = "1"
  11327. orders = append(orders, &order)
  11328. }
  11329. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11330. var order models.FsiOrderDtos
  11331. order.RxID = strconv.FormatInt(item.ID, 10)
  11332. order.Rxno = strconv.FormatInt(item.ID, 10)
  11333. order.LongDrordFlag = "0"
  11334. order.HilistType = "1"
  11335. order.ChrgType = "1"
  11336. order.DrordBhvr = "-"
  11337. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11338. order.HosplistName = subItem.GoodInfo.GoodName
  11339. order.HilistLv = "1"
  11340. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11341. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11342. order.HosplistName = subItem.GoodInfo.GoodName
  11343. order.Cnt = subItem.Count
  11344. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11345. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11346. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11347. order.OwnpayAmt = ""
  11348. order.SelfpayAmt = ""
  11349. order.Spec = ""
  11350. order.SpecUnt = ""
  11351. order.DrordBegnDate = s_tm
  11352. order.DrordStopDate = ""
  11353. order.DrordDrCodg = doctor_info.DoctorNumber
  11354. order.DrordDeptName = department.Name
  11355. order.DrordDeptCodg = department.Number
  11356. order.DrordDrName = doctor_info.UserName
  11357. order.DrordDrProfttl = "234"
  11358. order.CurrDrordFlag = "1"
  11359. orders = append(orders, &order)
  11360. }
  11361. }
  11362. }
  11363. //处方医嘱信息
  11364. }
  11365. fed.MatnStas = "0"
  11366. fed.MedfeeSumamt = "0"
  11367. fed.OwnpayAmt = "0"
  11368. fed.SelfpayAmt = "0"
  11369. fed.AcctPayamt = "0"
  11370. fed.MaAmt = "0"
  11371. fed.HifpPayamt = "0"
  11372. fed.SetlTotlnum = "1"
  11373. fed.Insutype = his.Insutype
  11374. fed.ReimFlag = "0"
  11375. fed.OutSetlFlag = "0"
  11376. var fopd []*models.FsiOperationDtosData
  11377. data := make(map[string]interface{})
  11378. data["fed"] = fed
  11379. data["fdd"] = fdds
  11380. data["fod"] = orders
  11381. data["pd"] = pd
  11382. data["pp"] = pp
  11383. data["fopd"] = fopd
  11384. data["trig_scen"] = trig_scen
  11385. fmt.Println(data)
  11386. fmt.Println(fed)
  11387. fmt.Println(fdds)
  11388. fmt.Println(orders)
  11389. fmt.Println(pd)
  11390. fmt.Println(pp)
  11391. fmt.Println(fopd)
  11392. client := &http.Client{}
  11393. bytesData, _ := json.Marshal(data)
  11394. var req *http.Request
  11395. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11396. if miConfig.MdtrtareaAdmvs == "320830" {
  11397. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  11398. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11399. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11400. } else {
  11401. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11402. }
  11403. resp, _ := client.Do(req)
  11404. defer resp.Body.Close()
  11405. body, ioErr := ioutil.ReadAll(resp.Body)
  11406. if ioErr != nil {
  11407. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11409. return res
  11410. }
  11411. var respJSON map[string]interface{}
  11412. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11413. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11415. return res
  11416. }
  11417. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11418. fmt.Println(respJSON)
  11419. result, _ := json.Marshal(respJSON)
  11420. fmt.Println(result)
  11421. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11422. utils.ErrorLog("解析失败:%v", err)
  11423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11424. return res
  11425. }
  11426. return res
  11427. } else {
  11428. //if miConfig.MdtrtareaAdmvs == "441202" {
  11429. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11430. saveLog(output, input, "3101", "事前")
  11431. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11432. utils.ErrorLog("解析失败:%v", err)
  11433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11434. return
  11435. }
  11436. return res
  11437. //}
  11438. }
  11439. }
  11440. 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) {
  11441. adminUser := c.GetAdminUserInfo()
  11442. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11443. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11444. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11445. //record_time := c.GetString("record_time")
  11446. //trig_scen := c.GetString("trig_scen")
  11447. timeLayout := "2006-01-02"
  11448. loc, _ := time.LoadLocation("Local")
  11449. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11450. if err != nil {
  11451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11452. return res
  11453. }
  11454. recordDateTime := theTime.Unix()
  11455. var patientPrescription models.HisPrescriptionInfo
  11456. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11457. if patientPrescription.ID == 0 {
  11458. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11459. }
  11460. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11461. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11462. //
  11463. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11464. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11465. var pp models.PublicParams
  11466. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11467. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11468. pp.FixmedinsName = miConfig.OrgName
  11469. pp.FixmedinsCode = miConfig.Code
  11470. pp.RequestUrl = miConfig.Url
  11471. pp.Cainfo = miConfig.Cainfo
  11472. pp.SecretKey = miConfig.SecretKey
  11473. pp.AccessKey = miConfig.AccessKey
  11474. pp.OpterName = roles.UserName
  11475. var config []*models.HisXtDiagnoseConfig
  11476. for _, item := range diagnosis_ids {
  11477. id, _ := strconv.ParseInt(item, 10, 64)
  11478. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11479. config = append(config, &diagnosisConfig)
  11480. }
  11481. var pd models.PatientDtos
  11482. pd.PatnID = his.PsnNo
  11483. pd.PatnName = his.Name
  11484. pd.Gend = his.Gend
  11485. pd.Brdy = his.Brdy
  11486. pd.Poolarea = his.InsuplcAdmdvs
  11487. pd.CurrMdtrtID = his.Number
  11488. var fed models.FsiEncounterDtos
  11489. fed.MdtrtID = his.Number
  11490. fed.MedinsID = miConfig.Code
  11491. fed.MedinsName = miConfig.OrgName
  11492. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11493. fed.MedMdtrtType = "1"
  11494. fed.MedinsType = "1"
  11495. fed.MedinsLv = "11"
  11496. tm := time.Unix(his.RecordDate, 0)
  11497. s_tm := tm.Format("2006-01-02 15:04:05")
  11498. fed.AdmDate = s_tm
  11499. fed.DscgDate = s_tm
  11500. fed.DscgMainDiseCodg = config[0].CountryCode
  11501. fed.DscgMainDiseName = config[0].CountryContentName
  11502. //诊断信息
  11503. var fdds []*models.FsiDiagnoseDtos
  11504. for index, item := range config {
  11505. if index == 0 {
  11506. var fdd models.FsiDiagnoseDtos
  11507. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11508. fdd.InoutDiseType = "1"
  11509. fdd.MaindiseFlag = "1"
  11510. fdd.DiseDate = s_tm
  11511. fdd.DiasSrtNo = "1"
  11512. fdd.DiseName = item.CountryContentName
  11513. fdd.DiseCodg = item.CountryCode
  11514. fdds = append(fdds, &fdd)
  11515. } else {
  11516. var fdd models.FsiDiagnoseDtos
  11517. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11518. fdd.InoutDiseType = "1"
  11519. fdd.MaindiseFlag = "1"
  11520. fdd.DiseDate = s_tm
  11521. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11522. fdd.DiseName = item.CountryContentName
  11523. fdd.DiseCodg = item.CountryCode
  11524. fdds = append(fdds, &fdd)
  11525. }
  11526. }
  11527. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11528. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11529. fed.AdmDeptName = department.Name
  11530. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11531. fed.DscgDeptName = department.Name
  11532. fed.MedMdtrtType = "1"
  11533. fed.MedType = "11"
  11534. //if his.Insutype == "390" {
  11535. // fed.MedType = "1402"
  11536. //} else {
  11537. // fed.MedType = "9933"
  11538. //}
  11539. var orders []*models.FsiOrderDtos
  11540. if trig_scen == "2" {
  11541. //处方医嘱信息
  11542. for _, item := range prescriptions {
  11543. for _, subItem := range item.HisDoctorAdviceInfo {
  11544. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11545. var order models.FsiOrderDtos
  11546. order.RxID = strconv.FormatInt(item.ID, 10)
  11547. order.Rxno = strconv.FormatInt(item.ID, 10)
  11548. order.LongDrordFlag = "0"
  11549. order.HilistType = "1"
  11550. order.ChrgType = "1"
  11551. order.DrordBhvr = "-"
  11552. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11553. order.HosplistName = subItem.BaseDrugLib.DrugName
  11554. order.HilistLv = "1"
  11555. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11556. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11557. order.HosplistName = subItem.BaseDrugLib.DrugName
  11558. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11559. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11560. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11561. order.OwnpayAmt = ""
  11562. order.SelfpayAmt = ""
  11563. order.Spec = ""
  11564. order.SpecUnt = ""
  11565. order.DrordBegnDate = s_tm
  11566. order.DrordStopDate = ""
  11567. order.DrordDrCodg = doctor_info.DoctorNumber
  11568. order.DrordDeptName = department.Name
  11569. order.DrordDeptCodg = department.Number
  11570. order.DrordDrName = doctor_info.UserName
  11571. order.DrordDrProfttl = "234"
  11572. order.CurrDrordFlag = "1"
  11573. orders = append(orders, &order)
  11574. }
  11575. }
  11576. for _, subItem := range item.HisPrescriptionProject {
  11577. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11578. var order models.FsiOrderDtos
  11579. order.RxID = strconv.FormatInt(item.ID, 10)
  11580. order.Rxno = strconv.FormatInt(item.ID, 10)
  11581. order.LongDrordFlag = "0"
  11582. order.HilistType = "1"
  11583. order.ChrgType = "1"
  11584. order.DrordBhvr = "-"
  11585. order.HilistCode = subItem.HisProject.MedicalCode
  11586. order.HosplistName = subItem.HisProject.ProjectName
  11587. order.HilistLv = "1"
  11588. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11589. order.HosplistCode = subItem.HisProject.MedicalCode
  11590. order.HosplistName = subItem.HisProject.ProjectName
  11591. order.Cnt = subItem.Count
  11592. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11593. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11594. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11595. order.OwnpayAmt = ""
  11596. order.SelfpayAmt = ""
  11597. order.Spec = ""
  11598. order.SpecUnt = ""
  11599. order.DrordBegnDate = s_tm
  11600. order.DrordStopDate = ""
  11601. order.DrordDrCodg = doctor_info.DoctorNumber
  11602. order.DrordDeptName = department.Name
  11603. order.DrordDeptCodg = department.Number
  11604. order.DrordDrName = doctor_info.UserName
  11605. order.DrordDrProfttl = "234"
  11606. order.CurrDrordFlag = "1"
  11607. orders = append(orders, &order)
  11608. }
  11609. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11610. var order models.FsiOrderDtos
  11611. order.RxID = strconv.FormatInt(item.ID, 10)
  11612. order.Rxno = strconv.FormatInt(item.ID, 10)
  11613. order.LongDrordFlag = "0"
  11614. order.HilistType = "1"
  11615. order.ChrgType = "1"
  11616. order.DrordBhvr = "-"
  11617. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11618. order.HosplistName = subItem.GoodInfo.GoodName
  11619. order.HilistLv = "1"
  11620. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11621. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11622. order.HosplistName = subItem.GoodInfo.GoodName
  11623. order.Cnt = subItem.Count
  11624. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11625. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11626. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11627. order.OwnpayAmt = ""
  11628. order.SelfpayAmt = ""
  11629. order.Spec = ""
  11630. order.SpecUnt = ""
  11631. order.DrordBegnDate = s_tm
  11632. order.DrordStopDate = ""
  11633. order.DrordDrCodg = doctor_info.DoctorNumber
  11634. order.DrordDeptName = department.Name
  11635. order.DrordDeptCodg = department.Number
  11636. order.DrordDrName = doctor_info.UserName
  11637. order.DrordDrProfttl = "234"
  11638. order.CurrDrordFlag = "1"
  11639. orders = append(orders, &order)
  11640. }
  11641. }
  11642. }
  11643. //处方医嘱信息
  11644. }
  11645. fed.MatnStas = "0"
  11646. fed.MedfeeSumamt = "0"
  11647. fed.OwnpayAmt = "0"
  11648. fed.SelfpayAmt = "0"
  11649. fed.AcctPayamt = "0"
  11650. fed.MaAmt = "0"
  11651. fed.HifpPayamt = "0"
  11652. fed.SetlTotlnum = "1"
  11653. fed.Insutype = his.Insutype
  11654. fed.ReimFlag = "0"
  11655. fed.OutSetlFlag = "0"
  11656. var fopd []*models.FsiOperationDtosData
  11657. data := make(map[string]interface{})
  11658. data["fed"] = fed
  11659. data["fdd"] = fdds
  11660. data["fod"] = orders
  11661. data["pd"] = pd
  11662. data["pp"] = pp
  11663. data["fopd"] = fopd
  11664. data["trig_scen"] = trig_scen
  11665. fmt.Println(data)
  11666. fmt.Println(fed)
  11667. fmt.Println(fdds)
  11668. fmt.Println(orders)
  11669. fmt.Println(pd)
  11670. fmt.Println(pp)
  11671. fmt.Println(fopd)
  11672. client := &http.Client{}
  11673. bytesData, _ := json.Marshal(data)
  11674. var req *http.Request
  11675. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11676. if miConfig.MdtrtareaAdmvs == "320830" {
  11677. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  11678. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11679. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11680. } else {
  11681. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11682. }
  11683. resp, _ := client.Do(req)
  11684. defer resp.Body.Close()
  11685. body, ioErr := ioutil.ReadAll(resp.Body)
  11686. if ioErr != nil {
  11687. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11689. return res
  11690. }
  11691. var respJSON map[string]interface{}
  11692. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11693. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11695. return res
  11696. }
  11697. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11698. fmt.Println(respJSON)
  11699. result, _ := json.Marshal(respJSON)
  11700. fmt.Println(result)
  11701. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11702. utils.ErrorLog("解析失败:%v", err)
  11703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11704. return res
  11705. }
  11706. return res
  11707. } else {
  11708. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11709. saveLog(output, input, "3101", "事前")
  11710. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11711. utils.ErrorLog("解析失败:%v", err)
  11712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11713. return
  11714. }
  11715. return res
  11716. }
  11717. return res
  11718. }
  11719. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  11720. ////patient_id, _ := c.GetInt64("patient_id")
  11721. //order_id, _ := c.GetInt64("order_id")
  11722. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11723. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11724. //trig_scen := c.GetString("trig_scen")
  11725. adminUser := c.GetAdminUserInfo()
  11726. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11727. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11728. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11729. record_time := c.GetString("record_time")
  11730. order, _ := service.GetHisOrderByID(order_id)
  11731. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11732. timeLayout := "2006-01-02"
  11733. loc, _ := time.LoadLocation("Local")
  11734. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11735. if err != nil {
  11736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11737. return
  11738. }
  11739. recordDateTime := theTime.Unix()
  11740. var patientPrescription models.HisPrescriptionInfo
  11741. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11742. if patientPrescription.ID == 0 {
  11743. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11744. }
  11745. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11746. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11747. //
  11748. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11749. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11750. var pp models.PublicParams
  11751. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11752. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11753. pp.FixmedinsName = miConfig.OrgName
  11754. pp.FixmedinsCode = miConfig.Code
  11755. pp.RequestUrl = miConfig.Url
  11756. pp.Cainfo = miConfig.Cainfo
  11757. pp.SecretKey = miConfig.SecretKey
  11758. pp.AccessKey = miConfig.AccessKey
  11759. pp.OpterName = roles.UserName
  11760. var config []*models.HisXtDiagnoseConfig
  11761. for _, item := range diagnosis_ids {
  11762. id, _ := strconv.ParseInt(item, 10, 64)
  11763. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11764. config = append(config, &diagnosisConfig)
  11765. }
  11766. var pd models.PatientDtos
  11767. pd.PatnID = his.PsnNo
  11768. pd.PatnName = his.Name
  11769. pd.Gend = his.Gend
  11770. pd.Brdy = psn_info.Brdy
  11771. pd.Poolarea = his.InsuplcAdmdvs
  11772. pd.CurrMdtrtID = his.Number
  11773. var fed models.FsiEncounterDtos
  11774. fed.MdtrtID = his.Number
  11775. fed.MedinsID = miConfig.Code
  11776. fed.MedinsName = miConfig.OrgName
  11777. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11778. fed.MedMdtrtType = "1"
  11779. fed.MedinsType = "1"
  11780. fed.MedinsLv = "11"
  11781. tm := time.Unix(his.RecordDate, 0)
  11782. s_tm := tm.Format("2006-01-02 15:04:05")
  11783. fed.AdmDate = s_tm
  11784. fed.DscgDate = s_tm
  11785. fed.DscgMainDiseCodg = config[0].CountryCode
  11786. fed.DscgMainDiseName = config[0].CountryContentName
  11787. //诊断信息
  11788. var fdds []*models.FsiDiagnoseDtos
  11789. for index, item := range config {
  11790. if index == 0 {
  11791. var fdd models.FsiDiagnoseDtos
  11792. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11793. fdd.InoutDiseType = "1"
  11794. fdd.MaindiseFlag = "1"
  11795. fdd.DiseDate = s_tm
  11796. fdd.DiasSrtNo = "1"
  11797. fdd.DiseName = item.CountryContentName
  11798. fdd.DiseCodg = item.CountryCode
  11799. fdds = append(fdds, &fdd)
  11800. } else {
  11801. var fdd models.FsiDiagnoseDtos
  11802. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11803. fdd.InoutDiseType = "1"
  11804. fdd.MaindiseFlag = "1"
  11805. fdd.DiseDate = s_tm
  11806. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11807. fdd.DiseName = item.CountryContentName
  11808. fdd.DiseCodg = item.CountryCode
  11809. fdds = append(fdds, &fdd)
  11810. }
  11811. }
  11812. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11813. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11814. fed.AdmDeptName = department.Name
  11815. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11816. fed.DscgDeptName = department.Name
  11817. fed.MedType = order.MedType
  11818. //处方医嘱信息
  11819. var orders []*models.FsiOrderDtos
  11820. //for _, item := range prescriptions {
  11821. // for _, subItem := range item.HisDoctorAdviceInfo {
  11822. // var order models.FsiOrderDtos
  11823. // order.RxID = strconv.FormatInt(item.ID, 10)
  11824. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11825. // order.LongDrordFlag = "0"
  11826. // order.HilistType = "1"
  11827. // order.ChrgType = "1"
  11828. // order.DrordBhvr = "-"
  11829. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11830. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11831. // order.HilistLv = "1"
  11832. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11833. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11834. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11835. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11836. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11837. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11838. // order.OwnpayAmt = ""
  11839. // order.SelfpayAmt = ""
  11840. // order.Spec = ""
  11841. // order.SpecUnt = ""
  11842. // order.DrordBegnDate = s_tm
  11843. // order.DrordStopDate = ""
  11844. // order.DrordDrCodg = "1"
  11845. // order.DrordDeptName = department.Name
  11846. // order.DrordDrCodg = "1"
  11847. // order.DrordDrName = doctor_info.UserName
  11848. // order.DrordDrProfttl = ""
  11849. // order.CurrDrordFlag = "1"
  11850. // orders = append(orders, &order)
  11851. // }
  11852. // for _, subItem := range item.HisPrescriptionProject {
  11853. // if subItem.Type == 2 {
  11854. // var order models.FsiOrderDtos
  11855. // order.RxID = strconv.FormatInt(item.ID, 10)
  11856. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11857. // order.LongDrordFlag = "0"
  11858. // order.HilistType = "1"
  11859. // order.ChrgType = "1"
  11860. // order.DrordBhvr = "-"
  11861. // order.HilistCode = subItem.HisProject.MedicalCode
  11862. // order.HosplistName = subItem.HisProject.ProjectName
  11863. // order.HilistLv = "1"
  11864. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11865. // order.HosplistCode = subItem.HisProject.MedicalCode
  11866. // order.HosplistName = subItem.HisProject.ProjectName
  11867. // order.Cnt = subItem.Count
  11868. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11869. //
  11870. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11871. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11872. // order.OwnpayAmt = ""
  11873. // order.SelfpayAmt = ""
  11874. // order.Spec = ""
  11875. // order.SpecUnt = ""
  11876. // order.DrordBegnDate = s_tm
  11877. // order.DrordStopDate = ""
  11878. // order.DrordDrCodg = "1"
  11879. // order.DrordDeptName = department.Name
  11880. // order.DrordDrCodg = "1"
  11881. // order.DrordDrName = doctor_info.UserName
  11882. // order.DrordDrProfttl = ""
  11883. // order.CurrDrordFlag = "1"
  11884. // orders = append(orders, &order)
  11885. //
  11886. // }
  11887. // if subItem.Type == 3 {
  11888. //
  11889. // var order models.FsiOrderDtos
  11890. // order.RxID = strconv.FormatInt(item.ID, 10)
  11891. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11892. // order.LongDrordFlag = "0"
  11893. // order.HilistType = "1"
  11894. // order.ChrgType = "1"
  11895. // order.DrordBhvr = "-"
  11896. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11897. // order.HosplistName = subItem.GoodInfo.GoodName
  11898. // order.HilistLv = "1"
  11899. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11900. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11901. // order.HosplistName = subItem.GoodInfo.GoodName
  11902. // order.Cnt = subItem.Count
  11903. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11904. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11905. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11906. // order.OwnpayAmt = ""
  11907. // order.SelfpayAmt = ""
  11908. // order.Spec = ""
  11909. // order.SpecUnt = ""
  11910. // order.DrordBegnDate = s_tm
  11911. // order.DrordStopDate = ""
  11912. // order.DrordDrCodg = "1"
  11913. // order.DrordDeptName = department.Name
  11914. // order.DrordDrCodg = "1"
  11915. // order.DrordDrName = doctor_info.UserName
  11916. // order.DrordDrProfttl = ""
  11917. // order.CurrDrordFlag = "1"
  11918. // orders = append(orders, &order)
  11919. //
  11920. // }
  11921. // }
  11922. //}
  11923. for _, item := range prescriptions {
  11924. for _, subItem := range item.HisDoctorAdviceInfo {
  11925. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11926. var order models.FsiOrderDtos
  11927. order.RxID = strconv.FormatInt(item.ID, 10)
  11928. order.Rxno = strconv.FormatInt(item.ID, 10)
  11929. order.LongDrordFlag = "0"
  11930. order.HilistType = "101"
  11931. order.ChrgType = "1"
  11932. order.DrordBhvr = "-"
  11933. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11934. order.HosplistName = subItem.BaseDrugLib.DrugName
  11935. order.HilistLv = "1"
  11936. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11937. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11938. order.HosplistName = subItem.BaseDrugLib.DrugName
  11939. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11940. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11941. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11942. order.OwnpayAmt = ""
  11943. order.SelfpayAmt = ""
  11944. order.Spec = ""
  11945. order.SpecUnt = ""
  11946. order.DrordBegnDate = s_tm
  11947. order.DrordStopDate = ""
  11948. order.DrordDrCodg = doctor_info.DoctorNumber
  11949. order.DrordDeptName = department.Name
  11950. order.DrordDeptCodg = department.Number
  11951. order.DrordDrName = doctor_info.UserName
  11952. order.DrordDrProfttl = "234"
  11953. order.CurrDrordFlag = "1"
  11954. orders = append(orders, &order)
  11955. }
  11956. }
  11957. for _, subItem := range item.HisPrescriptionProject {
  11958. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11959. var order models.FsiOrderDtos
  11960. order.RxID = strconv.FormatInt(item.ID, 10)
  11961. order.Rxno = strconv.FormatInt(item.ID, 10)
  11962. order.LongDrordFlag = "0"
  11963. order.HilistType = "201"
  11964. order.ChrgType = "1"
  11965. order.DrordBhvr = "-"
  11966. order.HilistCode = subItem.HisProject.MedicalCode
  11967. order.HosplistName = subItem.HisProject.ProjectName
  11968. order.HilistLv = "1"
  11969. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11970. order.HosplistCode = subItem.HisProject.MedicalCode
  11971. order.HosplistName = subItem.HisProject.ProjectName
  11972. order.Cnt = subItem.Count
  11973. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11974. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11975. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11976. order.OwnpayAmt = ""
  11977. order.SelfpayAmt = ""
  11978. order.Spec = ""
  11979. order.SpecUnt = ""
  11980. order.DrordBegnDate = s_tm
  11981. order.DrordStopDate = ""
  11982. order.DrordDrCodg = doctor_info.DoctorNumber
  11983. order.DrordDeptName = department.Name
  11984. order.DrordDeptCodg = department.Number
  11985. order.DrordDrName = doctor_info.UserName
  11986. order.DrordDrProfttl = "234"
  11987. order.CurrDrordFlag = "1"
  11988. orders = append(orders, &order)
  11989. }
  11990. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11991. var order models.FsiOrderDtos
  11992. order.RxID = strconv.FormatInt(item.ID, 10)
  11993. order.Rxno = strconv.FormatInt(item.ID, 10)
  11994. order.LongDrordFlag = "0"
  11995. order.HilistType = "301"
  11996. order.ChrgType = "1"
  11997. order.DrordBhvr = "0"
  11998. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11999. order.HosplistName = subItem.GoodInfo.GoodName
  12000. order.HilistLv = "1"
  12001. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12002. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12003. order.HosplistName = subItem.GoodInfo.GoodName
  12004. order.Cnt = subItem.Count
  12005. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12006. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12007. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12008. order.OwnpayAmt = ""
  12009. order.SelfpayAmt = ""
  12010. order.Spec = ""
  12011. order.SpecUnt = ""
  12012. order.DrordBegnDate = s_tm
  12013. order.DrordStopDate = ""
  12014. order.DrordDrCodg = doctor_info.DoctorNumber
  12015. order.DrordDeptName = department.Name
  12016. order.DrordDeptCodg = department.Number
  12017. order.DrordDrName = doctor_info.UserName
  12018. order.DrordDrProfttl = "234"
  12019. order.CurrDrordFlag = "1"
  12020. orders = append(orders, &order)
  12021. }
  12022. }
  12023. }
  12024. //处方医嘱信息
  12025. fed.MatnStas = "0"
  12026. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  12027. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  12028. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  12029. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  12030. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  12031. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  12032. fed.SetlTotlnum = "1"
  12033. fed.Insutype = his.Insutype
  12034. fed.ReimFlag = "0"
  12035. fed.OutSetlFlag = "0"
  12036. var fopd []*models.FsiOperationDtosData
  12037. data := make(map[string]interface{})
  12038. data["fed"] = fed
  12039. data["fdd"] = fdds
  12040. data["fod"] = orders
  12041. data["pd"] = pd
  12042. data["pp"] = pp
  12043. data["fopd"] = fopd
  12044. data["trig_scen"] = trig_scen
  12045. client := &http.Client{}
  12046. bytesData, _ := json.Marshal(data)
  12047. var req *http.Request
  12048. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12049. if miConfig.MdtrtareaAdmvs == "320830" {
  12050. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3102", bytes.NewReader(bytesData))
  12051. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12052. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12053. } else {
  12054. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12055. }
  12056. resp, _ := client.Do(req)
  12057. defer resp.Body.Close()
  12058. body, ioErr := ioutil.ReadAll(resp.Body)
  12059. if ioErr != nil {
  12060. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12062. return res
  12063. }
  12064. var respJSON map[string]interface{}
  12065. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12066. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12068. return res
  12069. }
  12070. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12071. result, _ := json.Marshal(respJSON)
  12072. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12073. utils.ErrorLog("解析失败:%v", err)
  12074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12075. return res
  12076. }
  12077. return res
  12078. } else {
  12079. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12080. saveLog(output, input, "3102", "事中")
  12081. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12082. utils.ErrorLog("解析失败:%v", err)
  12083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12084. return
  12085. }
  12086. return res
  12087. }
  12088. return res
  12089. }
  12090. func 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) {
  12091. var res Resultgd3101
  12092. adminUser := c.GetAdminUserInfo()
  12093. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12094. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12095. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12096. //record_time := c.GetString("record_time")
  12097. //trig_scen := c.GetString("trig_scen")
  12098. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  12099. //psn_info, _ := service.GetPatientId(patient_id)
  12100. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12101. timeLayout := "2006-01-02"
  12102. loc, _ := time.LoadLocation("Local")
  12103. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12104. if err != nil {
  12105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12106. return res
  12107. }
  12108. recordDateTime := theTime.Unix()
  12109. var patientPrescription models.HisPrescriptionInfo
  12110. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12111. //if patientPrescription.ID == 0 {
  12112. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12113. //}
  12114. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12115. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12116. //
  12117. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  12118. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12119. var str string
  12120. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12121. str = timestampToBirthdayString(patient.Birthday)
  12122. } else {
  12123. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12124. }
  12125. var pp models.PublicParams
  12126. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12127. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12128. pp.FixmedinsName = miConfig.OrgName
  12129. pp.FixmedinsCode = miConfig.Code
  12130. pp.RequestUrl = miConfig.Url
  12131. pp.Cainfo = miConfig.Cainfo
  12132. pp.SecretKey = miConfig.SecretKey
  12133. pp.AccessKey = miConfig.AccessKey
  12134. pp.OpterName = roles.UserName
  12135. var config []*models.HisXtDiagnoseConfig
  12136. for _, item := range diagnosis_ids {
  12137. id, _ := strconv.ParseInt(item, 10, 64)
  12138. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12139. config = append(config, &diagnosisConfig)
  12140. }
  12141. if len(config) == 0 {
  12142. var config1 models.HisXtDiagnoseConfig
  12143. config1.CountryCode = "N18.500"
  12144. config1.CountryContentName = "慢性肾脏病5期"
  12145. config = append(config, &config1)
  12146. }
  12147. var pd models.PatientDtos
  12148. pd.PatnID = his.PsnNo
  12149. pd.PatnName = his.Name
  12150. pd.Gend = his.Gend
  12151. pd.Brdy = str
  12152. pd.Poolarea = miConfig.MdtrtareaAdmvs
  12153. pd.CurrMdtrtID = his.Number
  12154. var fed models.FsiEncounterDtos
  12155. fed.MdtrtID = his.Number
  12156. fed.MedinsID = miConfig.Code
  12157. fed.MedinsName = miConfig.OrgName
  12158. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12159. fed.MedMdtrtType = "1"
  12160. fed.MedinsType = "1"
  12161. fed.MedinsLv = "11"
  12162. tm := time.Unix(his.RecordDate, 0)
  12163. s_tm := tm.Format("2006-01-02 15:04:05")
  12164. fed.AdmDate = s_tm
  12165. fed.DscgDate = s_tm
  12166. fed.DscgMainDiseCodg = config[0].CountryCode
  12167. fed.DscgMainDiseName = config[0].CountryContentName
  12168. //诊断信息
  12169. var fdds []*models.FsiDiagnoseDtos
  12170. for index, item := range config {
  12171. if index == 0 {
  12172. var fdd models.FsiDiagnoseDtos
  12173. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12174. fdd.InoutDiseType = "1"
  12175. fdd.MaindiseFlag = "1"
  12176. fdd.DiseDate = s_tm
  12177. fdd.DiasSrtNo = "1"
  12178. fdd.DiseName = item.CountryContentName
  12179. fdd.DiseCodg = item.CountryCode
  12180. fdds = append(fdds, &fdd)
  12181. } else {
  12182. var fdd models.FsiDiagnoseDtos
  12183. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12184. fdd.InoutDiseType = "1"
  12185. fdd.MaindiseFlag = "1"
  12186. fdd.DiseDate = s_tm
  12187. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12188. fdd.DiseName = item.CountryContentName
  12189. fdd.DiseCodg = item.CountryCode
  12190. fdds = append(fdds, &fdd)
  12191. }
  12192. }
  12193. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12194. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  12195. fed.AdmDeptName = de.Name
  12196. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  12197. fed.DscgDeptName = de.Name
  12198. fed.MedMdtrtType = "1"
  12199. fed.MedType = "11"
  12200. //if his.Insutype == "390" {
  12201. // fed.MedType = "1402"
  12202. //} else {
  12203. // fed.MedType = "9933"
  12204. //}
  12205. var orders []*models.FsiOrderDtos
  12206. if trig_scen == "2" {
  12207. //处方医嘱信息
  12208. for _, item := range prescriptions {
  12209. for _, subItem := range item.HisDoctorAdviceInfo {
  12210. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12211. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12212. var order models.FsiOrderDtos
  12213. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12214. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12215. order.LongDrordFlag = "0"
  12216. order.HilistType = "101"
  12217. order.ChrgType = "1"
  12218. order.DrordBhvr = "0"
  12219. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12220. order.HosplistName = subItem.BaseDrugLib.DrugName
  12221. order.HilistLv = "1"
  12222. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12223. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12224. order.HosplistName = subItem.BaseDrugLib.DrugName
  12225. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12226. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12227. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12228. order.OwnpayAmt = ""
  12229. order.SelfpayAmt = ""
  12230. order.Spec = spec
  12231. order.SpecUnt = subItem.PrescribingNumberUnit
  12232. order.DrordBegnDate = s_tm
  12233. order.DrordStopDate = ""
  12234. order.DrordDrCodg = doctor_info.DoctorNumber
  12235. order.DrordDeptName = department.Name
  12236. order.DrordDeptCodg = department.Number
  12237. order.DrordDrName = doctor_info.UserName
  12238. order.DrordDrProfttl = "234"
  12239. order.CurrDrordFlag = "1"
  12240. orders = append(orders, &order)
  12241. }
  12242. }
  12243. for _, subItem := range item.HisPrescriptionProject {
  12244. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12245. var order models.FsiOrderDtos
  12246. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12247. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12248. order.LongDrordFlag = "0"
  12249. order.HilistType = "201"
  12250. order.ChrgType = "1"
  12251. order.DrordBhvr = "0"
  12252. order.HilistCode = subItem.HisProject.MedicalCode
  12253. order.HosplistName = subItem.HisProject.ProjectName
  12254. order.HilistLv = "1"
  12255. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12256. order.HosplistCode = subItem.HisProject.MedicalCode
  12257. order.HosplistName = subItem.HisProject.ProjectName
  12258. order.Cnt = subItem.Count
  12259. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12260. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12261. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12262. order.OwnpayAmt = ""
  12263. order.SelfpayAmt = ""
  12264. if subItem.Unit == "" {
  12265. order.Spec = "次"
  12266. order.SpecUnt = "次"
  12267. } else {
  12268. order.Spec = subItem.Unit
  12269. order.SpecUnt = subItem.Unit
  12270. }
  12271. order.DrordBegnDate = s_tm
  12272. order.DrordStopDate = ""
  12273. order.DrordDrCodg = doctor_info.DoctorNumber
  12274. order.DrordDeptName = department.Name
  12275. order.DrordDeptCodg = department.Number
  12276. order.DrordDrName = doctor_info.UserName
  12277. order.DrordDrProfttl = "234"
  12278. order.CurrDrordFlag = "1"
  12279. orders = append(orders, &order)
  12280. }
  12281. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12282. var order models.FsiOrderDtos
  12283. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12284. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12285. order.LongDrordFlag = "0"
  12286. order.HilistType = "301"
  12287. order.ChrgType = "1"
  12288. order.DrordBhvr = "0"
  12289. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12290. order.HosplistName = subItem.GoodInfo.GoodName
  12291. order.HilistLv = "1"
  12292. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12293. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12294. order.HosplistName = subItem.GoodInfo.GoodName
  12295. order.Cnt = subItem.Count
  12296. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12297. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12298. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12299. order.OwnpayAmt = ""
  12300. order.SelfpayAmt = ""
  12301. order.Spec = subItem.GoodInfo.SpecificationName
  12302. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12303. order.DrordBegnDate = s_tm
  12304. order.DrordStopDate = ""
  12305. order.DrordDrCodg = doctor_info.DoctorNumber
  12306. order.DrordDeptName = department.Name
  12307. order.DrordDeptCodg = department.Number
  12308. order.DrordDrName = doctor_info.UserName
  12309. order.DrordDrProfttl = "234"
  12310. order.CurrDrordFlag = "1"
  12311. orders = append(orders, &order)
  12312. }
  12313. }
  12314. }
  12315. //处方医嘱信息
  12316. }
  12317. fed.MatnStas = "0"
  12318. fed.MedfeeSumamt = "0"
  12319. fed.OwnpayAmt = "0"
  12320. fed.SelfpayAmt = "0"
  12321. fed.AcctPayamt = "0"
  12322. fed.MaAmt = "0"
  12323. fed.HifpPayamt = "0"
  12324. fed.SetlTotlnum = "1"
  12325. fed.Insutype = his.Insutype
  12326. fed.ReimFlag = "0"
  12327. fed.OutSetlFlag = "0"
  12328. var fopd []*models.FsiOperationDtosData
  12329. data := make(map[string]interface{})
  12330. data["fed"] = fed
  12331. data["fdd"] = fdds
  12332. data["fod"] = orders
  12333. data["pd"] = pd
  12334. data["pp"] = pp
  12335. data["fopd"] = fopd
  12336. data["trig_scen"] = trig_scen
  12337. fmt.Println(data)
  12338. fmt.Println(fed)
  12339. fmt.Println(fdds)
  12340. fmt.Println(orders)
  12341. fmt.Println(pd)
  12342. fmt.Println(pp)
  12343. fmt.Println(fopd)
  12344. client := &http.Client{}
  12345. bytesData, _ := json.Marshal(data)
  12346. var req *http.Request
  12347. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12348. if miConfig.MdtrtareaAdmvs == "320830" {
  12349. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  12350. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12351. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12352. } else {
  12353. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12354. }
  12355. resp, _ := client.Do(req)
  12356. defer resp.Body.Close()
  12357. body, ioErr := ioutil.ReadAll(resp.Body)
  12358. if ioErr != nil {
  12359. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12361. return res
  12362. }
  12363. var respJSON map[string]interface{}
  12364. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12367. return res
  12368. }
  12369. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12370. fmt.Println(respJSON)
  12371. result, _ := json.Marshal(respJSON)
  12372. fmt.Println(result)
  12373. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12374. utils.ErrorLog("解析失败:%v", err)
  12375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12376. return res
  12377. }
  12378. return res
  12379. } else {
  12380. //if miConfig.MdtrtareaAdmvs == "441202" {
  12381. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12382. saveLog(output, input, "3101", "事前")
  12383. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12384. utils.ErrorLog("解析失败:%v", err)
  12385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12386. return
  12387. }
  12388. return res
  12389. //}
  12390. }
  12391. }
  12392. 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) {
  12393. adminUser := c.GetAdminUserInfo()
  12394. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12395. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12396. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12397. //record_time := c.GetString("record_time")
  12398. //trig_scen := c.GetString("trig_scen")
  12399. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  12400. timeLayout := "2006-01-02"
  12401. loc, _ := time.LoadLocation("Local")
  12402. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12403. if err != nil {
  12404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12405. return res
  12406. }
  12407. recordDateTime := theTime.Unix()
  12408. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12409. var patientPrescription models.HisPrescriptionInfo
  12410. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12411. if patientPrescription.ID == 0 {
  12412. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12413. }
  12414. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12415. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12416. //
  12417. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  12418. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12419. var pp models.PublicParams
  12420. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12421. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12422. pp.FixmedinsName = miConfig.OrgName
  12423. pp.FixmedinsCode = miConfig.Code
  12424. pp.RequestUrl = miConfig.Url
  12425. pp.Cainfo = miConfig.Cainfo
  12426. pp.SecretKey = miConfig.SecretKey
  12427. pp.AccessKey = miConfig.AccessKey
  12428. pp.OpterName = roles.UserName
  12429. var config []*models.HisXtDiagnoseConfig
  12430. for _, item := range diagnosis_ids {
  12431. id, _ := strconv.ParseInt(item, 10, 64)
  12432. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12433. config = append(config, &diagnosisConfig)
  12434. }
  12435. //str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  12436. var str string
  12437. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12438. str = timestampToBirthdayString(patient.Birthday)
  12439. } else {
  12440. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12441. }
  12442. var pd models.PatientDtos
  12443. pd.PatnID = his.PsnNo
  12444. pd.PatnName = his.Name
  12445. pd.Gend = his.Gend
  12446. pd.Brdy = str
  12447. pd.Poolarea = his.InsuplcAdmdvs
  12448. pd.CurrMdtrtID = his.Number
  12449. var fed models.FsiEncounterDtos
  12450. fed.MdtrtID = his.Number
  12451. fed.MedinsID = miConfig.Code
  12452. fed.MedinsName = miConfig.OrgName
  12453. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12454. fed.MedMdtrtType = "1"
  12455. fed.MedinsType = "1"
  12456. fed.MedinsLv = "11"
  12457. tm := time.Unix(his.RecordDate, 0)
  12458. s_tm := tm.Format("2006-01-02 15:04:05")
  12459. fed.AdmDate = s_tm
  12460. fed.DscgDate = s_tm
  12461. fed.DscgMainDiseCodg = config[0].CountryCode
  12462. fed.DscgMainDiseName = config[0].CountryContentName
  12463. //诊断信息
  12464. var fdds []*models.FsiDiagnoseDtos
  12465. for index, item := range config {
  12466. if index == 0 {
  12467. var fdd models.FsiDiagnoseDtos
  12468. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12469. fdd.InoutDiseType = "1"
  12470. fdd.MaindiseFlag = "1"
  12471. fdd.DiseDate = s_tm
  12472. fdd.DiasSrtNo = "1"
  12473. fdd.DiseName = item.CountryContentName
  12474. fdd.DiseCodg = item.CountryCode
  12475. fdds = append(fdds, &fdd)
  12476. } else {
  12477. var fdd models.FsiDiagnoseDtos
  12478. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12479. fdd.InoutDiseType = "1"
  12480. fdd.MaindiseFlag = "1"
  12481. fdd.DiseDate = s_tm
  12482. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12483. fdd.DiseName = item.CountryContentName
  12484. fdd.DiseCodg = item.CountryCode
  12485. fdds = append(fdds, &fdd)
  12486. }
  12487. }
  12488. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12489. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  12490. fed.AdmDeptName = department.Name
  12491. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  12492. fed.DscgDeptName = department.Name
  12493. fed.MedMdtrtType = "1"
  12494. fed.MedType = "11"
  12495. //if his.Insutype == "390" {
  12496. // fed.MedType = "1402"
  12497. //} else {
  12498. // fed.MedType = "9933"
  12499. //}
  12500. var orders []*models.FsiOrderDtos
  12501. if trig_scen == "2" {
  12502. //处方医嘱信息
  12503. for _, item := range prescriptions {
  12504. for _, subItem := range item.HisDoctorAdviceInfo {
  12505. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12506. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "/" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit
  12507. var order models.FsiOrderDtos
  12508. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12509. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12510. order.LongDrordFlag = "0"
  12511. order.HilistType = "101"
  12512. order.ChrgType = "1"
  12513. order.DrordBhvr = "0"
  12514. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12515. order.HosplistName = subItem.BaseDrugLib.DrugName
  12516. order.HilistLv = "1"
  12517. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12518. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12519. order.HosplistName = subItem.BaseDrugLib.DrugName
  12520. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12521. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12522. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12523. order.OwnpayAmt = ""
  12524. order.SelfpayAmt = ""
  12525. order.Spec = spec
  12526. order.SpecUnt = subItem.PrescribingNumberUnit
  12527. order.DrordBegnDate = s_tm
  12528. order.DrordStopDate = ""
  12529. order.DrordDrCodg = doctor_info.DoctorNumber
  12530. order.DrordDeptName = department.Name
  12531. order.DrordDeptCodg = department.Number
  12532. order.DrordDrName = doctor_info.UserName
  12533. order.DrordDrProfttl = "234"
  12534. order.CurrDrordFlag = "1"
  12535. orders = append(orders, &order)
  12536. }
  12537. }
  12538. for _, subItem := range item.HisPrescriptionProject {
  12539. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12540. var order models.FsiOrderDtos
  12541. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12542. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12543. order.LongDrordFlag = "0"
  12544. order.HilistType = "201"
  12545. order.ChrgType = "1"
  12546. order.DrordBhvr = "0"
  12547. order.HilistCode = subItem.HisProject.MedicalCode
  12548. order.HosplistName = subItem.HisProject.ProjectName
  12549. order.HilistLv = "1"
  12550. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12551. order.HosplistCode = subItem.HisProject.MedicalCode
  12552. order.HosplistName = subItem.HisProject.ProjectName
  12553. order.Cnt = subItem.Count
  12554. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12555. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12556. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12557. order.OwnpayAmt = ""
  12558. order.SelfpayAmt = ""
  12559. if subItem.Unit == "" {
  12560. order.Spec = "次"
  12561. order.SpecUnt = "次"
  12562. } else {
  12563. order.Spec = subItem.Unit
  12564. order.SpecUnt = subItem.Unit
  12565. }
  12566. order.DrordBegnDate = s_tm
  12567. order.DrordStopDate = ""
  12568. order.DrordDrCodg = doctor_info.DoctorNumber
  12569. order.DrordDeptName = department.Name
  12570. order.DrordDeptCodg = department.Number
  12571. order.DrordDrName = doctor_info.UserName
  12572. order.DrordDrProfttl = "234"
  12573. order.CurrDrordFlag = "1"
  12574. orders = append(orders, &order)
  12575. }
  12576. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12577. var order models.FsiOrderDtos
  12578. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12579. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12580. order.LongDrordFlag = "0"
  12581. order.HilistType = "301"
  12582. order.ChrgType = "1"
  12583. order.DrordBhvr = "0"
  12584. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12585. order.HosplistName = subItem.GoodInfo.GoodName
  12586. order.HilistLv = "1"
  12587. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12588. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12589. order.HosplistName = subItem.GoodInfo.GoodName
  12590. order.Cnt = subItem.Count
  12591. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12592. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12593. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12594. order.OwnpayAmt = ""
  12595. order.SelfpayAmt = ""
  12596. order.Spec = subItem.GoodInfo.SpecificationName
  12597. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12598. order.DrordBegnDate = s_tm
  12599. order.DrordStopDate = ""
  12600. order.DrordDrCodg = doctor_info.DoctorNumber
  12601. order.DrordDeptName = department.Name
  12602. order.DrordDeptCodg = department.Number
  12603. order.DrordDrName = doctor_info.UserName
  12604. order.DrordDrProfttl = "234"
  12605. order.CurrDrordFlag = "1"
  12606. orders = append(orders, &order)
  12607. }
  12608. }
  12609. }
  12610. //处方医嘱信息
  12611. }
  12612. fed.MatnStas = "0"
  12613. fed.MedfeeSumamt = "0"
  12614. fed.OwnpayAmt = "0"
  12615. fed.SelfpayAmt = "0"
  12616. fed.AcctPayamt = "0"
  12617. fed.MaAmt = "0"
  12618. fed.HifpPayamt = "0"
  12619. fed.SetlTotlnum = "1"
  12620. fed.Insutype = his.Insutype
  12621. fed.ReimFlag = "0"
  12622. fed.OutSetlFlag = "0"
  12623. var fopd []*models.FsiOperationDtosData
  12624. data := make(map[string]interface{})
  12625. data["fed"] = fed
  12626. data["fdd"] = fdds
  12627. data["fod"] = orders
  12628. data["pd"] = pd
  12629. data["pp"] = pp
  12630. data["fopd"] = fopd
  12631. data["trig_scen"] = trig_scen
  12632. fmt.Println(data)
  12633. fmt.Println(fed)
  12634. fmt.Println(fdds)
  12635. fmt.Println(orders)
  12636. fmt.Println(pd)
  12637. fmt.Println(pp)
  12638. fmt.Println(fopd)
  12639. client := &http.Client{}
  12640. bytesData, _ := json.Marshal(data)
  12641. var req *http.Request
  12642. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12643. if miConfig.MdtrtareaAdmvs == "320830" {
  12644. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  12645. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12646. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12647. } else {
  12648. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12649. }
  12650. resp, _ := client.Do(req)
  12651. defer resp.Body.Close()
  12652. body, ioErr := ioutil.ReadAll(resp.Body)
  12653. if ioErr != nil {
  12654. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12656. return res
  12657. }
  12658. var respJSON map[string]interface{}
  12659. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12660. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12662. return res
  12663. }
  12664. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12665. fmt.Println(respJSON)
  12666. result, _ := json.Marshal(respJSON)
  12667. fmt.Println(result)
  12668. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12669. utils.ErrorLog("解析失败:%v", err)
  12670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12671. return res
  12672. }
  12673. return res
  12674. } else {
  12675. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12676. saveLog(output, input, "3101", "事前")
  12677. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12678. utils.ErrorLog("解析失败:%v", err)
  12679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12680. return
  12681. }
  12682. return res
  12683. }
  12684. return res
  12685. }
  12686. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  12687. adminUser := c.GetAdminUserInfo()
  12688. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12689. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12690. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12691. record_time := c.GetString("record_time")
  12692. order, _ := service.GetHisOrderByID(order_id)
  12693. timeLayout := "2006-01-02"
  12694. loc, _ := time.LoadLocation("Local")
  12695. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12696. if err != nil {
  12697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12698. return
  12699. }
  12700. recordDateTime := theTime.Unix()
  12701. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12702. var patientPrescription models.HisPrescriptionInfo
  12703. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12704. if patientPrescription.ID == 0 {
  12705. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12706. }
  12707. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12708. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12709. //
  12710. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12711. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12712. var pp models.PublicParams
  12713. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12714. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12715. pp.FixmedinsName = miConfig.OrgName
  12716. pp.FixmedinsCode = miConfig.Code
  12717. pp.RequestUrl = miConfig.Url
  12718. pp.Cainfo = miConfig.Cainfo
  12719. pp.SecretKey = miConfig.SecretKey
  12720. pp.AccessKey = miConfig.AccessKey
  12721. pp.OpterName = roles.UserName
  12722. var config []*models.HisXtDiagnoseConfig
  12723. for _, item := range diagnosis_ids {
  12724. id, _ := strconv.ParseInt(item, 10, 64)
  12725. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12726. config = append(config, &diagnosisConfig)
  12727. }
  12728. //str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  12729. var str string
  12730. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12731. str = timestampToBirthdayString(patient.Birthday)
  12732. } else {
  12733. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12734. }
  12735. var pd models.PatientDtos
  12736. pd.PatnID = his.PsnNo
  12737. pd.PatnName = his.Name
  12738. pd.Gend = his.Gend
  12739. pd.Brdy = str
  12740. pd.Poolarea = his.InsuplcAdmdvs
  12741. pd.CurrMdtrtID = his.Number
  12742. var fed models.FsiEncounterDtos
  12743. fed.MdtrtID = his.Number
  12744. fed.MedinsID = miConfig.Code
  12745. fed.MedinsName = miConfig.OrgName
  12746. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12747. fed.MedMdtrtType = "1"
  12748. fed.MedinsType = "1"
  12749. fed.MedinsLv = "11"
  12750. tm := time.Unix(his.RecordDate, 0)
  12751. s_tm := tm.Format("2006-01-02 15:04:05")
  12752. fed.AdmDate = s_tm
  12753. fed.DscgDate = s_tm
  12754. fed.DscgMainDiseCodg = config[0].CountryCode
  12755. fed.DscgMainDiseName = config[0].CountryContentName
  12756. //诊断信息
  12757. var fdds []*models.FsiDiagnoseDtos
  12758. for index, item := range config {
  12759. if index == 0 {
  12760. var fdd models.FsiDiagnoseDtos
  12761. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12762. fdd.InoutDiseType = "1"
  12763. fdd.MaindiseFlag = "1"
  12764. fdd.DiseDate = s_tm
  12765. fdd.DiasSrtNo = "1"
  12766. fdd.DiseName = item.CountryContentName
  12767. fdd.DiseCodg = item.CountryCode
  12768. fdds = append(fdds, &fdd)
  12769. } else {
  12770. var fdd models.FsiDiagnoseDtos
  12771. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12772. fdd.InoutDiseType = "1"
  12773. fdd.MaindiseFlag = "1"
  12774. fdd.DiseDate = s_tm
  12775. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12776. fdd.DiseName = item.CountryContentName
  12777. fdd.DiseCodg = item.CountryCode
  12778. fdds = append(fdds, &fdd)
  12779. }
  12780. }
  12781. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12782. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  12783. fed.AdmDeptName = department.Name
  12784. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  12785. fed.DscgDeptName = department.Name
  12786. fed.MedType = order.MedType
  12787. //处方医嘱信息
  12788. var orders []*models.FsiOrderDtos
  12789. //for _, item := range prescriptions {
  12790. // for _, subItem := range item.HisDoctorAdviceInfo {
  12791. // var order models.FsiOrderDtos
  12792. // order.RxID = strconv.FormatInt(item.ID, 10)
  12793. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12794. // order.LongDrordFlag = "0"
  12795. // order.HilistType = "1"
  12796. // order.ChrgType = "1"
  12797. // order.DrordBhvr = "-"
  12798. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12799. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12800. // order.HilistLv = "1"
  12801. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12802. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12803. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12804. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  12805. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12806. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  12807. // order.OwnpayAmt = ""
  12808. // order.SelfpayAmt = ""
  12809. // order.Spec = ""
  12810. // order.SpecUnt = ""
  12811. // order.DrordBegnDate = s_tm
  12812. // order.DrordStopDate = ""
  12813. // order.DrordDrCodg = "1"
  12814. // order.DrordDeptName = department.Name
  12815. // order.DrordDrCodg = "1"
  12816. // order.DrordDrName = doctor_info.UserName
  12817. // order.DrordDrProfttl = ""
  12818. // order.CurrDrordFlag = "1"
  12819. // orders = append(orders, &order)
  12820. // }
  12821. // for _, subItem := range item.HisPrescriptionProject {
  12822. // if subItem.Type == 2 {
  12823. // var order models.FsiOrderDtos
  12824. // order.RxID = strconv.FormatInt(item.ID, 10)
  12825. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12826. // order.LongDrordFlag = "0"
  12827. // order.HilistType = "1"
  12828. // order.ChrgType = "1"
  12829. // order.DrordBhvr = "-"
  12830. // order.HilistCode = subItem.HisProject.MedicalCode
  12831. // order.HosplistName = subItem.HisProject.ProjectName
  12832. // order.HilistLv = "1"
  12833. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12834. // order.HosplistCode = subItem.HisProject.MedicalCode
  12835. // order.HosplistName = subItem.HisProject.ProjectName
  12836. // order.Cnt = subItem.Count
  12837. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12838. //
  12839. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12840. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12841. // order.OwnpayAmt = ""
  12842. // order.SelfpayAmt = ""
  12843. // order.Spec = ""
  12844. // order.SpecUnt = ""
  12845. // order.DrordBegnDate = s_tm
  12846. // order.DrordStopDate = ""
  12847. // order.DrordDrCodg = "1"
  12848. // order.DrordDeptName = department.Name
  12849. // order.DrordDrCodg = "1"
  12850. // order.DrordDrName = doctor_info.UserName
  12851. // order.DrordDrProfttl = ""
  12852. // order.CurrDrordFlag = "1"
  12853. // orders = append(orders, &order)
  12854. //
  12855. // }
  12856. // if subItem.Type == 3 {
  12857. //
  12858. // var order models.FsiOrderDtos
  12859. // order.RxID = strconv.FormatInt(item.ID, 10)
  12860. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12861. // order.LongDrordFlag = "0"
  12862. // order.HilistType = "1"
  12863. // order.ChrgType = "1"
  12864. // order.DrordBhvr = "-"
  12865. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12866. // order.HosplistName = subItem.GoodInfo.GoodName
  12867. // order.HilistLv = "1"
  12868. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12869. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12870. // order.HosplistName = subItem.GoodInfo.GoodName
  12871. // order.Cnt = subItem.Count
  12872. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12873. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12874. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12875. // order.OwnpayAmt = ""
  12876. // order.SelfpayAmt = ""
  12877. // order.Spec = ""
  12878. // order.SpecUnt = ""
  12879. // order.DrordBegnDate = s_tm
  12880. // order.DrordStopDate = ""
  12881. // order.DrordDrCodg = "1"
  12882. // order.DrordDeptName = department.Name
  12883. // order.DrordDrCodg = "1"
  12884. // order.DrordDrName = doctor_info.UserName
  12885. // order.DrordDrProfttl = ""
  12886. // order.CurrDrordFlag = "1"
  12887. // orders = append(orders, &order)
  12888. //
  12889. // }
  12890. // }
  12891. //}
  12892. for _, item := range prescriptions {
  12893. for _, subItem := range item.HisDoctorAdviceInfo {
  12894. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12895. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12896. var order models.FsiOrderDtos
  12897. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12898. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12899. order.LongDrordFlag = "0"
  12900. order.HilistType = "101"
  12901. order.ChrgType = "01"
  12902. order.DrordBhvr = "0"
  12903. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12904. order.HosplistName = subItem.BaseDrugLib.DrugName
  12905. order.HilistLv = "1"
  12906. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12907. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12908. order.HosplistName = subItem.BaseDrugLib.DrugName
  12909. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12910. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12911. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12912. order.OwnpayAmt = ""
  12913. order.SelfpayAmt = ""
  12914. order.Spec = spec
  12915. order.SpecUnt = subItem.PrescribingNumberUnit
  12916. order.DrordBegnDate = s_tm
  12917. order.DrordStopDate = ""
  12918. order.DrordDrCodg = doctor_info.DoctorNumber
  12919. order.DrordDeptName = department.Name
  12920. order.DrordDeptCodg = department.Number
  12921. order.DrordDrName = doctor_info.UserName
  12922. order.DrordDrProfttl = "234"
  12923. order.CurrDrordFlag = "1"
  12924. orders = append(orders, &order)
  12925. }
  12926. }
  12927. for _, subItem := range item.HisPrescriptionProject {
  12928. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12929. var order models.FsiOrderDtos
  12930. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12931. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12932. order.LongDrordFlag = "0"
  12933. order.HilistType = "201"
  12934. order.ChrgType = "05"
  12935. order.DrordBhvr = "0"
  12936. order.HilistCode = subItem.HisProject.MedicalCode
  12937. order.HosplistName = subItem.HisProject.ProjectName
  12938. order.HilistLv = "1"
  12939. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12940. order.HosplistCode = subItem.HisProject.MedicalCode
  12941. order.HosplistName = subItem.HisProject.ProjectName
  12942. order.Cnt = subItem.Count
  12943. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12944. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12945. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12946. order.OwnpayAmt = ""
  12947. order.SelfpayAmt = ""
  12948. if subItem.Unit == "" {
  12949. order.Spec = "次"
  12950. order.SpecUnt = "次"
  12951. } else {
  12952. order.Spec = subItem.Unit
  12953. order.SpecUnt = subItem.Unit
  12954. }
  12955. order.DrordBegnDate = s_tm
  12956. order.DrordStopDate = ""
  12957. order.DrordDrCodg = doctor_info.DoctorNumber
  12958. order.DrordDeptName = department.Name
  12959. order.DrordDeptCodg = department.Number
  12960. order.DrordDrName = doctor_info.UserName
  12961. order.DrordDrProfttl = "234"
  12962. order.CurrDrordFlag = "1"
  12963. orders = append(orders, &order)
  12964. }
  12965. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12966. var order models.FsiOrderDtos
  12967. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12968. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12969. order.LongDrordFlag = "0"
  12970. order.HilistType = "301"
  12971. order.ChrgType = "08"
  12972. order.DrordBhvr = "0"
  12973. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12974. order.HosplistName = subItem.GoodInfo.GoodName
  12975. order.HilistLv = "1"
  12976. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12977. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12978. order.HosplistName = subItem.GoodInfo.GoodName
  12979. order.Cnt = subItem.Count
  12980. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12981. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12982. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12983. order.OwnpayAmt = ""
  12984. order.SelfpayAmt = ""
  12985. order.Spec = subItem.GoodInfo.SpecificationName
  12986. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12987. order.DrordBegnDate = s_tm
  12988. order.DrordStopDate = ""
  12989. order.DrordDrCodg = doctor_info.DoctorNumber
  12990. order.DrordDeptName = department.Name
  12991. order.DrordDeptCodg = department.Number
  12992. order.DrordDrName = doctor_info.UserName
  12993. order.DrordDrProfttl = "234"
  12994. order.CurrDrordFlag = "1"
  12995. orders = append(orders, &order)
  12996. }
  12997. }
  12998. }
  12999. //处方医嘱信息
  13000. fed.MatnStas = "0"
  13001. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  13002. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  13003. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  13004. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  13005. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  13006. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  13007. fed.SetlTotlnum = "1"
  13008. fed.Insutype = his.Insutype
  13009. fed.ReimFlag = "0"
  13010. fed.OutSetlFlag = "0"
  13011. var fopd []*models.FsiOperationDtosData
  13012. data := make(map[string]interface{})
  13013. data["fed"] = fed
  13014. data["fdd"] = fdds
  13015. data["fod"] = orders
  13016. data["pd"] = pd
  13017. data["pp"] = pp
  13018. data["fopd"] = fopd
  13019. data["trig_scen"] = trig_scen
  13020. client := &http.Client{}
  13021. bytesData, _ := json.Marshal(data)
  13022. var req *http.Request
  13023. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  13024. if miConfig.MdtrtareaAdmvs == "320830" {
  13025. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3102", bytes.NewReader(bytesData))
  13026. } else if miConfig.MdtrtareaAdmvs == "320921" {
  13027. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  13028. } else {
  13029. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  13030. }
  13031. resp, _ := client.Do(req)
  13032. defer resp.Body.Close()
  13033. body, ioErr := ioutil.ReadAll(resp.Body)
  13034. if ioErr != nil {
  13035. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13037. return res
  13038. }
  13039. var respJSON map[string]interface{}
  13040. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13041. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13043. return res
  13044. }
  13045. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13046. result, _ := json.Marshal(respJSON)
  13047. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13048. utils.ErrorLog("解析失败:%v", err)
  13049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13050. return res
  13051. }
  13052. return res
  13053. } else {
  13054. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  13055. saveLog(output, input, "3102", "事中")
  13056. if err := json.Unmarshal([]byte(output), &res); err != nil {
  13057. utils.ErrorLog("解析失败:%v", err)
  13058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13059. return
  13060. }
  13061. return res
  13062. }
  13063. return res
  13064. }
  13065. func (c *HisApiController) Check() {
  13066. psn_no := c.GetString("psn_no")
  13067. in := c.GetString("in")
  13068. mt := c.GetString("mt")
  13069. baseParams := models.BaseParams{
  13070. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  13071. FixmedinsCode: "H15049901371",
  13072. InsuplcAdmdvs: "150404",
  13073. MdtrtareaAdmvs: "150404",
  13074. OrgName: "赤峰费森血液透析中心",
  13075. Doctor: "1111",
  13076. }
  13077. service.Gdyb2001(baseParams, psn_no, in, mt)
  13078. }
  13079. func (c *HisApiController) GetPsnNcdsInfo() {
  13080. admin_user_id, _ := c.GetInt64("admin_user_id")
  13081. patient_id, _ := c.GetInt64("patient_id")
  13082. //id, _ := c.GetInt64("id")
  13083. adminUser := c.GetAdminUserInfo()
  13084. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13085. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13086. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  13087. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13088. //psn_record, _ := service.GetP(id)
  13089. psn_info, _ := service.GetPsnByPatientId(patient_id)
  13090. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  13091. //
  13092. //if psn_record.ID == 0 {
  13093. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  13094. // return
  13095. //}
  13096. var res Result5301
  13097. var res10265 Result5301For10265
  13098. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  13099. psn_info, _ := service.GetPsnByPatientId(patient_id)
  13100. var api string
  13101. if miConfig.MdtrtareaAdmvs == "320830" {
  13102. api = miConfig.AppSecret + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  13103. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13104. } else if miConfig.MdtrtareaAdmvs == "320921" {
  13105. 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 +
  13106. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13107. } else {
  13108. 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 +
  13109. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13110. }
  13111. resp, requestErr := http.Get(api)
  13112. if requestErr != nil {
  13113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13114. return
  13115. }
  13116. body, ioErr := ioutil.ReadAll(resp.Body)
  13117. if ioErr != nil {
  13118. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13120. return
  13121. }
  13122. var respJSON map[string]interface{}
  13123. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13124. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13126. return
  13127. }
  13128. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13129. result, _ := json.Marshal(respJSON)
  13130. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13131. utils.ErrorLog("解析失败:%v", err)
  13132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13133. return
  13134. }
  13135. res.ErrMsg = res10265.ErrMsg
  13136. res.Output = res10265.Output
  13137. res.InfRefmsgid = res10265.InfRefmsgid
  13138. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13139. res.Infcode = infocode
  13140. } else if miConfig.MdtrtareaAdmvs == "341203" {
  13141. psn_info, _ := service.GetPsnByPatientId(patient_id)
  13142. var api string
  13143. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  13144. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13145. resp, requestErr := http.Get(api)
  13146. if requestErr != nil {
  13147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13148. return
  13149. }
  13150. body, ioErr := ioutil.ReadAll(resp.Body)
  13151. if ioErr != nil {
  13152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13154. return
  13155. }
  13156. var respJSON map[string]interface{}
  13157. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13160. return
  13161. }
  13162. status := respJSON["data"].(map[string]interface{})["status"].(string)
  13163. if status == "0" {
  13164. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  13165. c.ServeSuccessJSON(map[string]interface{}{
  13166. "failed_code": -10,
  13167. "msg": err_msg,
  13168. })
  13169. return
  13170. }
  13171. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13172. result, _ := json.Marshal(respJSON)
  13173. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13174. utils.ErrorLog("解析失败:%v", err)
  13175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13176. return
  13177. }
  13178. } else if miConfig.MdtrtareaAdmvs == "340699" {
  13179. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  13180. var api string
  13181. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  13182. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13183. resp, requestErr := http.Get(api)
  13184. if requestErr != nil {
  13185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13186. return
  13187. }
  13188. body, ioErr := ioutil.ReadAll(resp.Body)
  13189. if ioErr != nil {
  13190. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13192. return
  13193. }
  13194. var respJSON map[string]interface{}
  13195. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13196. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13198. return
  13199. }
  13200. status := respJSON["data"].(map[string]interface{})["status"].(string)
  13201. if status == "0" {
  13202. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  13203. c.ServeSuccessJSON(map[string]interface{}{
  13204. "failed_code": -10,
  13205. "msg": err_msg,
  13206. })
  13207. return
  13208. }
  13209. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13210. result, _ := json.Marshal(respJSON)
  13211. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13212. utils.ErrorLog("解析失败:%v", err)
  13213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13214. return
  13215. }
  13216. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13217. p, _ := service.GetHisPatientById(patient_id)
  13218. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13219. var dat map[string]interface{}
  13220. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13221. fmt.Println(dat)
  13222. } else {
  13223. fmt.Println(err)
  13224. }
  13225. userJSONBytes, _ := json.Marshal(dat)
  13226. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13227. utils.ErrorLog("解析失败:%v", err)
  13228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13229. return
  13230. }
  13231. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13232. p, _ := service.GetHisPatientById(patient_id)
  13233. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13234. var dat map[string]interface{}
  13235. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13236. fmt.Println(dat)
  13237. } else {
  13238. fmt.Println(err)
  13239. }
  13240. userJSONBytes, _ := json.Marshal(dat)
  13241. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13242. utils.ErrorLog("解析失败:%v", err)
  13243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13244. return
  13245. }
  13246. } else if miConfig.MdtrtareaAdmvs == "360100" {
  13247. p, _ := service.GetHisPatientById(patient_id)
  13248. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13249. var dat map[string]interface{}
  13250. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13251. fmt.Println(dat)
  13252. } else {
  13253. fmt.Println(err)
  13254. }
  13255. userJSONBytes, _ := json.Marshal(dat)
  13256. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13257. utils.ErrorLog("解析失败:%v", err)
  13258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13259. return
  13260. }
  13261. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13262. p, _ := service.GetHisPatientById(patient_id)
  13263. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13264. var dat map[string]interface{}
  13265. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13266. fmt.Println(dat)
  13267. } else {
  13268. fmt.Println(err)
  13269. }
  13270. userJSONBytes, _ := json.Marshal(dat)
  13271. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13272. utils.ErrorLog("解析失败:%v", err)
  13273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13274. return
  13275. }
  13276. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13277. p, _ := service.GetHisPatientById(patient_id)
  13278. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  13279. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13280. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13281. resp, requestErr := http.Get(api)
  13282. if requestErr != nil {
  13283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13284. return
  13285. }
  13286. body, ioErr := ioutil.ReadAll(resp.Body)
  13287. if ioErr != nil {
  13288. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13290. return
  13291. }
  13292. var respJSON map[string]interface{}
  13293. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13294. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13296. return
  13297. }
  13298. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13299. result, _ := json.Marshal(respJSON)
  13300. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13301. utils.ErrorLog("解析失败:%v", err)
  13302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13303. return
  13304. }
  13305. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13306. p, _ := service.GetHisPatientById(patient_id)
  13307. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  13308. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13309. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13310. resp, requestErr := http.Get(api)
  13311. if requestErr != nil {
  13312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13313. return
  13314. }
  13315. body, ioErr := ioutil.ReadAll(resp.Body)
  13316. if ioErr != nil {
  13317. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13319. return
  13320. }
  13321. var respJSON map[string]interface{}
  13322. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13323. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13325. return
  13326. }
  13327. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13328. result, _ := json.Marshal(respJSON)
  13329. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13330. utils.ErrorLog("解析失败:%v", err)
  13331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13332. return
  13333. }
  13334. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13335. p, _ := service.GetHisPatientById(patient_id)
  13336. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  13337. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13338. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13339. resp, requestErr := http.Get(api)
  13340. if requestErr != nil {
  13341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13342. return
  13343. }
  13344. body, ioErr := ioutil.ReadAll(resp.Body)
  13345. if ioErr != nil {
  13346. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13348. return
  13349. }
  13350. var respJSON map[string]interface{}
  13351. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13352. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13354. return
  13355. }
  13356. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13357. result, _ := json.Marshal(respJSON)
  13358. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13359. utils.ErrorLog("解析失败:%v", err)
  13360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13361. return
  13362. }
  13363. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13364. p, _ := service.GetHisPatientById(patient_id)
  13365. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  13366. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13367. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13368. resp, requestErr := http.Get(api)
  13369. if requestErr != nil {
  13370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13371. return
  13372. }
  13373. body, ioErr := ioutil.ReadAll(resp.Body)
  13374. if ioErr != nil {
  13375. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13377. return
  13378. }
  13379. var respJSON map[string]interface{}
  13380. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13381. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13383. return
  13384. }
  13385. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13386. result, _ := json.Marshal(respJSON)
  13387. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13388. utils.ErrorLog("解析失败:%v", err)
  13389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13390. return
  13391. }
  13392. } else if miConfig.MdtrtareaAdmvs == "421300" {
  13393. p, _ := service.GetHisPatientById(patient_id)
  13394. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  13395. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13396. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13397. resp, requestErr := http.Get(api)
  13398. if requestErr != nil {
  13399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13400. return
  13401. }
  13402. body, ioErr := ioutil.ReadAll(resp.Body)
  13403. if ioErr != nil {
  13404. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13406. return
  13407. }
  13408. var respJSON map[string]interface{}
  13409. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13410. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13412. return
  13413. }
  13414. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13415. result, _ := json.Marshal(respJSON)
  13416. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13417. utils.ErrorLog("解析失败:%v", err)
  13418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13419. return
  13420. }
  13421. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13422. p, _ := service.GetHisPatientById(patient_id)
  13423. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  13424. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13425. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13426. resp, requestErr := http.Get(api)
  13427. if requestErr != nil {
  13428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13429. return
  13430. }
  13431. body, ioErr := ioutil.ReadAll(resp.Body)
  13432. if ioErr != nil {
  13433. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13435. return
  13436. }
  13437. var respJSON map[string]interface{}
  13438. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13439. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13441. return
  13442. }
  13443. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13444. result, _ := json.Marshal(respJSON)
  13445. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13446. utils.ErrorLog("解析失败:%v", err)
  13447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13448. return
  13449. }
  13450. } else {
  13451. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  13452. var dat map[string]interface{}
  13453. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13454. fmt.Println(dat)
  13455. } else {
  13456. fmt.Println(err)
  13457. }
  13458. userJSONBytes, _ := json.Marshal(dat)
  13459. if miConfig.Code == "H15049901371" {
  13460. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13461. utils.ErrorLog("解析失败:%v", err)
  13462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13463. return
  13464. }
  13465. res.InfRefmsgid = res10265.InfRefmsgid
  13466. res.Output = res10265.Output
  13467. res.ErrMsg = res10265.ErrMsg
  13468. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13469. res.Infcode = infocode
  13470. } else {
  13471. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13472. utils.ErrorLog("解析失败:%v", err)
  13473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13474. return
  13475. }
  13476. }
  13477. }
  13478. if res.Infcode == 0 {
  13479. c.ServeSuccessJSON(map[string]interface{}{
  13480. "result": res.Output.Result,
  13481. })
  13482. }
  13483. }
  13484. func (c *HisApiController) CheckInsutype() {
  13485. his_patient_id, _ := c.GetInt64("his_patient_id")
  13486. admin_user_id, _ := c.GetInt64("admin_user_id")
  13487. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13488. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  13489. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13490. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13491. var dat map[string]interface{}
  13492. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13493. fmt.Println(dat)
  13494. } else {
  13495. fmt.Println(err)
  13496. }
  13497. userJSONBytes, _ := json.Marshal(dat)
  13498. var res Result90100
  13499. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13500. utils.ErrorLog("解析失败:%v", err)
  13501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13502. return
  13503. }
  13504. if res.Infcode != 0 {
  13505. c.ServeSuccessJSON(map[string]interface{}{
  13506. "failed_code": -10,
  13507. "msg": res.ErrMsg,
  13508. })
  13509. return
  13510. } else {
  13511. fmt.Println(res)
  13512. }
  13513. }
  13514. func (c *HisApiController) CheckCardPWD() {
  13515. card_pwd := c.GetString("card_pwd")
  13516. his_patient_id, _ := c.GetInt64("his_patient_id")
  13517. admin_user_id, _ := c.GetInt64("admin_user_id")
  13518. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13519. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13520. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  13521. psn, _ := service.GetPsnByPatientId(his.PatientId)
  13522. bas := strings.Split(psn.CardInfo, "|")
  13523. basNumber := bas[2]
  13524. if psn.InsuplcAdmdvs[:4] == "4403" {
  13525. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  13526. var dat map[string]interface{}
  13527. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13528. fmt.Println(dat)
  13529. } else {
  13530. fmt.Println(err)
  13531. }
  13532. userJSONBytes, _ := json.Marshal(dat)
  13533. var res Result90991
  13534. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13535. utils.ErrorLog("解析失败:%v", err)
  13536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13537. return
  13538. }
  13539. if res.Infcode != 0 {
  13540. c.ServeSuccessJSON(map[string]interface{}{
  13541. "failed_code": -10,
  13542. "msg": res.ErrMsg,
  13543. })
  13544. return
  13545. } else {
  13546. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  13547. var msg string
  13548. switch res.Output.Result.CardStat {
  13549. case "00":
  13550. msg = "未激活"
  13551. break
  13552. case "10":
  13553. msg = "激活"
  13554. break
  13555. case "20":
  13556. msg = "窗口挂失"
  13557. break
  13558. case "21":
  13559. msg = "电话挂失"
  13560. break
  13561. case "22":
  13562. msg = "单位网上申报挂失"
  13563. break
  13564. case "23":
  13565. msg = "保健办挂失"
  13566. break
  13567. case "24":
  13568. msg = "个人网上挂失"
  13569. break
  13570. case "25":
  13571. msg = "网上服务大厅挂失"
  13572. break
  13573. case "30":
  13574. msg = "注销"
  13575. break
  13576. case "40":
  13577. msg = "回收"
  13578. break
  13579. case "99":
  13580. msg = "制卡中(无效卡)"
  13581. break
  13582. }
  13583. c.ServeSuccessJSON(map[string]interface{}{
  13584. "failed_code": -10,
  13585. "msg": msg,
  13586. })
  13587. return
  13588. } else {
  13589. c.ServeSuccessJSON(map[string]interface{}{
  13590. "msg": "校验成功",
  13591. })
  13592. return
  13593. }
  13594. }
  13595. } else {
  13596. c.ServeSuccessJSON(map[string]interface{}{
  13597. "msg": "校验成功",
  13598. })
  13599. return
  13600. }
  13601. }
  13602. func (c *HisApiController) CheckCardPWDTwo() {
  13603. //card_pwd := c.GetString("card_pwd")
  13604. //his_patient_id, _ := c.GetInt64("his_patient_id")
  13605. admin_user_id, _ := c.GetInt64("admin_user_id")
  13606. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13607. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13608. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  13609. var dat map[string]interface{}
  13610. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13611. fmt.Println(dat)
  13612. } else {
  13613. fmt.Println(err)
  13614. }
  13615. userJSONBytes, _ := json.Marshal(dat)
  13616. var res Result90991
  13617. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13618. utils.ErrorLog("解析失败:%v", err)
  13619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13620. return
  13621. }
  13622. if res.Infcode != 0 {
  13623. c.ServeSuccessJSON(map[string]interface{}{
  13624. "failed_code": -10,
  13625. "msg": res.ErrMsg,
  13626. })
  13627. return
  13628. } else {
  13629. if res.Output.Result.SscnoCheckStat == "0" {
  13630. var msg string
  13631. switch res.Output.Result.CardStat {
  13632. case "00":
  13633. msg = "未激活"
  13634. break
  13635. case "10":
  13636. msg = "激活"
  13637. break
  13638. case "20":
  13639. msg = "窗口挂失"
  13640. break
  13641. case "21":
  13642. msg = "电话挂失"
  13643. break
  13644. case "22":
  13645. msg = "单位网上申报挂失"
  13646. break
  13647. case "23":
  13648. msg = "保健办挂失"
  13649. break
  13650. case "24":
  13651. msg = "个人网上挂失"
  13652. break
  13653. case "25":
  13654. msg = "网上服务大厅挂失"
  13655. break
  13656. case "30":
  13657. msg = "注销"
  13658. break
  13659. case "40":
  13660. msg = "回收"
  13661. break
  13662. case "99":
  13663. msg = "制卡中(无效卡)"
  13664. break
  13665. }
  13666. c.ServeSuccessJSON(map[string]interface{}{
  13667. "failed_code": -10,
  13668. "msg": msg,
  13669. })
  13670. return
  13671. } else {
  13672. c.ServeSuccessJSON(map[string]interface{}{
  13673. "msg": "校验成功",
  13674. })
  13675. return
  13676. }
  13677. }
  13678. }
  13679. type ELeCertData struct {
  13680. Data struct {
  13681. Extra string `json:"extra"`
  13682. IDNo string `json:"idNo"`
  13683. IDType string `json:"idType"`
  13684. EcToken string `json:"ecToken"`
  13685. InsuOrg string `json:"insuOrg"`
  13686. UserName string `json:"userName"`
  13687. EcIndexNo string `json:"ecIndexNo"`
  13688. Gender string `json:"gender"`
  13689. Birthday string `json:"birthday"`
  13690. Nationality string `json:"nationality"`
  13691. Email string `json:"email"`
  13692. } `json:"OutData"`
  13693. }
  13694. func (c *HisApiController) ReadCard() {
  13695. id_card_type, _ := c.GetInt64("id_card_type")
  13696. admin_user_id, _ := c.GetInt64("admin_user_id")
  13697. certificates, _ := c.GetInt64("certificates")
  13698. //
  13699. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  13700. id_card_no := c.GetString("id_card_no")
  13701. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13702. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13703. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13704. switch id_card_type {
  13705. case 1:
  13706. if miConfig.MdtrtareaAdmvs == "421300" {
  13707. var res ResultTwo
  13708. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  13709. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13710. "&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)
  13711. resp, requestErr := http.Get(api)
  13712. if requestErr != nil {
  13713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13714. return
  13715. }
  13716. body, ioErr := ioutil.ReadAll(resp.Body)
  13717. if ioErr != nil {
  13718. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13720. return
  13721. }
  13722. var respJSON map[string]interface{}
  13723. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13724. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13726. return
  13727. }
  13728. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13729. result, _ := json.Marshal(respJSON)
  13730. fmt.Println("log")
  13731. fmt.Println(string(result))
  13732. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13733. utils.ErrorLog("解析失败:%v", err)
  13734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13735. return
  13736. }
  13737. if res.Infcode == 0 {
  13738. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13739. if err == gorm.ErrRecordNotFound {
  13740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13741. return
  13742. } else if err != nil {
  13743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13744. return
  13745. } else {
  13746. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13747. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13748. infoStr := string(Iinfos)
  13749. idetinfoStr := string(Idetinfos)
  13750. var rf []*ResultFive
  13751. json.Unmarshal([]byte(infoStr), &rf)
  13752. var insutypes []*ResultFive
  13753. var insutype string
  13754. var is390 int = 0
  13755. var is310 int = 0
  13756. for _, item := range rf {
  13757. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13758. insutypes = append(insutypes, item)
  13759. }
  13760. }
  13761. if len(insutypes) == 1 {
  13762. insutype = insutypes[0].Insutype
  13763. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13764. } else {
  13765. for _, i := range insutypes {
  13766. if i.Insutype == "390" {
  13767. is390 = 1
  13768. }
  13769. if i.Insutype == "310" {
  13770. is310 = 1
  13771. }
  13772. }
  13773. }
  13774. if is390 == 1 {
  13775. insutype = "390"
  13776. }
  13777. if is310 == 1 {
  13778. insutype = "310"
  13779. }
  13780. if len(insutypes) == 0 {
  13781. insutype = "390"
  13782. }
  13783. var insuplc_admdvs string
  13784. for _, item := range rf {
  13785. if item.Insutype == insutype {
  13786. insuplc_admdvs = item.InsuplcAdmdvs
  13787. }
  13788. }
  13789. if strings.Contains(insuplc_admdvs, "4213") {
  13790. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  13791. }
  13792. psn := &models.HisPsn{
  13793. PsnNo: res.Output.Baseinfo.PsnNo,
  13794. PatientId: patient.ID,
  13795. Certno: res.Output.Baseinfo.Certno,
  13796. Gend: res.Output.Baseinfo.Gend,
  13797. Naty: res.Output.Baseinfo.Naty,
  13798. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13799. PsnName: res.Output.Baseinfo.PsnName,
  13800. Idetinfo: idetinfoStr,
  13801. Insuinfo: infoStr,
  13802. InsuplcAdmdvs: insuplc_admdvs,
  13803. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13804. }
  13805. service.CreateHisPsn(psn)
  13806. c.ServeSuccessJSON(map[string]interface{}{
  13807. "patient": patient,
  13808. "number": res.Output.Baseinfo.Certno,
  13809. })
  13810. }
  13811. } else {
  13812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13813. return
  13814. }
  13815. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13816. var res ResultTwo
  13817. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  13818. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13819. "&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)
  13820. resp, requestErr := http.Get(api)
  13821. if requestErr != nil {
  13822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13823. return
  13824. }
  13825. body, ioErr := ioutil.ReadAll(resp.Body)
  13826. if ioErr != nil {
  13827. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13829. return
  13830. }
  13831. var respJSON map[string]interface{}
  13832. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13835. return
  13836. }
  13837. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13838. result, _ := json.Marshal(respJSON)
  13839. fmt.Println("log")
  13840. fmt.Println(string(result))
  13841. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13842. utils.ErrorLog("解析失败:%v", err)
  13843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13844. return
  13845. }
  13846. if res.Infcode == 0 {
  13847. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13848. if err == gorm.ErrRecordNotFound {
  13849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13850. return
  13851. } else if err != nil {
  13852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13853. return
  13854. } else {
  13855. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13856. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13857. infoStr := string(Iinfos)
  13858. idetinfoStr := string(Idetinfos)
  13859. psn := &models.HisPsn{
  13860. PsnNo: res.Output.Baseinfo.PsnNo,
  13861. PatientId: patient.ID,
  13862. Certno: res.Output.Baseinfo.Certno,
  13863. Gend: res.Output.Baseinfo.Gend,
  13864. Naty: res.Output.Baseinfo.Naty,
  13865. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13866. PsnName: res.Output.Baseinfo.PsnName,
  13867. Idetinfo: idetinfoStr,
  13868. Insuinfo: infoStr,
  13869. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13870. }
  13871. service.CreateHisPsn(psn)
  13872. var rf []*ResultFive
  13873. json.Unmarshal([]byte(infoStr), &rf)
  13874. var insutypes []*ResultFive
  13875. var insutype string
  13876. var is390 int = 0
  13877. var is310 int = 0
  13878. for _, item := range rf {
  13879. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13880. insutypes = append(insutypes, item)
  13881. }
  13882. }
  13883. if len(insutypes) == 1 {
  13884. insutype = insutypes[0].Insutype
  13885. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13886. } else {
  13887. for _, i := range insutypes {
  13888. if i.Insutype == "390" {
  13889. is390 = 1
  13890. }
  13891. if i.Insutype == "310" {
  13892. is310 = 1
  13893. }
  13894. }
  13895. }
  13896. if is390 == 1 {
  13897. insutype = "390"
  13898. }
  13899. if is310 == 1 {
  13900. insutype = "310"
  13901. }
  13902. if len(insutypes) == 0 {
  13903. insutype = "310"
  13904. }
  13905. c.ServeSuccessJSON(map[string]interface{}{
  13906. "patient": patient,
  13907. "number": res.Output.Baseinfo.Certno,
  13908. "insutype": insutype,
  13909. })
  13910. }
  13911. } else {
  13912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13913. return
  13914. }
  13915. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13916. var res ResultTwo
  13917. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13918. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13919. "&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)
  13920. resp, requestErr := http.Get(api)
  13921. if requestErr != nil {
  13922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13923. return
  13924. }
  13925. body, ioErr := ioutil.ReadAll(resp.Body)
  13926. if ioErr != nil {
  13927. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13929. return
  13930. }
  13931. var respJSON map[string]interface{}
  13932. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13935. return
  13936. }
  13937. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13938. result, _ := json.Marshal(respJSON)
  13939. fmt.Println("log")
  13940. fmt.Println(string(result))
  13941. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13942. utils.ErrorLog("解析失败:%v", err)
  13943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13944. return
  13945. }
  13946. if res.Infcode == 0 {
  13947. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13948. if err == gorm.ErrRecordNotFound {
  13949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13950. return
  13951. } else if err != nil {
  13952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13953. return
  13954. } else {
  13955. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13956. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13957. infoStr := string(Iinfos)
  13958. idetinfoStr := string(Idetinfos)
  13959. var rf []*ResultFive
  13960. json.Unmarshal([]byte(infoStr), &rf)
  13961. var insutypes []*ResultFive
  13962. var insutype string
  13963. var is390 int = 0
  13964. var is310 int = 0
  13965. for _, item := range rf {
  13966. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13967. insutypes = append(insutypes, item)
  13968. }
  13969. }
  13970. if len(insutypes) == 1 {
  13971. insutype = insutypes[0].Insutype
  13972. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13973. } else {
  13974. for _, i := range insutypes {
  13975. if i.Insutype == "390" {
  13976. is390 = 1
  13977. }
  13978. if i.Insutype == "310" {
  13979. is310 = 1
  13980. }
  13981. }
  13982. }
  13983. if is390 == 1 {
  13984. insutype = "390"
  13985. }
  13986. if is310 == 1 {
  13987. insutype = "310"
  13988. }
  13989. if len(insutypes) == 0 {
  13990. insutype = "390"
  13991. }
  13992. var insuplc_admdvs string
  13993. for _, item := range rf {
  13994. if item.Insutype == insutype {
  13995. insuplc_admdvs = item.InsuplcAdmdvs
  13996. }
  13997. }
  13998. psn := &models.HisPsn{
  13999. PsnNo: res.Output.Baseinfo.PsnNo,
  14000. PatientId: patient.ID,
  14001. Certno: res.Output.Baseinfo.Certno,
  14002. Gend: res.Output.Baseinfo.Gend,
  14003. Naty: res.Output.Baseinfo.Naty,
  14004. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14005. PsnName: res.Output.Baseinfo.PsnName,
  14006. Idetinfo: idetinfoStr,
  14007. Insuinfo: infoStr,
  14008. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14009. InsuplcAdmdvs: insuplc_admdvs,
  14010. }
  14011. service.CreateHisPsn(psn)
  14012. for _, item := range rf {
  14013. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14014. insutypes = append(insutypes, item)
  14015. }
  14016. }
  14017. if len(insutypes) == 1 {
  14018. insutype = insutypes[0].Insutype
  14019. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14020. } else {
  14021. for _, i := range insutypes {
  14022. if i.Insutype == "390" {
  14023. is390 = 1
  14024. }
  14025. if i.Insutype == "310" {
  14026. is310 = 1
  14027. }
  14028. }
  14029. }
  14030. if is390 == 1 {
  14031. insutype = "390"
  14032. }
  14033. if is310 == 1 {
  14034. insutype = "310"
  14035. }
  14036. if len(insutypes) == 0 {
  14037. insutype = "310"
  14038. }
  14039. c.ServeSuccessJSON(map[string]interface{}{
  14040. "patient": patient,
  14041. "number": res.Output.Baseinfo.Certno,
  14042. "insutype": insutype,
  14043. })
  14044. }
  14045. } else {
  14046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14047. return
  14048. }
  14049. } else if miConfig.MdtrtareaAdmvs == "421182" {
  14050. var res ResultTwo
  14051. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  14052. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14053. "&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)
  14054. resp, requestErr := http.Get(api)
  14055. if requestErr != nil {
  14056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14057. return
  14058. }
  14059. body, ioErr := ioutil.ReadAll(resp.Body)
  14060. if ioErr != nil {
  14061. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14063. return
  14064. }
  14065. var respJSON map[string]interface{}
  14066. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14067. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14069. return
  14070. }
  14071. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14072. result, _ := json.Marshal(respJSON)
  14073. fmt.Println("log")
  14074. fmt.Println(string(result))
  14075. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14076. utils.ErrorLog("解析失败:%v", err)
  14077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14078. return
  14079. }
  14080. if res.Infcode == 0 {
  14081. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14082. if err == gorm.ErrRecordNotFound {
  14083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14084. return
  14085. } else if err != nil {
  14086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14087. return
  14088. } else {
  14089. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14090. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14091. infoStr := string(Iinfos)
  14092. idetinfoStr := string(Idetinfos)
  14093. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  14094. psn := &models.HisPsn{
  14095. PsnNo: res.Output.Baseinfo.PsnNo,
  14096. PatientId: patient.ID,
  14097. Certno: res.Output.Baseinfo.Certno,
  14098. Brdy: b,
  14099. Age: float64(age),
  14100. Gend: res.Output.Baseinfo.Gend,
  14101. Naty: res.Output.Baseinfo.Naty,
  14102. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14103. PsnName: res.Output.Baseinfo.PsnName,
  14104. Idetinfo: idetinfoStr,
  14105. Insuinfo: infoStr,
  14106. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14107. }
  14108. service.CreateHisPsn(psn)
  14109. var rf []*ResultFive
  14110. json.Unmarshal([]byte(infoStr), &rf)
  14111. var insutypes []*ResultFive
  14112. var insutype string
  14113. var is390 int = 0
  14114. var is310 int = 0
  14115. for _, item := range rf {
  14116. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14117. insutypes = append(insutypes, item)
  14118. }
  14119. }
  14120. if len(insutypes) == 1 {
  14121. insutype = insutypes[0].Insutype
  14122. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14123. } else {
  14124. for _, i := range insutypes {
  14125. if i.Insutype == "390" {
  14126. is390 = 1
  14127. }
  14128. if i.Insutype == "310" {
  14129. is310 = 1
  14130. }
  14131. }
  14132. }
  14133. if is390 == 1 {
  14134. insutype = "390"
  14135. }
  14136. if is310 == 1 {
  14137. insutype = "310"
  14138. }
  14139. if len(insutypes) == 0 {
  14140. insutype = "310"
  14141. }
  14142. c.ServeSuccessJSON(map[string]interface{}{
  14143. "patient": patient,
  14144. "number": res.Output.Baseinfo.Certno,
  14145. "insutype": insutype,
  14146. })
  14147. }
  14148. } else {
  14149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14150. return
  14151. }
  14152. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  14153. var api string
  14154. if miConfig.MdtrtareaAdmvs == "320830" {
  14155. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14156. "&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
  14157. fmt.Println(api)
  14158. } else if miConfig.MdtrtareaAdmvs == "320921" {
  14159. 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 +
  14160. "&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
  14161. fmt.Println(api)
  14162. } else {
  14163. 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 +
  14164. "&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)
  14165. }
  14166. resp, requestErr := http.Get(api)
  14167. if requestErr != nil {
  14168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14169. return
  14170. }
  14171. body, ioErr := ioutil.ReadAll(resp.Body)
  14172. if ioErr != nil {
  14173. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14175. return
  14176. }
  14177. var respJSON map[string]interface{}
  14178. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14179. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14181. return
  14182. }
  14183. var status string
  14184. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14185. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14186. //console.log()
  14187. fmt.Println("type===")
  14188. fmt.Println(card_type)
  14189. var token string
  14190. var res ResultTwo //1101结果
  14191. var res10265 ResultTwo10265 //1101结果
  14192. var card_info string //卡信息
  14193. var busi_card_info string
  14194. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14195. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14196. if status == "0" { //读卡成功
  14197. if card_type == "1" {
  14198. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14199. result, _ := json.Marshal(respJSON)
  14200. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14201. utils.ErrorLog("解析失败:%v", err)
  14202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14203. return
  14204. }
  14205. res.ErrMsg = res10265.ErrMsg
  14206. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14207. res.Infcode = infocode
  14208. res.Output = res10265.Output
  14209. res.InfRefmsgid = res10265.InfRefmsgid
  14210. } else {
  14211. //var card_info string //卡信息
  14212. //var busi_card_info string
  14213. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14214. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14215. //fmt.Println(card_info)
  14216. //fmt.Println(busi_card_info)
  14217. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14218. result, _ := json.Marshal(respJSON)
  14219. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14220. utils.ErrorLog("解析失败:%v", err)
  14221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14222. return
  14223. }
  14224. res.ErrMsg = res10265.ErrMsg
  14225. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14226. res.Infcode = infocode
  14227. res.Output = res10265.Output
  14228. res.InfRefmsgid = res10265.InfRefmsgid
  14229. }
  14230. if res.Infcode == 0 {
  14231. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14232. if err == gorm.ErrRecordNotFound {
  14233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14234. return
  14235. } else if err != nil {
  14236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14237. return
  14238. } else {
  14239. if card_type == "1" {
  14240. bas := strings.Split(card_info, "|")
  14241. basNumber := bas[2]
  14242. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14243. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14244. infoStr := string(Iinfos)
  14245. idetinfoStr := string(Idetinfos)
  14246. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  14247. psn := &models.HisPsn{
  14248. PsnNo: res.Output.Baseinfo.PsnNo,
  14249. PatientId: patient.ID,
  14250. Certno: res.Output.Baseinfo.Certno,
  14251. Brdy: b,
  14252. Age: float64(age),
  14253. Gend: res.Output.Baseinfo.Gend,
  14254. Naty: res.Output.Baseinfo.Naty,
  14255. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14256. PsnName: res.Output.Baseinfo.PsnName,
  14257. Idetinfo: idetinfoStr,
  14258. Insuinfo: infoStr,
  14259. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14260. CardInfo: card_info,
  14261. VerifyNumber: busi_card_info,
  14262. }
  14263. service.CreateHisPsn(psn)
  14264. var rf []*ResultFive
  14265. json.Unmarshal([]byte(infoStr), &rf)
  14266. var insutypes []*ResultFive
  14267. var insutype string
  14268. var is390 int = 0
  14269. var is310 int = 0
  14270. for _, item := range rf {
  14271. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14272. insutypes = append(insutypes, item)
  14273. }
  14274. }
  14275. if len(insutypes) == 1 {
  14276. insutype = insutypes[0].Insutype
  14277. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14278. } else {
  14279. for _, i := range insutypes {
  14280. if i.Insutype == "390" {
  14281. is390 = 1
  14282. }
  14283. if i.Insutype == "310" {
  14284. is310 = 1
  14285. }
  14286. }
  14287. }
  14288. if is390 == 1 {
  14289. insutype = "390"
  14290. }
  14291. if is310 == 1 {
  14292. insutype = "310"
  14293. }
  14294. if len(insutypes) == 0 {
  14295. insutype = "310"
  14296. }
  14297. c.ServeSuccessJSON(map[string]interface{}{
  14298. "patient": patient,
  14299. "number": basNumber,
  14300. "insutype": insutype,
  14301. })
  14302. } else {
  14303. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14304. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14305. infoStr := string(Iinfos)
  14306. idetinfoStr := string(Idetinfos)
  14307. psn := &models.HisPsn{
  14308. PsnNo: res.Output.Baseinfo.PsnNo,
  14309. PatientId: patient.ID,
  14310. Certno: res.Output.Baseinfo.Certno,
  14311. Gend: res.Output.Baseinfo.Gend,
  14312. Naty: res.Output.Baseinfo.Naty,
  14313. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14314. PsnName: res.Output.Baseinfo.PsnName,
  14315. Idetinfo: idetinfoStr,
  14316. Insuinfo: infoStr,
  14317. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14318. CardInfo: card_info,
  14319. VerifyNumber: token,
  14320. }
  14321. service.CreateHisPsn(psn)
  14322. c.ServeSuccessJSON(map[string]interface{}{
  14323. "patient": patient,
  14324. "number": token,
  14325. })
  14326. }
  14327. }
  14328. } else {
  14329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14330. return
  14331. }
  14332. } else { //读卡失败
  14333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14334. return
  14335. }
  14336. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14337. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  14338. cardnum = DeleteExtraSpaceTwo(cardnum)
  14339. cardCode = DeleteExtraSpaceTwo(cardCode)
  14340. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  14341. name = DeleteExtraSpaceTwo(name)
  14342. errmsg = DeleteExtraSpaceTwo(errmsg)
  14343. cardnum = Remove0000(cardnum)
  14344. cardCode = Remove0000(cardCode)
  14345. id_card_no = Remove0000(id_card_no)
  14346. name = Remove0000(name)
  14347. errmsg = Remove0000(errmsg)
  14348. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  14349. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  14350. //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)
  14351. //fmt.Println(result2)
  14352. //fmt.Println(requestLog2)
  14353. //fmt.Println(errMsgLog2)
  14354. 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)
  14355. saveLog(result, requestLog, "1101", "获取人员信息")
  14356. fmt.Println(errMsgLog)
  14357. if len(errMsgLog) > 0 {
  14358. } else {
  14359. var dat map[string]interface{}
  14360. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14361. fmt.Println(dat)
  14362. } else {
  14363. fmt.Println(err)
  14364. }
  14365. userJSONBytes, _ := json.Marshal(dat)
  14366. var res ResultTwo
  14367. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14368. utils.ErrorLog("解析失败:%v", err)
  14369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14370. return
  14371. }
  14372. res.ErrMsg = errMsgLog
  14373. if res.Infcode == 0 {
  14374. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  14375. if err == gorm.ErrRecordNotFound {
  14376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14377. return
  14378. } else if err != nil {
  14379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14380. return
  14381. } else {
  14382. fmt.Println(res)
  14383. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14384. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14385. infoStr := string(Iinfos)
  14386. idetinfoStr := string(Idetinfos)
  14387. var rf []*ResultFive
  14388. json.Unmarshal([]byte(infoStr), &rf)
  14389. var insutypes []*ResultFive
  14390. var insutype string
  14391. var is390 int = 0
  14392. var is310 int = 0
  14393. for _, item := range rf {
  14394. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14395. insutypes = append(insutypes, item)
  14396. }
  14397. }
  14398. if len(insutypes) == 1 {
  14399. insutype = insutypes[0].Insutype
  14400. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14401. } else {
  14402. for _, i := range insutypes {
  14403. if i.Insutype == "390" {
  14404. is390 = 1
  14405. }
  14406. if i.Insutype == "310" {
  14407. is310 = 1
  14408. }
  14409. }
  14410. }
  14411. if is390 == 1 {
  14412. insutype = "390"
  14413. }
  14414. if is310 == 1 {
  14415. insutype = "310"
  14416. }
  14417. if len(insutypes) == 0 {
  14418. insutype = "390"
  14419. }
  14420. var insuplc_admdvs string
  14421. for _, item := range rf {
  14422. if item.Insutype == insutype {
  14423. insuplc_admdvs = item.InsuplcAdmdvs
  14424. }
  14425. }
  14426. psn := &models.HisPsn{
  14427. PsnNo: res.Output.Baseinfo.PsnNo,
  14428. PatientId: patient.ID,
  14429. Certno: res.Output.Baseinfo.Certno,
  14430. Gend: res.Output.Baseinfo.Gend,
  14431. Naty: res.Output.Baseinfo.Naty,
  14432. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14433. PsnName: res.Output.Baseinfo.PsnName,
  14434. Idetinfo: idetinfoStr,
  14435. Insuinfo: infoStr,
  14436. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14437. CardInfo: basStr,
  14438. VerifyNumber: "",
  14439. InsuplcAdmdvs: insuplc_admdvs,
  14440. }
  14441. service.CreateHisPsn(psn)
  14442. c.ServeSuccessJSON(map[string]interface{}{
  14443. "patient": patient,
  14444. "number": cardnum,
  14445. "insutype": insutype,
  14446. })
  14447. }
  14448. } else {
  14449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14450. return
  14451. }
  14452. }
  14453. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14454. fmt.Println(initFlag)
  14455. fmt.Println("initFlag")
  14456. if initFlag == 0 {
  14457. c.TestGetJiangXiBasBaseInit()
  14458. }
  14459. basStr := c.GetBasBaseInfo()
  14460. if len(basStr) == 0 {
  14461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14462. return
  14463. }
  14464. fmt.Println(basStr)
  14465. bas := strings.Split(basStr, "|")
  14466. basNumber := bas[1]
  14467. fmt.Println(basNumber)
  14468. card := bas[2]
  14469. card_sn := bas[3]
  14470. fmt.Println(card_sn)
  14471. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14472. 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)
  14473. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14474. var dat map[string]interface{}
  14475. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14476. fmt.Println(dat)
  14477. } else {
  14478. fmt.Println(err)
  14479. }
  14480. userJSONBytes, _ := json.Marshal(dat)
  14481. var res ResultTwo
  14482. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14483. utils.ErrorLog("解析失败:%v", err)
  14484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14485. return
  14486. }
  14487. if res.Infcode == 0 {
  14488. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14489. if err == gorm.ErrRecordNotFound {
  14490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14491. return
  14492. } else if err != nil {
  14493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14494. return
  14495. } else {
  14496. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14497. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14498. infoStr := string(Iinfos)
  14499. idetinfoStr := string(Idetinfos)
  14500. var rf []*ResultFive
  14501. json.Unmarshal([]byte(infoStr), &rf)
  14502. var insutypes []*ResultFive
  14503. var insutype string
  14504. var is390 int = 0
  14505. var is310 int = 0
  14506. var insuplc_admdvs string
  14507. for _, item := range rf {
  14508. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14509. insutypes = append(insutypes, item)
  14510. }
  14511. }
  14512. if len(insutypes) == 1 {
  14513. insutype = insutypes[0].Insutype
  14514. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14515. } else {
  14516. for _, i := range insutypes {
  14517. if i.Insutype == "390" {
  14518. is390 = 1
  14519. }
  14520. if i.Insutype == "310" {
  14521. is310 = 1
  14522. }
  14523. }
  14524. }
  14525. if is390 == 1 {
  14526. insutype = "390"
  14527. }
  14528. if is310 == 1 {
  14529. insutype = "310"
  14530. }
  14531. if len(insutypes) == 0 {
  14532. insutype = "310"
  14533. }
  14534. for _, item := range rf {
  14535. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14536. insuplc_admdvs = item.InsuplcAdmdvs
  14537. }
  14538. }
  14539. psn := &models.HisPsn{
  14540. PsnNo: res.Output.Baseinfo.PsnNo,
  14541. PatientId: patient.ID,
  14542. Certno: res.Output.Baseinfo.Certno,
  14543. Gend: res.Output.Baseinfo.Gend,
  14544. Naty: res.Output.Baseinfo.Naty,
  14545. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14546. PsnName: res.Output.Baseinfo.PsnName,
  14547. Idetinfo: idetinfoStr,
  14548. Insuinfo: infoStr,
  14549. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14550. CardInfo: basStr,
  14551. InsuplcAdmdvs: insuplc_admdvs,
  14552. VerifyNumber: "",
  14553. }
  14554. service.CreateHisPsn(psn)
  14555. c.ServeSuccessJSON(map[string]interface{}{
  14556. "patient": patient,
  14557. "number": basNumber,
  14558. "insutype": insutype,
  14559. })
  14560. }
  14561. } else {
  14562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14563. return
  14564. }
  14565. } else if miConfig.MdtrtareaAdmvs == "361025" {
  14566. basStr := c.GetBasBaseInfo22222()
  14567. fmt.Println(basStr)
  14568. if len(basStr) == 0 {
  14569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14570. return
  14571. }
  14572. fmt.Println(basStr)
  14573. bas := strings.Split(basStr, "|")
  14574. basNumber := bas[2] //卡号
  14575. card_sn := bas[3] //
  14576. id_card_No := bas[1] //卡号
  14577. fmt.Println(basNumber)
  14578. fmt.Println(card_sn)
  14579. fmt.Println(id_card_No)
  14580. var patient service.Patients
  14581. if len(id_card_No) == 0 {
  14582. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14583. } else {
  14584. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14585. }
  14586. 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)
  14587. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14588. var dat map[string]interface{}
  14589. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14590. fmt.Println(dat)
  14591. } else {
  14592. fmt.Println(err)
  14593. }
  14594. userJSONBytes, _ := json.Marshal(dat)
  14595. var res ResultTwo
  14596. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14597. utils.ErrorLog("解析失败:%v", err)
  14598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14599. return
  14600. }
  14601. if res.Infcode == 0 {
  14602. var pateint2 service.Patients
  14603. var err error
  14604. if len(id_card_No) == 0 {
  14605. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14606. } else {
  14607. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14608. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14609. }
  14610. if err == gorm.ErrRecordNotFound {
  14611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14612. return
  14613. } else if err != nil {
  14614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14615. return
  14616. } else {
  14617. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14618. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14619. infoStr := string(Iinfos)
  14620. idetinfoStr := string(Idetinfos)
  14621. var rf []*ResultFive
  14622. json.Unmarshal([]byte(infoStr), &rf)
  14623. var insutypes []*ResultFive
  14624. var insutype string
  14625. var is390 int = 0
  14626. var is310 int = 0
  14627. var insuplc_admdvs string
  14628. for _, item := range rf {
  14629. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14630. insutypes = append(insutypes, item)
  14631. }
  14632. }
  14633. if len(insutypes) == 1 {
  14634. insutype = insutypes[0].Insutype
  14635. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14636. } else {
  14637. for _, i := range insutypes {
  14638. if i.Insutype == "390" {
  14639. is390 = 1
  14640. }
  14641. if i.Insutype == "310" {
  14642. is310 = 1
  14643. }
  14644. }
  14645. }
  14646. if is390 == 1 {
  14647. insutype = "390"
  14648. }
  14649. if is310 == 1 {
  14650. insutype = "310"
  14651. }
  14652. if len(insutypes) == 0 {
  14653. insutype = "310"
  14654. }
  14655. for _, item := range rf {
  14656. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14657. insuplc_admdvs = item.InsuplcAdmdvs
  14658. }
  14659. }
  14660. psn := &models.HisPsn{
  14661. PsnNo: res.Output.Baseinfo.PsnNo,
  14662. PatientId: pateint2.ID,
  14663. Certno: res.Output.Baseinfo.Certno,
  14664. Gend: res.Output.Baseinfo.Gend,
  14665. Naty: res.Output.Baseinfo.Naty,
  14666. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14667. PsnName: res.Output.Baseinfo.PsnName,
  14668. Idetinfo: idetinfoStr,
  14669. Insuinfo: infoStr,
  14670. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14671. CardInfo: basStr,
  14672. InsuplcAdmdvs: insuplc_admdvs,
  14673. VerifyNumber: "",
  14674. }
  14675. service.CreateHisPsn(psn)
  14676. c.ServeSuccessJSON(map[string]interface{}{
  14677. "patient": patient,
  14678. "number": basNumber,
  14679. "insutype": insutype,
  14680. })
  14681. }
  14682. } else {
  14683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14684. return
  14685. }
  14686. } else if miConfig.MdtrtareaAdmvs == "360100" {
  14687. fmt.Println(initFlag)
  14688. fmt.Println("initFlag")
  14689. if initFlag == 0 {
  14690. c.TestGetJiangXiBasBaseInittwo()
  14691. }
  14692. basStr := c.GetBasBaseInfo()
  14693. if len(basStr) == 0 {
  14694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14695. return
  14696. }
  14697. fmt.Println(basStr)
  14698. bas := strings.Split(basStr, "|")
  14699. basNumber := bas[1]
  14700. fmt.Println(basNumber)
  14701. card_sn := bas[3]
  14702. fmt.Println(card_sn)
  14703. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14704. 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)
  14705. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14706. var dat map[string]interface{}
  14707. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14708. fmt.Println(dat)
  14709. } else {
  14710. fmt.Println(err)
  14711. }
  14712. userJSONBytes, _ := json.Marshal(dat)
  14713. var res ResultTwo
  14714. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14715. utils.ErrorLog("解析失败:%v", err)
  14716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14717. return
  14718. }
  14719. if res.Infcode == 0 {
  14720. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14721. if err == gorm.ErrRecordNotFound {
  14722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14723. return
  14724. } else if err != nil {
  14725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14726. return
  14727. } else {
  14728. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14729. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14730. infoStr := string(Iinfos)
  14731. idetinfoStr := string(Idetinfos)
  14732. var rf []*ResultFive
  14733. json.Unmarshal([]byte(infoStr), &rf)
  14734. var insutypes []*ResultFive
  14735. var insutype string
  14736. var is390 int = 0
  14737. var is310 int = 0
  14738. var insuplc_admdvs string
  14739. for _, item := range rf {
  14740. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14741. insutypes = append(insutypes, item)
  14742. }
  14743. }
  14744. if len(insutypes) == 1 {
  14745. insutype = insutypes[0].Insutype
  14746. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14747. } else {
  14748. for _, i := range insutypes {
  14749. if i.Insutype == "390" {
  14750. is390 = 1
  14751. }
  14752. if i.Insutype == "310" {
  14753. is310 = 1
  14754. }
  14755. }
  14756. }
  14757. if is390 == 1 {
  14758. insutype = "390"
  14759. }
  14760. if is310 == 1 {
  14761. insutype = "310"
  14762. }
  14763. if len(insutypes) == 0 {
  14764. insutype = "310"
  14765. }
  14766. for _, item := range rf {
  14767. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14768. insuplc_admdvs = item.InsuplcAdmdvs
  14769. }
  14770. }
  14771. psn := &models.HisPsn{
  14772. PsnNo: res.Output.Baseinfo.PsnNo,
  14773. PatientId: patient.ID,
  14774. Certno: res.Output.Baseinfo.Certno,
  14775. Gend: res.Output.Baseinfo.Gend,
  14776. Naty: res.Output.Baseinfo.Naty,
  14777. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14778. PsnName: res.Output.Baseinfo.PsnName,
  14779. Idetinfo: idetinfoStr,
  14780. Insuinfo: infoStr,
  14781. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14782. CardInfo: basStr,
  14783. InsuplcAdmdvs: insuplc_admdvs,
  14784. VerifyNumber: "",
  14785. }
  14786. service.CreateHisPsn(psn)
  14787. c.ServeSuccessJSON(map[string]interface{}{
  14788. "patient": patient,
  14789. "number": basNumber,
  14790. "insutype": insutype,
  14791. })
  14792. }
  14793. } else {
  14794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14795. return
  14796. }
  14797. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14798. fmt.Println(initFlag)
  14799. fmt.Println("initFlag")
  14800. if initFlag == 0 {
  14801. c.TestGetHnBasBaseInit()
  14802. }
  14803. basStr := c.GetBasBaseInfo()
  14804. if len(basStr) == 0 {
  14805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14806. return
  14807. }
  14808. fmt.Println(basStr)
  14809. bas := strings.Split(basStr, "|")
  14810. basNumber := bas[1]
  14811. fmt.Println(basNumber)
  14812. card_sn := bas[3]
  14813. card_no := bas[2]
  14814. fmt.Println(card_sn)
  14815. name := bas[4]
  14816. name = ConvertToString(name, "gbk", "utf-8")
  14817. 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)
  14818. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14819. var dat map[string]interface{}
  14820. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14821. fmt.Println(dat)
  14822. } else {
  14823. fmt.Println(err)
  14824. }
  14825. userJSONBytes, _ := json.Marshal(dat)
  14826. var res ResultTwo
  14827. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14828. utils.ErrorLog("解析失败:%v", err)
  14829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14830. return
  14831. }
  14832. if res.Infcode == 0 {
  14833. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14834. if err == gorm.ErrRecordNotFound {
  14835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14836. return
  14837. } else if err != nil {
  14838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14839. return
  14840. } else {
  14841. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14842. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14843. infoStr := string(Iinfos)
  14844. idetinfoStr := string(Idetinfos)
  14845. psn := &models.HisPsn{
  14846. PsnNo: res.Output.Baseinfo.PsnNo,
  14847. PatientId: patient.ID,
  14848. Certno: res.Output.Baseinfo.Certno,
  14849. Gend: res.Output.Baseinfo.Gend,
  14850. Naty: res.Output.Baseinfo.Naty,
  14851. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14852. PsnName: res.Output.Baseinfo.PsnName,
  14853. Idetinfo: idetinfoStr,
  14854. Insuinfo: infoStr,
  14855. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14856. CardInfo: basStr,
  14857. VerifyNumber: "",
  14858. }
  14859. service.CreateHisPsn(psn)
  14860. var rf []*ResultFive
  14861. json.Unmarshal([]byte(infoStr), &rf)
  14862. var insutypes []*ResultFive
  14863. var insutype string
  14864. var is390 int = 0
  14865. var is310 int = 0
  14866. for _, item := range rf {
  14867. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14868. insutypes = append(insutypes, item)
  14869. }
  14870. }
  14871. if len(insutypes) == 1 {
  14872. insutype = insutypes[0].Insutype
  14873. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14874. } else {
  14875. for _, i := range insutypes {
  14876. if i.Insutype == "390" {
  14877. is390 = 1
  14878. }
  14879. if i.Insutype == "310" {
  14880. is310 = 1
  14881. }
  14882. }
  14883. }
  14884. if is390 == 1 {
  14885. insutype = "390"
  14886. }
  14887. if is310 == 1 {
  14888. insutype = "310"
  14889. }
  14890. if len(insutypes) == 0 {
  14891. insutype = "310"
  14892. }
  14893. c.ServeSuccessJSON(map[string]interface{}{
  14894. "patient": patient,
  14895. "number": basNumber,
  14896. "insutype": insutype,
  14897. })
  14898. }
  14899. } else {
  14900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14901. return
  14902. }
  14903. } else if miConfig.MdtrtareaAdmvs == "150404" {
  14904. var api string
  14905. 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 +
  14906. "&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
  14907. fmt.Println(api)
  14908. resp, requestErr := http.Get(api)
  14909. if requestErr != nil {
  14910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14911. return
  14912. }
  14913. body, ioErr := ioutil.ReadAll(resp.Body)
  14914. if ioErr != nil {
  14915. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14917. return
  14918. }
  14919. var respJSON map[string]interface{}
  14920. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14921. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14923. return
  14924. }
  14925. var res ResultTwo //1101结果
  14926. var res10265 ResultTwo10265 //1101结果
  14927. var card_info string //卡信息
  14928. token := respJSON["data"].(map[string]interface{})["token"].(string)
  14929. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14930. result, _ := json.Marshal(respJSON)
  14931. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14932. utils.ErrorLog("解析失败:%v", err)
  14933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14934. return
  14935. }
  14936. res.ErrMsg = res10265.ErrMsg
  14937. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14938. res.Infcode = infocode
  14939. res.Output = res10265.Output
  14940. res.InfRefmsgid = res10265.InfRefmsgid
  14941. if res.Infcode == 0 {
  14942. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14943. if err == gorm.ErrRecordNotFound {
  14944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14945. return
  14946. } else if err != nil {
  14947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14948. return
  14949. } else {
  14950. bas := strings.Split(card_info, "|")
  14951. basNumber := bas[2]
  14952. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14953. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14954. infoStr := string(Iinfos)
  14955. idetinfoStr := string(Idetinfos)
  14956. psn := &models.HisPsn{
  14957. PsnNo: res.Output.Baseinfo.PsnNo,
  14958. PatientId: patient.ID,
  14959. Certno: res.Output.Baseinfo.Certno,
  14960. Gend: res.Output.Baseinfo.Gend,
  14961. Naty: res.Output.Baseinfo.Naty,
  14962. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14963. PsnName: res.Output.Baseinfo.PsnName,
  14964. Idetinfo: idetinfoStr,
  14965. Insuinfo: infoStr,
  14966. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14967. CardInfo: card_info,
  14968. VerifyNumber: token,
  14969. }
  14970. service.CreateHisPsn(psn)
  14971. var rf []*ResultFive
  14972. json.Unmarshal([]byte(infoStr), &rf)
  14973. var insutypes []*ResultFive
  14974. var insutype string
  14975. var is390 int = 0
  14976. var is310 int = 0
  14977. for _, item := range rf {
  14978. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14979. insutypes = append(insutypes, item)
  14980. }
  14981. }
  14982. if len(insutypes) == 1 {
  14983. insutype = insutypes[0].Insutype
  14984. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14985. } else {
  14986. for _, i := range insutypes {
  14987. if i.Insutype == "390" {
  14988. is390 = 1
  14989. }
  14990. if i.Insutype == "310" {
  14991. is310 = 1
  14992. }
  14993. }
  14994. }
  14995. if is390 == 1 {
  14996. insutype = "390"
  14997. }
  14998. if is310 == 1 {
  14999. insutype = "310"
  15000. }
  15001. if len(insutypes) == 0 {
  15002. insutype = "310"
  15003. }
  15004. c.ServeSuccessJSON(map[string]interface{}{
  15005. "patient": patient,
  15006. "number": basNumber,
  15007. "insutype": insutype,
  15008. })
  15009. }
  15010. } else {
  15011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15012. return
  15013. }
  15014. } else if miConfig.MdtrtareaAdmvs == "450721" {
  15015. res := c.GetoleInfo()
  15016. if res.Infcode == 0 {
  15017. var result string
  15018. if res.Output.MdtrtCertType == "01" {
  15019. 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)
  15020. } else if res.Output.MdtrtCertType == "02" {
  15021. 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)
  15022. } else if res.Output.MdtrtCertType == "03" {
  15023. 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)
  15024. }
  15025. var dat map[string]interface{}
  15026. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15027. fmt.Println(dat)
  15028. } else {
  15029. fmt.Println(err)
  15030. }
  15031. userJSONBytes, _ := json.Marshal(dat)
  15032. var res2 ResultTwo
  15033. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15034. utils.ErrorLog("解析失败:%v", err)
  15035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15036. return
  15037. }
  15038. if res2.Infcode == 0 {
  15039. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  15040. if err == gorm.ErrRecordNotFound {
  15041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15042. return
  15043. } else if err != nil {
  15044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15045. return
  15046. } else {
  15047. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  15048. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  15049. infoStr := string(Iinfos)
  15050. idetinfoStr := string(Idetinfos)
  15051. var rf []*ResultFive
  15052. json.Unmarshal([]byte(infoStr), &rf)
  15053. var insutypes []*ResultFive
  15054. var insutype string
  15055. var is390 int = 0
  15056. var is310 int = 0
  15057. //var insuplc_admdvs string
  15058. for _, item := range rf {
  15059. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15060. insutypes = append(insutypes, item)
  15061. }
  15062. }
  15063. if len(insutypes) == 1 {
  15064. insutype = insutypes[0].Insutype
  15065. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15066. } else {
  15067. for _, i := range insutypes {
  15068. if i.Insutype == "390" {
  15069. is390 = 1
  15070. }
  15071. if i.Insutype == "310" {
  15072. is310 = 1
  15073. }
  15074. }
  15075. }
  15076. if is390 == 1 {
  15077. insutype = "390"
  15078. }
  15079. if is310 == 1 {
  15080. insutype = "310"
  15081. }
  15082. if len(insutypes) == 0 {
  15083. insutype = "310"
  15084. }
  15085. psn := &models.HisPsn{
  15086. PsnNo: res2.Output.Baseinfo.PsnNo,
  15087. PatientId: patient.ID,
  15088. Certno: res2.Output.Baseinfo.Certno,
  15089. Gend: res2.Output.Baseinfo.Gend,
  15090. Naty: res2.Output.Baseinfo.Naty,
  15091. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  15092. PsnName: res2.Output.Baseinfo.PsnName,
  15093. Idetinfo: idetinfoStr,
  15094. Insuinfo: infoStr,
  15095. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15096. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  15097. VerifyNumber: res.Output.EcToken,
  15098. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  15099. }
  15100. if res.Output.MdtrtCertType == "01" {
  15101. psn.VerifyNumber = res.Output.EcToken
  15102. //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)
  15103. } else if res.Output.MdtrtCertType == "02" {
  15104. psn.VerifyNumber = res.Output.MdtrtCertNo
  15105. //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)
  15106. } else if res.Output.MdtrtCertType == "03" {
  15107. psn.VerifyNumber = res.Output.MdtrtCertNo
  15108. //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)
  15109. }
  15110. var balc float64
  15111. for _, item := range rf {
  15112. if item.Insutype == insutype {
  15113. balc = item.Balc
  15114. }
  15115. }
  15116. service.CreateHisPsn(psn)
  15117. c.ServeSuccessJSON(map[string]interface{}{
  15118. "patient": patient,
  15119. "number": res.Output.CardNo,
  15120. "insutype": insutype,
  15121. "blac": balc,
  15122. "desc": idetinfoStr,
  15123. })
  15124. }
  15125. } else {
  15126. c.ServeSuccessJSON(map[string]interface{}{
  15127. "failed_code": -10,
  15128. "msg": res2.ErrMsg,
  15129. })
  15130. }
  15131. } else {
  15132. c.ServeSuccessJSON(map[string]interface{}{
  15133. "failed_code": -10,
  15134. "msg": res.ErrMsg,
  15135. })
  15136. }
  15137. } else if miConfig.MdtrtareaAdmvs == "341203" {
  15138. var api string
  15139. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15140. "&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
  15141. fmt.Println(api)
  15142. resp, requestErr := http.Get(api)
  15143. if requestErr != nil {
  15144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15145. return
  15146. }
  15147. body, ioErr := ioutil.ReadAll(resp.Body)
  15148. if ioErr != nil {
  15149. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15151. return
  15152. }
  15153. var respJSON map[string]interface{}
  15154. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15155. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15157. return
  15158. }
  15159. var status string
  15160. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15161. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15162. //console.log()
  15163. fmt.Println("type===")
  15164. fmt.Println(card_type)
  15165. var token string
  15166. var res ResultTwo //1101结果
  15167. //var res10265 ResultTwoesultTwo10265 //1101结果
  15168. var card_info string //卡信息
  15169. var busi_card_info string
  15170. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15171. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15172. if status == "0" { //读卡成功
  15173. if card_type == "1" {
  15174. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15175. result, _ := json.Marshal(respJSON)
  15176. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15177. utils.ErrorLog("解析失败:%v", err)
  15178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15179. return
  15180. }
  15181. } else {
  15182. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15183. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15184. result, _ := json.Marshal(respJSON)
  15185. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15186. utils.ErrorLog("解析失败:%v", err)
  15187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15188. return
  15189. }
  15190. }
  15191. if res.Infcode == 0 {
  15192. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15193. if err == gorm.ErrRecordNotFound {
  15194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15195. return
  15196. } else if err != nil {
  15197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15198. return
  15199. } else {
  15200. if card_type == "1" {
  15201. bas := strings.Split(card_info, "|")
  15202. basNumber := bas[2]
  15203. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15204. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15205. infoStr := string(Iinfos)
  15206. idetinfoStr := string(Idetinfos)
  15207. psn := &models.HisPsn{
  15208. PsnNo: res.Output.Baseinfo.PsnNo,
  15209. PatientId: patient.ID,
  15210. Certno: res.Output.Baseinfo.Certno,
  15211. Gend: res.Output.Baseinfo.Gend,
  15212. Naty: res.Output.Baseinfo.Naty,
  15213. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15214. PsnName: res.Output.Baseinfo.PsnName,
  15215. Idetinfo: idetinfoStr,
  15216. Insuinfo: infoStr,
  15217. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15218. CardInfo: card_info,
  15219. VerifyNumber: busi_card_info,
  15220. }
  15221. service.CreateHisPsn(psn)
  15222. var rf []*ResultFive
  15223. json.Unmarshal([]byte(infoStr), &rf)
  15224. var insutypes []*ResultFive
  15225. var insutype string
  15226. var is390 int = 0
  15227. var is310 int = 0
  15228. for _, item := range rf {
  15229. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15230. insutypes = append(insutypes, item)
  15231. }
  15232. }
  15233. if len(insutypes) == 1 {
  15234. insutype = insutypes[0].Insutype
  15235. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15236. } else {
  15237. for _, i := range insutypes {
  15238. if i.Insutype == "390" {
  15239. is390 = 1
  15240. }
  15241. if i.Insutype == "310" {
  15242. is310 = 1
  15243. }
  15244. }
  15245. }
  15246. if is390 == 1 {
  15247. insutype = "390"
  15248. }
  15249. if is310 == 1 {
  15250. insutype = "310"
  15251. }
  15252. if len(insutypes) == 0 {
  15253. insutype = "310"
  15254. }
  15255. c.ServeSuccessJSON(map[string]interface{}{
  15256. "patient": patient,
  15257. "number": basNumber,
  15258. "insutype": insutype,
  15259. })
  15260. } else {
  15261. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15262. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15263. infoStr := string(Iinfos)
  15264. idetinfoStr := string(Idetinfos)
  15265. psn := &models.HisPsn{
  15266. PsnNo: res.Output.Baseinfo.PsnNo,
  15267. PatientId: patient.ID,
  15268. Certno: res.Output.Baseinfo.Certno,
  15269. Gend: res.Output.Baseinfo.Gend,
  15270. Naty: res.Output.Baseinfo.Naty,
  15271. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15272. PsnName: res.Output.Baseinfo.PsnName,
  15273. Idetinfo: idetinfoStr,
  15274. Insuinfo: infoStr,
  15275. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15276. CardInfo: card_info,
  15277. VerifyNumber: token,
  15278. }
  15279. service.CreateHisPsn(psn)
  15280. c.ServeSuccessJSON(map[string]interface{}{
  15281. "patient": patient,
  15282. "number": token,
  15283. })
  15284. }
  15285. }
  15286. } else {
  15287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15288. return
  15289. }
  15290. } else { //读卡失败
  15291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15292. return
  15293. }
  15294. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15295. var api string
  15296. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15297. "&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
  15298. fmt.Println(api)
  15299. resp, requestErr := http.Get(api)
  15300. if requestErr != nil {
  15301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15302. return
  15303. }
  15304. body, ioErr := ioutil.ReadAll(resp.Body)
  15305. if ioErr != nil {
  15306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15308. return
  15309. }
  15310. var respJSON map[string]interface{}
  15311. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15314. return
  15315. }
  15316. var status string
  15317. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15318. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15319. //console.log()
  15320. fmt.Println("type===")
  15321. fmt.Println(card_type)
  15322. var token string
  15323. var res ResultTwo //1101结果
  15324. //var res10265 ResultTwoesultTwo10265 //1101结果
  15325. var card_info string //卡信息
  15326. //var busi_card_info string
  15327. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15328. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15329. if status == "0" { //读卡成功
  15330. if card_type == "1" {
  15331. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15332. result, _ := json.Marshal(respJSON)
  15333. fmt.Println(result)
  15334. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15335. utils.ErrorLog("解析失败:%v", err)
  15336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15337. return
  15338. }
  15339. fmt.Println(res)
  15340. } else {
  15341. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15342. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15343. result, _ := json.Marshal(respJSON)
  15344. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15345. utils.ErrorLog("解析失败:%v", err)
  15346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15347. return
  15348. }
  15349. }
  15350. if res.Infcode == 0 {
  15351. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15352. if err == gorm.ErrRecordNotFound {
  15353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15354. return
  15355. } else if err != nil {
  15356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15357. return
  15358. } else {
  15359. if card_type == "1" {
  15360. bas := strings.Split(card_info, "|")
  15361. basNumber := bas[2]
  15362. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15363. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15364. infoStr := string(Iinfos)
  15365. idetinfoStr := string(Idetinfos)
  15366. psn := &models.HisPsn{
  15367. PsnNo: res.Output.Baseinfo.PsnNo,
  15368. PatientId: patient.ID,
  15369. Certno: res.Output.Baseinfo.Certno,
  15370. Gend: res.Output.Baseinfo.Gend,
  15371. Naty: res.Output.Baseinfo.Naty,
  15372. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15373. PsnName: res.Output.Baseinfo.PsnName,
  15374. Idetinfo: idetinfoStr,
  15375. Insuinfo: infoStr,
  15376. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15377. CardInfo: card_info,
  15378. //VerifyNumber: busi_card_info,
  15379. }
  15380. service.CreateHisPsn(psn)
  15381. var rf []*ResultFive
  15382. json.Unmarshal([]byte(infoStr), &rf)
  15383. var insutypes []*ResultFive
  15384. var insutype string
  15385. var is390 int = 0
  15386. var is310 int = 0
  15387. for _, item := range rf {
  15388. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15389. insutypes = append(insutypes, item)
  15390. }
  15391. }
  15392. if len(insutypes) == 1 {
  15393. insutype = insutypes[0].Insutype
  15394. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15395. } else {
  15396. for _, i := range insutypes {
  15397. if i.Insutype == "390" {
  15398. is390 = 1
  15399. }
  15400. if i.Insutype == "310" {
  15401. is310 = 1
  15402. }
  15403. }
  15404. }
  15405. if is390 == 1 {
  15406. insutype = "390"
  15407. }
  15408. if is310 == 1 {
  15409. insutype = "310"
  15410. }
  15411. if len(insutypes) == 0 {
  15412. insutype = "310"
  15413. }
  15414. c.ServeSuccessJSON(map[string]interface{}{
  15415. "patient": patient,
  15416. "number": basNumber,
  15417. "insutype": insutype,
  15418. })
  15419. } else {
  15420. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15421. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15422. infoStr := string(Iinfos)
  15423. idetinfoStr := string(Idetinfos)
  15424. psn := &models.HisPsn{
  15425. PsnNo: res.Output.Baseinfo.PsnNo,
  15426. PatientId: patient.ID,
  15427. Certno: res.Output.Baseinfo.Certno,
  15428. Gend: res.Output.Baseinfo.Gend,
  15429. Naty: res.Output.Baseinfo.Naty,
  15430. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15431. PsnName: res.Output.Baseinfo.PsnName,
  15432. Idetinfo: idetinfoStr,
  15433. Insuinfo: infoStr,
  15434. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15435. CardInfo: card_info,
  15436. VerifyNumber: token,
  15437. }
  15438. service.CreateHisPsn(psn)
  15439. c.ServeSuccessJSON(map[string]interface{}{
  15440. "patient": patient,
  15441. "number": token,
  15442. })
  15443. }
  15444. }
  15445. } else {
  15446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15447. return
  15448. }
  15449. } else { //读卡失败
  15450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15451. return
  15452. }
  15453. } else {
  15454. if initFlag == 0 {
  15455. c.TestGetBasBaseInit()
  15456. }
  15457. basStr := c.GetBasBaseInfo()
  15458. if len(basStr) == 0 {
  15459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15460. return
  15461. }
  15462. fmt.Println(basStr)
  15463. bas := strings.Split(basStr, "|")
  15464. basNumber := bas[1]
  15465. fmt.Println(basNumber)
  15466. card_sn := bas[3]
  15467. fmt.Println(card_sn)
  15468. cardNumber := bas[2]
  15469. fmt.Println(cardNumber)
  15470. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  15471. var result string
  15472. if bas[0][:2] == "44" {
  15473. 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)
  15474. } else {
  15475. 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)
  15476. }
  15477. var dat map[string]interface{}
  15478. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15479. fmt.Println(dat)
  15480. } else {
  15481. fmt.Println(err)
  15482. }
  15483. userJSONBytes, _ := json.Marshal(dat)
  15484. var res ResultTwo
  15485. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15486. utils.ErrorLog("解析失败:%v", err)
  15487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15488. return
  15489. }
  15490. if res.Infcode == 0 {
  15491. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  15492. if err == gorm.ErrRecordNotFound {
  15493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15494. return
  15495. } else if err != nil {
  15496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15497. return
  15498. } else {
  15499. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15500. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15501. infoStr := string(Iinfos)
  15502. idetinfoStr := string(Idetinfos)
  15503. var rf []*ResultFive
  15504. json.Unmarshal([]byte(infoStr), &rf)
  15505. var insutypes []*ResultFive
  15506. var insutype string
  15507. var is390 int = 0
  15508. var is310 int = 0
  15509. var insuplc_admdvs string
  15510. for _, item := range rf {
  15511. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15512. insutypes = append(insutypes, item)
  15513. }
  15514. }
  15515. if len(insutypes) == 1 {
  15516. insutype = insutypes[0].Insutype
  15517. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15518. } else {
  15519. for _, i := range insutypes {
  15520. if i.Insutype == "390" {
  15521. is390 = 1
  15522. }
  15523. if i.Insutype == "310" {
  15524. is310 = 1
  15525. }
  15526. }
  15527. }
  15528. if is390 == 1 {
  15529. insutype = "390"
  15530. }
  15531. if is310 == 1 {
  15532. insutype = "310"
  15533. }
  15534. if len(insutypes) == 0 {
  15535. insutype = "310"
  15536. }
  15537. for _, item := range rf {
  15538. if item.Insutype == insutype {
  15539. insuplc_admdvs = item.InsuplcAdmdvs
  15540. }
  15541. }
  15542. psn := &models.HisPsn{
  15543. PsnNo: res.Output.Baseinfo.PsnNo,
  15544. PatientId: patient.ID,
  15545. Certno: res.Output.Baseinfo.Certno,
  15546. Gend: res.Output.Baseinfo.Gend,
  15547. Naty: res.Output.Baseinfo.Naty,
  15548. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15549. PsnName: res.Output.Baseinfo.PsnName,
  15550. Idetinfo: idetinfoStr,
  15551. Insuinfo: infoStr,
  15552. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15553. CardInfo: basStr,
  15554. VerifyNumber: "",
  15555. InsuplcAdmdvs: insuplc_admdvs,
  15556. }
  15557. service.CreateHisPsn(psn)
  15558. c.ServeSuccessJSON(map[string]interface{}{
  15559. "patient": patient,
  15560. "insutype": insutype,
  15561. "number": basNumber,
  15562. })
  15563. }
  15564. } else {
  15565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15566. return
  15567. }
  15568. break
  15569. }
  15570. case 2:
  15571. if miConfig.MdtrtareaAdmvs == "430800" {
  15572. if initFlag == 0 {
  15573. c.TestGetHnBasBaseInit()
  15574. }
  15575. SFZStr := c.GetSFZBaseInfo()
  15576. if len(SFZStr) == 0 {
  15577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15578. return
  15579. }
  15580. fmt.Println(SFZStr)
  15581. id_card_str := strings.Split(SFZStr, "^")
  15582. card_no := id_card_str[0]
  15583. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  15584. //name := id_card_str[1]
  15585. //name = ConvertToString(name, "gbk", "utf-8")
  15586. 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)
  15587. var dat map[string]interface{}
  15588. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15589. fmt.Println(dat)
  15590. } else {
  15591. fmt.Println(err)
  15592. }
  15593. userJSONBytes, _ := json.Marshal(dat)
  15594. var res ResultTwo
  15595. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15596. utils.ErrorLog("解析失败:%v", err)
  15597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15598. return
  15599. }
  15600. if res.Infcode == 0 {
  15601. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  15602. if err == gorm.ErrRecordNotFound {
  15603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15604. return
  15605. } else if err != nil {
  15606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15607. return
  15608. } else {
  15609. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15610. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15611. infoStr := string(Iinfos)
  15612. idetinfoStr := string(Idetinfos)
  15613. var rf []*ResultFive
  15614. json.Unmarshal([]byte(infoStr), &rf)
  15615. var insutypes []*ResultFive
  15616. var insutype string
  15617. var is390 int = 0
  15618. var is310 int = 0
  15619. for _, item := range rf {
  15620. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15621. insutypes = append(insutypes, item)
  15622. }
  15623. }
  15624. if len(insutypes) == 1 {
  15625. insutype = insutypes[0].Insutype
  15626. } else {
  15627. for _, i := range insutypes {
  15628. if i.Insutype == "390" {
  15629. is390 = 1
  15630. }
  15631. if i.Insutype == "310" {
  15632. is310 = 1
  15633. }
  15634. }
  15635. }
  15636. if is390 == 1 {
  15637. insutype = "390"
  15638. }
  15639. if is310 == 1 {
  15640. insutype = "310"
  15641. }
  15642. if len(insutypes) == 0 {
  15643. insutype = "310"
  15644. }
  15645. var InsuplcAdmdvs string
  15646. for _, item := range rf {
  15647. if item.Insutype == insutype {
  15648. InsuplcAdmdvs = item.InsuplcAdmdvs
  15649. }
  15650. }
  15651. psn := &models.HisPsn{
  15652. PsnNo: res.Output.Baseinfo.PsnNo,
  15653. PatientId: patient.ID,
  15654. Certno: res.Output.Baseinfo.Certno,
  15655. Gend: res.Output.Baseinfo.Gend,
  15656. Naty: res.Output.Baseinfo.Naty,
  15657. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15658. PsnName: res.Output.Baseinfo.PsnName,
  15659. Idetinfo: idetinfoStr,
  15660. Insuinfo: infoStr,
  15661. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15662. CardInfo: SFZStr,
  15663. VerifyNumber: "",
  15664. InsuplcAdmdvs: InsuplcAdmdvs,
  15665. }
  15666. service.CreateHisPsn(psn)
  15667. c.ServeSuccessJSON(map[string]interface{}{
  15668. "patient": patient,
  15669. "number": card_no,
  15670. "insutype": insutype,
  15671. })
  15672. }
  15673. } else {
  15674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15675. return
  15676. }
  15677. } else if miConfig.MdtrtareaAdmvs == "420200" {
  15678. var res ResultTwo
  15679. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  15680. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15681. "&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)
  15682. resp, requestErr := http.Get(api)
  15683. if requestErr != nil {
  15684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15685. return
  15686. }
  15687. body, ioErr := ioutil.ReadAll(resp.Body)
  15688. if ioErr != nil {
  15689. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15691. return
  15692. }
  15693. var respJSON map[string]interface{}
  15694. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15695. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15697. return
  15698. }
  15699. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15700. result, _ := json.Marshal(respJSON)
  15701. fmt.Println("log")
  15702. fmt.Println(string(result))
  15703. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15704. utils.ErrorLog("解析失败:%v", err)
  15705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15706. return
  15707. }
  15708. if res.Infcode == 0 {
  15709. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15710. if err == gorm.ErrRecordNotFound {
  15711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15712. return
  15713. } else if err != nil {
  15714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15715. return
  15716. } else {
  15717. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15718. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15719. infoStr := string(Iinfos)
  15720. idetinfoStr := string(Idetinfos)
  15721. psn := &models.HisPsn{
  15722. PsnNo: res.Output.Baseinfo.PsnNo,
  15723. PatientId: patient.ID,
  15724. Certno: res.Output.Baseinfo.Certno,
  15725. Gend: res.Output.Baseinfo.Gend,
  15726. Naty: res.Output.Baseinfo.Naty,
  15727. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15728. PsnName: res.Output.Baseinfo.PsnName,
  15729. Idetinfo: idetinfoStr,
  15730. Insuinfo: infoStr,
  15731. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15732. }
  15733. service.CreateHisPsn(psn)
  15734. c.ServeSuccessJSON(map[string]interface{}{
  15735. "patient": patient,
  15736. "number": res.Output.Baseinfo.Certno,
  15737. })
  15738. }
  15739. } else {
  15740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15741. return
  15742. }
  15743. } else if miConfig.MdtrtareaAdmvs == "421182" {
  15744. var res ResultTwo
  15745. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15746. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15747. "&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)
  15748. resp, requestErr := http.Get(api)
  15749. if requestErr != nil {
  15750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15751. return
  15752. }
  15753. body, ioErr := ioutil.ReadAll(resp.Body)
  15754. if ioErr != nil {
  15755. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15757. return
  15758. }
  15759. var respJSON map[string]interface{}
  15760. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15763. return
  15764. }
  15765. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15766. result, _ := json.Marshal(respJSON)
  15767. fmt.Println("log")
  15768. fmt.Println(string(result))
  15769. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15770. utils.ErrorLog("解析失败:%v", err)
  15771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15772. return
  15773. }
  15774. if res.Infcode == 0 {
  15775. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15776. if err == gorm.ErrRecordNotFound {
  15777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15778. return
  15779. } else if err != nil {
  15780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15781. return
  15782. } else {
  15783. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15784. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15785. infoStr := string(Iinfos)
  15786. idetinfoStr := string(Idetinfos)
  15787. psn := &models.HisPsn{
  15788. PsnNo: res.Output.Baseinfo.PsnNo,
  15789. PatientId: patient.ID,
  15790. Certno: res.Output.Baseinfo.Certno,
  15791. Gend: res.Output.Baseinfo.Gend,
  15792. Naty: res.Output.Baseinfo.Naty,
  15793. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15794. PsnName: res.Output.Baseinfo.PsnName,
  15795. Idetinfo: idetinfoStr,
  15796. Insuinfo: infoStr,
  15797. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15798. }
  15799. service.CreateHisPsn(psn)
  15800. c.ServeSuccessJSON(map[string]interface{}{
  15801. "patient": patient,
  15802. "number": res.Output.Baseinfo.Certno,
  15803. })
  15804. }
  15805. } else {
  15806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15807. return
  15808. }
  15809. } else if miConfig.MdtrtareaAdmvs == "420902" {
  15810. var res ResultTwo
  15811. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15812. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15813. "&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)
  15814. resp, requestErr := http.Get(api)
  15815. if requestErr != nil {
  15816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15817. return
  15818. }
  15819. body, ioErr := ioutil.ReadAll(resp.Body)
  15820. if ioErr != nil {
  15821. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15823. return
  15824. }
  15825. var respJSON map[string]interface{}
  15826. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15827. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15829. return
  15830. }
  15831. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15832. result, _ := json.Marshal(respJSON)
  15833. fmt.Println("log")
  15834. fmt.Println(string(result))
  15835. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15836. utils.ErrorLog("解析失败:%v", err)
  15837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15838. return
  15839. }
  15840. if res.Infcode == 0 {
  15841. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15842. if err == gorm.ErrRecordNotFound {
  15843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15844. return
  15845. } else if err != nil {
  15846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15847. return
  15848. } else {
  15849. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15850. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15851. infoStr := string(Iinfos)
  15852. idetinfoStr := string(Idetinfos)
  15853. var rf []*ResultFive
  15854. json.Unmarshal([]byte(infoStr), &rf)
  15855. var insutypes []*ResultFive
  15856. var insutype string
  15857. var is390 int = 0
  15858. var is310 int = 0
  15859. for _, item := range rf {
  15860. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  15861. insutypes = append(insutypes, item)
  15862. }
  15863. }
  15864. if len(insutypes) == 1 {
  15865. insutype = insutypes[0].Insutype
  15866. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15867. } else {
  15868. for _, i := range insutypes {
  15869. if i.Insutype == "390" {
  15870. is390 = 1
  15871. }
  15872. if i.Insutype == "310" {
  15873. is310 = 1
  15874. }
  15875. }
  15876. }
  15877. if is390 == 1 {
  15878. insutype = "390"
  15879. }
  15880. if is310 == 1 {
  15881. insutype = "310"
  15882. }
  15883. if len(insutypes) == 0 {
  15884. insutype = "390"
  15885. }
  15886. var insuplc_admdvs string
  15887. for _, item := range rf {
  15888. if item.Insutype == insutype {
  15889. insuplc_admdvs = item.InsuplcAdmdvs
  15890. }
  15891. }
  15892. psn := &models.HisPsn{
  15893. PsnNo: res.Output.Baseinfo.PsnNo,
  15894. PatientId: patient.ID,
  15895. Certno: res.Output.Baseinfo.Certno,
  15896. Gend: res.Output.Baseinfo.Gend,
  15897. Naty: res.Output.Baseinfo.Naty,
  15898. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15899. PsnName: res.Output.Baseinfo.PsnName,
  15900. Idetinfo: idetinfoStr,
  15901. Insuinfo: infoStr,
  15902. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15903. InsuplcAdmdvs: insuplc_admdvs,
  15904. }
  15905. service.CreateHisPsn(psn)
  15906. c.ServeSuccessJSON(map[string]interface{}{
  15907. "patient": patient,
  15908. "number": res.Output.Baseinfo.Certno,
  15909. })
  15910. }
  15911. } else {
  15912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15913. return
  15914. }
  15915. } else if miConfig.MdtrtareaAdmvs == "450721" {
  15916. res := c.GetoleInfo()
  15917. if res.Infcode == 0 {
  15918. var result string
  15919. if res.Output.MdtrtCertType == "01" {
  15920. 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)
  15921. } else if res.Output.MdtrtCertType == "02" {
  15922. 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)
  15923. } else if res.Output.MdtrtCertType == "03" {
  15924. 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)
  15925. }
  15926. var dat map[string]interface{}
  15927. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15928. fmt.Println(dat)
  15929. } else {
  15930. fmt.Println(err)
  15931. }
  15932. userJSONBytes, _ := json.Marshal(dat)
  15933. var res2 ResultTwo
  15934. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15935. utils.ErrorLog("解析失败:%v", err)
  15936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15937. return
  15938. }
  15939. if res2.Infcode == 0 {
  15940. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  15941. if err == gorm.ErrRecordNotFound {
  15942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15943. return
  15944. } else if err != nil {
  15945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15946. return
  15947. } else {
  15948. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  15949. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  15950. infoStr := string(Iinfos)
  15951. idetinfoStr := string(Idetinfos)
  15952. var rf []*ResultFive
  15953. json.Unmarshal([]byte(infoStr), &rf)
  15954. var insutypes []*ResultFive
  15955. var insutype string
  15956. var is390 int = 0
  15957. var is310 int = 0
  15958. //var insuplc_admdvs string
  15959. for _, item := range rf {
  15960. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15961. insutypes = append(insutypes, item)
  15962. }
  15963. }
  15964. if len(insutypes) == 1 {
  15965. insutype = insutypes[0].Insutype
  15966. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15967. } else {
  15968. for _, i := range insutypes {
  15969. if i.Insutype == "390" {
  15970. is390 = 1
  15971. }
  15972. if i.Insutype == "310" {
  15973. is310 = 1
  15974. }
  15975. }
  15976. }
  15977. if is390 == 1 {
  15978. insutype = "390"
  15979. }
  15980. if is310 == 1 {
  15981. insutype = "310"
  15982. }
  15983. if len(insutypes) == 0 {
  15984. insutype = "310"
  15985. }
  15986. psn := &models.HisPsn{
  15987. PsnNo: res2.Output.Baseinfo.PsnNo,
  15988. PatientId: patient.ID,
  15989. //Brdy: res2.Output.Baseinfo.Brdy,
  15990. Certno: res2.Output.Baseinfo.Certno,
  15991. Gend: res2.Output.Baseinfo.Gend,
  15992. Naty: res2.Output.Baseinfo.Naty,
  15993. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  15994. PsnName: res2.Output.Baseinfo.PsnName,
  15995. Idetinfo: idetinfoStr,
  15996. Insuinfo: infoStr,
  15997. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15998. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  15999. VerifyNumber: res.Output.EcToken,
  16000. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  16001. }
  16002. service.CreateHisPsn(psn)
  16003. var balc float64
  16004. for _, item := range rf {
  16005. if item.Insutype == insutype {
  16006. balc = item.Balc
  16007. }
  16008. }
  16009. c.ServeSuccessJSON(map[string]interface{}{
  16010. "patient": patient,
  16011. "number": res.Output.CardNo,
  16012. "insutype": insutype,
  16013. "blac": balc,
  16014. "desc": idetinfoStr,
  16015. })
  16016. }
  16017. } else {
  16018. c.ServeSuccessJSON(map[string]interface{}{
  16019. "failed_code": -10,
  16020. "msg": res2.ErrMsg,
  16021. })
  16022. }
  16023. } else {
  16024. c.ServeSuccessJSON(map[string]interface{}{
  16025. "failed_code": -10,
  16026. "msg": res.ErrMsg,
  16027. })
  16028. }
  16029. } else if miConfig.MdtrtareaAdmvs == "340699" {
  16030. var insuplc_admdvs string
  16031. if len(patient.InsuplcAdmdvs) > 0 {
  16032. insuplc_admdvs = patient.InsuplcAdmdvs
  16033. } else {
  16034. if len(insuplc_admdvs_str) > 0 {
  16035. insuplc_admdvs = insuplc_admdvs_str
  16036. } else {
  16037. insuplc_admdvs = miConfig.InsuplcAdmdvs
  16038. }
  16039. }
  16040. //请求内网数据
  16041. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  16042. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16043. "&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=" + ""
  16044. resp, requestErr := http.Get(api)
  16045. if requestErr != nil {
  16046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16047. return
  16048. }
  16049. body, ioErr := ioutil.ReadAll(resp.Body)
  16050. if ioErr != nil {
  16051. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16053. return
  16054. }
  16055. var respJSON map[string]interface{}
  16056. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16059. return
  16060. }
  16061. status := respJSON["data"].(map[string]interface{})["status"].(string)
  16062. if status == "0" {
  16063. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  16064. c.ServeSuccessJSON(map[string]interface{}{
  16065. "failed_code": -10,
  16066. "msg": err_msg,
  16067. })
  16068. return
  16069. }
  16070. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16071. var res ResultTwo
  16072. result, _ := json.Marshal(respJSON)
  16073. fmt.Println("log")
  16074. fmt.Println(string(result))
  16075. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16076. utils.ErrorLog("解析失败:%v", err)
  16077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16078. return
  16079. }
  16080. if res.Infcode == 0 {
  16081. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16082. if err == gorm.ErrRecordNotFound {
  16083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16084. return
  16085. } else if err != nil {
  16086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16087. return
  16088. } else {
  16089. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16090. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16091. infoStr := string(Iinfos)
  16092. idetinfoStr := string(Idetinfos)
  16093. psn := &models.HisPsn{
  16094. PsnNo: res.Output.Baseinfo.PsnNo,
  16095. PatientId: patient.ID,
  16096. Certno: res.Output.Baseinfo.Certno,
  16097. Gend: res.Output.Baseinfo.Gend,
  16098. Naty: res.Output.Baseinfo.Naty,
  16099. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16100. PsnName: res.Output.Baseinfo.PsnName,
  16101. Idetinfo: idetinfoStr,
  16102. Insuinfo: infoStr,
  16103. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16104. }
  16105. service.CreateHisPsn(psn)
  16106. var rf []*ResultFive
  16107. json.Unmarshal([]byte(infoStr), &rf)
  16108. var insutypes []*ResultFive
  16109. var is390 int = 0
  16110. var is310 int = 0
  16111. var insutype string
  16112. for _, item := range rf {
  16113. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16114. insutypes = append(insutypes, item)
  16115. }
  16116. }
  16117. if len(insutypes) == 1 {
  16118. insutype = insutypes[0].Insutype
  16119. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16120. } else {
  16121. for _, i := range insutypes {
  16122. if i.Insutype == "390" {
  16123. is390 = 1
  16124. }
  16125. if i.Insutype == "310" {
  16126. is310 = 1
  16127. }
  16128. }
  16129. }
  16130. if is390 == 1 {
  16131. insutype = "390"
  16132. }
  16133. if is310 == 1 {
  16134. insutype = "310"
  16135. }
  16136. if len(insutypes) == 0 {
  16137. insutype = "390"
  16138. }
  16139. c.ServeSuccessJSON(map[string]interface{}{
  16140. "patient": patient,
  16141. "insutype": insutype,
  16142. "number": res.Output.Baseinfo.Certno,
  16143. "info": res,
  16144. })
  16145. }
  16146. } else {
  16147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16148. return
  16149. }
  16150. } else {
  16151. SFZStr := c.GetSFZBaseInfo()
  16152. id_card_str := strings.Split(SFZStr, "^")
  16153. id_card_number := id_card_str[0]
  16154. card_sn := ""
  16155. 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)
  16156. var dat map[string]interface{}
  16157. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16158. fmt.Println(dat)
  16159. } else {
  16160. fmt.Println(err)
  16161. }
  16162. userJSONBytes, _ := json.Marshal(dat)
  16163. var res ResultTwo
  16164. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16165. utils.ErrorLog("解析失败:%v", err)
  16166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16167. return
  16168. }
  16169. if res.Infcode == 0 {
  16170. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  16171. if err == gorm.ErrRecordNotFound {
  16172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16173. return
  16174. } else if err != nil {
  16175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16176. return
  16177. } else {
  16178. c.ServeSuccessJSON(map[string]interface{}{
  16179. "patient": patient,
  16180. "number": id_card_number,
  16181. })
  16182. }
  16183. } else {
  16184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16185. return
  16186. }
  16187. }
  16188. break
  16189. case 3:
  16190. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  16191. var api string
  16192. if miConfig.MdtrtareaAdmvs == "320830" {
  16193. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16194. "&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
  16195. fmt.Println(api)
  16196. } else if miConfig.MdtrtareaAdmvs == "320921" {
  16197. 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 +
  16198. "&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
  16199. fmt.Println(api)
  16200. } else {
  16201. 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 +
  16202. "&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)
  16203. }
  16204. resp, requestErr := http.Get(api)
  16205. if requestErr != nil {
  16206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16207. return
  16208. }
  16209. body, ioErr := ioutil.ReadAll(resp.Body)
  16210. if ioErr != nil {
  16211. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16213. return
  16214. }
  16215. var respJSON map[string]interface{}
  16216. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16217. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16219. return
  16220. }
  16221. var status string
  16222. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16223. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16224. var token string
  16225. var res ResultTwo //1101结果
  16226. var res10265 ResultTwo10265 //1101结果
  16227. var card_info string //卡信息
  16228. var busi_card_info string
  16229. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16230. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16231. if status == "0" { //读卡成功
  16232. if card_type == "1" {
  16233. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16234. result, _ := json.Marshal(respJSON)
  16235. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16236. utils.ErrorLog("解析失败:%v", err)
  16237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16238. return
  16239. }
  16240. res.ErrMsg = res10265.ErrMsg
  16241. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16242. res.Infcode = infocode
  16243. res.Output = res10265.Output
  16244. res.InfRefmsgid = res10265.InfRefmsgid
  16245. } else {
  16246. //var card_info string //卡信息
  16247. //var busi_card_info string
  16248. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16249. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16250. //fmt.Println(card_info)
  16251. //fmt.Println(busi_card_info)
  16252. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16253. result, _ := json.Marshal(respJSON)
  16254. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16255. utils.ErrorLog("解析失败:%v", err)
  16256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16257. return
  16258. }
  16259. res.ErrMsg = res10265.ErrMsg
  16260. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16261. res.Infcode = infocode
  16262. res.Output = res10265.Output
  16263. res.InfRefmsgid = res10265.InfRefmsgid
  16264. }
  16265. if res.Infcode == 0 {
  16266. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16267. if err == gorm.ErrRecordNotFound {
  16268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16269. return
  16270. } else if err != nil {
  16271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16272. return
  16273. } else {
  16274. if card_type == "1" {
  16275. bas := strings.Split(card_info, "|")
  16276. basNumber := bas[2]
  16277. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16278. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16279. infoStr := string(Iinfos)
  16280. idetinfoStr := string(Idetinfos)
  16281. psn := &models.HisPsn{
  16282. PsnNo: res.Output.Baseinfo.PsnNo,
  16283. PatientId: patient.ID,
  16284. Certno: res.Output.Baseinfo.Certno,
  16285. //Brdy: res.Output.Baseinfo.Brdy,
  16286. Gend: res.Output.Baseinfo.Gend,
  16287. Naty: res.Output.Baseinfo.Naty,
  16288. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16289. PsnName: res.Output.Baseinfo.PsnName,
  16290. Idetinfo: idetinfoStr,
  16291. Insuinfo: infoStr,
  16292. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16293. CardInfo: card_info,
  16294. VerifyNumber: busi_card_info,
  16295. }
  16296. service.CreateHisPsn(psn)
  16297. c.ServeSuccessJSON(map[string]interface{}{
  16298. "patient": patient,
  16299. "number": basNumber,
  16300. })
  16301. } else {
  16302. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16303. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16304. infoStr := string(Iinfos)
  16305. idetinfoStr := string(Idetinfos)
  16306. psn := &models.HisPsn{
  16307. PsnNo: res.Output.Baseinfo.PsnNo,
  16308. PatientId: patient.ID,
  16309. Certno: res.Output.Baseinfo.Certno,
  16310. Gend: res.Output.Baseinfo.Gend,
  16311. Naty: res.Output.Baseinfo.Naty,
  16312. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16313. PsnName: res.Output.Baseinfo.PsnName,
  16314. Idetinfo: idetinfoStr,
  16315. Insuinfo: infoStr,
  16316. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16317. CardInfo: card_info,
  16318. VerifyNumber: token,
  16319. }
  16320. service.CreateHisPsn(psn)
  16321. var rf []*ResultFive
  16322. json.Unmarshal([]byte(infoStr), &rf)
  16323. var insutypes []*ResultFive
  16324. var insutype string
  16325. var is390 int = 0
  16326. var is310 int = 0
  16327. for _, item := range rf {
  16328. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16329. insutypes = append(insutypes, item)
  16330. }
  16331. }
  16332. if len(insutypes) == 1 {
  16333. insutype = insutypes[0].Insutype
  16334. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16335. } else {
  16336. for _, i := range insutypes {
  16337. if i.Insutype == "390" {
  16338. is390 = 1
  16339. }
  16340. if i.Insutype == "310" {
  16341. is310 = 1
  16342. }
  16343. }
  16344. }
  16345. if is390 == 1 {
  16346. insutype = "390"
  16347. }
  16348. if is310 == 1 {
  16349. insutype = "310"
  16350. }
  16351. if len(insutypes) == 0 {
  16352. insutype = "310"
  16353. }
  16354. c.ServeSuccessJSON(map[string]interface{}{
  16355. "patient": patient,
  16356. "number": token,
  16357. "insutype": insutype,
  16358. })
  16359. }
  16360. }
  16361. } else {
  16362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16363. return
  16364. }
  16365. } else { //读卡失败
  16366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16367. return
  16368. }
  16369. }
  16370. break
  16371. case 4:
  16372. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  16373. var api string
  16374. if miConfig.MdtrtareaAdmvs == "320830" {
  16375. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16376. "&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
  16377. fmt.Println(api)
  16378. } else if miConfig.MdtrtareaAdmvs == "320921" {
  16379. 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 +
  16380. "&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
  16381. fmt.Println(api)
  16382. } else {
  16383. 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 +
  16384. "&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)
  16385. }
  16386. resp, requestErr := http.Get(api)
  16387. if requestErr != nil {
  16388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16389. return
  16390. }
  16391. body, ioErr := ioutil.ReadAll(resp.Body)
  16392. if ioErr != nil {
  16393. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16395. return
  16396. }
  16397. var respJSON map[string]interface{}
  16398. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16401. return
  16402. }
  16403. var status string
  16404. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16405. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16406. var token string
  16407. var res ResultTwo //1101结果
  16408. var res10265 ResultTwo10265 //1101结果
  16409. if status == "0" { //读卡成功
  16410. var card_info string //卡信息
  16411. var busi_card_info string
  16412. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16413. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16414. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16415. fmt.Println(card_info)
  16416. fmt.Println(busi_card_info)
  16417. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16418. result, _ := json.Marshal(respJSON)
  16419. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16420. utils.ErrorLog("解析失败:%v", err)
  16421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16422. return
  16423. }
  16424. res.ErrMsg = res10265.ErrMsg
  16425. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16426. res.Infcode = infocode
  16427. res.Output = res10265.Output
  16428. res.InfRefmsgid = res10265.InfRefmsgid
  16429. if res.Infcode == 0 {
  16430. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16431. if err == gorm.ErrRecordNotFound {
  16432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16433. return
  16434. } else if err != nil {
  16435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16436. return
  16437. } else {
  16438. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16439. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16440. infoStr := string(Iinfos)
  16441. idetinfoStr := string(Idetinfos)
  16442. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16443. psn := &models.HisPsn{
  16444. PsnNo: res.Output.Baseinfo.PsnNo,
  16445. PatientId: patient.ID,
  16446. Certno: res.Output.Baseinfo.Certno,
  16447. Brdy: b,
  16448. Age: float64(age),
  16449. //Brdy: res.Output.Baseinfo.Brdy,
  16450. Gend: res.Output.Baseinfo.Gend,
  16451. Naty: res.Output.Baseinfo.Naty,
  16452. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16453. PsnName: res.Output.Baseinfo.PsnName,
  16454. Idetinfo: idetinfoStr,
  16455. Insuinfo: infoStr,
  16456. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16457. CardInfo: card_info,
  16458. VerifyNumber: token,
  16459. }
  16460. var rf []*ResultFive
  16461. json.Unmarshal([]byte(infoStr), &rf)
  16462. var insutypes []*ResultFive
  16463. var insutype string
  16464. var is390 int = 0
  16465. var is310 int = 0
  16466. for _, item := range rf {
  16467. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16468. insutypes = append(insutypes, item)
  16469. }
  16470. }
  16471. if len(insutypes) == 1 {
  16472. insutype = insutypes[0].Insutype
  16473. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16474. } else {
  16475. for _, i := range insutypes {
  16476. if i.Insutype == "390" {
  16477. is390 = 1
  16478. }
  16479. if i.Insutype == "310" {
  16480. is310 = 1
  16481. }
  16482. }
  16483. }
  16484. if is390 == 1 {
  16485. insutype = "390"
  16486. }
  16487. if is310 == 1 {
  16488. insutype = "310"
  16489. }
  16490. if len(insutypes) == 0 {
  16491. insutype = "310"
  16492. }
  16493. service.CreateHisPsn(psn)
  16494. c.ServeSuccessJSON(map[string]interface{}{
  16495. "patient": patient,
  16496. "number": token,
  16497. "insutype": insutype,
  16498. })
  16499. }
  16500. } else {
  16501. c.ServeSuccessJSON(map[string]interface{}{
  16502. "failed_code": -10,
  16503. "msg": res.ErrMsg,
  16504. })
  16505. }
  16506. } else { //读卡失败
  16507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16508. return
  16509. }
  16510. } else if miConfig.MdtrtareaAdmvs == "341203" {
  16511. var api string
  16512. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16513. "&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
  16514. resp, requestErr := http.Get(api)
  16515. if requestErr != nil {
  16516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16517. return
  16518. }
  16519. body, ioErr := ioutil.ReadAll(resp.Body)
  16520. if ioErr != nil {
  16521. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16523. return
  16524. }
  16525. var respJSON map[string]interface{}
  16526. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16527. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16529. return
  16530. }
  16531. var status string
  16532. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16533. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16534. var token string
  16535. var res ResultTwo //1101结果
  16536. if status == "1" { //读卡成功
  16537. var card_info string //卡信息
  16538. var busi_card_info string
  16539. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16540. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16541. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16542. fmt.Println(card_info)
  16543. fmt.Println(busi_card_info)
  16544. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16545. result, _ := json.Marshal(respJSON)
  16546. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16547. utils.ErrorLog("解析失败:%v", err)
  16548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16549. return
  16550. }
  16551. if res.Infcode == 0 {
  16552. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16553. if err == gorm.ErrRecordNotFound {
  16554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16555. return
  16556. } else if err != nil {
  16557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16558. return
  16559. } else {
  16560. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16561. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16562. infoStr := string(Iinfos)
  16563. idetinfoStr := string(Idetinfos)
  16564. psn := &models.HisPsn{
  16565. PsnNo: res.Output.Baseinfo.PsnNo,
  16566. PatientId: patient.ID,
  16567. Certno: res.Output.Baseinfo.Certno,
  16568. Gend: res.Output.Baseinfo.Gend,
  16569. Naty: res.Output.Baseinfo.Naty,
  16570. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16571. PsnName: res.Output.Baseinfo.PsnName,
  16572. Idetinfo: idetinfoStr,
  16573. Insuinfo: infoStr,
  16574. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16575. CardInfo: card_info,
  16576. VerifyNumber: token,
  16577. }
  16578. var rf []*ResultFive
  16579. json.Unmarshal([]byte(infoStr), &rf)
  16580. var insutypes []*ResultFive
  16581. var insutype string
  16582. var is390 int = 0
  16583. var is310 int = 0
  16584. for _, item := range rf {
  16585. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16586. insutypes = append(insutypes, item)
  16587. }
  16588. }
  16589. if len(insutypes) == 1 {
  16590. insutype = insutypes[0].Insutype
  16591. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16592. } else {
  16593. for _, i := range insutypes {
  16594. if i.Insutype == "390" {
  16595. is390 = 1
  16596. }
  16597. if i.Insutype == "310" {
  16598. is310 = 1
  16599. }
  16600. }
  16601. }
  16602. if is390 == 1 {
  16603. insutype = "390"
  16604. }
  16605. if is310 == 1 {
  16606. insutype = "310"
  16607. }
  16608. if len(insutypes) == 0 {
  16609. insutype = "310"
  16610. }
  16611. service.CreateHisPsn(psn)
  16612. c.ServeSuccessJSON(map[string]interface{}{
  16613. "patient": patient,
  16614. "number": token,
  16615. "insutype": insutype,
  16616. })
  16617. }
  16618. } else {
  16619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16620. return
  16621. }
  16622. } else { //读卡失败
  16623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16624. return
  16625. }
  16626. } else if miConfig.MdtrtareaAdmvs == "340699" {
  16627. var api string
  16628. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16629. "&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
  16630. resp, requestErr := http.Get(api)
  16631. if requestErr != nil {
  16632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16633. return
  16634. }
  16635. body, ioErr := ioutil.ReadAll(resp.Body)
  16636. if ioErr != nil {
  16637. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16639. return
  16640. }
  16641. var respJSON map[string]interface{}
  16642. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16643. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16645. return
  16646. }
  16647. var status string
  16648. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16649. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16650. var token string
  16651. var res ResultTwo //1101结果
  16652. if status == "1" { //读卡成功
  16653. var card_info string //卡信息
  16654. var busi_card_info string
  16655. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16656. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16657. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16658. fmt.Println(card_info)
  16659. fmt.Println(busi_card_info)
  16660. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16661. result, _ := json.Marshal(respJSON)
  16662. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16663. utils.ErrorLog("解析失败:%v", err)
  16664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16665. return
  16666. }
  16667. if res.Infcode == 0 {
  16668. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16669. if err == gorm.ErrRecordNotFound {
  16670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16671. return
  16672. } else if err != nil {
  16673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16674. return
  16675. } else {
  16676. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16677. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16678. infoStr := string(Iinfos)
  16679. idetinfoStr := string(Idetinfos)
  16680. psn := &models.HisPsn{
  16681. PsnNo: res.Output.Baseinfo.PsnNo,
  16682. PatientId: patient.ID,
  16683. Certno: res.Output.Baseinfo.Certno,
  16684. Gend: res.Output.Baseinfo.Gend,
  16685. Naty: res.Output.Baseinfo.Naty,
  16686. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16687. PsnName: res.Output.Baseinfo.PsnName,
  16688. Idetinfo: idetinfoStr,
  16689. Insuinfo: infoStr,
  16690. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16691. CardInfo: card_info,
  16692. VerifyNumber: token,
  16693. }
  16694. var rf []*ResultFive
  16695. json.Unmarshal([]byte(infoStr), &rf)
  16696. var insutypes []*ResultFive
  16697. var insutype string
  16698. var is390 int = 0
  16699. var is310 int = 0
  16700. for _, item := range rf {
  16701. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16702. insutypes = append(insutypes, item)
  16703. }
  16704. }
  16705. if len(insutypes) == 1 {
  16706. insutype = insutypes[0].Insutype
  16707. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16708. } else {
  16709. for _, i := range insutypes {
  16710. if i.Insutype == "390" {
  16711. is390 = 1
  16712. }
  16713. if i.Insutype == "310" {
  16714. is310 = 1
  16715. }
  16716. }
  16717. }
  16718. if is390 == 1 {
  16719. insutype = "390"
  16720. }
  16721. if is310 == 1 {
  16722. insutype = "310"
  16723. }
  16724. if len(insutypes) == 0 {
  16725. insutype = "390"
  16726. }
  16727. service.CreateHisPsn(psn)
  16728. c.ServeSuccessJSON(map[string]interface{}{
  16729. "patient": patient,
  16730. "number": token,
  16731. "insutype": insutype,
  16732. })
  16733. }
  16734. } else {
  16735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16736. return
  16737. }
  16738. } else { //读卡失败
  16739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16740. return
  16741. }
  16742. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16743. //idNo := c.GetString("idNo")
  16744. //userName := c.GetString("userName")
  16745. //ecToken := c.GetString("ecToken")
  16746. //insuOrg := c.GetString("insuOrg")
  16747. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  16748. utils.ErrorLog("解析失败:%v", json_result)
  16749. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16750. type ELeData struct {
  16751. Data struct {
  16752. IdNo string `json:"idNo"`
  16753. IdType string `json:"idType"`
  16754. UserName string `json:"userName"`
  16755. EcToken string `json:"ecToken"`
  16756. InsuOrg string `json:"insuOrg"`
  16757. Gender string `json:"gender"`
  16758. Birthday string `json:"birthday"`
  16759. Nationality string `json:"nationality"`
  16760. Email string `json:"email"`
  16761. Extra string `json:"extra"`
  16762. } `json:"data"`
  16763. Code int `json:"code"`
  16764. Message string `json:"message"`
  16765. }
  16766. var ele ELeData
  16767. err := json.Unmarshal([]byte(json_result), &ele)
  16768. if err != nil {
  16769. utils.ErrorLog("解析失败:%v", err)
  16770. }
  16771. token := ele.Data.EcToken
  16772. token = Remove0000(token)
  16773. 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)
  16774. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16775. var res ResultTwo
  16776. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16777. utils.ErrorLog("解析失败:%v", err)
  16778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16779. return
  16780. }
  16781. if res.Infcode == 0 {
  16782. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16783. if err == gorm.ErrRecordNotFound {
  16784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16785. return
  16786. } else if err != nil {
  16787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16788. return
  16789. } else {
  16790. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16791. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16792. infoStr := string(Iinfos)
  16793. idetinfoStr := string(Idetinfos)
  16794. psn := &models.HisPsn{
  16795. PsnNo: res.Output.Baseinfo.PsnNo,
  16796. PatientId: patient.ID,
  16797. Certno: res.Output.Baseinfo.Certno,
  16798. Gend: res.Output.Baseinfo.Gend,
  16799. Naty: res.Output.Baseinfo.Naty,
  16800. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16801. PsnName: res.Output.Baseinfo.PsnName,
  16802. Idetinfo: idetinfoStr,
  16803. Insuinfo: infoStr,
  16804. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16805. CardInfo: "",
  16806. Stage: "1",
  16807. VerifyNumber: token,
  16808. InsuplcAdmdvs: ele.Data.InsuOrg,
  16809. }
  16810. service.CreateHisPsn(psn)
  16811. var rf []*ResultFive
  16812. json.Unmarshal([]byte(infoStr), &rf)
  16813. var insutypes []*ResultFive
  16814. var insutype string
  16815. var is390 int = 0
  16816. var is310 int = 0
  16817. for _, item := range rf {
  16818. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16819. insutypes = append(insutypes, item)
  16820. }
  16821. }
  16822. if len(insutypes) == 1 {
  16823. insutype = insutypes[0].Insutype
  16824. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16825. } else {
  16826. for _, i := range insutypes {
  16827. if i.Insutype == "390" {
  16828. is390 = 1
  16829. }
  16830. if i.Insutype == "310" {
  16831. is310 = 1
  16832. }
  16833. }
  16834. }
  16835. if is390 == 1 {
  16836. insutype = "390"
  16837. }
  16838. if is310 == 1 {
  16839. insutype = "310"
  16840. }
  16841. if len(insutypes) == 0 {
  16842. insutype = "310"
  16843. }
  16844. c.ServeSuccessJSON(map[string]interface{}{
  16845. "patient": patient,
  16846. "number": token,
  16847. "insutype": insutype,
  16848. })
  16849. }
  16850. } else {
  16851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16852. return
  16853. }
  16854. } else if miConfig.MdtrtareaAdmvs == "360302" {
  16855. //if initFlag == 0 {
  16856. //c.TestGetJiangXiBasBaseInit()
  16857. //}
  16858. //if initEleFlag == 0 {
  16859. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16860. //}
  16861. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16862. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16863. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16864. type ELeData struct {
  16865. Data struct {
  16866. IdNo string `json:"idNo"`
  16867. IdType string `json:"idType"`
  16868. UserName string `json:"userName"`
  16869. EcToken string `json:"ecToken"`
  16870. InsuOrg string `json:"insuOrg"`
  16871. Gender string `json:"gender"`
  16872. Birthday string `json:"birthday"`
  16873. Nationality string `json:"nationality"`
  16874. Email string `json:"email"`
  16875. Extra string `json:"extra"`
  16876. } `json:"data"`
  16877. Code int `json:"code"`
  16878. Message string `json:"message"`
  16879. }
  16880. var ele ELeData
  16881. err := json.Unmarshal([]byte(result), &ele)
  16882. if err != nil {
  16883. utils.ErrorLog("解析失败:%v", err)
  16884. }
  16885. token := ele.Data.EcToken
  16886. token = Remove0000(token)
  16887. 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)
  16888. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16889. var res ResultTwo
  16890. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16891. utils.ErrorLog("解析失败:%v", err)
  16892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16893. return
  16894. }
  16895. if res.Infcode == 0 {
  16896. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16897. if err == gorm.ErrRecordNotFound {
  16898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16899. return
  16900. } else if err != nil {
  16901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16902. return
  16903. } else {
  16904. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16905. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16906. infoStr := string(Iinfos)
  16907. idetinfoStr := string(Idetinfos)
  16908. psn := &models.HisPsn{
  16909. PsnNo: res.Output.Baseinfo.PsnNo,
  16910. PatientId: patient.ID,
  16911. Certno: res.Output.Baseinfo.Certno,
  16912. Gend: res.Output.Baseinfo.Gend,
  16913. Naty: res.Output.Baseinfo.Naty,
  16914. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16915. PsnName: res.Output.Baseinfo.PsnName,
  16916. Idetinfo: idetinfoStr,
  16917. Insuinfo: infoStr,
  16918. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16919. CardInfo: "",
  16920. VerifyNumber: token,
  16921. InsuplcAdmdvs: ele.Data.InsuOrg,
  16922. }
  16923. service.CreateHisPsn(psn)
  16924. var rf []*ResultFive
  16925. json.Unmarshal([]byte(infoStr), &rf)
  16926. var insutypes []*ResultFive
  16927. var insutype string
  16928. var is390 int = 0
  16929. var is310 int = 0
  16930. for _, item := range rf {
  16931. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16932. insutypes = append(insutypes, item)
  16933. }
  16934. }
  16935. if len(insutypes) == 1 {
  16936. insutype = insutypes[0].Insutype
  16937. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16938. } else {
  16939. for _, i := range insutypes {
  16940. if i.Insutype == "390" {
  16941. is390 = 1
  16942. }
  16943. if i.Insutype == "310" {
  16944. is310 = 1
  16945. }
  16946. }
  16947. }
  16948. if is390 == 1 {
  16949. insutype = "390"
  16950. }
  16951. if is310 == 1 {
  16952. insutype = "310"
  16953. }
  16954. if len(insutypes) == 0 {
  16955. insutype = "310"
  16956. }
  16957. c.ServeSuccessJSON(map[string]interface{}{
  16958. "patient": patient,
  16959. "number": token,
  16960. "insutype": insutype,
  16961. })
  16962. }
  16963. } else {
  16964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16965. return
  16966. }
  16967. } else if miConfig.MdtrtareaAdmvs == "361025" {
  16968. //if initFlag == 0 {
  16969. //c.TestGetJiangXiBasBaseInit()
  16970. //}
  16971. //if initEleFlag == 0 {
  16972. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16973. //}
  16974. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16975. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16976. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16977. type ELeData struct {
  16978. Data struct {
  16979. IdNo string `json:"idNo"`
  16980. IdType string `json:"idType"`
  16981. UserName string `json:"userName"`
  16982. EcToken string `json:"ecToken"`
  16983. InsuOrg string `json:"insuOrg"`
  16984. Gender string `json:"gender"`
  16985. Birthday string `json:"birthday"`
  16986. Nationality string `json:"nationality"`
  16987. Email string `json:"email"`
  16988. Extra string `json:"extra"`
  16989. } `json:"data"`
  16990. Code int `json:"code"`
  16991. Message string `json:"message"`
  16992. }
  16993. var ele ELeData
  16994. err := json.Unmarshal([]byte(result), &ele)
  16995. if err != nil {
  16996. utils.ErrorLog("解析失败:%v", err)
  16997. }
  16998. token := ele.Data.EcToken
  16999. token = Remove0000(token)
  17000. 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)
  17001. saveLog(result2, requestLog2, "1101", "获取人员信息")
  17002. var res ResultTwo
  17003. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17004. utils.ErrorLog("解析失败:%v", err)
  17005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17006. return
  17007. }
  17008. if res.Infcode == 0 {
  17009. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17010. if err == gorm.ErrRecordNotFound {
  17011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17012. return
  17013. } else if err != nil {
  17014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17015. return
  17016. } else {
  17017. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17018. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17019. infoStr := string(Iinfos)
  17020. idetinfoStr := string(Idetinfos)
  17021. psn := &models.HisPsn{
  17022. PsnNo: res.Output.Baseinfo.PsnNo,
  17023. PatientId: patient.ID,
  17024. Certno: res.Output.Baseinfo.Certno,
  17025. Gend: res.Output.Baseinfo.Gend,
  17026. Naty: res.Output.Baseinfo.Naty,
  17027. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17028. PsnName: res.Output.Baseinfo.PsnName,
  17029. Idetinfo: idetinfoStr,
  17030. Insuinfo: infoStr,
  17031. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17032. CardInfo: "",
  17033. VerifyNumber: token,
  17034. InsuplcAdmdvs: ele.Data.InsuOrg,
  17035. }
  17036. service.CreateHisPsn(psn)
  17037. var rf []*ResultFive
  17038. json.Unmarshal([]byte(infoStr), &rf)
  17039. var insutypes []*ResultFive
  17040. var insutype string
  17041. var is390 int = 0
  17042. var is310 int = 0
  17043. for _, item := range rf {
  17044. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17045. insutypes = append(insutypes, item)
  17046. }
  17047. }
  17048. if len(insutypes) == 1 {
  17049. insutype = insutypes[0].Insutype
  17050. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17051. } else {
  17052. for _, i := range insutypes {
  17053. if i.Insutype == "390" {
  17054. is390 = 1
  17055. }
  17056. if i.Insutype == "310" {
  17057. is310 = 1
  17058. }
  17059. }
  17060. }
  17061. if is390 == 1 {
  17062. insutype = "390"
  17063. }
  17064. if is310 == 1 {
  17065. insutype = "310"
  17066. }
  17067. if len(insutypes) == 0 {
  17068. insutype = "310"
  17069. }
  17070. c.ServeSuccessJSON(map[string]interface{}{
  17071. "patient": patient,
  17072. "number": token,
  17073. "insutype": insutype,
  17074. })
  17075. }
  17076. } else {
  17077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17078. return
  17079. }
  17080. } else if miConfig.MdtrtareaAdmvs == "360100" {
  17081. //if initFlag == 0 {
  17082. //c.TestGetJiangXiBasBaseInit()
  17083. //}
  17084. //if initEleFlag == 0 {
  17085. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  17086. //}
  17087. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  17088. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  17089. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  17090. type ELeData struct {
  17091. Data struct {
  17092. IdNo string `json:"idNo"`
  17093. IdType string `json:"idType"`
  17094. UserName string `json:"userName"`
  17095. EcToken string `json:"ecToken"`
  17096. InsuOrg string `json:"insuOrg"`
  17097. Gender string `json:"gender"`
  17098. Birthday string `json:"birthday"`
  17099. Nationality string `json:"nationality"`
  17100. Email string `json:"email"`
  17101. Extra string `json:"extra"`
  17102. } `json:"data"`
  17103. Code int `json:"code"`
  17104. Message string `json:"message"`
  17105. }
  17106. var ele ELeData
  17107. err := json.Unmarshal([]byte(result), &ele)
  17108. if err != nil {
  17109. utils.ErrorLog("解析失败:%v", err)
  17110. }
  17111. token := ele.Data.EcToken
  17112. token = Remove0000(token)
  17113. 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)
  17114. saveLog(result2, requestLog2, "1101", "获取人员信息")
  17115. var res ResultTwo
  17116. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17117. utils.ErrorLog("解析失败:%v", err)
  17118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17119. return
  17120. }
  17121. if res.Infcode == 0 {
  17122. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17123. if err == gorm.ErrRecordNotFound {
  17124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17125. return
  17126. } else if err != nil {
  17127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17128. return
  17129. } else {
  17130. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17131. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17132. infoStr := string(Iinfos)
  17133. idetinfoStr := string(Idetinfos)
  17134. psn := &models.HisPsn{
  17135. PsnNo: res.Output.Baseinfo.PsnNo,
  17136. PatientId: patient.ID,
  17137. Certno: res.Output.Baseinfo.Certno,
  17138. Gend: res.Output.Baseinfo.Gend,
  17139. Naty: res.Output.Baseinfo.Naty,
  17140. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17141. PsnName: res.Output.Baseinfo.PsnName,
  17142. Idetinfo: idetinfoStr,
  17143. Insuinfo: infoStr,
  17144. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17145. CardInfo: "",
  17146. VerifyNumber: token,
  17147. InsuplcAdmdvs: ele.Data.InsuOrg,
  17148. }
  17149. service.CreateHisPsn(psn)
  17150. var rf []*ResultFive
  17151. json.Unmarshal([]byte(infoStr), &rf)
  17152. var insutypes []*ResultFive
  17153. var insutype string
  17154. var is390 int = 0
  17155. var is310 int = 0
  17156. for _, item := range rf {
  17157. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17158. insutypes = append(insutypes, item)
  17159. }
  17160. }
  17161. if len(insutypes) == 1 {
  17162. insutype = insutypes[0].Insutype
  17163. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17164. } else {
  17165. for _, i := range insutypes {
  17166. if i.Insutype == "390" {
  17167. is390 = 1
  17168. }
  17169. if i.Insutype == "310" {
  17170. is310 = 1
  17171. }
  17172. }
  17173. }
  17174. if is390 == 1 {
  17175. insutype = "390"
  17176. }
  17177. if is310 == 1 {
  17178. insutype = "310"
  17179. }
  17180. if len(insutypes) == 0 {
  17181. insutype = "310"
  17182. }
  17183. c.ServeSuccessJSON(map[string]interface{}{
  17184. "patient": patient,
  17185. "number": token,
  17186. "insutype": insutype,
  17187. })
  17188. }
  17189. } else {
  17190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17191. return
  17192. }
  17193. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17194. //if initFlag == 0 {
  17195. c.TestGetJiangXiBasBaseInit()
  17196. //}
  17197. //if initEleFlag == 0 {
  17198. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  17199. //}
  17200. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  17201. type ELeData struct {
  17202. Data struct {
  17203. IdNo string `json:"idNo"`
  17204. IdType string `json:"idType"`
  17205. UserName string `json:"userName"`
  17206. EcToken string `json:"ecToken"`
  17207. InsuOrg string `json:"insuOrg"`
  17208. Gender string `json:"gender"`
  17209. Birthday string `json:"birthday"`
  17210. Nationality string `json:"nationality"`
  17211. Email string `json:"email"`
  17212. Extra string `json:"extra"`
  17213. } `json:"data"`
  17214. Code int `json:"code"`
  17215. Message string `json:"message"`
  17216. }
  17217. var ele ELeData
  17218. err := json.Unmarshal([]byte(json_result), &ele)
  17219. if err != nil {
  17220. utils.ErrorLog("解析失败:%v", err)
  17221. }
  17222. token := ele.Data.EcToken
  17223. token = Remove0000(token)
  17224. 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)
  17225. saveLog(result2, requestLog2, "1101", "获取人员信息")
  17226. var res ResultTwo
  17227. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17228. utils.ErrorLog("解析失败:%v", err)
  17229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17230. return
  17231. }
  17232. if res.Infcode == 0 {
  17233. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17234. if err == gorm.ErrRecordNotFound {
  17235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17236. return
  17237. } else if err != nil {
  17238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17239. return
  17240. } else {
  17241. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17242. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17243. infoStr := string(Iinfos)
  17244. idetinfoStr := string(Idetinfos)
  17245. psn := &models.HisPsn{
  17246. PsnNo: res.Output.Baseinfo.PsnNo,
  17247. PatientId: patient.ID,
  17248. Certno: res.Output.Baseinfo.Certno,
  17249. Gend: res.Output.Baseinfo.Gend,
  17250. Naty: res.Output.Baseinfo.Naty,
  17251. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17252. PsnName: res.Output.Baseinfo.PsnName,
  17253. Idetinfo: idetinfoStr,
  17254. Insuinfo: infoStr,
  17255. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17256. CardInfo: "",
  17257. VerifyNumber: token,
  17258. }
  17259. service.CreateHisPsn(psn)
  17260. var rf []*ResultFive
  17261. json.Unmarshal([]byte(infoStr), &rf)
  17262. var insutypes []*ResultFive
  17263. var insutype string
  17264. var is390 int = 0
  17265. var is310 int = 0
  17266. for _, item := range rf {
  17267. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17268. insutypes = append(insutypes, item)
  17269. }
  17270. }
  17271. if len(insutypes) == 1 {
  17272. insutype = insutypes[0].Insutype
  17273. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17274. } else {
  17275. for _, i := range insutypes {
  17276. if i.Insutype == "390" {
  17277. is390 = 1
  17278. }
  17279. if i.Insutype == "310" {
  17280. is310 = 1
  17281. }
  17282. }
  17283. }
  17284. if is390 == 1 {
  17285. insutype = "390"
  17286. }
  17287. if is310 == 1 {
  17288. insutype = "310"
  17289. }
  17290. if len(insutypes) == 0 {
  17291. insutype = "310"
  17292. }
  17293. c.ServeSuccessJSON(map[string]interface{}{
  17294. "patient": patient,
  17295. "number": token,
  17296. "insutype": insutype,
  17297. })
  17298. }
  17299. } else {
  17300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17301. return
  17302. }
  17303. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17304. type ELeData struct {
  17305. Code string `json:"code"`
  17306. Data struct {
  17307. Aac002 string `json:"aac002"`
  17308. Aaz500 string `json:"aaz500"`
  17309. ActCardNo string `json:"actCardNo"`
  17310. Bab520 string `json:"bab520"`
  17311. Bkz543 string `json:"bkz543"`
  17312. BusinessType string `json:"businessType"`
  17313. CertfCodg string `json:"certfCodg"`
  17314. EcIndexNo string `json:"ecIndexNo"`
  17315. EcToken string `json:"ecToken"`
  17316. ID0000 string `json:"id0000"`
  17317. IDNo string `json:"idNo"`
  17318. IDType string `json:"idType"`
  17319. Idcode string `json:"idcode"`
  17320. IdentityToken string `json:"identity_token"`
  17321. InsuOrg string `json:"insuOrg"`
  17322. OfficeID string `json:"officeId"`
  17323. OfficeName string `json:"officeName"`
  17324. OperatorID string `json:"operatorId"`
  17325. OperatorName string `json:"operatorName"`
  17326. OrgID string `json:"orgId"`
  17327. UserName string `json:"userName"`
  17328. } `json:"data"`
  17329. Infno interface{} `json:"infno"`
  17330. Message string `json:"message"`
  17331. OrgID string `json:"orgId"`
  17332. TransType string `json:"transType"`
  17333. }
  17334. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  17335. outPutInfo = Remove0000(outPutInfo)
  17336. if len(outPutInfo) > 0 {
  17337. var ele ELeData
  17338. err := json.Unmarshal([]byte(outPutInfo), &ele)
  17339. if err != nil {
  17340. utils.ErrorLog("解析失败:%v", err)
  17341. }
  17342. token := ele.Data.EcToken
  17343. fmt.Println(inputInfo)
  17344. fmt.Println(outPutInfo)
  17345. 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)
  17346. saveLog(result, requestLog, "1101", "获取人员信息")
  17347. var dat map[string]interface{}
  17348. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17349. fmt.Println(dat)
  17350. } else {
  17351. fmt.Println(err)
  17352. }
  17353. userJSONBytes, _ := json.Marshal(dat)
  17354. var res ResultTwo
  17355. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17356. utils.ErrorLog("解析失败:%v", err)
  17357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17358. return
  17359. }
  17360. res.ErrMsg = errMsgLog
  17361. if res.Infcode == 0 {
  17362. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  17363. if err == gorm.ErrRecordNotFound {
  17364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17365. return
  17366. } else if err != nil {
  17367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17368. return
  17369. } else {
  17370. fmt.Println(res)
  17371. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17372. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17373. infoStr := string(Iinfos)
  17374. idetinfoStr := string(Idetinfos)
  17375. psn := &models.HisPsn{
  17376. PsnNo: res.Output.Baseinfo.PsnNo,
  17377. PatientId: patient.ID,
  17378. Certno: res.Output.Baseinfo.Certno,
  17379. Gend: res.Output.Baseinfo.Gend,
  17380. Naty: res.Output.Baseinfo.Naty,
  17381. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17382. PsnName: res.Output.Baseinfo.PsnName,
  17383. Idetinfo: idetinfoStr,
  17384. Insuinfo: infoStr,
  17385. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17386. CardInfo: outPutInfo,
  17387. VerifyNumber: token,
  17388. InsuplcAdmdvs: ele.Data.InsuOrg,
  17389. }
  17390. service.CreateHisPsn(psn)
  17391. var rf []*ResultFive
  17392. json.Unmarshal([]byte(infoStr), &rf)
  17393. var insutypes []*ResultFive
  17394. var insutype string
  17395. var is390 int = 0
  17396. var is310 int = 0
  17397. for _, item := range rf {
  17398. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  17399. insutypes = append(insutypes, item)
  17400. }
  17401. }
  17402. if len(insutypes) == 1 {
  17403. insutype = insutypes[0].Insutype
  17404. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17405. } else {
  17406. for _, i := range insutypes {
  17407. if i.Insutype == "390" {
  17408. is390 = 1
  17409. }
  17410. if i.Insutype == "310" {
  17411. is310 = 1
  17412. }
  17413. }
  17414. }
  17415. if is390 == 1 {
  17416. insutype = "390"
  17417. }
  17418. if is310 == 1 {
  17419. insutype = "310"
  17420. }
  17421. if len(insutypes) == 0 {
  17422. insutype = "310"
  17423. }
  17424. c.ServeSuccessJSON(map[string]interface{}{
  17425. "patient": patient,
  17426. "number": token,
  17427. "insutype": insutype,
  17428. })
  17429. }
  17430. } else {
  17431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17432. return
  17433. }
  17434. }
  17435. } else if miConfig.MdtrtareaAdmvs == "150404" {
  17436. var api string
  17437. 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 +
  17438. "&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
  17439. resp, requestErr := http.Get(api)
  17440. if requestErr != nil {
  17441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17442. return
  17443. }
  17444. body, ioErr := ioutil.ReadAll(resp.Body)
  17445. if ioErr != nil {
  17446. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17448. return
  17449. }
  17450. var respJSON map[string]interface{}
  17451. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17452. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17454. return
  17455. }
  17456. var status string
  17457. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17458. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17459. var token string
  17460. var res ResultTwo //1101结果
  17461. var res10265 ResultTwo10265 //1101结果
  17462. if status == "0" { //读卡成功
  17463. var card_info string //卡信息
  17464. var busi_card_info string
  17465. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17466. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17467. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17468. fmt.Println(card_info)
  17469. fmt.Println(busi_card_info)
  17470. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17471. result, _ := json.Marshal(respJSON)
  17472. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17473. utils.ErrorLog("解析失败:%v", err)
  17474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17475. return
  17476. }
  17477. res.ErrMsg = res10265.ErrMsg
  17478. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17479. res.Infcode = infocode
  17480. res.Output = res10265.Output
  17481. res.InfRefmsgid = res10265.InfRefmsgid
  17482. if res.Infcode == 0 {
  17483. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17484. if err == gorm.ErrRecordNotFound {
  17485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17486. return
  17487. } else if err != nil {
  17488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17489. return
  17490. } else {
  17491. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17492. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17493. infoStr := string(Iinfos)
  17494. idetinfoStr := string(Idetinfos)
  17495. psn := &models.HisPsn{
  17496. PsnNo: res.Output.Baseinfo.PsnNo,
  17497. PatientId: patient.ID,
  17498. Certno: res.Output.Baseinfo.Certno,
  17499. Gend: res.Output.Baseinfo.Gend,
  17500. Naty: res.Output.Baseinfo.Naty,
  17501. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17502. PsnName: res.Output.Baseinfo.PsnName,
  17503. Idetinfo: idetinfoStr,
  17504. Insuinfo: infoStr,
  17505. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17506. CardInfo: card_info,
  17507. VerifyNumber: token,
  17508. }
  17509. var rf []*ResultFive
  17510. json.Unmarshal([]byte(infoStr), &rf)
  17511. var insutypes []*ResultFive
  17512. var insutype string
  17513. var is390 int = 0
  17514. var is310 int = 0
  17515. for _, item := range rf {
  17516. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17517. insutypes = append(insutypes, item)
  17518. }
  17519. }
  17520. if len(insutypes) == 1 {
  17521. insutype = insutypes[0].Insutype
  17522. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17523. } else {
  17524. for _, i := range insutypes {
  17525. if i.Insutype == "390" {
  17526. is390 = 1
  17527. }
  17528. if i.Insutype == "310" {
  17529. is310 = 1
  17530. }
  17531. }
  17532. }
  17533. if is390 == 1 {
  17534. insutype = "390"
  17535. }
  17536. if is310 == 1 {
  17537. insutype = "310"
  17538. }
  17539. if len(insutypes) == 0 {
  17540. insutype = "310"
  17541. }
  17542. service.CreateHisPsn(psn)
  17543. c.ServeSuccessJSON(map[string]interface{}{
  17544. "patient": patient,
  17545. "number": token,
  17546. "insutype": insutype,
  17547. })
  17548. }
  17549. } else {
  17550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17551. return
  17552. }
  17553. } else { //读卡失败
  17554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17555. return
  17556. }
  17557. } else if miConfig.MdtrtareaAdmvs == "450721" {
  17558. res := c.GetoleInfo()
  17559. if res.Infcode == 0 {
  17560. var result string
  17561. if res.Output.MdtrtCertType == "01" {
  17562. 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)
  17563. } else if res.Output.MdtrtCertType == "02" {
  17564. 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)
  17565. } else if res.Output.MdtrtCertType == "03" {
  17566. 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)
  17567. }
  17568. var dat map[string]interface{}
  17569. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17570. fmt.Println(dat)
  17571. } else {
  17572. fmt.Println(err)
  17573. }
  17574. userJSONBytes, _ := json.Marshal(dat)
  17575. var res2 ResultTwo
  17576. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17577. utils.ErrorLog("解析失败:%v", err)
  17578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17579. return
  17580. }
  17581. if res2.Infcode == 0 {
  17582. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  17583. if err == gorm.ErrRecordNotFound {
  17584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17585. return
  17586. } else if err != nil {
  17587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17588. return
  17589. } else {
  17590. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  17591. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  17592. infoStr := string(Iinfos)
  17593. idetinfoStr := string(Idetinfos)
  17594. var rf []*ResultFive
  17595. json.Unmarshal([]byte(infoStr), &rf)
  17596. var insutypes []*ResultFive
  17597. var insutype string
  17598. var is390 int = 0
  17599. var is310 int = 0
  17600. //var insuplc_admdvs string
  17601. for _, item := range rf {
  17602. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17603. insutypes = append(insutypes, item)
  17604. }
  17605. }
  17606. if len(insutypes) == 1 {
  17607. insutype = insutypes[0].Insutype
  17608. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17609. } else {
  17610. for _, i := range insutypes {
  17611. if i.Insutype == "390" {
  17612. is390 = 1
  17613. }
  17614. if i.Insutype == "310" {
  17615. is310 = 1
  17616. }
  17617. }
  17618. }
  17619. if is390 == 1 {
  17620. insutype = "390"
  17621. }
  17622. if is310 == 1 {
  17623. insutype = "310"
  17624. }
  17625. if len(insutypes) == 0 {
  17626. insutype = "310"
  17627. }
  17628. psn := &models.HisPsn{
  17629. PsnNo: res2.Output.Baseinfo.PsnNo,
  17630. PatientId: patient.ID,
  17631. Certno: res2.Output.Baseinfo.Certno,
  17632. Gend: res2.Output.Baseinfo.Gend,
  17633. Naty: res2.Output.Baseinfo.Naty,
  17634. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  17635. PsnName: res2.Output.Baseinfo.PsnName,
  17636. Idetinfo: idetinfoStr,
  17637. Insuinfo: infoStr,
  17638. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17639. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  17640. VerifyNumber: res.Output.EcToken,
  17641. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  17642. }
  17643. if res.Output.MdtrtCertType == "01" {
  17644. psn.VerifyNumber = res.Output.EcToken
  17645. //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)
  17646. } else if res.Output.MdtrtCertType == "02" {
  17647. psn.VerifyNumber = res.Output.CardNo
  17648. //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)
  17649. } else if res.Output.MdtrtCertType == "03" {
  17650. psn.VerifyNumber = res.Output.MdtrtCertNo
  17651. //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)
  17652. }
  17653. service.CreateHisPsn(psn)
  17654. var balc float64
  17655. for _, item := range rf {
  17656. if item.Insutype == insutype {
  17657. balc = item.Balc
  17658. }
  17659. }
  17660. c.ServeSuccessJSON(map[string]interface{}{
  17661. "patient": patient,
  17662. "number": res.Output.CardNo,
  17663. "insutype": insutype,
  17664. "blac": balc,
  17665. "desc": idetinfoStr,
  17666. })
  17667. }
  17668. } else {
  17669. c.ServeSuccessJSON(map[string]interface{}{
  17670. "failed_code": -10,
  17671. "msg": res2.ErrMsg,
  17672. })
  17673. }
  17674. } else {
  17675. c.ServeSuccessJSON(map[string]interface{}{
  17676. "failed_code": -10,
  17677. "msg": res.ErrMsg,
  17678. })
  17679. }
  17680. } else if miConfig.MdtrtareaAdmvs == "420902" {
  17681. var res ResultTwo
  17682. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  17683. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  17684. "&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)
  17685. resp, requestErr := http.Get(api)
  17686. if requestErr != nil {
  17687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17688. return
  17689. }
  17690. body, ioErr := ioutil.ReadAll(resp.Body)
  17691. if ioErr != nil {
  17692. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17694. return
  17695. }
  17696. var respJSON map[string]interface{}
  17697. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17700. return
  17701. }
  17702. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17703. result, _ := json.Marshal(respJSON)
  17704. fmt.Println("log")
  17705. fmt.Println(string(result))
  17706. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17707. utils.ErrorLog("解析失败:%v", err)
  17708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17709. return
  17710. }
  17711. if res.Infcode == 0 {
  17712. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17713. if err == gorm.ErrRecordNotFound {
  17714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17715. return
  17716. } else if err != nil {
  17717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17718. return
  17719. } else {
  17720. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17721. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17722. infoStr := string(Iinfos)
  17723. idetinfoStr := string(Idetinfos)
  17724. var rf []*ResultFive
  17725. json.Unmarshal([]byte(infoStr), &rf)
  17726. var insutypes []*ResultFive
  17727. var insutype string
  17728. var is390 int = 0
  17729. var is310 int = 0
  17730. for _, item := range rf {
  17731. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  17732. insutypes = append(insutypes, item)
  17733. }
  17734. }
  17735. if len(insutypes) == 1 {
  17736. insutype = insutypes[0].Insutype
  17737. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17738. } else {
  17739. for _, i := range insutypes {
  17740. if i.Insutype == "390" {
  17741. is390 = 1
  17742. }
  17743. if i.Insutype == "310" {
  17744. is310 = 1
  17745. }
  17746. }
  17747. }
  17748. if is390 == 1 {
  17749. insutype = "390"
  17750. }
  17751. if is310 == 1 {
  17752. insutype = "310"
  17753. }
  17754. if len(insutypes) == 0 {
  17755. insutype = "390"
  17756. }
  17757. var insuplc_admdvs string
  17758. for _, item := range rf {
  17759. if item.Insutype == insutype {
  17760. insuplc_admdvs = item.InsuplcAdmdvs
  17761. }
  17762. }
  17763. psn := &models.HisPsn{
  17764. PsnNo: res.Output.Baseinfo.PsnNo,
  17765. PatientId: patient.ID,
  17766. Certno: res.Output.Baseinfo.Certno,
  17767. Gend: res.Output.Baseinfo.Gend,
  17768. Naty: res.Output.Baseinfo.Naty,
  17769. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17770. PsnName: res.Output.Baseinfo.PsnName,
  17771. Idetinfo: idetinfoStr,
  17772. Insuinfo: infoStr,
  17773. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17774. InsuplcAdmdvs: insuplc_admdvs,
  17775. }
  17776. service.CreateHisPsn(psn)
  17777. c.ServeSuccessJSON(map[string]interface{}{
  17778. "patient": patient,
  17779. "number": res.Output.Baseinfo.Certno,
  17780. })
  17781. }
  17782. } else {
  17783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17784. return
  17785. }
  17786. } else {
  17787. type ELeData struct {
  17788. Code string `json:"code"`
  17789. Data struct {
  17790. Aac002 string `json:"aac002"`
  17791. Aaz500 string `json:"aaz500"`
  17792. ActCardNo string `json:"actCardNo"`
  17793. Bab520 string `json:"bab520"`
  17794. Bkz543 string `json:"bkz543"`
  17795. BusinessType string `json:"businessType"`
  17796. CertfCodg string `json:"certfCodg"`
  17797. EcIndexNo string `json:"ecIndexNo"`
  17798. EcToken string `json:"ecToken"`
  17799. ID0000 string `json:"id0000"`
  17800. IDNo string `json:"idNo"`
  17801. IDType string `json:"idType"`
  17802. Idcode string `json:"idcode"`
  17803. IdentityToken string `json:"identity_token"`
  17804. InsuOrg string `json:"insuOrg"`
  17805. OfficeID string `json:"officeId"`
  17806. OfficeName string `json:"officeName"`
  17807. OperatorID string `json:"operatorId"`
  17808. OperatorName string `json:"operatorName"`
  17809. OrgID string `json:"orgId"`
  17810. UserName string `json:"userName"`
  17811. } `json:"data"`
  17812. Infno interface{} `json:"infno"`
  17813. Message string `json:"message"`
  17814. OrgID string `json:"orgId"`
  17815. TransType string `json:"transType"`
  17816. }
  17817. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  17818. fmt.Println(result)
  17819. outPutInfo := Remove0000(result)
  17820. fmt.Println(outPutInfo)
  17821. if len(outPutInfo) > 0 {
  17822. var ele ELeData
  17823. err := json.Unmarshal([]byte(outPutInfo), &ele)
  17824. if err != nil {
  17825. utils.ErrorLog("解析失败:%v", err)
  17826. }
  17827. token := ele.Data.EcToken
  17828. fmt.Println(outPutInfo)
  17829. 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)
  17830. saveLog(result, requestLog, "1101", "获取人员信息")
  17831. var dat map[string]interface{}
  17832. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17833. fmt.Println(dat)
  17834. } else {
  17835. fmt.Println(err)
  17836. }
  17837. userJSONBytes, _ := json.Marshal(dat)
  17838. var res ResultTwo
  17839. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17840. utils.ErrorLog("解析失败:%v", err)
  17841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17842. return
  17843. }
  17844. if res.Infcode == 0 {
  17845. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  17846. if err == gorm.ErrRecordNotFound {
  17847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17848. return
  17849. } else if err != nil {
  17850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17851. return
  17852. } else {
  17853. fmt.Println(res)
  17854. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17855. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17856. infoStr := string(Iinfos)
  17857. idetinfoStr := string(Idetinfos)
  17858. psn := &models.HisPsn{
  17859. PsnNo: res.Output.Baseinfo.PsnNo,
  17860. PatientId: patient.ID,
  17861. Certno: res.Output.Baseinfo.Certno,
  17862. Gend: res.Output.Baseinfo.Gend,
  17863. Naty: res.Output.Baseinfo.Naty,
  17864. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17865. PsnName: res.Output.Baseinfo.PsnName,
  17866. Idetinfo: idetinfoStr,
  17867. Insuinfo: infoStr,
  17868. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17869. CardInfo: outPutInfo,
  17870. VerifyNumber: token,
  17871. InsuplcAdmdvs: ele.Data.InsuOrg,
  17872. }
  17873. service.CreateHisPsn(psn)
  17874. var rf []*ResultFive
  17875. json.Unmarshal([]byte(infoStr), &rf)
  17876. var insutypes []*ResultFive
  17877. var insutype string
  17878. var is390 int = 0
  17879. var is310 int = 0
  17880. for _, item := range rf {
  17881. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17882. insutypes = append(insutypes, item)
  17883. }
  17884. }
  17885. if len(insutypes) == 1 {
  17886. insutype = insutypes[0].Insutype
  17887. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17888. } else {
  17889. for _, i := range insutypes {
  17890. if i.Insutype == "390" {
  17891. is390 = 1
  17892. }
  17893. if i.Insutype == "310" {
  17894. is310 = 1
  17895. }
  17896. }
  17897. }
  17898. if is390 == 1 {
  17899. insutype = "390"
  17900. }
  17901. if is310 == 1 {
  17902. insutype = "310"
  17903. }
  17904. if len(insutypes) == 0 {
  17905. insutype = "310"
  17906. }
  17907. c.ServeSuccessJSON(map[string]interface{}{
  17908. "patient": patient,
  17909. "number": token,
  17910. "insutype": insutype,
  17911. })
  17912. }
  17913. } else {
  17914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17915. return
  17916. }
  17917. }
  17918. //fmt.Println(result)
  17919. //
  17920. //if initFlag == 0 {
  17921. // c.TestGetBasBaseInit()
  17922. //}
  17923. //token := c.GetEleBaseInfo()
  17924. //
  17925. //token = Remove0000(token)
  17926. //
  17927. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  17928. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  17929. ////
  17930. //var res ResultTwo
  17931. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17932. // utils.ErrorLog("解析失败:%v", err)
  17933. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17934. // return
  17935. //}
  17936. //
  17937. //if res.Infcode == 0 {
  17938. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17939. // if err == gorm.ErrRecordNotFound {
  17940. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17941. // return
  17942. // } else if err != nil {
  17943. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17944. // return
  17945. //
  17946. // } else {
  17947. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17948. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17949. // infoStr := string(Iinfos)
  17950. // idetinfoStr := string(Idetinfos)
  17951. //
  17952. //
  17953. //
  17954. //
  17955. // var rf []*ResultFive
  17956. // json.Unmarshal([]byte(infoStr), &rf)
  17957. //
  17958. // var insutypes []*ResultFive
  17959. // var insutype string
  17960. // var is390 int = 0
  17961. // var is310 int = 0
  17962. // var insuplc_admdvs string
  17963. //
  17964. // for _, item := range rf {
  17965. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17966. // insutypes = append(insutypes, item)
  17967. // }
  17968. // }
  17969. //
  17970. // if len(insutypes) == 1 {
  17971. // insutype = insutypes[0].Insutype
  17972. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17973. // } else {
  17974. // for _, i := range insutypes {
  17975. // if i.Insutype == "390" {
  17976. // is390 = 1
  17977. // }
  17978. //
  17979. // if i.Insutype == "310" {
  17980. // is310 = 1
  17981. // }
  17982. // }
  17983. // }
  17984. // if is390 == 1 {
  17985. // insutype = "390"
  17986. // }
  17987. //
  17988. // if is310 == 1 {
  17989. // insutype = "310"
  17990. // }
  17991. // if len(insutypes) == 0 {
  17992. // insutype = "310"
  17993. // }
  17994. // for _, item := range rf {
  17995. // if item.Insutype == insutype {
  17996. // insuplc_admdvs = item.InsuplcAdmdvs
  17997. // }
  17998. // }
  17999. // psn := &models.HisPsn{
  18000. // PsnNo: res.Output.Baseinfo.PsnNo,
  18001. // Age: res.Output.Baseinfo.Age,
  18002. // PatientId: patient.ID,
  18003. // Certno: res.Output.Baseinfo.Certno,
  18004. // Brdy: res.Output.Baseinfo.Brdy,
  18005. // Gend: res.Output.Baseinfo.Gend,
  18006. // Naty: res.Output.Baseinfo.Naty,
  18007. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  18008. // PsnName: res.Output.Baseinfo.PsnName,
  18009. // Idetinfo: idetinfoStr,
  18010. // Insuinfo: infoStr,
  18011. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18012. // CardInfo: "",
  18013. // VerifyNumber: token,
  18014. // InsuplcAdmdvs: insuplc_admdvs,
  18015. // }
  18016. // service.CreateHisPsn(psn)
  18017. //
  18018. // c.ServeSuccessJSON(map[string]interface{}{
  18019. // "patient": patient,
  18020. // "number": token,
  18021. // })
  18022. // }
  18023. //} else {
  18024. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18025. // return
  18026. //}
  18027. }
  18028. break
  18029. case 5:
  18030. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  18031. var api string
  18032. if miConfig.MdtrtareaAdmvs == "320830" {
  18033. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  18034. "&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
  18035. fmt.Println(api)
  18036. } else if miConfig.MdtrtareaAdmvs == "320921" {
  18037. 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 +
  18038. "&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
  18039. fmt.Println(api)
  18040. } else {
  18041. 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 +
  18042. "&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)
  18043. }
  18044. resp, requestErr := http.Get(api)
  18045. if requestErr != nil {
  18046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18047. return
  18048. }
  18049. body, ioErr := ioutil.ReadAll(resp.Body)
  18050. if ioErr != nil {
  18051. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18053. return
  18054. }
  18055. var respJSON map[string]interface{}
  18056. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18059. return
  18060. }
  18061. var status string
  18062. status = respJSON["data"].(map[string]interface{})["status"].(string)
  18063. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  18064. var token string
  18065. var res ResultTwo //1101结果
  18066. var res10265 ResultTwo10265 //1101结果
  18067. if status == "0" { //读卡成功
  18068. var card_info string //卡信息
  18069. //var busi_card_info string
  18070. var auth_info string
  18071. token = respJSON["data"].(map[string]interface{})["token"].(string)
  18072. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  18073. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  18074. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  18075. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  18076. result, _ := json.Marshal(respJSON)
  18077. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  18078. utils.ErrorLog("解析失败:%v", err)
  18079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18080. return
  18081. }
  18082. res.ErrMsg = res10265.ErrMsg
  18083. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  18084. res.Infcode = infocode
  18085. res.Output = res10265.Output
  18086. res.InfRefmsgid = res10265.InfRefmsgid
  18087. if res.Infcode == 0 {
  18088. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  18089. if err == gorm.ErrRecordNotFound {
  18090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  18091. return
  18092. } else if err != nil {
  18093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  18094. return
  18095. } else {
  18096. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18097. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18098. infoStr := string(Iinfos)
  18099. idetinfoStr := string(Idetinfos)
  18100. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  18101. psn := &models.HisPsn{
  18102. PsnNo: res.Output.Baseinfo.PsnNo,
  18103. PatientId: patient.ID,
  18104. Certno: res.Output.Baseinfo.Certno,
  18105. Gend: res.Output.Baseinfo.Gend,
  18106. Brdy: b,
  18107. Age: float64(age),
  18108. Naty: res.Output.Baseinfo.Naty,
  18109. PsnCertType: res.Output.Baseinfo.PsnCertType,
  18110. PsnName: res.Output.Baseinfo.PsnName,
  18111. Idetinfo: idetinfoStr,
  18112. Insuinfo: infoStr,
  18113. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18114. CardInfo: card_info,
  18115. VerifyNumber: token,
  18116. AuthInfo: auth_info,
  18117. }
  18118. var rf []*ResultFive
  18119. json.Unmarshal([]byte(infoStr), &rf)
  18120. var insutypes []*ResultFive
  18121. var insutype string
  18122. var is390 int = 0
  18123. var is310 int = 0
  18124. for _, item := range rf {
  18125. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18126. insutypes = append(insutypes, item)
  18127. }
  18128. }
  18129. if len(insutypes) == 1 {
  18130. insutype = insutypes[0].Insutype
  18131. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  18132. } else {
  18133. for _, i := range insutypes {
  18134. if i.Insutype == "390" {
  18135. is390 = 1
  18136. }
  18137. if i.Insutype == "310" {
  18138. is310 = 1
  18139. }
  18140. }
  18141. }
  18142. if is390 == 1 {
  18143. insutype = "390"
  18144. }
  18145. if is310 == 1 {
  18146. insutype = "310"
  18147. }
  18148. if len(insutypes) == 0 {
  18149. insutype = "310"
  18150. }
  18151. service.CreateHisPsn(psn)
  18152. c.ServeSuccessJSON(map[string]interface{}{
  18153. "patient": patient,
  18154. "number": token,
  18155. "insutype": insutype,
  18156. })
  18157. }
  18158. } else {
  18159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18160. return
  18161. }
  18162. } else { //读卡失败
  18163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18164. return
  18165. }
  18166. }
  18167. break
  18168. }
  18169. }
  18170. var initFlag int64 = 0
  18171. var initEleFlag int64 = 0
  18172. func (c *HisApiController) TestGetBasBaseInit() {
  18173. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18174. Iinit := DllDef.MustFindProc("Init")
  18175. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18176. url := ""
  18177. if miConfig.InsuplcAdmdvs[:4] == "4403" {
  18178. url = "http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"
  18179. } else if miConfig.InsuplcAdmdvs[:4] == "4401" {
  18180. url = ""
  18181. } else {
  18182. url = "http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"
  18183. }
  18184. fmt.Println("SSCard的报错原因:", url)
  18185. fmt.Println("SSCard的报错原因:", miConfig.InsuplcAdmdvs)
  18186. ret, _, err := Iinit.Call(StrPtr(url), StrPtr(miConfig.InsuplcAdmdvs))
  18187. if ret != 0 {
  18188. fmt.Println("SSCard的报错原因:", err)
  18189. fmt.Println("SSCard的运算结果为:", ret)
  18190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18191. return
  18192. }
  18193. result := int(ret)
  18194. fmt.Println("SSCard的运算结果为1:", result)
  18195. initFlag = 1
  18196. return
  18197. }
  18198. func (c *HisApiController) HandleJiangXiReadCard() {
  18199. fmt.Println("~~~~~~")
  18200. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18201. admin_user_id, _ := c.GetInt64("admin_user_id")
  18202. id_card_type, _ := c.GetInt64("id_card_type")
  18203. //certificates, _ := c.GetInt64("certificates")
  18204. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18205. if initFlag == 0 {
  18206. c.TestGetJiangXiBasBaseInit()
  18207. }
  18208. basStr := c.GetBasBaseInfo()
  18209. if len(basStr) == 0 {
  18210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18211. return
  18212. }
  18213. fmt.Println(basStr)
  18214. bas := strings.Split(basStr, "|")
  18215. basNumber := bas[1]
  18216. fmt.Println(basNumber)
  18217. card_sn := bas[3]
  18218. fmt.Println(card_sn)
  18219. 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, "")
  18220. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  18221. var dat map[string]interface{}
  18222. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18223. fmt.Println(dat)
  18224. } else {
  18225. fmt.Println(err)
  18226. }
  18227. userJSONBytes, _ := json.Marshal(dat)
  18228. var res ResultTwo
  18229. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18230. utils.ErrorLog("解析失败:%v", err)
  18231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18232. return
  18233. }
  18234. if res.Infcode == 0 {
  18235. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  18236. if err == gorm.ErrRecordNotFound {
  18237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  18238. return
  18239. } else if err != nil {
  18240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  18241. return
  18242. } else {
  18243. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18244. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18245. infoStr := string(Iinfos)
  18246. idetinfoStr := string(Idetinfos)
  18247. psn := &models.HisPsn{
  18248. PsnNo: res.Output.Baseinfo.PsnNo,
  18249. PatientId: patient.ID,
  18250. Certno: res.Output.Baseinfo.Certno,
  18251. Gend: res.Output.Baseinfo.Gend,
  18252. Naty: res.Output.Baseinfo.Naty,
  18253. PsnCertType: res.Output.Baseinfo.PsnCertType,
  18254. PsnName: res.Output.Baseinfo.PsnName,
  18255. Idetinfo: idetinfoStr,
  18256. Insuinfo: infoStr,
  18257. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18258. CardInfo: basStr,
  18259. VerifyNumber: "",
  18260. }
  18261. service.CreateHisPsn(psn)
  18262. c.ServeSuccessJSON(map[string]interface{}{
  18263. "patient": patient,
  18264. "number": basNumber,
  18265. })
  18266. }
  18267. } else {
  18268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18269. return
  18270. }
  18271. }
  18272. func (c *HisApiController) TestGetHnBasBaseInit() {
  18273. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18274. Iinit := DllDef.MustFindProc("Init")
  18275. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18276. //http://10.77.211.236/CSB/hsa-fsi-1303
  18277. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  18278. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  18279. // 调用 Init 函数
  18280. 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"))))
  18281. //if ret != 0 {
  18282. fmt.Println("SSCard的报错原因:", err)
  18283. fmt.Println("SSCard的运算结果为:", ret)
  18284. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18285. // return
  18286. //}
  18287. result := int(ret)
  18288. fmt.Println("SSCard的运算结果为1:", result)
  18289. initFlag = 1
  18290. return
  18291. }
  18292. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  18293. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18294. Iinit := DllDef.MustFindProc("Init")
  18295. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18296. //http://10.77.211.236/CSB/hsa-fsi-1303
  18297. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  18298. if ret != 0 {
  18299. fmt.Println("SSCard的报错原因:", err)
  18300. fmt.Println("SSCard的运算结果为:", ret)
  18301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18302. return
  18303. }
  18304. result := int(ret)
  18305. fmt.Println("SSCard的运算结果为1:", result)
  18306. initFlag = 1
  18307. return
  18308. }
  18309. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  18310. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18311. Iinit := DllDef.MustFindProc("Init")
  18312. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18313. //http://10.77.211.236/CSB/hsa-fsi-1303
  18314. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  18315. if ret != 0 {
  18316. fmt.Println("SSCard的报错原因:", err)
  18317. fmt.Println("SSCard的运算结果为:", ret)
  18318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18319. return
  18320. }
  18321. result := int(ret)
  18322. fmt.Println("SSCard的运算结果为1:", result)
  18323. initFlag = 1
  18324. return
  18325. }
  18326. func (c *HisApiController) GetSFZBaseInfo() string {
  18327. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18328. readCard := DllDef.MustFindProc("ReadSFZ")
  18329. if readCard == nil {
  18330. fmt.Println("readcard is nil")
  18331. readCard = DllDef.MustFindProc("ReadSFZ")
  18332. }
  18333. str := make([]byte, 8096)
  18334. str1 := make([]byte, 8096)
  18335. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  18336. fmt.Println(r)
  18337. return Remove0000(string(str))
  18338. }
  18339. func (c *HisApiController) GetEleBaseInfo() string {
  18340. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18341. readCard := DllDef.MustFindProc("GetQRBase")
  18342. fmt.Println(readCard)
  18343. if readCard == nil {
  18344. fmt.Println("readcard is nil")
  18345. readCard = DllDef.MustFindProc("GetQRBase")
  18346. }
  18347. str := make([]byte, 1024)
  18348. str1 := make([]byte, 1024)
  18349. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  18350. fmt.Println(ret2)
  18351. fmt.Println(string(str1))
  18352. fmt.Println(string(str))
  18353. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18354. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18355. if ret2 != 0 {
  18356. return ""
  18357. }
  18358. return string(str)
  18359. }
  18360. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  18361. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18362. readCard := DllDef.MustFindProc("NationEcTrans")
  18363. fmt.Println(readCard)
  18364. fmt.Println("!!!!!")
  18365. pBusiCardInfo := make([]byte, 2048)
  18366. input := make(map[string]interface{})
  18367. inputData := make(map[string]interface{})
  18368. inputData["orgId"] = code
  18369. inputData["businessType"] = "01101"
  18370. inputData["operatorId"] = "1"
  18371. inputData["operatorName"] = "admin"
  18372. inputData["officeId"] = "001"
  18373. inputData["officeName"] = "血透室"
  18374. inputData["deviceType"] = ""
  18375. input["data"] = inputData
  18376. input["orgId"] = code
  18377. input["transType"] = "ec.query"
  18378. bytesData, _ := json.Marshal(input)
  18379. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  18380. fmt.Println(ret2)
  18381. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18382. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18383. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  18384. }
  18385. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  18386. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18387. readCard := DllDef.MustFindProc("NationEcTrans")
  18388. fmt.Println(readCard)
  18389. fmt.Println("!!!!!")
  18390. pBusiCardInfo := make([]byte, 2048)
  18391. input := make(map[string]interface{})
  18392. inputData := make(map[string]interface{})
  18393. inputData["orgId"] = code
  18394. inputData["businessType"] = "01101"
  18395. inputData["operatorId"] = "9"
  18396. inputData["operatorName"] = "admin"
  18397. inputData["officeId"] = "001"
  18398. inputData["officeName"] = "血透室"
  18399. inputData["deviceType"] = ""
  18400. input["data"] = inputData
  18401. input["orgId"] = code
  18402. input["transType"] = "ec.query"
  18403. bytesData, _ := json.Marshal(input)
  18404. 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])))
  18405. fmt.Println(ret2)
  18406. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18407. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18408. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  18409. }
  18410. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  18411. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18412. readCard := DllDef.MustFindProc("NationEcTrans")
  18413. fmt.Println(readCard)
  18414. fmt.Println("!!!!!")
  18415. pBusiCardInfo := make([]byte, 2048)
  18416. input := make(map[string]interface{})
  18417. inputData := make(map[string]interface{})
  18418. inputData["orgId"] = code
  18419. inputData["businessType"] = "01301"
  18420. inputData["operatorId"] = "9"
  18421. inputData["operatorName"] = "admin"
  18422. inputData["officeId"] = "001"
  18423. inputData["officeName"] = "血透室"
  18424. inputData["deviceType"] = ""
  18425. input["data"] = inputData
  18426. input["orgId"] = code
  18427. input["transType"] = "ec.query"
  18428. bytesData, _ := json.Marshal(input)
  18429. 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])))
  18430. fmt.Println(ret2)
  18431. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18432. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18433. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  18434. }
  18435. func GetJxEleBaseInfo(org_id int64) string {
  18436. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18437. readCard := DllDef.MustFindProc("NationEcTrans")
  18438. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18439. if readCard == nil {
  18440. fmt.Println("readcard is nil")
  18441. readCard = DllDef.MustFindProc("NationEcTrans")
  18442. }
  18443. str1 := make([]byte, 1024)
  18444. data := make(map[string]interface{})
  18445. inputData := make(map[string]interface{})
  18446. inputData["orgId"] = miConfig.Code
  18447. inputData["businessType"] = "01101"
  18448. inputData["operatorId"] = "test001"
  18449. inputData["operatorName"] = "cn"
  18450. inputData["officeId"] = "32760"
  18451. inputData["officeName"] = "waike"
  18452. inputData["deviceType"] = ""
  18453. data["data"] = inputData
  18454. data["transType"] = "ec.query"
  18455. data["extra "] = ""
  18456. data["orgId"] = miConfig.Code
  18457. bytesData, _ := json.Marshal(data)
  18458. //bytesData, _ := json.Marshal(data)
  18459. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18460. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18461. fmt.Println(ret2)
  18462. fmt.Println(string(str1))
  18463. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18464. if ret2 != 0 {
  18465. return ""
  18466. }
  18467. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18468. }
  18469. //func GetJxEleBaseInfoTWO(org_id int64) string {
  18470. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  18471. // readCard := DllDef.MustFindProc("NationEcTrans")
  18472. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18473. //
  18474. // if readCard == nil {
  18475. // fmt.Println("readcard is nil")
  18476. // readCard = DllDef.MustFindProc("NationEcTrans")
  18477. // }
  18478. // str1 := make([]byte, 1024)
  18479. //
  18480. // data := make(map[string]interface{})
  18481. //
  18482. // inputData := make(map[string]interface{})
  18483. // inputData["orgId"] = miConfig.Code
  18484. // inputData["businessType"] = "01101"
  18485. // inputData["operatorId"] = "test001"
  18486. // inputData["operatorName"] = "cn"
  18487. // inputData["officeId"] = "32760"
  18488. // inputData["officeName"] = "waike"
  18489. // inputData["deviceType"] = ""
  18490. //
  18491. // data["data"] = inputData
  18492. // data["transType"] = "ec.query"
  18493. // data["extra "] = ""
  18494. // data["orgId"] = miConfig.Code
  18495. // bytesData, _ := json.Marshal(data)
  18496. // //bytesData, _ := json.Marshal(data)
  18497. //
  18498. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18499. //
  18500. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18501. // fmt.Println(ret2)
  18502. // fmt.Println(string(str1))
  18503. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18504. //
  18505. // if ret2 != 0 {
  18506. // return ""
  18507. // }
  18508. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18509. //}
  18510. func GetJxEleBaseInitInfo(org_id int64) string {
  18511. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18512. readCard := DllDef.MustFindProc("NationEcTrans")
  18513. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18514. if readCard == nil {
  18515. fmt.Println("readcard is nil")
  18516. readCard = DllDef.MustFindProc("NationEcTrans")
  18517. }
  18518. str1 := make([]byte, 2048)
  18519. data := make(map[string]interface{})
  18520. inputData := make(map[string]interface{})
  18521. inputData["orgId"] = miConfig.Code
  18522. inputData["businessType"] = "01101"
  18523. inputData["operatorId"] = "1"
  18524. inputData["operatorName"] = "huangchuang"
  18525. inputData["officeId"] = "101"
  18526. inputData["officeName"] = "xuetou"
  18527. inputData["deviceType"] = ""
  18528. data["data"] = inputData
  18529. data["transType"] = "ec.query"
  18530. data["orgId"] = miConfig.Code
  18531. bytesData, _ := json.Marshal(data)
  18532. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18533. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18534. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  18535. fmt.Println(ret2)
  18536. fmt.Println(string(str1))
  18537. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18538. if ret2 != 0 {
  18539. return ""
  18540. }
  18541. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  18542. initEleFlag = 1
  18543. }
  18544. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18545. }
  18546. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  18547. // // 构建命令
  18548. // cmd := exec.Command("python", "b.py")
  18549. //
  18550. // // 执行命令并等待完成
  18551. // output, err := cmd.CombinedOutput()
  18552. // if err != nil {
  18553. // fmt.Println("Error executing Python script:", err)
  18554. // return
  18555. // }
  18556. //
  18557. // // 打印Python脚本的输出
  18558. // fmt.Println(string(output))
  18559. //}
  18560. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  18561. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  18562. readCard := DllDef.MustFindProc("gxyb_call")
  18563. if readCard == nil {
  18564. fmt.Println("readcard is nil")
  18565. readCard = DllDef.MustFindProc("gxyb_call")
  18566. }
  18567. str := make([]byte, 1024)
  18568. str1 := make([]byte, 1024)
  18569. //data := make(map[string]interface{})
  18570. currentTime := time.Now()
  18571. // 格式化时间为 "YYYYMMDDHH24MISS"
  18572. formattedTime := currentTime.Format("20060102150405")
  18573. inputData := make(map[string]interface{})
  18574. inputData2 := make(map[string]interface{})
  18575. inputData["transNo"] = "1401"
  18576. inputData["transType"] = "passwordCheck"
  18577. inputData["timestamp"] = formattedTime
  18578. inputData2["fixmedinsCode"] = code
  18579. inputData2["psnNo"] = ""
  18580. inputData["data"] = inputData2
  18581. jsonBytes, err := json.Marshal(inputData)
  18582. if err != nil {
  18583. fmt.Println("Error encoding map to JSON:", err)
  18584. }
  18585. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18586. fmt.Println(string(str1))
  18587. fmt.Println(string(str))
  18588. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18589. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18590. if ret2 != 0 {
  18591. return ""
  18592. }
  18593. return string(str)
  18594. }
  18595. func (c *HisApiController) GetoleInfo() Response {
  18596. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  18597. defer ole.CoUninitialize()
  18598. // Replace with the ProgID or CLSID of your COM object
  18599. progID := "YinHai.XJ.Actual.Interface.New"
  18600. // Create COM object
  18601. unknown, err := oleutil.CreateObject(progID)
  18602. if err != nil {
  18603. fmt.Println("Unable to create COM object:", err)
  18604. }
  18605. defer unknown.Release()
  18606. // Query for the IDispatch interface
  18607. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  18608. if err != nil {
  18609. fmt.Println("Unable to get IDispatch interface:", err)
  18610. }
  18611. defer dispatch.Release()
  18612. // Prepare parameters
  18613. transNo := "1401"
  18614. transType := "passwordCheck"
  18615. timestamp := time.Now().Unix()
  18616. fixmedinsCode := "H45072101171"
  18617. psnNo := ""
  18618. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  18619. result2 := ""
  18620. // Call COM object's method using the IDispatch interface
  18621. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  18622. fmt.Println(resulr)
  18623. fmt.Println(result2)
  18624. if err != nil {
  18625. fmt.Println("调用COM对象方法失败:", err)
  18626. }
  18627. var response Response
  18628. err2 := json.Unmarshal([]byte(result2), &response)
  18629. if err2 != nil {
  18630. fmt.Println("解析JSON失败:", err)
  18631. }
  18632. return response
  18633. }
  18634. func (c *HisApiController) GetBasBaseInfo() string {
  18635. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18636. readCard := DllDef.MustFindProc("ReadCardBas")
  18637. if readCard == nil {
  18638. fmt.Println("readcard is nil")
  18639. readCard = DllDef.MustFindProc("ReadCardBas")
  18640. }
  18641. str := make([]byte, 1024)
  18642. str1 := make([]byte, 1024)
  18643. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  18644. fmt.Println(string(str1))
  18645. fmt.Println(string(str))
  18646. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18647. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18648. if ret2 != 0 {
  18649. return ""
  18650. }
  18651. return string(str)
  18652. }
  18653. type Program struct {
  18654. FunctionID string `xml:"function_id"`
  18655. CardInfo string `xml:"cardinfo"`
  18656. User string `xml:"user"`
  18657. }
  18658. func (c *HisApiController) GetBasBaseInfo1111() string {
  18659. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  18660. readCard := DllDef.MustFindProc("ReadSICardInfo")
  18661. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  18662. if readCard == nil {
  18663. fmt.Println("readcard is nil")
  18664. readCard = DllDef.MustFindProc("ReadSICardInfo")
  18665. }
  18666. if readCard2 == nil {
  18667. fmt.Println("readcard is nil")
  18668. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  18669. }
  18670. str := make([]byte, 1024)
  18671. str1 := make([]byte, 1024)
  18672. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18673. str3 := make([]byte, 1024)
  18674. str4 := make([]byte, 1024)
  18675. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  18676. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18677. //if err != nil {
  18678. // fmt.Println("Error opening file:", err)
  18679. //}
  18680. //defer file.Close()
  18681. //
  18682. //var lastProgram Program
  18683. //scanner := bufio.NewScanner(file)
  18684. //inProgram := false
  18685. //
  18686. //for scanner.Scan() {
  18687. // line := scanner.Text()
  18688. // if strings.Contains(line, "<program>") {
  18689. // inProgram = true
  18690. // programXML := "<program>"
  18691. // for scanner.Scan() {
  18692. // line = scanner.Text()
  18693. // programXML += line
  18694. // if strings.Contains(line, "</program>") {
  18695. // programXML += "</program>"
  18696. // break
  18697. // }
  18698. // }
  18699. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18700. // // 解析成功,更新最后的 Program
  18701. // }
  18702. // inProgram = false
  18703. // }
  18704. //}
  18705. //
  18706. // fmt.Println("Error reading file:", inProgram)
  18707. //
  18708. //if err := scanner.Err(); err != nil {
  18709. // fmt.Println("Error reading file:", err)
  18710. //}
  18711. // 输出最后一次的 Program
  18712. //fmt.Printf("最后一次的 <program>:\n")
  18713. //fmt.Printf("<program>\n")
  18714. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18715. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18716. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18717. //fmt.Printf("</program>\n")
  18718. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18719. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18720. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  18721. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  18722. return ConvertToString(string(str), "gbk", "utf-8")
  18723. }
  18724. func (c *HisApiController) GetBasBaseInfo22222() string {
  18725. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  18726. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  18727. if readCard == nil {
  18728. fmt.Println("readcard is nil")
  18729. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  18730. }
  18731. str := make([]byte, 1024)
  18732. str1 := make([]byte, 1024)
  18733. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  18734. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  18735. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18736. //if err != nil {
  18737. // fmt.Println("Error opening file:", err)
  18738. //}
  18739. //defer file.Close()
  18740. //
  18741. //var lastProgram Program
  18742. //scanner := bufio.NewScanner(file)
  18743. //inProgram := false
  18744. //
  18745. //for scanner.Scan() {
  18746. // line := scanner.Text()
  18747. // if strings.Contains(line, "<program>") {
  18748. // inProgram = true
  18749. // programXML := "<program>"
  18750. // for scanner.Scan() {
  18751. // line = scanner.Text()
  18752. // programXML += line
  18753. // if strings.Contains(line, "</program>") {
  18754. // programXML += "</program>"
  18755. // break
  18756. // }
  18757. // }
  18758. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18759. // // 解析成功,更新最后的 Program
  18760. // }
  18761. // inProgram = false
  18762. // }
  18763. //}
  18764. //
  18765. // fmt.Println("Error reading file:", inProgram)
  18766. //
  18767. //if err := scanner.Err(); err != nil {
  18768. // fmt.Println("Error reading file:", err)
  18769. //}
  18770. // 输出最后一次的 Program
  18771. //fmt.Printf("最后一次的 <program>:\n")
  18772. //fmt.Printf("<program>\n")
  18773. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18774. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18775. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18776. //fmt.Printf("</program>\n")
  18777. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18778. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18779. return ConvertToString(string(str1), "gbk", "utf-8")
  18780. }
  18781. func (c *HisApiController) GetahBasBaseInfo() string {
  18782. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  18783. readCard := DllDef.MustFindProc("iReadCardBas")
  18784. if readCard == nil {
  18785. fmt.Println("readcard is nil")
  18786. readCard = DllDef.MustFindProc("iReadCardBas")
  18787. }
  18788. //str := make([]byte, 1024)
  18789. str1 := make([]byte, 1024)
  18790. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  18791. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18792. //if err != nil {
  18793. // fmt.Println("Error opening file:", err)
  18794. //}
  18795. //defer file.Close()
  18796. //
  18797. //var lastProgram Program
  18798. //scanner := bufio.NewScanner(file)
  18799. //inProgram := false
  18800. //
  18801. //for scanner.Scan() {
  18802. // line := scanner.Text()
  18803. // if strings.Contains(line, "<program>") {
  18804. // inProgram = true
  18805. // programXML := "<program>"
  18806. // for scanner.Scan() {
  18807. // line = scanner.Text()
  18808. // programXML += line
  18809. // if strings.Contains(line, "</program>") {
  18810. // programXML += "</program>"
  18811. // break
  18812. // }
  18813. // }
  18814. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18815. // // 解析成功,更新最后的 Program
  18816. // }
  18817. // inProgram = false
  18818. // }
  18819. //}
  18820. //
  18821. // fmt.Println("Error reading file:", inProgram)
  18822. //
  18823. //if err := scanner.Err(); err != nil {
  18824. // fmt.Println("Error reading file:", err)
  18825. //}
  18826. // 输出最后一次的 Program
  18827. //fmt.Printf("最后一次的 <program>:\n")
  18828. //fmt.Printf("<program>\n")
  18829. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18830. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18831. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18832. //fmt.Printf("</program>\n")
  18833. fmt.Println(string(str1))
  18834. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18835. if ret2 != 0 {
  18836. return ""
  18837. }
  18838. return string(str1)
  18839. }
  18840. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  18841. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  18842. readCard := DllDef.MustFindProc("read_cardinfo")
  18843. if readCard == nil {
  18844. fmt.Println("readcard is nil")
  18845. readCard = DllDef.MustFindProc("read_cardinfo")
  18846. }
  18847. str := make([]byte, 1024) //卡号
  18848. str1 := make([]byte, 1024) //卡识别码
  18849. str2 := make([]byte, 1024) //身份证号
  18850. str3 := make([]byte, 1024) //姓名
  18851. str4 := make([]byte, 1024) //错误信息
  18852. 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])))
  18853. fmt.Println(string(str1))
  18854. fmt.Println(string(str))
  18855. fmt.Println(string(str2))
  18856. fmt.Println(string(str3))
  18857. fmt.Println(string(str4))
  18858. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18859. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18860. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  18861. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  18862. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  18863. if ret2 != 0 {
  18864. return "", "", "", "", ""
  18865. }
  18866. return string(str), string(str1), string(str2), string(str3), string(str4)
  18867. }
  18868. type CustomFundPay struct {
  18869. FundPayType string `json:"fund_pay_type"`
  18870. FundPayamt float64 `json:"fund_payamt"`
  18871. InscpScpAmt float64 `json:"inscp_scp_amt"`
  18872. }
  18873. //func (c *HisApiController) GetBatchSettleList() {
  18874. // start_time_str := c.GetString("start_time")
  18875. // //end_time_str := c.GetString("end_time")
  18876. // admin_user_id, _ := c.GetInt64("admin_user_id")
  18877. //
  18878. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  18879. //
  18880. // for _, item := range orders {
  18881. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  18882. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18883. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18884. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18885. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18886. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18887. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18888. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18889. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18890. //
  18891. // if order.ID == 0 {
  18892. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  18893. // return
  18894. // }
  18895. //
  18896. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18897. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18898. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18899. // //fmt.Println(count)
  18900. // //var zero string
  18901. // //number := count + 1
  18902. // //if number >= 1000 {
  18903. // // zero = "0000" + strconv.FormatInt(number, 10)
  18904. // //} else if number >= 10000 {
  18905. // // zero = "000" + strconv.FormatInt(number, 10)
  18906. // //} else if number >= 100000 {
  18907. // // zero = "00" + strconv.FormatInt(number, 10)
  18908. // //} else if number >= 1000000 {
  18909. // // zero = "0" + strconv.FormatInt(number, 10)
  18910. // //} else {
  18911. // // zero = strconv.FormatInt(number, 10)
  18912. // //}
  18913. // //fmt.Println(zero)
  18914. //
  18915. // struct4101 := service.Struct4101{
  18916. // PsnNo: order.PsnNo,
  18917. // MdtrtId: order.MdtrtId,
  18918. // SetlId: order.SetlId,
  18919. // PsnName: order.PsnName,
  18920. // Gend: order.Gend,
  18921. // Brdy: his.Brdy,
  18922. // Age: his.Age,
  18923. // Naty: order.Naty,
  18924. // PatnCertType: "01",
  18925. // Certno: order.Certno,
  18926. // Prfs: "90",
  18927. // ConerName: roles[0].UserName,
  18928. // PatnRlts: "99",
  18929. // ConerAddr: miConfig.OrgName,
  18930. // ConerTel: admin.Mobile,
  18931. // HiType: order.Insutype,
  18932. // Insuplc: miConfig.InsuplcAdmdvs,
  18933. // MaindiagFlag: "1",
  18934. // BillCode: order.SetlId,
  18935. // BillNo: order.SetlId,
  18936. // BizSn: order.Number,
  18937. // PsnSelfPay: order.PsnPartAmt,
  18938. // PsnOwnPay: order.PsnPartAmt,
  18939. // AcctPay: order.AcctPay,
  18940. // PsnCashpay: order.PsnCashPay,
  18941. // HiPaymtd: "1",
  18942. // Hsorg: miConfig.InsuplcAdmdvs,
  18943. // HsorgOpter: miConfig.InsuplcAdmdvs,
  18944. // MedinsFillPsn: curRoles.UserName,
  18945. // MedinsFillDept: miConfig.OrgName,
  18946. // IptMedType: "2",
  18947. // }
  18948. // struct4101.SetlBegnDate = order.SetlTime
  18949. // struct4101.SetlEndDate = order.SetlTime
  18950. // time_arr := strings.Split(order.SetlTime, " ")
  18951. // struct4101.AdmTime = time_arr[0]
  18952. // struct4101.AdmEndTime = time_arr[0]
  18953. //
  18954. // var rf []CustomFundPay
  18955. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  18956. //
  18957. // var tempFunPays []service.CustomStruct
  18958. // for _, item := range rf {
  18959. // var tempFunPay service.CustomStruct
  18960. // tempFunPay.FundPayamt = item.FundPayamt
  18961. // tempFunPay.FundPayType = item.FundPayType
  18962. // tempFunPays = append(tempFunPays, tempFunPay)
  18963. // }
  18964. // struct4101.CustomStruct = tempFunPays
  18965. //
  18966. // var tempDiaginfos []service.DiaginfoStructTwo
  18967. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18968. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18969. //
  18970. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18971. // var config []*models.HisXtDiagnoseConfig
  18972. // for _, item := range diagnosis_ids {
  18973. // id, _ := strconv.ParseInt(item, 10, 64)
  18974. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  18975. // config = append(config, &diagnosisConfig)
  18976. // }
  18977. //
  18978. // for index, item := range config {
  18979. // if index == 0 {
  18980. // var tempDiaginfo service.DiaginfoStructTwo
  18981. // tempDiaginfo.DiagCode = item.CountryCode
  18982. // tempDiaginfo.DiagName = item.CountryContentName
  18983. // tempDiaginfo.DiagType = "1"
  18984. // tempDiaginfo.MaindiagFlag = "1"
  18985. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18986. // } else {
  18987. // var tempDiaginfo service.DiaginfoStructTwo
  18988. // tempDiaginfo.DiagCode = item.CountryCode
  18989. // tempDiaginfo.DiagName = item.CountryContentName
  18990. // tempDiaginfo.DiagType = "1"
  18991. // tempDiaginfo.MaindiagFlag = "0"
  18992. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18993. // }
  18994. // }
  18995. // struct4101.Diseinfo = tempDiaginfos
  18996. //
  18997. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  18998. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18999. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19000. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19001. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19002. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19003. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19004. //
  19005. // var iteminfo service.IteminfoStruct
  19006. //
  19007. // var bedCostTotal float64 = 0 //床位总费
  19008. // var bedCostSelfTotal float64 = 0 //床位自费
  19009. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19010. //
  19011. // var operationCostTotal float64 = 0 //手术费
  19012. // var operationCostSelfTotal float64 = 0 //手术费
  19013. // var operationCostPartSelfTotal float64 = 0 //手术费
  19014. //
  19015. // var otherCostTotal float64 = 0 //其他费用
  19016. // var otherCostSelfTotal float64 = 0 //其他费用
  19017. // var otherCostPartSelfTotal float64 = 0 //其他费用
  19018. //
  19019. // var materialCostTotal float64 = 0 //材料费
  19020. // var materialCostSelfTotal float64 = 0 //材料费
  19021. // var materialCostPartSelfTotal float64 = 0 //材料费
  19022. //
  19023. // var westernMedicineCostTotal float64 = 0 //西药费
  19024. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  19025. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19026. //
  19027. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19028. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19029. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19030. //
  19031. // var checkCostTotal float64 = 0 //检查费
  19032. // var checkCostSelfTotal float64 = 0 //检查费
  19033. // var checkCostPartSelfTotal float64 = 0 //检查费
  19034. //
  19035. // var laboratoryCostTotal float64 = 0 //化验费
  19036. // var laboratoryCostSelfTotal float64 = 0 //化验费
  19037. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19038. //
  19039. // var treatCostTotal float64 = 0 //治疗费用
  19040. // var treatCostSelfTotal float64 = 0 //治疗费用
  19041. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  19042. //
  19043. // decimal.DivisionPrecision = 2
  19044. //
  19045. // var bed_fulamt_ownpay_amt float64 = 0
  19046. // var operation_fulamt_ownpay_amt float64 = 0
  19047. // var other_fulamt_ownpay_amt float64 = 0
  19048. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  19049. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19050. // var check_fulamt_ownpay_amt float64 = 0
  19051. // var material_fulamt_ownpay_amt float64 = 0
  19052. // var laboratory_fulamt_ownpay_amt float64 = 0
  19053. // var treat_fulamt_ownpay_amt float64 = 0
  19054. //
  19055. // var bed_claa_sunmfee float64 = 0
  19056. // var bed_clab_amt float64 = 0
  19057. // var bed_other_amt float64 = 0
  19058. //
  19059. // var operation_claa_sunmfee float64 = 0
  19060. // var operation_clab_amt float64 = 0
  19061. // var operation_other_amt float64 = 0
  19062. //
  19063. // var other_claa_sunmfee float64 = 0
  19064. // var other_clab_amt float64 = 0
  19065. // var other_other_amt float64 = 0
  19066. //
  19067. // var westernMedicine_claa_sunmfee float64 = 0
  19068. // var westernMedicine_clab_amt float64 = 0
  19069. // var westernMedicine_other_amt float64 = 0
  19070. //
  19071. // var chineseTraditional_claa_sunmfee float64 = 0
  19072. // var chineseTraditional_clab_amt float64 = 0
  19073. // var chineseTraditional_other_amt float64 = 0
  19074. //
  19075. // var check_claa_sunmfee float64 = 0
  19076. // var check_clab_amt float64 = 0
  19077. // var check_other_amt float64 = 0
  19078. //
  19079. // var material_claa_sunmfee float64 = 0
  19080. // var material_clab_amt float64 = 0
  19081. // var material_other_amt float64 = 0
  19082. //
  19083. // var laboratory_claa_sunmfee float64 = 0
  19084. // var laboratory_clab_amt float64 = 0
  19085. // var laboratory_other_amt float64 = 0
  19086. //
  19087. // var treat_claa_sunmfee float64 = 0
  19088. // var treat_clab_amt float64 = 0
  19089. // var treat_other_amt float64 = 0
  19090. //
  19091. // for _, item := range order.HisOrderInfo {
  19092. // if item.MedChrgitmType == "01" { //床位费
  19093. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19094. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19095. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19096. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19097. // if item.ChrgitmLv == "1" {
  19098. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19099. // }
  19100. // if item.ChrgitmLv == "2" {
  19101. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19102. //
  19103. // }
  19104. // if item.ChrgitmLv == "3" {
  19105. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19106. // }
  19107. //
  19108. // }
  19109. //
  19110. // if item.MedChrgitmType == "03" { //检查费
  19111. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19112. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19113. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19114. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19115. // if item.ChrgitmLv == "1" {
  19116. //
  19117. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19118. //
  19119. // }
  19120. // if item.ChrgitmLv == "2" {
  19121. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19122. //
  19123. // }
  19124. // if item.ChrgitmLv == "3" {
  19125. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19126. // }
  19127. // }
  19128. //
  19129. // if item.MedChrgitmType == "04" { //化验费
  19130. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19131. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19132. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19133. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19134. // if item.ChrgitmLv == "1" {
  19135. //
  19136. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19137. //
  19138. // }
  19139. // if item.ChrgitmLv == "2" {
  19140. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19141. //
  19142. // }
  19143. // if item.ChrgitmLv == "3" {
  19144. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19145. // }
  19146. // }
  19147. //
  19148. // if item.MedChrgitmType == "05" { //治疗费
  19149. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19150. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19151. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19152. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19153. // if item.ChrgitmLv == "1" {
  19154. //
  19155. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19156. //
  19157. // }
  19158. // if item.ChrgitmLv == "2" {
  19159. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19160. //
  19161. // }
  19162. // if item.ChrgitmLv == "3" {
  19163. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19164. // }
  19165. // }
  19166. //
  19167. // if item.MedChrgitmType == "06" { //手术费
  19168. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19169. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19170. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19171. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19172. //
  19173. // if item.ChrgitmLv == "1" {
  19174. //
  19175. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19176. //
  19177. // }
  19178. // if item.ChrgitmLv == "2" {
  19179. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19180. //
  19181. // }
  19182. // if item.ChrgitmLv == "3" {
  19183. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19184. // }
  19185. // }
  19186. //
  19187. // if item.MedChrgitmType == "08" { //材料费
  19188. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19189. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19190. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19191. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19192. // if item.ChrgitmLv == "1" {
  19193. //
  19194. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19195. //
  19196. // }
  19197. // if item.ChrgitmLv == "2" {
  19198. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19199. //
  19200. // }
  19201. // if item.ChrgitmLv == "3" {
  19202. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19203. // }
  19204. // }
  19205. //
  19206. // if item.MedChrgitmType == "09" { //西药费
  19207. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19208. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19209. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19210. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19211. // if item.ChrgitmLv == "1" {
  19212. //
  19213. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19214. //
  19215. // }
  19216. // if item.ChrgitmLv == "2" {
  19217. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19218. //
  19219. // }
  19220. // if item.ChrgitmLv == "3" {
  19221. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19222. // }
  19223. // }
  19224. //
  19225. // if item.MedChrgitmType == "11" { //中成费
  19226. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19227. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19228. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19229. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19230. // if item.ChrgitmLv == "1" {
  19231. //
  19232. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19233. //
  19234. // }
  19235. // if item.ChrgitmLv == "2" {
  19236. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19237. //
  19238. // }
  19239. // if item.ChrgitmLv == "3" {
  19240. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19241. // }
  19242. // }
  19243. //
  19244. // if item.MedChrgitmType == "14" { //其他费
  19245. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19246. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19247. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19248. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19249. // if item.ChrgitmLv == "1" {
  19250. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19251. //
  19252. // }
  19253. // if item.ChrgitmLv == "2" {
  19254. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19255. //
  19256. // }
  19257. // if item.ChrgitmLv == "3" {
  19258. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19259. // }
  19260. // }
  19261. //
  19262. // }
  19263. //
  19264. // var iteminfoStructs []service.IteminfoStruct
  19265. //
  19266. // if bedCostTotal != 0 {
  19267. // iteminfo.MedChrgitm = "01"
  19268. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19269. // iteminfo.Amt = bedCostTotal
  19270. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  19271. // iteminfo.ClabAmt = bed_clab_amt
  19272. // iteminfo.OthAmt = bed_other_amt
  19273. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19274. // }
  19275. //
  19276. // if checkCostTotal != 0 {
  19277. // iteminfo.MedChrgitm = "03"
  19278. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19279. // iteminfo.Amt = checkCostTotal
  19280. // iteminfo.ClaaSumfee = check_claa_sunmfee
  19281. // iteminfo.ClabAmt = check_clab_amt
  19282. // iteminfo.OthAmt = check_other_amt
  19283. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19284. //
  19285. // }
  19286. //
  19287. // if laboratoryCostTotal != 0 {
  19288. // iteminfo.MedChrgitm = "04"
  19289. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19290. // iteminfo.Amt = laboratoryCostTotal
  19291. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19292. // iteminfo.ClabAmt = laboratory_clab_amt
  19293. // iteminfo.OthAmt = laboratory_other_amt
  19294. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19295. //
  19296. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19297. //
  19298. // }
  19299. //
  19300. // if treatCostTotal != 0 {
  19301. // iteminfo.MedChrgitm = "05"
  19302. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19303. // iteminfo.Amt = treatCostTotal
  19304. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  19305. // iteminfo.ClabAmt = treat_clab_amt
  19306. // iteminfo.OthAmt = treat_other_amt
  19307. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19308. // //(struct4101.IteminfoStruct, iteminfo)
  19309. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19310. // }
  19311. //
  19312. // if operationCostTotal != 0 {
  19313. // iteminfo.MedChrgitm = "06"
  19314. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19315. // iteminfo.Amt = operationCostTotal
  19316. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  19317. // iteminfo.ClabAmt = operation_clab_amt
  19318. // iteminfo.OthAmt = operation_other_amt
  19319. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19320. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19321. // }
  19322. //
  19323. // if materialCostTotal != 0 {
  19324. // iteminfo.MedChrgitm = "08"
  19325. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19326. // iteminfo.Amt = materialCostTotal
  19327. // iteminfo.ClaaSumfee = material_claa_sunmfee
  19328. // iteminfo.ClabAmt = material_clab_amt
  19329. // iteminfo.OthAmt = material_other_amt
  19330. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19331. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19332. // }
  19333. //
  19334. // if westernMedicineCostTotal != 0 {
  19335. // iteminfo.MedChrgitm = "09"
  19336. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19337. // iteminfo.Amt = westernMedicineCostTotal
  19338. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19339. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19340. // iteminfo.OthAmt = westernMedicine_other_amt
  19341. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19342. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19343. //
  19344. // }
  19345. // if chineseTraditionalMedicineCostTotal != 0 {
  19346. // iteminfo.MedChrgitm = "11"
  19347. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19348. // iteminfo.Amt = westernMedicineCostTotal
  19349. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19350. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19351. // iteminfo.OthAmt = westernMedicine_other_amt
  19352. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19353. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19354. //
  19355. // }
  19356. // if otherCostTotal != 0 {
  19357. // iteminfo.MedChrgitm = "14"
  19358. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19359. // iteminfo.Amt = otherCostTotal
  19360. // iteminfo.ClaaSumfee = other_claa_sunmfee
  19361. // iteminfo.ClabAmt = other_clab_amt
  19362. // iteminfo.OthAmt = other_other_amt
  19363. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19364. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19365. //
  19366. // }
  19367. // struct4101.IteminfoStruct = iteminfoStructs
  19368. // struct4101.Ntly = "中国"
  19369. // struct4101.AdmCaty = "A03.06"
  19370. //
  19371. // struct4101.DoctorName = doctor.UserName
  19372. // struct4101.DoctorCode = doctor.DoctorNumber
  19373. //
  19374. // var res ResultSeventeen
  19375. //
  19376. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19377. // struct4101.BillCode = order.Number
  19378. // struct4101.BillNo = order.SetlId
  19379. // var resOther ResultSeventeenOther
  19380. // var pp models.PublicParams
  19381. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19382. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19383. // pp.FixmedinsName = miConfig.OrgName
  19384. // pp.FixmedinsCode = miConfig.Code
  19385. // pp.RequestUrl = miConfig.Url
  19386. // pp.Cainfo = miConfig.Cainfo
  19387. // pp.SecretKey = miConfig.SecretKey
  19388. // pp.AccessKey = miConfig.AccessKey
  19389. // pp.OpterName = curRoles.UserName
  19390. //
  19391. // client := &http.Client{}
  19392. // var req *http.Request
  19393. // data := make(map[string]interface{})
  19394. // data["struct4101"] = struct4101
  19395. // data["pp"] = pp
  19396. // bytesData, _ := json.Marshal(data)
  19397. // if miConfig.MdtrtareaAdmvs == "320921" {
  19398. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19399. // } else {
  19400. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19401. // }
  19402. // resp, _ := client.Do(req)
  19403. // defer resp.Body.Close()
  19404. // body, ioErr := ioutil.ReadAll(resp.Body)
  19405. // if ioErr != nil {
  19406. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19407. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19408. // return
  19409. // }
  19410. // var respJSON map[string]interface{}
  19411. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19412. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19413. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19414. // return
  19415. // }
  19416. //
  19417. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19418. // userJSONBytes, _ := json.Marshal(respJSON)
  19419. // fmt.Println("log")
  19420. // fmt.Println(string(userJSONBytes))
  19421. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19422. // utils.ErrorLog("解析失败:%v", err)
  19423. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19424. // return
  19425. // }
  19426. // res.InfRefmsgid = resOther.InfRefmsgid
  19427. // res.Output = resOther.Output
  19428. // res.ErrMsg = resOther.ErrMsg
  19429. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19430. // res.Infcode = infocode
  19431. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  19432. //
  19433. // var pp models.PublicParams
  19434. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19435. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19436. // pp.FixmedinsName = miConfig.OrgName
  19437. // pp.FixmedinsCode = miConfig.Code
  19438. // pp.RequestUrl = miConfig.Url
  19439. // pp.Cainfo = miConfig.Cainfo
  19440. // pp.SecretKey = miConfig.SecretKey
  19441. // pp.AccessKey = miConfig.AccessKey
  19442. // pp.OpterName = curRoles.UserName
  19443. // result, _ := service.Jxyb4101(struct4101, pp)
  19444. // var dat map[string]interface{}
  19445. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19446. // fmt.Println(dat)
  19447. // } else {
  19448. // fmt.Println(err)
  19449. // }
  19450. // userJSONBytes, _ := json.Marshal(dat)
  19451. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19452. // utils.ErrorLog("解析失败:%v", err)
  19453. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19454. // return
  19455. // }
  19456. //
  19457. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  19458. // var pp models.PublicParams
  19459. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19460. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19461. // pp.FixmedinsName = miConfig.OrgName
  19462. // pp.FixmedinsCode = miConfig.Code
  19463. // pp.RequestUrl = miConfig.Url
  19464. // pp.Cainfo = miConfig.Cainfo
  19465. // pp.SecretKey = miConfig.SecretKey
  19466. // pp.AccessKey = miConfig.AccessKey
  19467. // pp.OpterName = curRoles.UserName
  19468. // result, _ := service.Hnyb4101(struct4101, pp)
  19469. // var dat map[string]interface{}
  19470. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19471. // fmt.Println(dat)
  19472. // } else {
  19473. // fmt.Println(err)
  19474. // }
  19475. // userJSONBytes, _ := json.Marshal(dat)
  19476. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19477. // utils.ErrorLog("解析失败:%v", err)
  19478. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19479. // return
  19480. // }
  19481. //
  19482. // } else if miConfig.MdtrtareaAdmvs == "150404" {
  19483. // var resOther ResultSeventeenOther
  19484. //
  19485. // var pp models.PublicParams
  19486. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19487. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19488. // pp.FixmedinsName = miConfig.OrgName
  19489. // pp.FixmedinsCode = miConfig.Code
  19490. // pp.RequestUrl = miConfig.Url
  19491. // pp.Cainfo = miConfig.Cainfo
  19492. // pp.SecretKey = miConfig.SecretKey
  19493. // pp.AccessKey = miConfig.AccessKey
  19494. // pp.OpterName = curRoles.UserName
  19495. // client := &http.Client{}
  19496. // var req *http.Request
  19497. // data := make(map[string]interface{})
  19498. // data["struct4101"] = struct4101
  19499. // data["pp"] = pp
  19500. // bytesData, _ := json.Marshal(data)
  19501. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19502. // resp, _ := client.Do(req)
  19503. // defer resp.Body.Close()
  19504. // body, ioErr := ioutil.ReadAll(resp.Body)
  19505. // if ioErr != nil {
  19506. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19507. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19508. // return
  19509. // }
  19510. // var respJSON map[string]interface{}
  19511. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19512. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19513. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19514. // return
  19515. // }
  19516. //
  19517. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19518. // userJSONBytes, _ := json.Marshal(respJSON)
  19519. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19520. // utils.ErrorLog("解析失败:%v", err)
  19521. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19522. // return
  19523. // }
  19524. // res.InfRefmsgid = resOther.InfRefmsgid
  19525. // res.Output = resOther.Output
  19526. // res.ErrMsg = resOther.ErrMsg
  19527. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19528. // res.Infcode = infocode
  19529. //
  19530. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  19531. // var pp models.PublicParams
  19532. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19533. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19534. // pp.FixmedinsName = miConfig.OrgName
  19535. // pp.FixmedinsCode = miConfig.Code
  19536. // pp.RequestUrl = miConfig.Url
  19537. // pp.Cainfo = miConfig.Cainfo
  19538. // pp.SecretKey = miConfig.SecretKey
  19539. // pp.AccessKey = miConfig.AccessKey
  19540. // pp.OpterName = curRoles.UserName
  19541. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19542. // fmt.Println(requestLog)
  19543. // fmt.Println(errMsgLog)
  19544. //
  19545. // saveLog(result, requestLog, "4101a", "上传清单")
  19546. //
  19547. // var dat map[string]interface{}
  19548. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19549. // fmt.Println(dat)
  19550. // } else {
  19551. // fmt.Println(err)
  19552. // }
  19553. // userJSONBytes, _ := json.Marshal(dat)
  19554. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19555. // utils.ErrorLog("解析失败:%v", err)
  19556. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19557. // return
  19558. // }
  19559. //
  19560. // } else {
  19561. //
  19562. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  19563. // var dat map[string]interface{}
  19564. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19565. // fmt.Println(dat)
  19566. // } else {
  19567. // fmt.Println(err)
  19568. // }
  19569. // userJSONBytes, _ := json.Marshal(dat)
  19570. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19571. // utils.ErrorLog("解析失败:%v", err)
  19572. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19573. // return
  19574. // }
  19575. // }
  19576. //
  19577. // if res.Infcode != 0 {
  19578. // adminUser := c.GetAdminUserInfo()
  19579. // errlog := &models.HisOrderError{
  19580. // UserOrgId: adminUser.CurrentOrgId,
  19581. // Ctime: time.Now().Unix(),
  19582. // Mtime: time.Now().Unix(),
  19583. // ErrMsg: res.ErrMsg,
  19584. // Status: 1,
  19585. // PatientId: order.ID,
  19586. // Stage: 10265,
  19587. // }
  19588. // service.CreateErrMsgLog(errlog)
  19589. // continue
  19590. // } else {
  19591. // //order.FaPiaoNumber = zero
  19592. // //order.FaPiaoCode = last_order.FaPiaoCode
  19593. // //service.UpdateOrder(order)
  19594. // hisFundSettleListResult := &models.HisFundSettleListResult{
  19595. // Number: res.Output.SetlListId,
  19596. // Status: 1,
  19597. // Ctime: time.Now().Unix(),
  19598. // Mtime: time.Now().Unix(),
  19599. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19600. // IsUpload: 1,
  19601. // OrderId: order.ID,
  19602. // }
  19603. // service.CreateUploadRecord(hisFundSettleListResult)
  19604. // c.ServeSuccessJSON(map[string]interface{}{
  19605. // "msg": "上传成功",
  19606. // "result": hisFundSettleListResult,
  19607. // })
  19608. // continue
  19609. // }
  19610. // }
  19611. //}
  19612. func (c *HisApiController) GetbatchSettleList() {
  19613. //order_id, _ := c.GetInt64("order_id")
  19614. admin_user_id, _ := c.GetInt64("admin_user_id")
  19615. start_date := c.GetString("start_date")
  19616. end_date := c.GetString("end_date")
  19617. orders, _ := service.GetAllHisOrderTwo10485(start_date, end_date)
  19618. for _, item := range orders {
  19619. order, _ := service.GetHisOrderByIDTwo(item.ID)
  19620. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19621. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19622. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19623. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19624. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19625. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19626. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19627. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19628. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19629. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19630. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19631. //fmt.Println(count)
  19632. //var zero string
  19633. //number := count + 1
  19634. //if number >= 1000 {
  19635. // zero = "0000" + strconv.FormatInt(number, 10)
  19636. //} else if number >= 10000 {
  19637. // zero = "000" + strconv.FormatInt(number, 10)
  19638. //} else if number >= 100000 {
  19639. // zero = "00" + strconv.FormatInt(number, 10)
  19640. //} else if number >= 1000000 {
  19641. // zero = "0" + strconv.FormatInt(number, 10)
  19642. //} else {
  19643. // zero = strconv.FormatInt(number, 10)
  19644. //}
  19645. //fmt.Println(zero)
  19646. struct4101 := service.Struct4101{
  19647. PsnNo: order.PsnNo,
  19648. MdtrtId: order.MdtrtId,
  19649. SetlId: order.SetlId,
  19650. PsnName: order.PsnName,
  19651. Gend: order.Gend,
  19652. Brdy: his.Brdy,
  19653. Age: his.Age,
  19654. Naty: order.Naty,
  19655. PatnCertType: "01",
  19656. Certno: order.Certno,
  19657. Prfs: "90",
  19658. ConerName: roles[0].UserName,
  19659. PatnRlts: "99",
  19660. ConerAddr: miConfig.OrgName,
  19661. ConerTel: admin.Mobile,
  19662. HiType: order.Insutype,
  19663. Insuplc: miConfig.InsuplcAdmdvs,
  19664. MaindiagFlag: "1",
  19665. BillCode: order.SetlId,
  19666. BillNo: order.SetlId,
  19667. BizSn: order.Number,
  19668. PsnSelfPay: order.PsnPartAmt,
  19669. PsnOwnPay: order.PsnPartAmt,
  19670. AcctPay: order.AcctPay,
  19671. PsnCashpay: order.PsnCashPay,
  19672. HiPaymtd: "1",
  19673. Hsorg: miConfig.InsuplcAdmdvs,
  19674. HsorgOpter: miConfig.InsuplcAdmdvs,
  19675. MedinsFillPsn: curRoles.UserName,
  19676. MedinsFillDept: miConfig.OrgName,
  19677. IptMedType: "2",
  19678. }
  19679. struct4101.SetlBegnDate = order.SetlTime
  19680. struct4101.SetlEndDate = order.SetlTime
  19681. time_arr := strings.Split(order.SetlTime, " ")
  19682. struct4101.AdmTime = time_arr[0]
  19683. struct4101.AdmEndTime = time_arr[0]
  19684. //var rf []CustomFundPay
  19685. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19686. //
  19687. //var tempFunPays []service.CustomStruct
  19688. //for _, item := range rf {
  19689. // var tempFunPay service.CustomStruct
  19690. // tempFunPay.FundPayamt = item.FundPayamt
  19691. // tempFunPay.FundPayType = item.FundPayType
  19692. // tempFunPays = append(tempFunPays, tempFunPay)
  19693. //}
  19694. //struct4101.CustomStruct = tempFunPays
  19695. var tempDiaginfos []service.DiaginfoStructTwo
  19696. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19697. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19698. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19699. var config []*models.HisXtDiagnoseConfig
  19700. for _, item := range diagnosis_ids {
  19701. id, _ := strconv.ParseInt(item, 10, 64)
  19702. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19703. config = append(config, &diagnosisConfig)
  19704. }
  19705. for index, item := range config {
  19706. if index == 0 {
  19707. var tempDiaginfo service.DiaginfoStructTwo
  19708. tempDiaginfo.DiagCode = item.CountryCode
  19709. tempDiaginfo.DiagName = item.CountryContentName
  19710. tempDiaginfo.DiagType = "1"
  19711. tempDiaginfo.MaindiagFlag = "1"
  19712. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19713. } else {
  19714. var tempDiaginfo service.DiaginfoStructTwo
  19715. tempDiaginfo.DiagCode = item.CountryCode
  19716. tempDiaginfo.DiagName = item.CountryContentName
  19717. tempDiaginfo.DiagType = "1"
  19718. tempDiaginfo.MaindiagFlag = "0"
  19719. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19720. }
  19721. }
  19722. struct4101.Diseinfo = tempDiaginfos
  19723. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19724. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19725. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19726. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19727. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19728. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19729. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19730. var iteminfo service.IteminfoStruct
  19731. var bedCostTotal float64 = 0 //床位总费
  19732. var bedCostSelfTotal float64 = 0 //床位自费
  19733. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19734. var operationCostTotal float64 = 0 //手术费
  19735. var operationCostSelfTotal float64 = 0 //手术费
  19736. var operationCostPartSelfTotal float64 = 0 //手术费
  19737. var otherCostTotal float64 = 0 //其他费用
  19738. var otherCostSelfTotal float64 = 0 //其他费用
  19739. var otherCostPartSelfTotal float64 = 0 //其他费用
  19740. var materialCostTotal float64 = 0 //材料费
  19741. var materialCostSelfTotal float64 = 0 //材料费
  19742. var materialCostPartSelfTotal float64 = 0 //材料费
  19743. var westernMedicineCostTotal float64 = 0 //西药费
  19744. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19745. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19746. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19747. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19748. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19749. var checkCostTotal float64 = 0 //检查费
  19750. var checkCostSelfTotal float64 = 0 //检查费
  19751. var checkCostPartSelfTotal float64 = 0 //检查费
  19752. var laboratoryCostTotal float64 = 0 //化验费
  19753. var laboratoryCostSelfTotal float64 = 0 //化验费
  19754. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19755. var treatCostTotal float64 = 0 //治疗费用
  19756. var treatCostSelfTotal float64 = 0 //治疗费用
  19757. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19758. decimal.DivisionPrecision = 2
  19759. var bed_fulamt_ownpay_amt float64 = 0
  19760. var operation_fulamt_ownpay_amt float64 = 0
  19761. var other_fulamt_ownpay_amt float64 = 0
  19762. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19763. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19764. var check_fulamt_ownpay_amt float64 = 0
  19765. var material_fulamt_ownpay_amt float64 = 0
  19766. var laboratory_fulamt_ownpay_amt float64 = 0
  19767. var treat_fulamt_ownpay_amt float64 = 0
  19768. var bed_claa_sunmfee float64 = 0
  19769. var bed_clab_amt float64 = 0
  19770. var bed_other_amt float64 = 0
  19771. var operation_claa_sunmfee float64 = 0
  19772. var operation_clab_amt float64 = 0
  19773. var operation_other_amt float64 = 0
  19774. var other_claa_sunmfee float64 = 0
  19775. var other_clab_amt float64 = 0
  19776. var other_other_amt float64 = 0
  19777. var westernMedicine_claa_sunmfee float64 = 0
  19778. var westernMedicine_clab_amt float64 = 0
  19779. var westernMedicine_other_amt float64 = 0
  19780. var chineseTraditional_claa_sunmfee float64 = 0
  19781. var chineseTraditional_clab_amt float64 = 0
  19782. var chineseTraditional_other_amt float64 = 0
  19783. var check_claa_sunmfee float64 = 0
  19784. var check_clab_amt float64 = 0
  19785. var check_other_amt float64 = 0
  19786. var material_claa_sunmfee float64 = 0
  19787. var material_clab_amt float64 = 0
  19788. var material_other_amt float64 = 0
  19789. var laboratory_claa_sunmfee float64 = 0
  19790. var laboratory_clab_amt float64 = 0
  19791. var laboratory_other_amt float64 = 0
  19792. var treat_claa_sunmfee float64 = 0
  19793. var treat_clab_amt float64 = 0
  19794. var treat_other_amt float64 = 0
  19795. for _, item := range order.HisOrderInfo {
  19796. if item.MedChrgitmType == "01" { //床位费
  19797. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19798. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19799. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19800. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19801. if item.ChrgitmLv == "1" {
  19802. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19803. }
  19804. if item.ChrgitmLv == "2" {
  19805. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19806. }
  19807. if item.ChrgitmLv == "3" {
  19808. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19809. }
  19810. }
  19811. if item.MedChrgitmType == "03" { //检查费
  19812. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19813. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19814. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19815. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19816. if item.ChrgitmLv == "1" {
  19817. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19818. }
  19819. if item.ChrgitmLv == "2" {
  19820. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19821. }
  19822. if item.ChrgitmLv == "3" {
  19823. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19824. }
  19825. }
  19826. if item.MedChrgitmType == "04" { //化验费
  19827. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19828. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19829. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19830. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19831. if item.ChrgitmLv == "1" {
  19832. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19833. }
  19834. if item.ChrgitmLv == "2" {
  19835. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19836. }
  19837. if item.ChrgitmLv == "3" {
  19838. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19839. }
  19840. }
  19841. if item.MedChrgitmType == "05" { //治疗费
  19842. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19843. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19844. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19845. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19846. if item.ChrgitmLv == "1" {
  19847. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19848. }
  19849. if item.ChrgitmLv == "2" {
  19850. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19851. }
  19852. if item.ChrgitmLv == "3" {
  19853. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19854. }
  19855. }
  19856. if item.MedChrgitmType == "06" { //手术费
  19857. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19858. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19859. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19860. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19861. if item.ChrgitmLv == "1" {
  19862. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19863. }
  19864. if item.ChrgitmLv == "2" {
  19865. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19866. }
  19867. if item.ChrgitmLv == "3" {
  19868. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19869. }
  19870. }
  19871. if item.MedChrgitmType == "08" { //材料费
  19872. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19873. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19874. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19875. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19876. if item.ChrgitmLv == "1" {
  19877. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19878. }
  19879. if item.ChrgitmLv == "2" {
  19880. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19881. }
  19882. if item.ChrgitmLv == "3" {
  19883. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19884. }
  19885. }
  19886. if item.MedChrgitmType == "09" { //西药费
  19887. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19888. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19889. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19890. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19891. if item.ChrgitmLv == "1" {
  19892. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19893. }
  19894. if item.ChrgitmLv == "2" {
  19895. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19896. }
  19897. if item.ChrgitmLv == "3" {
  19898. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19899. }
  19900. }
  19901. if item.MedChrgitmType == "11" { //中成费
  19902. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19903. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19904. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19905. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19906. if item.ChrgitmLv == "1" {
  19907. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19908. }
  19909. if item.ChrgitmLv == "2" {
  19910. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19911. }
  19912. if item.ChrgitmLv == "3" {
  19913. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19914. }
  19915. }
  19916. if item.MedChrgitmType == "14" { //其他费
  19917. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19918. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19919. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19920. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19921. if item.ChrgitmLv == "1" {
  19922. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19923. }
  19924. if item.ChrgitmLv == "2" {
  19925. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19926. }
  19927. if item.ChrgitmLv == "3" {
  19928. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19929. }
  19930. }
  19931. }
  19932. var iteminfoStructs []service.IteminfoStruct
  19933. if bedCostTotal != 0 {
  19934. iteminfo.MedChrgitm = "01"
  19935. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19936. iteminfo.Amt = bedCostTotal
  19937. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19938. iteminfo.ClabAmt = bed_clab_amt
  19939. iteminfo.OthAmt = bed_other_amt
  19940. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19941. }
  19942. if checkCostTotal != 0 {
  19943. iteminfo.MedChrgitm = "03"
  19944. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19945. iteminfo.Amt = checkCostTotal
  19946. iteminfo.ClaaSumfee = check_claa_sunmfee
  19947. iteminfo.ClabAmt = check_clab_amt
  19948. iteminfo.OthAmt = check_other_amt
  19949. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19950. }
  19951. if laboratoryCostTotal != 0 {
  19952. iteminfo.MedChrgitm = "04"
  19953. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19954. iteminfo.Amt = laboratoryCostTotal
  19955. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19956. iteminfo.ClabAmt = laboratory_clab_amt
  19957. iteminfo.OthAmt = laboratory_other_amt
  19958. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19959. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19960. }
  19961. if treatCostTotal != 0 {
  19962. iteminfo.MedChrgitm = "05"
  19963. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19964. iteminfo.Amt = treatCostTotal
  19965. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19966. iteminfo.ClabAmt = treat_clab_amt
  19967. iteminfo.OthAmt = treat_other_amt
  19968. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19969. //(struct4101.IteminfoStruct, iteminfo)
  19970. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19971. }
  19972. if operationCostTotal != 0 {
  19973. iteminfo.MedChrgitm = "06"
  19974. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19975. iteminfo.Amt = operationCostTotal
  19976. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19977. iteminfo.ClabAmt = operation_clab_amt
  19978. iteminfo.OthAmt = operation_other_amt
  19979. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19980. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19981. }
  19982. if materialCostTotal != 0 {
  19983. iteminfo.MedChrgitm = "08"
  19984. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19985. iteminfo.Amt = materialCostTotal
  19986. iteminfo.ClaaSumfee = material_claa_sunmfee
  19987. iteminfo.ClabAmt = material_clab_amt
  19988. iteminfo.OthAmt = material_other_amt
  19989. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19990. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19991. }
  19992. if westernMedicineCostTotal != 0 {
  19993. iteminfo.MedChrgitm = "09"
  19994. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19995. iteminfo.Amt = westernMedicineCostTotal
  19996. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19997. iteminfo.ClabAmt = westernMedicine_clab_amt
  19998. iteminfo.OthAmt = westernMedicine_other_amt
  19999. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20000. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20001. }
  20002. if chineseTraditionalMedicineCostTotal != 0 {
  20003. iteminfo.MedChrgitm = "11"
  20004. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20005. iteminfo.Amt = westernMedicineCostTotal
  20006. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20007. iteminfo.ClabAmt = westernMedicine_clab_amt
  20008. iteminfo.OthAmt = westernMedicine_other_amt
  20009. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20010. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20011. }
  20012. if otherCostTotal != 0 {
  20013. iteminfo.MedChrgitm = "14"
  20014. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20015. iteminfo.Amt = otherCostTotal
  20016. iteminfo.ClaaSumfee = other_claa_sunmfee
  20017. iteminfo.ClabAmt = other_clab_amt
  20018. iteminfo.OthAmt = other_other_amt
  20019. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20020. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20021. }
  20022. struct4101.IteminfoStruct = iteminfoStructs
  20023. struct4101.Ntly = "中国"
  20024. struct4101.AdmCaty = "A03.06"
  20025. struct4101.DoctorName = doctor.UserName
  20026. struct4101.DoctorCode = doctor.DoctorNumber
  20027. var res ResultSeventeen
  20028. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  20029. struct4101.BillCode = order.Number
  20030. struct4101.BillNo = order.SetlId
  20031. var resOther ResultSeventeenOther
  20032. var pp models.PublicParams
  20033. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20034. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20035. pp.FixmedinsName = miConfig.OrgName
  20036. pp.FixmedinsCode = miConfig.Code
  20037. pp.RequestUrl = miConfig.Url
  20038. pp.Cainfo = miConfig.Cainfo
  20039. pp.SecretKey = miConfig.SecretKey
  20040. pp.AccessKey = miConfig.AccessKey
  20041. pp.OpterName = curRoles.UserName
  20042. client := &http.Client{}
  20043. var req *http.Request
  20044. data := make(map[string]interface{})
  20045. data["struct4101"] = struct4101
  20046. data["pp"] = pp
  20047. bytesData, _ := json.Marshal(data)
  20048. if miConfig.MdtrtareaAdmvs == "320830" {
  20049. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/4101", bytes.NewReader(bytesData))
  20050. } else if miConfig.MdtrtareaAdmvs == "320921" {
  20051. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20052. } else {
  20053. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20054. }
  20055. resp, _ := client.Do(req)
  20056. defer resp.Body.Close()
  20057. body, ioErr := ioutil.ReadAll(resp.Body)
  20058. if ioErr != nil {
  20059. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20061. return
  20062. }
  20063. var respJSON map[string]interface{}
  20064. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20065. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20067. return
  20068. }
  20069. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  20070. userJSONBytes, _ := json.Marshal(respJSON)
  20071. fmt.Println("log")
  20072. fmt.Println(string(userJSONBytes))
  20073. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20074. utils.ErrorLog("解析失败:%v", err)
  20075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20076. return
  20077. }
  20078. res.InfRefmsgid = resOther.InfRefmsgid
  20079. res.Output = resOther.Output
  20080. res.ErrMsg = resOther.ErrMsg
  20081. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20082. res.Infcode = infocode
  20083. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20084. var pp models.PublicParams
  20085. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20086. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20087. pp.FixmedinsName = miConfig.OrgName
  20088. pp.FixmedinsCode = miConfig.Code
  20089. pp.RequestUrl = miConfig.Url
  20090. pp.Cainfo = miConfig.Cainfo
  20091. pp.SecretKey = miConfig.SecretKey
  20092. pp.AccessKey = miConfig.AccessKey
  20093. pp.OpterName = curRoles.UserName
  20094. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  20095. result, _ := service.Jxyb4101(struct4101, pp)
  20096. var dat map[string]interface{}
  20097. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20098. fmt.Println(dat)
  20099. } else {
  20100. fmt.Println(err)
  20101. }
  20102. userJSONBytes, _ := json.Marshal(dat)
  20103. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20104. utils.ErrorLog("解析失败:%v", err)
  20105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20106. return
  20107. }
  20108. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20109. var pp models.PublicParams
  20110. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20111. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20112. pp.FixmedinsName = miConfig.OrgName
  20113. pp.FixmedinsCode = miConfig.Code
  20114. pp.RequestUrl = miConfig.Url
  20115. pp.Cainfo = miConfig.Cainfo
  20116. pp.SecretKey = miConfig.SecretKey
  20117. pp.AccessKey = miConfig.AccessKey
  20118. pp.OpterName = curRoles.UserName
  20119. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  20120. result, _ := service.Jxyb4101(struct4101, pp)
  20121. var dat map[string]interface{}
  20122. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20123. fmt.Println(dat)
  20124. } else {
  20125. fmt.Println(err)
  20126. }
  20127. userJSONBytes, _ := json.Marshal(dat)
  20128. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20129. utils.ErrorLog("解析失败:%v", err)
  20130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20131. return
  20132. }
  20133. } else if miConfig.MdtrtareaAdmvs == "360100" {
  20134. var pp models.PublicParams
  20135. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20136. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20137. pp.FixmedinsName = miConfig.OrgName
  20138. pp.FixmedinsCode = miConfig.Code
  20139. pp.RequestUrl = miConfig.Url
  20140. pp.Cainfo = miConfig.Cainfo
  20141. pp.SecretKey = miConfig.SecretKey
  20142. pp.AccessKey = miConfig.AccessKey
  20143. pp.OpterName = curRoles.UserName
  20144. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  20145. result, _ := service.Jxyb4101(struct4101, pp)
  20146. var dat map[string]interface{}
  20147. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20148. fmt.Println(dat)
  20149. } else {
  20150. fmt.Println(err)
  20151. }
  20152. userJSONBytes, _ := json.Marshal(dat)
  20153. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20154. utils.ErrorLog("解析失败:%v", err)
  20155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20156. return
  20157. }
  20158. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20159. var pp models.PublicParams
  20160. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20161. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20162. pp.FixmedinsName = miConfig.OrgName
  20163. pp.FixmedinsCode = miConfig.Code
  20164. pp.RequestUrl = miConfig.Url
  20165. pp.Cainfo = miConfig.Cainfo
  20166. pp.SecretKey = miConfig.SecretKey
  20167. pp.AccessKey = miConfig.AccessKey
  20168. pp.OpterName = curRoles.UserName
  20169. result, _ := service.Hnyb4101(struct4101, pp)
  20170. var dat map[string]interface{}
  20171. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20172. fmt.Println(dat)
  20173. } else {
  20174. fmt.Println(err)
  20175. }
  20176. userJSONBytes, _ := json.Marshal(dat)
  20177. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20178. utils.ErrorLog("解析失败:%v", err)
  20179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20180. return
  20181. }
  20182. } else if miConfig.MdtrtareaAdmvs == "150404" {
  20183. var resOther ResultSeventeenOther
  20184. var pp models.PublicParams
  20185. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20186. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20187. pp.FixmedinsName = miConfig.OrgName
  20188. pp.FixmedinsCode = miConfig.Code
  20189. pp.RequestUrl = miConfig.Url
  20190. pp.Cainfo = miConfig.Cainfo
  20191. pp.SecretKey = miConfig.SecretKey
  20192. pp.AccessKey = miConfig.AccessKey
  20193. pp.OpterName = curRoles.UserName
  20194. client := &http.Client{}
  20195. var req *http.Request
  20196. data := make(map[string]interface{})
  20197. data["struct4101"] = struct4101
  20198. data["pp"] = pp
  20199. bytesData, _ := json.Marshal(data)
  20200. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20201. resp, _ := client.Do(req)
  20202. defer resp.Body.Close()
  20203. body, ioErr := ioutil.ReadAll(resp.Body)
  20204. if ioErr != nil {
  20205. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20207. return
  20208. }
  20209. var respJSON map[string]interface{}
  20210. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20211. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20213. return
  20214. }
  20215. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20216. userJSONBytes, _ := json.Marshal(respJSON)
  20217. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20218. utils.ErrorLog("解析失败:%v", err)
  20219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20220. return
  20221. }
  20222. res.InfRefmsgid = resOther.InfRefmsgid
  20223. res.Output = resOther.Output
  20224. res.ErrMsg = resOther.ErrMsg
  20225. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20226. res.Infcode = infocode
  20227. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20228. var pp models.PublicParams
  20229. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20230. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20231. pp.FixmedinsName = miConfig.OrgName
  20232. pp.FixmedinsCode = miConfig.Code
  20233. pp.RequestUrl = miConfig.Url
  20234. pp.Cainfo = miConfig.Cainfo
  20235. pp.SecretKey = miConfig.SecretKey
  20236. pp.AccessKey = miConfig.AccessKey
  20237. pp.OpterName = curRoles.UserName
  20238. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20239. fmt.Println(requestLog)
  20240. fmt.Println(errMsgLog)
  20241. saveLog(result, requestLog, "4101a", "上传清单")
  20242. var dat map[string]interface{}
  20243. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20244. fmt.Println(dat)
  20245. } else {
  20246. fmt.Println(err)
  20247. }
  20248. userJSONBytes, _ := json.Marshal(dat)
  20249. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20250. utils.ErrorLog("解析失败:%v", err)
  20251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20252. return
  20253. }
  20254. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20255. var pp models.PublicParams
  20256. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20257. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20258. pp.FixmedinsName = miConfig.OrgName
  20259. pp.FixmedinsCode = miConfig.Code
  20260. pp.RequestUrl = miConfig.Url
  20261. pp.Cainfo = miConfig.Cainfo
  20262. pp.SecretKey = miConfig.SecretKey
  20263. pp.AccessKey = miConfig.AccessKey
  20264. pp.OpterName = curRoles.UserName
  20265. client := &http.Client{}
  20266. var req *http.Request
  20267. data := make(map[string]interface{})
  20268. data["struct4101"] = struct4101
  20269. data["pp"] = pp
  20270. bytesData, _ := json.Marshal(data)
  20271. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  20272. resp, _ := client.Do(req)
  20273. defer resp.Body.Close()
  20274. body, ioErr := ioutil.ReadAll(resp.Body)
  20275. if ioErr != nil {
  20276. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20278. return
  20279. }
  20280. var respJSON map[string]interface{}
  20281. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20282. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20284. return
  20285. }
  20286. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20287. userJSONBytes, _ := json.Marshal(respJSON)
  20288. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20289. utils.ErrorLog("解析失败:%v", err)
  20290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20291. return
  20292. }
  20293. } else {
  20294. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20295. var dat map[string]interface{}
  20296. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20297. fmt.Println(dat)
  20298. } else {
  20299. fmt.Println(err)
  20300. }
  20301. userJSONBytes, _ := json.Marshal(dat)
  20302. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20303. utils.ErrorLog("解析失败:%v", err)
  20304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20305. return
  20306. }
  20307. }
  20308. if res.Infcode != 0 {
  20309. errlog := &models.HisOrderError{
  20310. UserOrgId: order.UserOrgId,
  20311. Ctime: time.Now().Unix(),
  20312. Mtime: time.Now().Unix(),
  20313. ErrMsg: res.ErrMsg + "解析失败",
  20314. Status: 1,
  20315. PatientId: order.ID,
  20316. Stage: 10485,
  20317. }
  20318. service.CreateErrMsgLog(errlog)
  20319. continue
  20320. //c.ServeSuccessJSON(map[string]interface{}{
  20321. // "failed_code": -10,
  20322. // "msg": res.ErrMsg,
  20323. //})
  20324. } else {
  20325. //order.FaPiaoNumber = zero
  20326. //order.FaPiaoCode = last_order.FaPiaoCode
  20327. //service.UpdateOrder(order)
  20328. hisFundSettleListResult := &models.HisFundSettleListResult{
  20329. Number: res.Output.SetlListId,
  20330. Status: 1,
  20331. Ctime: time.Now().Unix(),
  20332. Mtime: time.Now().Unix(),
  20333. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20334. IsUpload: 1,
  20335. OrderId: order.ID,
  20336. }
  20337. service.CreateUploadRecord(hisFundSettleListResult)
  20338. continue
  20339. }
  20340. }
  20341. }
  20342. func (c *HisApiController) GetSettleList() {
  20343. order_id, _ := c.GetInt64("order_id")
  20344. admin_user_id, _ := c.GetInt64("admin_user_id")
  20345. order, _ := service.GetHisOrderByIDTwo(order_id)
  20346. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20347. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20348. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20349. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  20350. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20351. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20352. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20353. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20354. if order.ID == 0 {
  20355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20356. return
  20357. }
  20358. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  20359. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  20360. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  20361. //fmt.Println(count)
  20362. //var zero string
  20363. //number := count + 1
  20364. //if number >= 1000 {
  20365. // zero = "0000" + strconv.FormatInt(number, 10)
  20366. //} else if number >= 10000 {
  20367. // zero = "000" + strconv.FormatInt(number, 10)
  20368. //} else if number >= 100000 {
  20369. // zero = "00" + strconv.FormatInt(number, 10)
  20370. //} else if number >= 1000000 {
  20371. // zero = "0" + strconv.FormatInt(number, 10)
  20372. //} else {
  20373. // zero = strconv.FormatInt(number, 10)
  20374. //}
  20375. //fmt.Println(zero)
  20376. struct4101 := service.Struct4101{
  20377. PsnNo: order.PsnNo,
  20378. MdtrtId: order.MdtrtId,
  20379. SetlId: order.SetlId,
  20380. PsnName: order.PsnName,
  20381. Gend: order.Gend,
  20382. Brdy: his.Brdy,
  20383. Age: his.Age,
  20384. Naty: order.Naty,
  20385. PatnCertType: "01",
  20386. Certno: order.Certno,
  20387. Prfs: "90",
  20388. ConerName: roles[0].UserName,
  20389. PatnRlts: "99",
  20390. ConerAddr: miConfig.OrgName,
  20391. ConerTel: admin.Mobile,
  20392. HiType: order.Insutype,
  20393. Insuplc: miConfig.InsuplcAdmdvs,
  20394. MaindiagFlag: "1",
  20395. BillCode: order.SetlId,
  20396. BillNo: order.SetlId,
  20397. BizSn: order.Number,
  20398. PsnSelfPay: order.PsnPartAmt,
  20399. PsnOwnPay: order.PsnPartAmt,
  20400. AcctPay: order.AcctPay,
  20401. PsnCashpay: order.PsnCashPay,
  20402. HiPaymtd: "1",
  20403. Hsorg: miConfig.InsuplcAdmdvs,
  20404. HsorgOpter: miConfig.InsuplcAdmdvs,
  20405. MedinsFillPsn: curRoles.UserName,
  20406. MedinsFillDept: miConfig.OrgName,
  20407. IptMedType: "2",
  20408. }
  20409. struct4101.SetlBegnDate = order.SetlTime
  20410. struct4101.SetlEndDate = order.SetlTime
  20411. time_arr := strings.Split(order.SetlTime, " ")
  20412. struct4101.AdmTime = time_arr[0]
  20413. struct4101.AdmEndTime = time_arr[0]
  20414. //
  20415. //var rf []CustomFundPay
  20416. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  20417. //
  20418. //var tempFunPays []service.CustomStruct
  20419. //for _, item := range rf {
  20420. // var tempFunPay service.CustomStruct
  20421. // tempFunPay.FundPayamt = item.FundPayamt
  20422. // tempFunPay.FundPayType = item.FundPayType
  20423. // tempFunPays = append(tempFunPays, tempFunPay)
  20424. //}
  20425. //struct4101.CustomStruct = tempFunPays
  20426. var tempDiaginfos []service.DiaginfoStructTwo
  20427. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20428. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20429. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  20430. var config []*models.HisXtDiagnoseConfig
  20431. for _, item := range diagnosis_ids {
  20432. id, _ := strconv.ParseInt(item, 10, 64)
  20433. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20434. config = append(config, &diagnosisConfig)
  20435. }
  20436. if miConfig.Code == "H15049901371" {
  20437. //for _, item := range config {
  20438. // if item.ID == 138 {
  20439. diagnosisConfig, _ := service.FindDiagnoseById(138)
  20440. var tempDiaginfo service.DiaginfoStructTwo
  20441. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  20442. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  20443. tempDiaginfo.DiagType = "1"
  20444. tempDiaginfo.MaindiagFlag = "1"
  20445. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20446. //}
  20447. //}
  20448. for _, item := range config {
  20449. if item.ID != 138 {
  20450. var tempDiaginfo service.DiaginfoStructTwo
  20451. tempDiaginfo.DiagCode = item.CountryCode
  20452. tempDiaginfo.DiagName = item.CountryContentName
  20453. tempDiaginfo.DiagType = "1"
  20454. tempDiaginfo.MaindiagFlag = "0"
  20455. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20456. }
  20457. }
  20458. } else {
  20459. for index, item := range config {
  20460. if index == 0 {
  20461. var tempDiaginfo service.DiaginfoStructTwo
  20462. tempDiaginfo.DiagCode = item.CountryCode
  20463. tempDiaginfo.DiagName = item.CountryContentName
  20464. tempDiaginfo.DiagType = "1"
  20465. tempDiaginfo.MaindiagFlag = "1"
  20466. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20467. } else {
  20468. var tempDiaginfo service.DiaginfoStructTwo
  20469. tempDiaginfo.DiagCode = item.CountryCode
  20470. tempDiaginfo.DiagName = item.CountryContentName
  20471. tempDiaginfo.DiagType = "1"
  20472. tempDiaginfo.MaindiagFlag = "0"
  20473. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20474. }
  20475. }
  20476. }
  20477. struct4101.Diseinfo = tempDiaginfos
  20478. sickConfigTwo, _ := service.FindSickById(his.SickType)
  20479. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20480. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20481. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  20482. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  20483. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20484. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20485. var iteminfo service.IteminfoStruct
  20486. var bedCostTotal float64 = 0 //床位总费
  20487. var bedCostSelfTotal float64 = 0 //床位自费
  20488. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20489. var operationCostTotal float64 = 0 //手术费
  20490. var operationCostSelfTotal float64 = 0 //手术费
  20491. var operationCostPartSelfTotal float64 = 0 //手术费
  20492. var otherCostTotal float64 = 0 //其他费用
  20493. var otherCostSelfTotal float64 = 0 //其他费用
  20494. var otherCostPartSelfTotal float64 = 0 //其他费用
  20495. var materialCostTotal float64 = 0 //材料费
  20496. var materialCostSelfTotal float64 = 0 //材料费
  20497. var materialCostPartSelfTotal float64 = 0 //材料费
  20498. var westernMedicineCostTotal float64 = 0 //西药费
  20499. var westernMedicineCostSelfTotal float64 = 0 //西药费
  20500. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20501. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20502. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20503. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20504. var checkCostTotal float64 = 0 //检查费
  20505. var checkCostSelfTotal float64 = 0 //检查费
  20506. var checkCostPartSelfTotal float64 = 0 //检查费
  20507. var laboratoryCostTotal float64 = 0 //化验费
  20508. var laboratoryCostSelfTotal float64 = 0 //化验费
  20509. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20510. var treatCostTotal float64 = 0 //治疗费用
  20511. var treatCostSelfTotal float64 = 0 //治疗费用
  20512. var treatCostPartSelfTotal float64 = 0 //治疗费用
  20513. decimal.DivisionPrecision = 2
  20514. var bed_fulamt_ownpay_amt float64 = 0
  20515. var operation_fulamt_ownpay_amt float64 = 0
  20516. var other_fulamt_ownpay_amt float64 = 0
  20517. var westernMedicine_fulamt_ownpay_amt float64 = 0
  20518. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20519. var check_fulamt_ownpay_amt float64 = 0
  20520. var material_fulamt_ownpay_amt float64 = 0
  20521. var laboratory_fulamt_ownpay_amt float64 = 0
  20522. var treat_fulamt_ownpay_amt float64 = 0
  20523. var bed_claa_sunmfee float64 = 0
  20524. var bed_clab_amt float64 = 0
  20525. var bed_other_amt float64 = 0
  20526. var operation_claa_sunmfee float64 = 0
  20527. var operation_clab_amt float64 = 0
  20528. var operation_other_amt float64 = 0
  20529. var other_claa_sunmfee float64 = 0
  20530. var other_clab_amt float64 = 0
  20531. var other_other_amt float64 = 0
  20532. var westernMedicine_claa_sunmfee float64 = 0
  20533. var westernMedicine_clab_amt float64 = 0
  20534. var westernMedicine_other_amt float64 = 0
  20535. var chineseTraditional_claa_sunmfee float64 = 0
  20536. var chineseTraditional_clab_amt float64 = 0
  20537. var chineseTraditional_other_amt float64 = 0
  20538. var check_claa_sunmfee float64 = 0
  20539. var check_clab_amt float64 = 0
  20540. var check_other_amt float64 = 0
  20541. var material_claa_sunmfee float64 = 0
  20542. var material_clab_amt float64 = 0
  20543. var material_other_amt float64 = 0
  20544. var laboratory_claa_sunmfee float64 = 0
  20545. var laboratory_clab_amt float64 = 0
  20546. var laboratory_other_amt float64 = 0
  20547. var treat_claa_sunmfee float64 = 0
  20548. var treat_clab_amt float64 = 0
  20549. var treat_other_amt float64 = 0
  20550. for _, item := range order.HisOrderInfo {
  20551. if item.MedChrgitmType == "01" { //床位费
  20552. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20553. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20554. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20555. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20556. if item.ChrgitmLv == "1" {
  20557. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20558. }
  20559. if item.ChrgitmLv == "2" {
  20560. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20561. }
  20562. if item.ChrgitmLv == "3" {
  20563. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20564. }
  20565. }
  20566. if item.MedChrgitmType == "03" { //检查费
  20567. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20568. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20569. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20570. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20571. if item.ChrgitmLv == "1" {
  20572. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20573. }
  20574. if item.ChrgitmLv == "2" {
  20575. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20576. }
  20577. if item.ChrgitmLv == "3" {
  20578. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20579. }
  20580. }
  20581. if item.MedChrgitmType == "04" { //化验费
  20582. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20583. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20584. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20585. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20586. if item.ChrgitmLv == "1" {
  20587. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20588. }
  20589. if item.ChrgitmLv == "2" {
  20590. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20591. }
  20592. if item.ChrgitmLv == "3" {
  20593. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20594. }
  20595. }
  20596. if item.MedChrgitmType == "05" { //治疗费
  20597. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20598. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20599. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20600. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20601. if item.ChrgitmLv == "1" {
  20602. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20603. }
  20604. if item.ChrgitmLv == "2" {
  20605. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20606. }
  20607. if item.ChrgitmLv == "3" {
  20608. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20609. }
  20610. }
  20611. if item.MedChrgitmType == "06" { //手术费
  20612. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20613. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20614. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20615. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20616. if item.ChrgitmLv == "1" {
  20617. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20618. }
  20619. if item.ChrgitmLv == "2" {
  20620. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20621. }
  20622. if item.ChrgitmLv == "3" {
  20623. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20624. }
  20625. }
  20626. if item.MedChrgitmType == "08" { //材料费
  20627. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20628. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20629. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20630. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20631. if item.ChrgitmLv == "1" {
  20632. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20633. }
  20634. if item.ChrgitmLv == "2" {
  20635. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20636. }
  20637. if item.ChrgitmLv == "3" {
  20638. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20639. }
  20640. }
  20641. if item.MedChrgitmType == "09" { //西药费
  20642. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20643. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20644. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20645. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20646. if item.ChrgitmLv == "1" {
  20647. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20648. }
  20649. if item.ChrgitmLv == "2" {
  20650. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20651. }
  20652. if item.ChrgitmLv == "3" {
  20653. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20654. }
  20655. }
  20656. if item.MedChrgitmType == "11" { //中成费
  20657. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20658. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20659. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20660. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20661. if item.ChrgitmLv == "1" {
  20662. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20663. }
  20664. if item.ChrgitmLv == "2" {
  20665. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20666. }
  20667. if item.ChrgitmLv == "3" {
  20668. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20669. }
  20670. }
  20671. if item.MedChrgitmType == "14" { //其他费
  20672. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20673. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20674. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20675. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20676. if item.ChrgitmLv == "1" {
  20677. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20678. }
  20679. if item.ChrgitmLv == "2" {
  20680. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20681. }
  20682. if item.ChrgitmLv == "3" {
  20683. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20684. }
  20685. }
  20686. }
  20687. var iteminfoStructs []service.IteminfoStruct
  20688. if bedCostTotal != 0 {
  20689. iteminfo.MedChrgitm = "01"
  20690. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20691. iteminfo.Amt = bedCostTotal
  20692. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20693. iteminfo.ClabAmt = bed_clab_amt
  20694. iteminfo.OthAmt = bed_other_amt
  20695. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20696. }
  20697. if checkCostTotal != 0 {
  20698. iteminfo.MedChrgitm = "03"
  20699. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20700. iteminfo.Amt = checkCostTotal
  20701. iteminfo.ClaaSumfee = check_claa_sunmfee
  20702. iteminfo.ClabAmt = check_clab_amt
  20703. iteminfo.OthAmt = check_other_amt
  20704. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20705. }
  20706. if laboratoryCostTotal != 0 {
  20707. iteminfo.MedChrgitm = "04"
  20708. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20709. iteminfo.Amt = laboratoryCostTotal
  20710. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20711. iteminfo.ClabAmt = laboratory_clab_amt
  20712. iteminfo.OthAmt = laboratory_other_amt
  20713. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20714. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20715. }
  20716. if treatCostTotal != 0 {
  20717. iteminfo.MedChrgitm = "05"
  20718. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20719. iteminfo.Amt = treatCostTotal
  20720. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20721. iteminfo.ClabAmt = treat_clab_amt
  20722. iteminfo.OthAmt = treat_other_amt
  20723. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20724. //(struct4101.IteminfoStruct, iteminfo)
  20725. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20726. }
  20727. if operationCostTotal != 0 {
  20728. iteminfo.MedChrgitm = "06"
  20729. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20730. iteminfo.Amt = operationCostTotal
  20731. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20732. iteminfo.ClabAmt = operation_clab_amt
  20733. iteminfo.OthAmt = operation_other_amt
  20734. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20735. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20736. }
  20737. if materialCostTotal != 0 {
  20738. iteminfo.MedChrgitm = "08"
  20739. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20740. iteminfo.Amt = materialCostTotal
  20741. iteminfo.ClaaSumfee = material_claa_sunmfee
  20742. iteminfo.ClabAmt = material_clab_amt
  20743. iteminfo.OthAmt = material_other_amt
  20744. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20745. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20746. }
  20747. if westernMedicineCostTotal != 0 {
  20748. iteminfo.MedChrgitm = "09"
  20749. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20750. iteminfo.Amt = westernMedicineCostTotal
  20751. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20752. iteminfo.ClabAmt = westernMedicine_clab_amt
  20753. iteminfo.OthAmt = westernMedicine_other_amt
  20754. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20755. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20756. }
  20757. if chineseTraditionalMedicineCostTotal != 0 {
  20758. iteminfo.MedChrgitm = "11"
  20759. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20760. iteminfo.Amt = westernMedicineCostTotal
  20761. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20762. iteminfo.ClabAmt = westernMedicine_clab_amt
  20763. iteminfo.OthAmt = westernMedicine_other_amt
  20764. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20765. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20766. }
  20767. if otherCostTotal != 0 {
  20768. iteminfo.MedChrgitm = "14"
  20769. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20770. iteminfo.Amt = otherCostTotal
  20771. iteminfo.ClaaSumfee = other_claa_sunmfee
  20772. iteminfo.ClabAmt = other_clab_amt
  20773. iteminfo.OthAmt = other_other_amt
  20774. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20775. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20776. }
  20777. struct4101.IteminfoStruct = iteminfoStructs
  20778. struct4101.Ntly = "中国"
  20779. struct4101.AdmCaty = "A03.06"
  20780. struct4101.DoctorName = doctor.UserName
  20781. struct4101.DoctorCode = doctor.DoctorNumber
  20782. var res ResultSeventeen
  20783. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  20784. struct4101.BillCode = order.Number
  20785. struct4101.BillNo = order.SetlId
  20786. var resOther ResultSeventeenOther
  20787. var pp models.PublicParams
  20788. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20789. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20790. pp.FixmedinsName = miConfig.OrgName
  20791. pp.FixmedinsCode = miConfig.Code
  20792. pp.RequestUrl = miConfig.Url
  20793. pp.Cainfo = miConfig.Cainfo
  20794. pp.SecretKey = miConfig.SecretKey
  20795. pp.AccessKey = miConfig.AccessKey
  20796. pp.OpterName = curRoles.UserName
  20797. client := &http.Client{}
  20798. var req *http.Request
  20799. data := make(map[string]interface{})
  20800. data["struct4101"] = struct4101
  20801. data["pp"] = pp
  20802. bytesData, _ := json.Marshal(data)
  20803. if miConfig.MdtrtareaAdmvs == "320830" {
  20804. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/4101", bytes.NewReader(bytesData))
  20805. } else if miConfig.MdtrtareaAdmvs == "320921" {
  20806. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20807. } else {
  20808. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20809. }
  20810. resp, _ := client.Do(req)
  20811. defer resp.Body.Close()
  20812. body, ioErr := ioutil.ReadAll(resp.Body)
  20813. if ioErr != nil {
  20814. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20816. return
  20817. }
  20818. var respJSON map[string]interface{}
  20819. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20822. return
  20823. }
  20824. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  20825. userJSONBytes, _ := json.Marshal(respJSON)
  20826. fmt.Println("log")
  20827. fmt.Println(string(userJSONBytes))
  20828. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20829. utils.ErrorLog("解析失败:%v", err)
  20830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20831. return
  20832. }
  20833. res.InfRefmsgid = resOther.InfRefmsgid
  20834. res.Output = resOther.Output
  20835. res.ErrMsg = resOther.ErrMsg
  20836. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20837. res.Infcode = infocode
  20838. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20839. var pp models.PublicParams
  20840. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20841. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20842. pp.FixmedinsName = miConfig.OrgName
  20843. pp.FixmedinsCode = miConfig.Code
  20844. pp.RequestUrl = miConfig.Url
  20845. pp.Cainfo = miConfig.Cainfo
  20846. pp.SecretKey = miConfig.SecretKey
  20847. pp.AccessKey = miConfig.AccessKey
  20848. pp.OpterName = curRoles.UserName
  20849. result, _ := service.Jxyb4101(struct4101, pp)
  20850. var dat map[string]interface{}
  20851. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20852. fmt.Println(dat)
  20853. } else {
  20854. fmt.Println(err)
  20855. }
  20856. userJSONBytes, _ := json.Marshal(dat)
  20857. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20858. utils.ErrorLog("解析失败:%v", err)
  20859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20860. return
  20861. }
  20862. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20863. var pp models.PublicParams
  20864. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20865. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20866. pp.FixmedinsName = miConfig.OrgName
  20867. pp.FixmedinsCode = miConfig.Code
  20868. pp.RequestUrl = miConfig.Url
  20869. pp.Cainfo = miConfig.Cainfo
  20870. pp.SecretKey = miConfig.SecretKey
  20871. pp.AccessKey = miConfig.AccessKey
  20872. pp.OpterName = curRoles.UserName
  20873. result, _ := service.Jxyb4101(struct4101, pp)
  20874. var dat map[string]interface{}
  20875. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20876. fmt.Println(dat)
  20877. } else {
  20878. fmt.Println(err)
  20879. }
  20880. userJSONBytes, _ := json.Marshal(dat)
  20881. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20882. utils.ErrorLog("解析失败:%v", err)
  20883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20884. return
  20885. }
  20886. } else if miConfig.MdtrtareaAdmvs == "360100" {
  20887. var pp models.PublicParams
  20888. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20889. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20890. pp.FixmedinsName = miConfig.OrgName
  20891. pp.FixmedinsCode = miConfig.Code
  20892. pp.RequestUrl = miConfig.Url
  20893. pp.Cainfo = miConfig.Cainfo
  20894. pp.SecretKey = miConfig.SecretKey
  20895. pp.AccessKey = miConfig.AccessKey
  20896. pp.OpterName = curRoles.UserName
  20897. result, _ := service.Jxyb4101(struct4101, pp)
  20898. var dat map[string]interface{}
  20899. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20900. fmt.Println(dat)
  20901. } else {
  20902. fmt.Println(err)
  20903. }
  20904. userJSONBytes, _ := json.Marshal(dat)
  20905. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20906. utils.ErrorLog("解析失败:%v", err)
  20907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20908. return
  20909. }
  20910. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20911. var pp models.PublicParams
  20912. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20913. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20914. pp.FixmedinsName = miConfig.OrgName
  20915. pp.FixmedinsCode = miConfig.Code
  20916. pp.RequestUrl = miConfig.Url
  20917. pp.Cainfo = miConfig.Cainfo
  20918. pp.SecretKey = miConfig.SecretKey
  20919. pp.AccessKey = miConfig.AccessKey
  20920. pp.OpterName = curRoles.UserName
  20921. result, _ := service.Hnyb4101(struct4101, pp)
  20922. var dat map[string]interface{}
  20923. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20924. fmt.Println(dat)
  20925. } else {
  20926. fmt.Println(err)
  20927. }
  20928. userJSONBytes, _ := json.Marshal(dat)
  20929. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20930. utils.ErrorLog("解析失败:%v", err)
  20931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20932. return
  20933. }
  20934. } else if miConfig.MdtrtareaAdmvs == "150404" {
  20935. var resOther ResultSeventeenOther
  20936. var pp models.PublicParams
  20937. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20938. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20939. pp.FixmedinsName = miConfig.OrgName
  20940. pp.FixmedinsCode = miConfig.Code
  20941. pp.RequestUrl = miConfig.Url
  20942. pp.Cainfo = miConfig.Cainfo
  20943. pp.SecretKey = miConfig.SecretKey
  20944. pp.AccessKey = miConfig.AccessKey
  20945. pp.OpterName = curRoles.UserName
  20946. client := &http.Client{}
  20947. var req *http.Request
  20948. data := make(map[string]interface{})
  20949. data["struct4101"] = struct4101
  20950. data["pp"] = pp
  20951. bytesData, _ := json.Marshal(data)
  20952. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20953. resp, _ := client.Do(req)
  20954. defer resp.Body.Close()
  20955. body, ioErr := ioutil.ReadAll(resp.Body)
  20956. if ioErr != nil {
  20957. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20959. return
  20960. }
  20961. var respJSON map[string]interface{}
  20962. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20963. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20965. return
  20966. }
  20967. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20968. userJSONBytes, _ := json.Marshal(respJSON)
  20969. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20970. utils.ErrorLog("解析失败:%v", err)
  20971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20972. return
  20973. }
  20974. res.InfRefmsgid = resOther.InfRefmsgid
  20975. res.Output = resOther.Output
  20976. res.ErrMsg = resOther.ErrMsg
  20977. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20978. res.Infcode = infocode
  20979. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20980. var pp models.PublicParams
  20981. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20982. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20983. pp.FixmedinsName = miConfig.OrgName
  20984. pp.FixmedinsCode = miConfig.Code
  20985. pp.RequestUrl = miConfig.Url
  20986. pp.Cainfo = miConfig.Cainfo
  20987. pp.SecretKey = miConfig.SecretKey
  20988. pp.AccessKey = miConfig.AccessKey
  20989. pp.OpterName = curRoles.UserName
  20990. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20991. fmt.Println(requestLog)
  20992. fmt.Println(errMsgLog)
  20993. saveLog(result, requestLog, "4101a", "上传清单")
  20994. var dat map[string]interface{}
  20995. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20996. fmt.Println(dat)
  20997. } else {
  20998. fmt.Println(err)
  20999. }
  21000. userJSONBytes, _ := json.Marshal(dat)
  21001. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21002. utils.ErrorLog("解析失败:%v", err)
  21003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21004. return
  21005. }
  21006. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21007. var pp models.PublicParams
  21008. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  21009. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21010. pp.FixmedinsName = miConfig.OrgName
  21011. pp.FixmedinsCode = miConfig.Code
  21012. pp.RequestUrl = miConfig.Url
  21013. pp.Cainfo = miConfig.Cainfo
  21014. pp.SecretKey = miConfig.SecretKey
  21015. pp.AccessKey = miConfig.AccessKey
  21016. pp.OpterName = curRoles.UserName
  21017. client := &http.Client{}
  21018. var req *http.Request
  21019. data := make(map[string]interface{})
  21020. data["struct4101"] = struct4101
  21021. data["pp"] = pp
  21022. bytesData, _ := json.Marshal(data)
  21023. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  21024. resp, _ := client.Do(req)
  21025. defer resp.Body.Close()
  21026. body, ioErr := ioutil.ReadAll(resp.Body)
  21027. if ioErr != nil {
  21028. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21030. return
  21031. }
  21032. var respJSON map[string]interface{}
  21033. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21036. return
  21037. }
  21038. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21039. userJSONBytes, _ := json.Marshal(respJSON)
  21040. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21041. utils.ErrorLog("解析失败:%v", err)
  21042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21043. return
  21044. }
  21045. } else {
  21046. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  21047. var dat map[string]interface{}
  21048. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21049. fmt.Println(dat)
  21050. } else {
  21051. fmt.Println(err)
  21052. }
  21053. userJSONBytes, _ := json.Marshal(dat)
  21054. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21055. utils.ErrorLog("解析失败:%v", err)
  21056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21057. return
  21058. }
  21059. }
  21060. if res.Infcode != 0 {
  21061. c.ServeSuccessJSON(map[string]interface{}{
  21062. "failed_code": -10,
  21063. "msg": res.ErrMsg,
  21064. })
  21065. return
  21066. } else {
  21067. //order.FaPiaoNumber = zero
  21068. //order.FaPiaoCode = last_order.FaPiaoCode
  21069. //service.UpdateOrder(order)
  21070. hisFundSettleListResult := &models.HisFundSettleListResult{
  21071. Number: res.Output.SetlListId,
  21072. Status: 1,
  21073. Ctime: time.Now().Unix(),
  21074. Mtime: time.Now().Unix(),
  21075. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21076. IsUpload: 1,
  21077. OrderId: order_id,
  21078. }
  21079. service.CreateUploadRecord(hisFundSettleListResult)
  21080. c.ServeSuccessJSON(map[string]interface{}{
  21081. "msg": "上传成功",
  21082. "result": hisFundSettleListResult,
  21083. })
  21084. return
  21085. }
  21086. }
  21087. func (c *HisApiController) GetSettleListHospital() {
  21088. order_id, _ := c.GetInt64("order_id")
  21089. admin_user_id, _ := c.GetInt64("admin_user_id")
  21090. order, _ := service.GetHisOrderByIDTwo(order_id)
  21091. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  21092. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  21093. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  21094. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  21095. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  21096. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  21097. if order.ID == 0 {
  21098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  21099. return
  21100. }
  21101. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  21102. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  21103. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  21104. fmt.Println(count)
  21105. var zero string
  21106. number := count + 1
  21107. if number >= 1000 {
  21108. zero = "0000" + strconv.FormatInt(number, 10)
  21109. } else if number >= 10000 {
  21110. zero = "000" + strconv.FormatInt(number, 10)
  21111. } else if number >= 100000 {
  21112. zero = "00" + strconv.FormatInt(number, 10)
  21113. } else if number >= 1000000 {
  21114. zero = "0" + strconv.FormatInt(number, 10)
  21115. } else {
  21116. zero = strconv.FormatInt(number, 10)
  21117. }
  21118. fmt.Println(zero)
  21119. struct4101 := service.Struct4101{
  21120. PsnNo: order.PsnNo,
  21121. MdtrtId: order.MdtrtId,
  21122. SetlId: order.SetlId,
  21123. PsnName: order.PsnName,
  21124. Gend: order.Gend,
  21125. Brdy: his.Brdy,
  21126. Age: int64(order.Age),
  21127. Naty: order.Naty,
  21128. PatnCertType: "01",
  21129. Certno: order.Certno,
  21130. Prfs: "90",
  21131. ConerName: roles[0].UserName,
  21132. PatnRlts: "99",
  21133. ConerAddr: miConfig.OrgName,
  21134. ConerTel: admin.Mobile,
  21135. HiType: order.Insutype,
  21136. Insuplc: miConfig.InsuplcAdmdvs,
  21137. MaindiagFlag: "1",
  21138. BillCode: order.SetlId,
  21139. BillNo: order.SetlId,
  21140. BizSn: order.Number,
  21141. PsnSelfPay: order.PsnPartAmt,
  21142. PsnOwnPay: order.PsnPartAmt,
  21143. AcctPay: order.AcctPay,
  21144. PsnCashpay: order.PsnCashPay,
  21145. HiPaymtd: "1",
  21146. Hsorg: miConfig.InsuplcAdmdvs,
  21147. HsorgOpter: miConfig.InsuplcAdmdvs,
  21148. MedinsFillPsn: curRoles.UserName,
  21149. MedinsFillDept: depart.Name,
  21150. IptMedType: "2",
  21151. AdmTime: his.InHosptialTime,
  21152. AdmEndTime: his.OutHosptialTime,
  21153. }
  21154. struct4101.SetlBegnDate = order.SetlTime
  21155. struct4101.SetlEndDate = order.SetlTime
  21156. //var rf []CustomFundPay
  21157. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  21158. //
  21159. //var tempFunPays []service.CustomStruct
  21160. //for _, item := range rf {
  21161. // var tempFunPay service.CustomStruct
  21162. // tempFunPay.FundPayamt = item.FundPayamt
  21163. // tempFunPay.FundPayType = item.FundPayType
  21164. // tempFunPays = append(tempFunPays, tempFunPay)
  21165. //}
  21166. //struct4101.CustomStruct = tempFunPays
  21167. var tempDiaginfos []service.DiaginfoStructTwo
  21168. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  21169. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  21170. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  21171. //for _, item := range infos {
  21172. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  21173. //}
  21174. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  21175. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  21176. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  21177. fmt.Println(diagnosis_ids_arr)
  21178. if order.UserOrgId == 10210 {
  21179. var diagnosis_ids_arr_two []int64
  21180. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  21181. var config []*models.HisXtDiagnoseConfig
  21182. for _, id := range diagnosis_ids_arr_two {
  21183. //id, _ := strconv.ParseInt(item, 10, 64)
  21184. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21185. if diagnosisConfig.ID > 0 {
  21186. config = append(config, &diagnosisConfig)
  21187. }
  21188. }
  21189. for index, item := range config {
  21190. if item.ID > 0 {
  21191. if index == 0 {
  21192. var tempDiaginfo service.DiaginfoStructTwo
  21193. tempDiaginfo.DiagCode = item.CountryCode
  21194. tempDiaginfo.DiagName = item.CountryContentName
  21195. tempDiaginfo.DiagType = "1"
  21196. tempDiaginfo.MaindiagFlag = "1"
  21197. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21198. } else {
  21199. var tempDiaginfo service.DiaginfoStructTwo
  21200. tempDiaginfo.DiagCode = item.CountryCode
  21201. tempDiaginfo.DiagName = item.CountryContentName
  21202. tempDiaginfo.DiagType = "1"
  21203. tempDiaginfo.MaindiagFlag = "0"
  21204. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21205. }
  21206. }
  21207. }
  21208. struct4101.Diseinfo = tempDiaginfos
  21209. } else {
  21210. var config []*models.HisXtDiagnoseConfig
  21211. for _, item := range diagnosis_ids_arr {
  21212. id, _ := strconv.ParseInt(item, 10, 64)
  21213. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21214. if diagnosisConfig.ID > 0 {
  21215. config = append(config, &diagnosisConfig)
  21216. }
  21217. }
  21218. for index, item := range config {
  21219. if item.ID > 0 {
  21220. if index == 0 {
  21221. var tempDiaginfo service.DiaginfoStructTwo
  21222. tempDiaginfo.DiagCode = item.CountryCode
  21223. tempDiaginfo.DiagName = item.CountryContentName
  21224. tempDiaginfo.DiagType = "1"
  21225. tempDiaginfo.MaindiagFlag = "1"
  21226. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21227. } else {
  21228. var tempDiaginfo service.DiaginfoStructTwo
  21229. tempDiaginfo.DiagCode = item.CountryCode
  21230. tempDiaginfo.DiagName = item.CountryContentName
  21231. tempDiaginfo.DiagType = "1"
  21232. tempDiaginfo.MaindiagFlag = "0"
  21233. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21234. }
  21235. }
  21236. }
  21237. struct4101.Diseinfo = tempDiaginfos
  21238. }
  21239. sickConfigTwo, _ := service.FindSickById(his.SickType)
  21240. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  21241. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  21242. tempOpspdiseinfo2.OprnOprtCode = ""
  21243. tempOpspdiseinfo2.OprnOprtName = ""
  21244. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  21245. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  21246. var iteminfo service.IteminfoStruct
  21247. var bedCostTotal float64 = 0 //床位总费
  21248. var bedCostSelfTotal float64 = 0 //床位自费
  21249. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  21250. var operationCostTotal float64 = 0 //手术费
  21251. var operationCostSelfTotal float64 = 0 //手术费
  21252. var operationCostPartSelfTotal float64 = 0 //手术费
  21253. var otherCostTotal float64 = 0 //其他费用
  21254. var otherCostSelfTotal float64 = 0 //其他费用
  21255. var otherCostPartSelfTotal float64 = 0 //其他费用
  21256. var materialCostTotal float64 = 0 //材料费
  21257. var materialCostSelfTotal float64 = 0 //材料费
  21258. var materialCostPartSelfTotal float64 = 0 //材料费
  21259. var westernMedicineCostTotal float64 = 0 //西药费
  21260. var westernMedicineCostSelfTotal float64 = 0 //西药费
  21261. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  21262. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  21263. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  21264. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  21265. var checkCostTotal float64 = 0 //检查费
  21266. var checkCostSelfTotal float64 = 0 //检查费
  21267. var checkCostPartSelfTotal float64 = 0 //检查费
  21268. var laboratoryCostTotal float64 = 0 //化验费
  21269. var laboratoryCostSelfTotal float64 = 0 //化验费
  21270. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  21271. var treatCostTotal float64 = 0 //治疗费用
  21272. var treatCostSelfTotal float64 = 0 //治疗费用
  21273. var treatCostPartSelfTotal float64 = 0 //治疗费用
  21274. decimal.DivisionPrecision = 2
  21275. var bed_fulamt_ownpay_amt float64 = 0
  21276. var operation_fulamt_ownpay_amt float64 = 0
  21277. var other_fulamt_ownpay_amt float64 = 0
  21278. var westernMedicine_fulamt_ownpay_amt float64 = 0
  21279. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21280. var check_fulamt_ownpay_amt float64 = 0
  21281. var material_fulamt_ownpay_amt float64 = 0
  21282. var laboratory_fulamt_ownpay_amt float64 = 0
  21283. var treat_fulamt_ownpay_amt float64 = 0
  21284. var bed_claa_sunmfee float64 = 0
  21285. var bed_clab_amt float64 = 0
  21286. var bed_other_amt float64 = 0
  21287. var operation_claa_sunmfee float64 = 0
  21288. var operation_clab_amt float64 = 0
  21289. var operation_other_amt float64 = 0
  21290. var other_claa_sunmfee float64 = 0
  21291. var other_clab_amt float64 = 0
  21292. var other_other_amt float64 = 0
  21293. var westernMedicine_claa_sunmfee float64 = 0
  21294. var westernMedicine_clab_amt float64 = 0
  21295. var westernMedicine_other_amt float64 = 0
  21296. var chineseTraditional_claa_sunmfee float64 = 0
  21297. var chineseTraditional_clab_amt float64 = 0
  21298. var chineseTraditional_other_amt float64 = 0
  21299. var check_claa_sunmfee float64 = 0
  21300. var check_clab_amt float64 = 0
  21301. var check_other_amt float64 = 0
  21302. var material_claa_sunmfee float64 = 0
  21303. var material_clab_amt float64 = 0
  21304. var material_other_amt float64 = 0
  21305. var laboratory_claa_sunmfee float64 = 0
  21306. var laboratory_clab_amt float64 = 0
  21307. var laboratory_other_amt float64 = 0
  21308. var treat_claa_sunmfee float64 = 0
  21309. var treat_clab_amt float64 = 0
  21310. var treat_other_amt float64 = 0
  21311. for _, item := range order.HisOrderInfo {
  21312. if item.MedChrgitmType == "01" { //床位费
  21313. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21314. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21315. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21316. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21317. if item.ChrgitmLv == "1" {
  21318. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21319. }
  21320. if item.ChrgitmLv == "2" {
  21321. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21322. }
  21323. if item.ChrgitmLv == "3" {
  21324. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21325. }
  21326. }
  21327. if item.MedChrgitmType == "03" { //检查费
  21328. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21329. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21330. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21331. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21332. if item.ChrgitmLv == "1" {
  21333. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21334. }
  21335. if item.ChrgitmLv == "2" {
  21336. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21337. }
  21338. if item.ChrgitmLv == "3" {
  21339. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21340. }
  21341. }
  21342. if item.MedChrgitmType == "04" { //化验费
  21343. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21344. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21345. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21346. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21347. if item.ChrgitmLv == "1" {
  21348. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21349. }
  21350. if item.ChrgitmLv == "2" {
  21351. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21352. }
  21353. if item.ChrgitmLv == "3" {
  21354. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21355. }
  21356. }
  21357. if item.MedChrgitmType == "05" { //治疗费
  21358. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21359. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21360. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21361. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21362. if item.ChrgitmLv == "1" {
  21363. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21364. }
  21365. if item.ChrgitmLv == "2" {
  21366. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21367. }
  21368. if item.ChrgitmLv == "3" {
  21369. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21370. }
  21371. }
  21372. if item.MedChrgitmType == "06" { //手术费
  21373. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21374. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21375. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21376. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21377. if item.ChrgitmLv == "1" {
  21378. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21379. }
  21380. if item.ChrgitmLv == "2" {
  21381. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21382. }
  21383. if item.ChrgitmLv == "3" {
  21384. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21385. }
  21386. }
  21387. if item.MedChrgitmType == "08" { //材料费
  21388. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21389. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21390. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21391. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21392. if item.ChrgitmLv == "1" {
  21393. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21394. }
  21395. if item.ChrgitmLv == "2" {
  21396. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21397. }
  21398. if item.ChrgitmLv == "3" {
  21399. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21400. }
  21401. }
  21402. if item.MedChrgitmType == "09" { //西药费
  21403. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21404. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21405. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21406. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21407. if item.ChrgitmLv == "1" {
  21408. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21409. }
  21410. if item.ChrgitmLv == "2" {
  21411. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21412. }
  21413. if item.ChrgitmLv == "3" {
  21414. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21415. }
  21416. }
  21417. if item.MedChrgitmType == "11" { //中成费
  21418. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21419. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21420. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21421. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21422. if item.ChrgitmLv == "1" {
  21423. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21424. }
  21425. if item.ChrgitmLv == "2" {
  21426. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21427. }
  21428. if item.ChrgitmLv == "3" {
  21429. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21430. }
  21431. }
  21432. if item.MedChrgitmType == "14" { //其他费
  21433. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21434. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21435. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21436. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21437. if item.ChrgitmLv == "1" {
  21438. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21439. }
  21440. if item.ChrgitmLv == "2" {
  21441. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21442. }
  21443. if item.ChrgitmLv == "3" {
  21444. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21445. }
  21446. }
  21447. }
  21448. var iteminfoStructs []service.IteminfoStruct
  21449. if bedCostTotal != 0 {
  21450. iteminfo.MedChrgitm = "01"
  21451. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21452. iteminfo.Amt = bedCostTotal
  21453. iteminfo.ClaaSumfee = bed_claa_sunmfee
  21454. iteminfo.ClabAmt = bed_clab_amt
  21455. iteminfo.OthAmt = bed_other_amt
  21456. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21457. }
  21458. if checkCostTotal != 0 {
  21459. iteminfo.MedChrgitm = "03"
  21460. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  21461. iteminfo.Amt = checkCostTotal
  21462. iteminfo.ClaaSumfee = check_claa_sunmfee
  21463. iteminfo.ClabAmt = check_clab_amt
  21464. iteminfo.OthAmt = check_other_amt
  21465. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21466. }
  21467. if laboratoryCostTotal != 0 {
  21468. iteminfo.MedChrgitm = "04"
  21469. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  21470. iteminfo.Amt = laboratoryCostTotal
  21471. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  21472. iteminfo.ClabAmt = laboratory_clab_amt
  21473. iteminfo.OthAmt = laboratory_other_amt
  21474. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21475. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21476. }
  21477. if treatCostTotal != 0 {
  21478. iteminfo.MedChrgitm = "05"
  21479. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  21480. iteminfo.Amt = treatCostTotal
  21481. iteminfo.ClaaSumfee = treat_claa_sunmfee
  21482. iteminfo.ClabAmt = treat_clab_amt
  21483. iteminfo.OthAmt = treat_other_amt
  21484. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21485. //(struct4101.IteminfoStruct, iteminfo)
  21486. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21487. }
  21488. if operationCostTotal != 0 {
  21489. iteminfo.MedChrgitm = "06"
  21490. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21491. iteminfo.Amt = operationCostTotal
  21492. iteminfo.ClaaSumfee = operation_claa_sunmfee
  21493. iteminfo.ClabAmt = operation_clab_amt
  21494. iteminfo.OthAmt = operation_other_amt
  21495. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21496. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21497. }
  21498. if materialCostTotal != 0 {
  21499. iteminfo.MedChrgitm = "08"
  21500. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  21501. iteminfo.Amt = materialCostTotal
  21502. iteminfo.ClaaSumfee = material_claa_sunmfee
  21503. iteminfo.ClabAmt = material_clab_amt
  21504. iteminfo.OthAmt = material_other_amt
  21505. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21506. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21507. }
  21508. if westernMedicineCostTotal != 0 {
  21509. iteminfo.MedChrgitm = "09"
  21510. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21511. iteminfo.Amt = westernMedicineCostTotal
  21512. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21513. iteminfo.ClabAmt = westernMedicine_clab_amt
  21514. iteminfo.OthAmt = westernMedicine_other_amt
  21515. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21516. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21517. }
  21518. if chineseTraditionalMedicineCostTotal != 0 {
  21519. iteminfo.MedChrgitm = "11"
  21520. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21521. iteminfo.Amt = westernMedicineCostTotal
  21522. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21523. iteminfo.ClabAmt = westernMedicine_clab_amt
  21524. iteminfo.OthAmt = westernMedicine_other_amt
  21525. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21526. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21527. }
  21528. if otherCostTotal != 0 {
  21529. iteminfo.MedChrgitm = "14"
  21530. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  21531. iteminfo.Amt = otherCostTotal
  21532. iteminfo.ClaaSumfee = other_claa_sunmfee
  21533. iteminfo.ClabAmt = other_clab_amt
  21534. iteminfo.OthAmt = other_other_amt
  21535. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21536. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21537. }
  21538. struct4101.IteminfoStruct = iteminfoStructs
  21539. struct4101.Ntly = "中国"
  21540. struct4101.AdmCaty = "A03.06"
  21541. var resOther ResultSeventeenOther
  21542. var res ResultSeventeen
  21543. if miConfig.MdtrtareaAdmvs == "150404" {
  21544. var pp models.PublicParams
  21545. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  21546. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21547. pp.FixmedinsName = miConfig.OrgName
  21548. pp.FixmedinsCode = miConfig.Code
  21549. pp.RequestUrl = miConfig.Url
  21550. pp.Cainfo = miConfig.Cainfo
  21551. pp.SecretKey = miConfig.SecretKey
  21552. pp.AccessKey = miConfig.AccessKey
  21553. pp.OpterName = curRoles.UserName
  21554. client := &http.Client{}
  21555. var req *http.Request
  21556. data := make(map[string]interface{})
  21557. data["struct4101"] = struct4101
  21558. data["pp"] = pp
  21559. bytesData, _ := json.Marshal(data)
  21560. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  21561. resp, _ := client.Do(req)
  21562. defer resp.Body.Close()
  21563. body, ioErr := ioutil.ReadAll(resp.Body)
  21564. if ioErr != nil {
  21565. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21567. return
  21568. }
  21569. var respJSON map[string]interface{}
  21570. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21573. return
  21574. }
  21575. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21576. userJSONBytes, _ := json.Marshal(respJSON)
  21577. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  21578. utils.ErrorLog("解析失败:%v", err)
  21579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21580. return
  21581. }
  21582. res.InfRefmsgid = resOther.InfRefmsgid
  21583. res.Output = resOther.Output
  21584. res.ErrMsg = resOther.ErrMsg
  21585. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  21586. res.Infcode = infocode
  21587. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21588. var pp models.PublicParams
  21589. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21590. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21591. pp.FixmedinsName = miConfig.OrgName
  21592. pp.FixmedinsCode = miConfig.Code
  21593. pp.RequestUrl = miConfig.Url
  21594. pp.Cainfo = miConfig.Cainfo
  21595. pp.SecretKey = miConfig.SecretKey
  21596. pp.AccessKey = miConfig.AccessKey
  21597. pp.OpterName = curRoles.UserName
  21598. result, _ := service.Jxyb4101(struct4101, pp)
  21599. var dat map[string]interface{}
  21600. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21601. fmt.Println(dat)
  21602. } else {
  21603. fmt.Println(err)
  21604. }
  21605. userJSONBytes, _ := json.Marshal(dat)
  21606. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21607. utils.ErrorLog("解析失败:%v", err)
  21608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21609. return
  21610. }
  21611. } else if miConfig.MdtrtareaAdmvs == "361025" {
  21612. var pp models.PublicParams
  21613. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21614. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21615. pp.FixmedinsName = miConfig.OrgName
  21616. pp.FixmedinsCode = miConfig.Code
  21617. pp.RequestUrl = miConfig.Url
  21618. pp.Cainfo = miConfig.Cainfo
  21619. pp.SecretKey = miConfig.SecretKey
  21620. pp.AccessKey = miConfig.AccessKey
  21621. pp.OpterName = curRoles.UserName
  21622. result, _ := service.Jxyb4101(struct4101, pp)
  21623. var dat map[string]interface{}
  21624. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21625. fmt.Println(dat)
  21626. } else {
  21627. fmt.Println(err)
  21628. }
  21629. userJSONBytes, _ := json.Marshal(dat)
  21630. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21631. utils.ErrorLog("解析失败:%v", err)
  21632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21633. return
  21634. }
  21635. } else if miConfig.MdtrtareaAdmvs == "360100" {
  21636. var pp models.PublicParams
  21637. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21638. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21639. pp.FixmedinsName = miConfig.OrgName
  21640. pp.FixmedinsCode = miConfig.Code
  21641. pp.RequestUrl = miConfig.Url
  21642. pp.Cainfo = miConfig.Cainfo
  21643. pp.SecretKey = miConfig.SecretKey
  21644. pp.AccessKey = miConfig.AccessKey
  21645. pp.OpterName = curRoles.UserName
  21646. result, _ := service.Jxyb4101(struct4101, pp)
  21647. var dat map[string]interface{}
  21648. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21649. fmt.Println(dat)
  21650. } else {
  21651. fmt.Println(err)
  21652. }
  21653. userJSONBytes, _ := json.Marshal(dat)
  21654. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21655. utils.ErrorLog("解析失败:%v", err)
  21656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21657. return
  21658. }
  21659. } else {
  21660. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  21661. var dat map[string]interface{}
  21662. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21663. fmt.Println(dat)
  21664. } else {
  21665. fmt.Println(err)
  21666. }
  21667. userJSONBytes, _ := json.Marshal(dat)
  21668. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21669. utils.ErrorLog("解析失败:%v", err)
  21670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21671. return
  21672. }
  21673. }
  21674. if res.Infcode != 0 {
  21675. c.ServeSuccessJSON(map[string]interface{}{
  21676. "failed_code": -10,
  21677. "msg": res.ErrMsg,
  21678. })
  21679. return
  21680. } else {
  21681. if miConfig.MdtrtareaAdmvs != "150404" {
  21682. order.FaPiaoNumber = zero
  21683. order.FaPiaoCode = last_order.FaPiaoCode
  21684. service.UpdateOrder(order)
  21685. }
  21686. hisFundSettleListResult := &models.HisFundSettleListResult{
  21687. Number: res.Output.SetlListId,
  21688. Status: 1,
  21689. Ctime: time.Now().Unix(),
  21690. Mtime: time.Now().Unix(),
  21691. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21692. IsUpload: 1,
  21693. OrderId: order_id,
  21694. }
  21695. service.CreateUploadRecord(hisFundSettleListResult)
  21696. c.ServeSuccessJSON(map[string]interface{}{
  21697. "msg": "上传成功",
  21698. "result": hisFundSettleListResult,
  21699. })
  21700. return
  21701. }
  21702. }
  21703. //func (c *HisApiController) GetBatchSettleList() {
  21704. // orders, _ := service.GetAllHisOrder(10106)
  21705. // for _, item := range orders {
  21706. // order_id := item.ID
  21707. // order, _ := service.GetHisOrderByIDTwo(order_id)
  21708. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  21709. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  21710. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  21711. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  21712. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  21713. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  21714. //
  21715. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  21716. //
  21717. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  21718. //
  21719. // if order.ID == 0 {
  21720. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  21721. // return
  21722. // }
  21723. // if his.BalanceAccountsType == 2 {
  21724. // continue
  21725. // }
  21726. // struct4101 := service.Struct4101{
  21727. // PsnNo: order.PsnNo,
  21728. // MdtrtId: order.MdtrtId,
  21729. // SetlId: order.SetlId,
  21730. // PsnName: order.PsnName,
  21731. // Gend: order.Gend,
  21732. // Brdy: his.Brdy,
  21733. // Age: his.Age,
  21734. // Naty: order.Naty,
  21735. // PatnCertType: "01",
  21736. // Certno: order.Certno,
  21737. // Prfs: "90",
  21738. // ConerName: roles[0].UserName,
  21739. // PatnRlts: "99",
  21740. // ConerAddr: miConfig.OrgName,
  21741. // ConerTel: admin.Mobile,
  21742. // HiType: order.Insutype,
  21743. // Insuplc: his.InsuplcAdmdvs,
  21744. // MaindiagFlag: "1",
  21745. // BillCode: order.SetlId,
  21746. // BillNo: order.SetlId,
  21747. // BizSn: order.Number,
  21748. // PsnSelfPay: order.PsnPartAmt,
  21749. // PsnOwnPay: order.PsnPartAmt,
  21750. // AcctPay: order.AcctPay,
  21751. // PsnCashpay: order.PsnCashPay,
  21752. // HiPaymtd: "1",
  21753. // Hsorg: his.InsuplcAdmdvs,
  21754. // HsorgOpter: his.InsuplcAdmdvs,
  21755. // MedinsFillPsn: curRoles.UserName,
  21756. // MedinsFillDept: depart.Name,
  21757. // IptMedType: "2",
  21758. // }
  21759. // struct4101.SetlBegnDate = order.SetlTime
  21760. // struct4101.SetlEndDate = order.SetlTime
  21761. // //if order.SettleType == 1 {
  21762. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  21763. // // dateStr := t.Format("2006-01-02")
  21764. // // struct4101.SetlBegnDate = dateStr
  21765. // // struct4101.SetlEndDate = dateStr
  21766. // //} else {
  21767. // // t := time.Unix(int64(order.SettleStartTime), 0)
  21768. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  21769. // // dateStartStr := t.Format("2006-01-02")
  21770. // // dateEndStr := t2.Format("2006-01-02")
  21771. // // struct4101.SetlBegnDate = dateStartStr
  21772. // // struct4101.SetlEndDate = dateEndStr
  21773. // //}
  21774. //
  21775. // var rf []CustomFundPay
  21776. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  21777. //
  21778. // var tempFunPays []service.CustomStruct
  21779. // var tempFunPay610100 service.CustomStruct
  21780. //
  21781. // for _, item := range rf {
  21782. // if item.FundPayType == "610100" {
  21783. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  21784. // tempFunPay610100.FundPayType = item.FundPayType
  21785. // } else {
  21786. // var tempFunPay service.CustomStruct
  21787. // tempFunPay.FundPayamt = item.FundPayamt
  21788. // tempFunPay.FundPayType = item.FundPayType
  21789. // tempFunPays = append(tempFunPays, tempFunPay)
  21790. // }
  21791. // }
  21792. // tempFunPays = append(tempFunPays, tempFunPay610100)
  21793. // struct4101.CustomStruct = tempFunPays
  21794. //
  21795. // var tempDiaginfos []service.DiaginfoStructTwo
  21796. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  21797. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  21798. //
  21799. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  21800. // var config []*models.HisXtDiagnoseConfig
  21801. // for _, item := range diagnosis_ids {
  21802. // id, _ := strconv.ParseInt(item, 10, 64)
  21803. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  21804. // config = append(config, &diagnosisConfig)
  21805. // }
  21806. //
  21807. // for index, item := range config {
  21808. // if index == 0 {
  21809. // var tempDiaginfo service.DiaginfoStructTwo
  21810. // tempDiaginfo.DiagCode = item.CountryCode
  21811. // tempDiaginfo.DiagName = item.CountryContentName
  21812. // tempDiaginfo.DiagType = "1"
  21813. // tempDiaginfo.MaindiagFlag = "1"
  21814. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21815. // } else {
  21816. //
  21817. // var tempDiaginfo service.DiaginfoStructTwo
  21818. // tempDiaginfo.DiagCode = item.CountryCode
  21819. // tempDiaginfo.DiagName = item.CountryContentName
  21820. // tempDiaginfo.DiagType = "2"
  21821. // tempDiaginfo.MaindiagFlag = "0"
  21822. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21823. // }
  21824. // }
  21825. // struct4101.Diseinfo = tempDiaginfos
  21826. //
  21827. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  21828. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  21829. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  21830. // tempOpspdiseinfo2.OprnOprtCode = ""
  21831. // tempOpspdiseinfo2.OprnOprtName = ""
  21832. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  21833. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  21834. //
  21835. // var iteminfo service.IteminfoStruct
  21836. //
  21837. // var bedCostTotal float64 = 0 //床位总费
  21838. // var bedCostSelfTotal float64 = 0 //床位自费
  21839. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  21840. //
  21841. // var examineCostTotal float64 = 0 //诊查总费
  21842. // var examineCostSelfTotal float64 = 0 //诊查自费
  21843. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  21844. //
  21845. // var nursingCostTotal float64 = 0 //护理总费
  21846. // var nursingCostSelfTotal float64 = 0 //护理自费
  21847. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  21848. //
  21849. // var chineseMedicineCostTotal float64 = 0 //中成药
  21850. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  21851. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  21852. //
  21853. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  21854. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  21855. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  21856. //
  21857. // var registerCostTotal float64 = 0 //一般诊疗费
  21858. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  21859. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  21860. //
  21861. // var operationCostTotal float64 = 0 //手术费
  21862. // var operationCostSelfTotal float64 = 0 //手术费
  21863. // var operationCostPartSelfTotal float64 = 0 //手术费
  21864. //
  21865. // var otherCostTotal float64 = 0 //其他费用
  21866. // var otherCostSelfTotal float64 = 0 //其他费用
  21867. // var otherCostPartSelfTotal float64 = 0 //其他费用
  21868. //
  21869. // var materialCostTotal float64 = 0 //材料费
  21870. // var materialCostSelfTotal float64 = 0 //材料费
  21871. // var materialCostPartSelfTotal float64 = 0 //材料费
  21872. //
  21873. // var westernMedicineCostTotal float64 = 0 //西药费
  21874. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  21875. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  21876. //
  21877. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  21878. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  21879. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  21880. //
  21881. // var checkCostTotal float64 = 0 //检查费
  21882. // var checkCostSelfTotal float64 = 0 //检查费
  21883. // var checkCostPartSelfTotal float64 = 0 //检查费
  21884. //
  21885. // var laboratoryCostTotal float64 = 0 //化验费
  21886. // var laboratoryCostSelfTotal float64 = 0 //化验费
  21887. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  21888. //
  21889. // var treatCostTotal float64 = 0 //治疗费用
  21890. // var treatCostSelfTotal float64 = 0 //治疗费用
  21891. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  21892. //
  21893. // decimal.DivisionPrecision = 2
  21894. //
  21895. // var bed_fulamt_ownpay_amt float64 = 0
  21896. //
  21897. // var examine_fulamt_ownpay_amt float64 = 0
  21898. //
  21899. // var nursing_fulamt_ownpay_amt float64 = 0
  21900. //
  21901. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  21902. //
  21903. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  21904. //
  21905. // var register_fulamt_ownpay_amt float64 = 0
  21906. //
  21907. // var operation_fulamt_ownpay_amt float64 = 0
  21908. // var other_fulamt_ownpay_amt float64 = 0
  21909. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  21910. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21911. // var check_fulamt_ownpay_amt float64 = 0
  21912. // var material_fulamt_ownpay_amt float64 = 0
  21913. // var laboratory_fulamt_ownpay_amt float64 = 0
  21914. // var treat_fulamt_ownpay_amt float64 = 0
  21915. //
  21916. // var bed_claa_sunmfee float64 = 0
  21917. // var bed_clab_amt float64 = 0
  21918. // var bed_other_amt float64 = 0
  21919. //
  21920. // var examine_claa_sunmfee float64 = 0
  21921. // var examine_clab_amt float64 = 0
  21922. // var examine_other_amt float64 = 0
  21923. //
  21924. // var nursing_claa_sunmfee float64 = 0
  21925. // var nursing_clab_amt float64 = 0
  21926. // var nursing_other_amt float64 = 0
  21927. //
  21928. // var chinese_medicine_claa_sunmfee float64 = 0
  21929. // var chinese_medicine_clab_amt float64 = 0
  21930. // var chinese_medicine_other_amt float64 = 0
  21931. //
  21932. // var commonly_treatment_claa_sunmfee float64 = 0
  21933. // var commonly_treatment_clab_amt float64 = 0
  21934. // var commonly_treatment_other_amt float64 = 0
  21935. //
  21936. // var operation_claa_sunmfee float64 = 0
  21937. // var operation_clab_amt float64 = 0
  21938. // var operation_other_amt float64 = 0
  21939. //
  21940. // var other_claa_sunmfee float64 = 0
  21941. // var other_clab_amt float64 = 0
  21942. // var other_other_amt float64 = 0
  21943. //
  21944. // var westernMedicine_claa_sunmfee float64 = 0
  21945. // var westernMedicine_clab_amt float64 = 0
  21946. // var westernMedicine_other_amt float64 = 0
  21947. //
  21948. // var chineseTraditional_claa_sunmfee float64 = 0
  21949. // var chineseTraditional_clab_amt float64 = 0
  21950. // var chineseTraditional_other_amt float64 = 0
  21951. //
  21952. // var check_claa_sunmfee float64 = 0
  21953. // var check_clab_amt float64 = 0
  21954. // var check_other_amt float64 = 0
  21955. //
  21956. // var material_claa_sunmfee float64 = 0
  21957. // var material_clab_amt float64 = 0
  21958. // var material_other_amt float64 = 0
  21959. //
  21960. // var laboratory_claa_sunmfee float64 = 0
  21961. // var laboratory_clab_amt float64 = 0
  21962. // var laboratory_other_amt float64 = 0
  21963. //
  21964. // var treat_claa_sunmfee float64 = 0
  21965. // var treat_clab_amt float64 = 0
  21966. // var treat_other_amt float64 = 0
  21967. //
  21968. // var register_claa_sunmfee float64 = 0
  21969. // var register_clab_amt float64 = 0
  21970. // var register_other_amt float64 = 0
  21971. //
  21972. // for _, item := range order.HisOrderInfo {
  21973. // if item.MedChrgitmType == "01" { //床位费
  21974. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21975. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21976. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21977. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21978. // if item.ChrgitmLv == "1" {
  21979. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21980. // }
  21981. // if item.ChrgitmLv == "2" {
  21982. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21983. //
  21984. // }
  21985. // if item.ChrgitmLv == "3" {
  21986. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21987. // }
  21988. //
  21989. // }
  21990. //
  21991. // if item.MedChrgitmType == "02" { //诊查
  21992. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21993. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21994. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21995. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21996. // if item.ChrgitmLv == "1" {
  21997. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21998. // }
  21999. // if item.ChrgitmLv == "2" {
  22000. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22001. //
  22002. // }
  22003. // if item.ChrgitmLv == "3" {
  22004. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22005. // }
  22006. //
  22007. // }
  22008. //
  22009. // if item.MedChrgitmType == "03" { //检查费
  22010. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22011. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22012. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22013. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22014. // if item.ChrgitmLv == "1" {
  22015. //
  22016. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22017. //
  22018. // }
  22019. // if item.ChrgitmLv == "2" {
  22020. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22021. //
  22022. // }
  22023. // if item.ChrgitmLv == "3" {
  22024. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22025. // }
  22026. // }
  22027. //
  22028. // if item.MedChrgitmType == "04" { //化验费
  22029. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22030. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22031. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22032. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22033. // if item.ChrgitmLv == "1" {
  22034. //
  22035. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22036. //
  22037. // }
  22038. // if item.ChrgitmLv == "2" {
  22039. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22040. //
  22041. // }
  22042. // if item.ChrgitmLv == "3" {
  22043. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22044. // }
  22045. // }
  22046. //
  22047. // if item.MedChrgitmType == "05" { //治疗费
  22048. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22049. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22050. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22051. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22052. // if item.ChrgitmLv == "1" {
  22053. //
  22054. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22055. //
  22056. // }
  22057. // if item.ChrgitmLv == "2" {
  22058. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22059. //
  22060. // }
  22061. // if item.ChrgitmLv == "3" {
  22062. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22063. // }
  22064. // }
  22065. //
  22066. // if item.MedChrgitmType == "06" { //手术费
  22067. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22068. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22069. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22070. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22071. //
  22072. // if item.ChrgitmLv == "1" {
  22073. //
  22074. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22075. //
  22076. // }
  22077. // if item.ChrgitmLv == "2" {
  22078. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22079. //
  22080. // }
  22081. // if item.ChrgitmLv == "3" {
  22082. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22083. // }
  22084. // }
  22085. //
  22086. // if item.MedChrgitmType == "07" { //手术费
  22087. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22088. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22089. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22090. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22091. //
  22092. // if item.ChrgitmLv == "1" {
  22093. //
  22094. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22095. //
  22096. // }
  22097. // if item.ChrgitmLv == "2" {
  22098. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22099. //
  22100. // }
  22101. // if item.ChrgitmLv == "3" {
  22102. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22103. // }
  22104. // }
  22105. //
  22106. // if item.MedChrgitmType == "08" { //材料费
  22107. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22108. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22109. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22110. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22111. // if item.ChrgitmLv == "1" {
  22112. //
  22113. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22114. //
  22115. // }
  22116. // if item.ChrgitmLv == "2" {
  22117. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22118. //
  22119. // }
  22120. // if item.ChrgitmLv == "3" {
  22121. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22122. // }
  22123. // }
  22124. // if item.MedChrgitmType == "09" { //西药费
  22125. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22126. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22127. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22128. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22129. // if item.ChrgitmLv == "1" {
  22130. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22131. // }
  22132. // if item.ChrgitmLv == "2" {
  22133. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22134. // }
  22135. // if item.ChrgitmLv == "3" {
  22136. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22137. // }
  22138. // }
  22139. // if item.MedChrgitmType == "10" { //中药饮片
  22140. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22141. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22142. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22143. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22144. // if item.ChrgitmLv == "1" {
  22145. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22146. // }
  22147. // if item.ChrgitmLv == "2" {
  22148. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22149. // }
  22150. // if item.ChrgitmLv == "3" {
  22151. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22152. // }
  22153. // }
  22154. //
  22155. // if item.MedChrgitmType == "11" { //中成费
  22156. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22157. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22158. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22159. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22160. // if item.ChrgitmLv == "1" {
  22161. //
  22162. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22163. //
  22164. // }
  22165. // if item.ChrgitmLv == "2" {
  22166. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22167. //
  22168. // }
  22169. // if item.ChrgitmLv == "3" {
  22170. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22171. // }
  22172. // }
  22173. //
  22174. // if item.MedChrgitmType == "12" { //中成费
  22175. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22176. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22177. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22178. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22179. // if item.ChrgitmLv == "1" {
  22180. //
  22181. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22182. //
  22183. // }
  22184. // if item.ChrgitmLv == "2" {
  22185. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22186. //
  22187. // }
  22188. // if item.ChrgitmLv == "3" {
  22189. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22190. // }
  22191. // }
  22192. //
  22193. // if item.MedChrgitmType == "13" { //中成费
  22194. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22195. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22196. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22197. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22198. // if item.ChrgitmLv == "1" {
  22199. //
  22200. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22201. //
  22202. // }
  22203. // if item.ChrgitmLv == "2" {
  22204. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22205. //
  22206. // }
  22207. // if item.ChrgitmLv == "3" {
  22208. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22209. // }
  22210. // }
  22211. //
  22212. // if item.MedChrgitmType == "14" { //其他费
  22213. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22214. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22215. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22216. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22217. // if item.ChrgitmLv == "1" {
  22218. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22219. //
  22220. // }
  22221. // if item.ChrgitmLv == "2" {
  22222. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22223. //
  22224. // }
  22225. // if item.ChrgitmLv == "3" {
  22226. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22227. // }
  22228. // }
  22229. //
  22230. // }
  22231. //
  22232. // var iteminfoStructs []service.IteminfoStruct
  22233. //
  22234. // if bedCostTotal != 0 {
  22235. // iteminfo.MedChrgitm = "01"
  22236. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  22237. // iteminfo.Amt = bedCostTotal
  22238. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  22239. // iteminfo.ClabAmt = bed_clab_amt
  22240. // iteminfo.OthAmt = bed_other_amt
  22241. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22242. // }
  22243. //
  22244. // if examineCostTotal != 0 {
  22245. // iteminfo.MedChrgitm = "02"
  22246. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  22247. // iteminfo.Amt = examineCostTotal
  22248. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  22249. // iteminfo.ClabAmt = examine_clab_amt
  22250. // iteminfo.OthAmt = examine_other_amt
  22251. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22252. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22253. // }
  22254. //
  22255. // if checkCostTotal != 0 {
  22256. // iteminfo.MedChrgitm = "03"
  22257. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  22258. // iteminfo.Amt = checkCostTotal
  22259. // iteminfo.ClaaSumfee = check_claa_sunmfee
  22260. // iteminfo.ClabAmt = check_clab_amt
  22261. // iteminfo.OthAmt = check_other_amt
  22262. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22263. //
  22264. // }
  22265. //
  22266. // if laboratoryCostTotal != 0 {
  22267. // iteminfo.MedChrgitm = "04"
  22268. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  22269. // iteminfo.Amt = laboratoryCostTotal
  22270. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  22271. // iteminfo.ClabAmt = laboratory_clab_amt
  22272. // iteminfo.OthAmt = laboratory_other_amt
  22273. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22274. //
  22275. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22276. //
  22277. // }
  22278. //
  22279. // if treatCostTotal != 0 {
  22280. // iteminfo.MedChrgitm = "05"
  22281. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  22282. // iteminfo.Amt = treatCostTotal
  22283. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  22284. // iteminfo.ClabAmt = treat_clab_amt
  22285. // iteminfo.OthAmt = treat_other_amt
  22286. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22287. // //(struct4101.IteminfoStruct, iteminfo)
  22288. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22289. // }
  22290. //
  22291. // if operationCostTotal != 0 {
  22292. // iteminfo.MedChrgitm = "06"
  22293. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  22294. // iteminfo.Amt = operationCostTotal
  22295. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  22296. // iteminfo.ClabAmt = operation_clab_amt
  22297. // iteminfo.OthAmt = operation_other_amt
  22298. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22299. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22300. // }
  22301. //
  22302. // if nursingCostTotal != 0 {
  22303. // iteminfo.MedChrgitm = "07"
  22304. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  22305. // iteminfo.Amt = nursingCostTotal
  22306. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  22307. // iteminfo.ClabAmt = nursing_clab_amt
  22308. // iteminfo.OthAmt = nursing_other_amt
  22309. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22310. // }
  22311. //
  22312. // if materialCostTotal != 0 {
  22313. // iteminfo.MedChrgitm = "08"
  22314. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  22315. // iteminfo.Amt = materialCostTotal
  22316. // iteminfo.ClaaSumfee = material_claa_sunmfee
  22317. // iteminfo.ClabAmt = material_clab_amt
  22318. // iteminfo.OthAmt = material_other_amt
  22319. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22320. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22321. // }
  22322. //
  22323. // if westernMedicineCostTotal != 0 {
  22324. // iteminfo.MedChrgitm = "09"
  22325. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  22326. // iteminfo.Amt = westernMedicineCostTotal
  22327. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  22328. // iteminfo.ClabAmt = westernMedicine_clab_amt
  22329. // iteminfo.OthAmt = westernMedicine_other_amt
  22330. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22331. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22332. //
  22333. // }
  22334. //
  22335. // if chineseMedicineCostTotal != 0 {
  22336. // iteminfo.MedChrgitm = "10"
  22337. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  22338. // iteminfo.Amt = chineseMedicineCostTotal
  22339. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  22340. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  22341. // iteminfo.OthAmt = chinese_medicine_other_amt
  22342. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22343. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22344. //
  22345. // }
  22346. //
  22347. // if chineseTraditionalMedicineCostTotal != 0 {
  22348. // iteminfo.MedChrgitm = "11"
  22349. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  22350. // iteminfo.Amt = westernMedicineCostTotal
  22351. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  22352. // iteminfo.ClabAmt = westernMedicine_clab_amt
  22353. // iteminfo.OthAmt = westernMedicine_other_amt
  22354. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22355. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22356. //
  22357. // }
  22358. //
  22359. // if commonlyTreatmentCostTotal != 0 {
  22360. // iteminfo.MedChrgitm = "12"
  22361. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  22362. // iteminfo.Amt = commonlyTreatmentCostTotal
  22363. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  22364. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  22365. // iteminfo.OthAmt = commonly_treatment_other_amt
  22366. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22367. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22368. //
  22369. // }
  22370. //
  22371. // if registerCostTotal != 0 {
  22372. // iteminfo.MedChrgitm = "13"
  22373. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  22374. // iteminfo.Amt = registerCostTotal
  22375. // iteminfo.ClaaSumfee = register_claa_sunmfee
  22376. // iteminfo.ClabAmt = register_clab_amt
  22377. // iteminfo.OthAmt = register_other_amt
  22378. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22379. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22380. //
  22381. // }
  22382. //
  22383. // if otherCostTotal != 0 {
  22384. // iteminfo.MedChrgitm = "14"
  22385. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  22386. // iteminfo.Amt = otherCostTotal
  22387. // iteminfo.ClaaSumfee = other_claa_sunmfee
  22388. // iteminfo.ClabAmt = other_clab_amt
  22389. // iteminfo.OthAmt = other_other_amt
  22390. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22391. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22392. //
  22393. // }
  22394. // struct4101.IteminfoStruct = iteminfoStructs
  22395. // time_arr := strings.Split(order.SetlTime, " ")
  22396. // struct4101.AdmTime = time_arr[0]
  22397. // struct4101.AdmEndTime = time_arr[0]
  22398. //
  22399. // struct4101.DoctorName = doctor.UserName
  22400. // struct4101.DoctorCode = doctor.DoctorNumber
  22401. //
  22402. // struct4101.Ntly = "中国"
  22403. // struct4101.AdmCaty = "A03.06"
  22404. // var res ResultSeventeen
  22405. // if miConfig.MdtrtareaAdmvs == "421300" {
  22406. // data := make(map[string]interface{})
  22407. // data["struct4101"] = struct4101
  22408. // data["secret_key"] = miConfig.SecretKey
  22409. // data["org_name"] = miConfig.OrgName
  22410. // data["opera"] = curRoles.UserName
  22411. // data["code"] = miConfig.Code
  22412. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  22413. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22414. //
  22415. // client := &http.Client{}
  22416. // bytesData, _ := json.Marshal(data)
  22417. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  22418. // resp, _ := client.Do(req)
  22419. // defer resp.Body.Close()
  22420. // body, ioErr := ioutil.ReadAll(resp.Body)
  22421. // if ioErr != nil {
  22422. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22423. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22424. // return
  22425. // }
  22426. // var respJSON map[string]interface{}
  22427. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22428. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22429. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22430. // return
  22431. // }
  22432. //
  22433. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22434. // userJSONBytes, _ := json.Marshal(respJSON)
  22435. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22436. // utils.ErrorLog("解析失败:%v", err)
  22437. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22438. // adminUser := c.GetAdminUserInfo()
  22439. // errlog := &models.HisOrderError{
  22440. // UserOrgId: adminUser.CurrentOrgId,
  22441. // Ctime: time.Now().Unix(),
  22442. // Mtime: time.Now().Unix(),
  22443. // ErrMsg: res.ErrMsg + "解析失败",
  22444. // Status: 1,
  22445. // PatientId: order_id,
  22446. // Stage: 10088,
  22447. // }
  22448. // service.CreateErrMsgLog(errlog)
  22449. // continue
  22450. // }
  22451. //
  22452. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  22453. // data := make(map[string]interface{})
  22454. // data["struct4101"] = struct4101
  22455. // data["secret_key"] = miConfig.SecretKey
  22456. // data["org_name"] = miConfig.OrgName
  22457. // data["opera"] = curRoles.UserName
  22458. // data["code"] = miConfig.Code
  22459. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  22460. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22461. //
  22462. // client := &http.Client{}
  22463. // bytesData, _ := json.Marshal(data)
  22464. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  22465. // resp, _ := client.Do(req)
  22466. // defer resp.Body.Close()
  22467. // body, ioErr := ioutil.ReadAll(resp.Body)
  22468. // if ioErr != nil {
  22469. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22470. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22471. // return
  22472. // }
  22473. // var respJSON map[string]interface{}
  22474. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22475. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22476. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22477. // return
  22478. // }
  22479. //
  22480. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22481. // userJSONBytes, _ := json.Marshal(respJSON)
  22482. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22483. // utils.ErrorLog("解析失败:%v", err)
  22484. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22485. // adminUser := c.GetAdminUserInfo()
  22486. // errlog := &models.HisOrderError{
  22487. // UserOrgId: adminUser.CurrentOrgId,
  22488. // Ctime: time.Now().Unix(),
  22489. // Mtime: time.Now().Unix(),
  22490. // ErrMsg: res.ErrMsg + "解析失败",
  22491. // Status: 1,
  22492. // PatientId: order_id,
  22493. // Stage: 10088,
  22494. // }
  22495. // service.CreateErrMsgLog(errlog)
  22496. // continue
  22497. // }
  22498. //
  22499. // } else {
  22500. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  22501. // fmt.Println(result)
  22502. //
  22503. // var dat map[string]interface{}
  22504. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22505. // fmt.Println(dat)
  22506. // } else {
  22507. // fmt.Println(err)
  22508. // }
  22509. // userJSONBytes, _ := json.Marshal(dat)
  22510. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22511. // utils.ErrorLog("解析失败:%v", err)
  22512. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22513. // adminUser := c.GetAdminUserInfo()
  22514. // errlog := &models.HisOrderError{
  22515. // UserOrgId: adminUser.CurrentOrgId,
  22516. // Ctime: time.Now().Unix(),
  22517. // Mtime: time.Now().Unix(),
  22518. // ErrMsg: res.ErrMsg + "解析失败",
  22519. // Status: 1,
  22520. // PatientId: order_id,
  22521. // Stage: 10106,
  22522. // }
  22523. // service.CreateErrMsgLog(errlog)
  22524. // continue
  22525. // }
  22526. // }
  22527. //
  22528. // if res.Infcode != 0 {
  22529. // adminUser := c.GetAdminUserInfo()
  22530. // errlog := &models.HisOrderError{
  22531. // UserOrgId: adminUser.CurrentOrgId,
  22532. // Ctime: time.Now().Unix(),
  22533. // Mtime: time.Now().Unix(),
  22534. // ErrMsg: res.ErrMsg,
  22535. // Status: 1,
  22536. // PatientId: order_id,
  22537. // Stage: 10106,
  22538. // }
  22539. // service.CreateErrMsgLog(errlog)
  22540. // continue
  22541. // } else {
  22542. // hisFundSettleListResult := &models.HisFundSettleListResult{
  22543. // Number: res.Output.SetlListId,
  22544. // Status: 1,
  22545. // Ctime: time.Now().Unix(),
  22546. // Mtime: time.Now().Unix(),
  22547. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  22548. // IsUpload: 1,
  22549. // OrderId: order_id,
  22550. // }
  22551. // service.CreateUploadRecord(hisFundSettleListResult)
  22552. // continue
  22553. // }
  22554. // }
  22555. //}
  22556. func (c *HisApiController) GetOrgInfo() {
  22557. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  22558. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  22559. }
  22560. func (c *HisApiController) GetHisPatientInfo() {
  22561. medical_insurance_card := c.GetString("medical_insurance_card")
  22562. id_card_type, _ := c.GetInt64("id_card_type")
  22563. id_card := c.GetString("id_card")
  22564. adminInfo := c.GetAdminUserInfo()
  22565. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  22566. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  22567. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  22568. IdCardNo := ""
  22569. if id_card_type == 1 {
  22570. IdCardNo = medical_insurance_card
  22571. } else if id_card_type == 2 {
  22572. IdCardNo = id_card
  22573. }
  22574. if config.IsOpen == 1 {
  22575. 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
  22576. resp, requestErr := http.Get(api)
  22577. if requestErr != nil {
  22578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22579. return
  22580. }
  22581. defer resp.Body.Close()
  22582. body, ioErr := ioutil.ReadAll(resp.Body)
  22583. if ioErr != nil {
  22584. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22586. return
  22587. }
  22588. var respJSON map[string]interface{}
  22589. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22590. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22592. return
  22593. }
  22594. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22595. userJSONBytes, _ := json.Marshal(userJSON)
  22596. var res ResultTwo
  22597. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22598. utils.ErrorLog("解析失败:%v", err)
  22599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22600. return
  22601. }
  22602. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22603. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22604. infoStr := string(Iinfos)
  22605. idetinfoStr := string(Idetinfos)
  22606. if res.Infcode == 0 {
  22607. his := models.VMHisPatient{
  22608. Status: 1,
  22609. Ctime: time.Now().Unix(),
  22610. Mtime: time.Now().Unix(),
  22611. PsnNo: res.Output.Baseinfo.PsnNo,
  22612. PsnCertType: res.Output.Baseinfo.PsnCertType,
  22613. Certno: res.Output.Baseinfo.Certno,
  22614. PsnName: res.Output.Baseinfo.PsnName,
  22615. Gend: res.Output.Baseinfo.Gend,
  22616. Naty: res.Output.Baseinfo.Naty,
  22617. Iinfo: infoStr,
  22618. Idetinfo: idetinfoStr,
  22619. UserOrgId: adminInfo.CurrentOrgId,
  22620. IsReturn: 1,
  22621. IdCardType: id_card_type,
  22622. }
  22623. c.ServeSuccessJSON(map[string]interface{}{
  22624. "info": his,
  22625. })
  22626. } else {
  22627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  22628. return
  22629. }
  22630. }
  22631. }
  22632. //func GetBasBaseInfo() (jsonStr string, err error) {
  22633. //
  22634. // handle := syscall.NewLazyDLL("SSCard.dll")
  22635. // add := handle.NewProc("ReadCardBas")
  22636. // str := make([]byte, 1024)
  22637. // str1 := make([]byte, 1024)
  22638. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  22639. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  22640. //
  22641. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  22642. //
  22643. // fmt.Println("> Add(4,5)的结果为:", ret)
  22644. // handle.Release()
  22645. //
  22646. // return "", nil
  22647. //
  22648. //}
  22649. //func GetQRBaseInfo() (jsonStr string, err error) {
  22650. // handle := syscall.LoadDLL("SSCard.dll")
  22651. // ReadCardBas := handle.FindProc("GetQRBase")
  22652. //
  22653. // str := make([]byte, 256)
  22654. // str1 := make([]byte, 256)
  22655. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  22656. //
  22657. // fmt.Println(string(str))
  22658. // fmt.Println(r)
  22659. // return string(str), nil
  22660. //}
  22661. //func CardInit() int {
  22662. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  22663. // add := DllTestDef.MustFindProc("Init")
  22664. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  22665. // if err != nil {
  22666. // fmt.Println("SSCard的运算结果为:", ret)
  22667. // }
  22668. // result := int(ret)
  22669. // return result
  22670. //}
  22671. //func CardInit() int {
  22672. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  22673. // if err != nil {
  22674. // fmt.Println("SSCard的运算结果为:", ret)
  22675. // }
  22676. // fmt.Println(err)
  22677. // result := int(ret)
  22678. // return result
  22679. //}
  22680. func IntPtr(n int) uintptr {
  22681. return uintptr(n)
  22682. }
  22683. func StrPtr(s string) uintptr {
  22684. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  22685. }
  22686. type Result2001 struct {
  22687. Cainfo interface{} `json:"cainfo"`
  22688. ErrMsg string `json:"err_msg"`
  22689. InfRefmsgid string `json:"inf_refmsgid"`
  22690. Infcode int64 `json:"infcode"`
  22691. Output struct {
  22692. Trtinfo struct {
  22693. PsnNo string `json:"psn_no"`
  22694. TrtChkType string `json:"trt_chk_type"`
  22695. FundPayType string `json:"fund_pay_type"`
  22696. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  22697. Begndate string `json:"begndate"`
  22698. Enddate string `json:"enddate"`
  22699. TrtChkRslt string `json:"trt_chk_rslt"`
  22700. } `json:"trtinfo"`
  22701. } `json:"output"`
  22702. RefmsgTime string `json:"refmsg_time"`
  22703. RespondTime string `json:"respond_time"`
  22704. Signtype interface{} `json:"signtype"`
  22705. WarnMsg interface{} `json:"warn_msg"`
  22706. }
  22707. type Result2001Org10265 struct {
  22708. Cainfo interface{} `json:"cainfo"`
  22709. ErrMsg string `json:"err_msg"`
  22710. InfRefmsgid string `json:"inf_refmsgid"`
  22711. Infcode string `json:"infcode"`
  22712. Output struct {
  22713. Trtinfo struct {
  22714. PsnNo string `json:"psn_no"`
  22715. TrtChkType string `json:"trt_chk_type"`
  22716. FundPayType string `json:"fund_pay_type"`
  22717. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  22718. Begndate string `json:"begndate"`
  22719. Enddate string `json:"enddate"`
  22720. TrtChkRslt string `json:"trt_chk_rslt"`
  22721. } `json:"trtinfo"`
  22722. } `json:"output"`
  22723. RefmsgTime string `json:"refmsg_time"`
  22724. RespondTime string `json:"respond_time"`
  22725. Signtype interface{} `json:"signtype"`
  22726. WarnMsg interface{} `json:"warn_msg"`
  22727. }
  22728. type ResultTwo struct {
  22729. ErrMsg string `json:"err_msg"`
  22730. InfRefmsgid string `json:"inf_refmsgid"`
  22731. Infcode int64 `json:"infcode"`
  22732. Output struct {
  22733. Baseinfo struct {
  22734. //Brdy string `json:"brdy"`
  22735. Certno string `json:"certno"`
  22736. Gend string `json:"gend"`
  22737. Naty string `json:"naty"`
  22738. PsnCertType string `json:"psn_cert_type"`
  22739. PsnName string `json:"psn_name"`
  22740. PsnNo string `json:"psn_no"`
  22741. } `json:"baseinfo"`
  22742. Idetinfo []interface{} `json:"idetinfo"`
  22743. Iinfo []struct {
  22744. Balc float64 `json:"balc"`
  22745. CvlservFlag string `json:"cvlserv_flag"`
  22746. EmpName string `json:"emp_name"`
  22747. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22748. Insutype string `json:"insutype"`
  22749. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22750. //PausInsuDate string `json:"paus_insu_date"`
  22751. //PsnInsuDate string `json:"psn_insu_date"`
  22752. PsnInsuStas string `json:"psn_insu_stas"`
  22753. PsnType string `json:"psn_type"`
  22754. } `json:"insuinfo"`
  22755. } `json:"output"`
  22756. RefmsgTime string `json:"refmsg_time"`
  22757. RespondTime string `json:"respond_time"`
  22758. Signtype interface{} `json:"signtype"`
  22759. WarnInfo interface{} `json:"warn_info"`
  22760. }
  22761. type ResultTwo10265 struct {
  22762. ErrMsg string `json:"err_msg"`
  22763. InfRefmsgid string `json:"inf_refmsgid"`
  22764. Infcode string `json:"infcode"`
  22765. Output struct {
  22766. Baseinfo struct {
  22767. //Brdy string `json:"brdy"`
  22768. Certno string `json:"certno"`
  22769. Gend string `json:"gend"`
  22770. Naty string `json:"naty"`
  22771. PsnCertType string `json:"psn_cert_type"`
  22772. PsnName string `json:"psn_name"`
  22773. PsnNo string `json:"psn_no"`
  22774. } `json:"baseinfo"`
  22775. Idetinfo []interface{} `json:"idetinfo"`
  22776. Iinfo []struct {
  22777. Balc float64 `json:"balc"`
  22778. CvlservFlag string `json:"cvlserv_flag"`
  22779. EmpName string `json:"emp_name"`
  22780. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22781. Insutype string `json:"insutype"`
  22782. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22783. PsnInsuStas string `json:"psn_insu_stas"`
  22784. PsnType string `json:"psn_type"`
  22785. } `json:"insuinfo"`
  22786. } `json:"output"`
  22787. RefmsgTime string `json:"refmsg_time"`
  22788. RespondTime string `json:"respond_time"`
  22789. Signtype interface{} `json:"signtype"`
  22790. WarnInfo interface{} `json:"warn_info"`
  22791. }
  22792. type ResultThree struct {
  22793. Cainfo interface{} `json:"cainfo"`
  22794. ErrMsg string `json:"err_msg"`
  22795. InfRefmsgid string `json:"inf_refmsgid"`
  22796. Infcode int64 `json:"infcode"`
  22797. Output struct {
  22798. Data struct {
  22799. IptOtpNo string `json:"ipt_otp_no"`
  22800. MdtrtID string `json:"mdtrt_id"`
  22801. PsnNo string `json:"psn_no"`
  22802. } `json:"data"`
  22803. } `json:"output"`
  22804. RefmsgTime string `json:"refmsg_time"`
  22805. RespondTime string `json:"respond_time"`
  22806. Signtype interface{} `json:"signtype"`
  22807. WarnMsg interface{} `json:"warn_msg"`
  22808. }
  22809. type ResultThree10265 struct {
  22810. Cainfo interface{} `json:"cainfo"`
  22811. ErrMsg string `json:"err_msg"`
  22812. InfRefmsgid string `json:"inf_refmsgid"`
  22813. Infcode string `json:"infcode"`
  22814. Output struct {
  22815. Data struct {
  22816. IptOtpNo string `json:"ipt_otp_no"`
  22817. MdtrtID string `json:"mdtrt_id"`
  22818. PsnNo string `json:"psn_no"`
  22819. } `json:"data"`
  22820. } `json:"output"`
  22821. RefmsgTime string `json:"refmsg_time"`
  22822. RespondTime string `json:"respond_time"`
  22823. Signtype interface{} `json:"signtype"`
  22824. WarnMsg interface{} `json:"warn_msg"`
  22825. }
  22826. type ResultFour struct {
  22827. Cainfo string `json:"cainfo"`
  22828. ErrMsg string `json:"err_msg"`
  22829. InfRefmsgid string `json:"inf_refmsgid"`
  22830. Infcode int64 `json:"infcode"`
  22831. Output struct {
  22832. Result []struct {
  22833. BasMednFlag string `json:"bas_medn_flag"`
  22834. ChldMedcFlag string `json:"chld_medc_flag"`
  22835. ChrgitmLv string `json:"chrgitm_lv"`
  22836. Cnt float64 `json:"cnt"`
  22837. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22838. DrtReimFlag string `json:"drt_reim_flag"`
  22839. FeedetlSn string `json:"feedetl_sn"`
  22840. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22841. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22842. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22843. ListSpItemFlag string `json:"list_sp_item_flag"`
  22844. LmtUsedFlag string `json:"lmt_used_flag"`
  22845. MedChrgitmType string `json:"med_chrgitm_type"`
  22846. Memo string `json:"memo"`
  22847. OverlmtAmt float64 `json:"overlmt_amt"`
  22848. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22849. Pric float64 `json:"pric"`
  22850. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22851. SelfpayProp float64 `json:"selfpay_prop"`
  22852. } `json:"result"`
  22853. } `json:"output"`
  22854. RefmsgTime string `json:"refmsg_time"`
  22855. RespondTime string `json:"respond_time"`
  22856. Signtype string `json:"signtype"`
  22857. WarnMsg string `json:"warn_msg"`
  22858. }
  22859. type ResultFour10265 struct {
  22860. Cainfo string `json:"cainfo"`
  22861. ErrMsg string `json:"err_msg"`
  22862. InfRefmsgid string `json:"inf_refmsgid"`
  22863. Infcode string `json:"infcode"`
  22864. Output struct {
  22865. Result []struct {
  22866. BasMednFlag string `json:"bas_medn_flag"`
  22867. ChldMedcFlag string `json:"chld_medc_flag"`
  22868. ChrgitmLv string `json:"chrgitm_lv"`
  22869. Cnt float64 `json:"cnt"`
  22870. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22871. DrtReimFlag string `json:"drt_reim_flag"`
  22872. FeedetlSn string `json:"feedetl_sn"`
  22873. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22874. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22875. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22876. ListSpItemFlag string `json:"list_sp_item_flag"`
  22877. LmtUsedFlag string `json:"lmt_used_flag"`
  22878. MedChrgitmType string `json:"med_chrgitm_type"`
  22879. Memo string `json:"memo"`
  22880. OverlmtAmt float64 `json:"overlmt_amt"`
  22881. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22882. Pric float64 `json:"pric"`
  22883. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22884. SelfpayProp float64 `json:"selfpay_prop"`
  22885. } `json:"result"`
  22886. } `json:"output"`
  22887. RefmsgTime string `json:"refmsg_time"`
  22888. RespondTime string `json:"respond_time"`
  22889. Signtype string `json:"signtype"`
  22890. WarnMsg string `json:"warn_msg"`
  22891. }
  22892. type ResultMemo struct {
  22893. InsuAdmdvs string `json:"insuAdmdvs"`
  22894. }
  22895. // [{"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}]
  22896. type ResultIDInfo struct {
  22897. Begntime string `json:"begntime"`
  22898. Endtime string `json:"endtime"`
  22899. Memo string `json:"memo"`
  22900. }
  22901. type ResultFive struct {
  22902. Balc float64 `json:"balc"`
  22903. CvlservFlag string `json:"cvlserv_flag"`
  22904. EmpName string `json:"emp_name"`
  22905. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22906. Insutype string `json:"insutype"`
  22907. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22908. PausInsuDate string `json:"paus_insu_date"`
  22909. PsnInsuDate string `json:"psn_insu_date"`
  22910. PsnInsuStas string `json:"psn_insu_stas"`
  22911. PsnType string `json:"psn_type"`
  22912. }
  22913. type ResultSix struct {
  22914. Cainfo interface{} `json:"cainfo"`
  22915. ErrMsg string `json:"err_msg"`
  22916. InfRefmsgid string `json:"inf_refmsgid"`
  22917. Infcode int64 `json:"infcode"`
  22918. Output struct {
  22919. } `json:"output"`
  22920. RefmsgTime string `json:"refmsg_time"`
  22921. RespondTime string `json:"respond_time"`
  22922. Signtype interface{} `json:"signtype"`
  22923. WarnMsg interface{} `json:"warn_msg"`
  22924. }
  22925. type ResultSix3103 struct {
  22926. Cainfo interface{} `json:"cainfo"`
  22927. ErrMsg string `json:"err_msg"`
  22928. InfRefmsgid string `json:"inf_refmsgid"`
  22929. Infcode int64 `json:"infcode"`
  22930. RefmsgTime string `json:"refmsg_time"`
  22931. RespondTime string `json:"respond_time"`
  22932. Signtype interface{} `json:"signtype"`
  22933. WarnMsg interface{} `json:"warn_msg"`
  22934. }
  22935. type FJ3507Result struct {
  22936. Cainfo interface{} `json:"cainfo"`
  22937. ErrMsg string `json:"err_msg"`
  22938. InfRefmsgid string `json:"inf_refmsgid"`
  22939. Infcode int64 `json:"infcode"`
  22940. Output struct {
  22941. retRslt string `json:"retRslt"`
  22942. msgRslt string `json:"msgRslt"`
  22943. } `json:"output"`
  22944. RefmsgTime string `json:"refmsg_time"`
  22945. RespondTime string `json:"respond_time"`
  22946. Signtype interface{} `json:"signtype"`
  22947. WarnMsg interface{} `json:"warn_msg"`
  22948. }
  22949. type FJ3507ResultFor10188 struct {
  22950. Cainfo interface{} `json:"cainfo"`
  22951. ErrMsg string `json:"err_msg"`
  22952. InfRefmsgid string `json:"inf_refmsgid"`
  22953. Infcode string `json:"infcode"`
  22954. RefmsgTime string `json:"refmsg_time"`
  22955. RespondTime string `json:"respond_time"`
  22956. Signtype interface{} `json:"signtype"`
  22957. WarnMsg interface{} `json:"warn_msg"`
  22958. }
  22959. type Result2406 struct {
  22960. Cainfo interface{} `json:"cainfo"`
  22961. ErrMsg string `json:"err_msg"`
  22962. InfRefmsgid string `json:"inf_refmsgid"`
  22963. Infcode int64 `json:"infcode"`
  22964. Output struct {
  22965. Result struct {
  22966. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  22967. } `json:"result"`
  22968. } `json:"output"`
  22969. RefmsgTime string `json:"refmsg_time"`
  22970. RespondTime string `json:"respond_time"`
  22971. Signtype interface{} `json:"signtype"`
  22972. WarnMsg interface{} `json:"warn_msg"`
  22973. }
  22974. type GZResultSix struct {
  22975. Cainfo interface{} `json:"cainfo"`
  22976. ErrMsg string `json:"err_msg"`
  22977. InfRefmsgid string `json:"inf_refmsgid"`
  22978. Infcode int64 `json:"infcode"`
  22979. Output string `json:"output"`
  22980. RefmsgTime string `json:"refmsg_time"`
  22981. RespondTime string `json:"respond_time"`
  22982. Signtype interface{} `json:"signtype"`
  22983. WarnMsg interface{} `json:"warn_msg"`
  22984. }
  22985. type ResultSix10265 struct {
  22986. Cainfo interface{} `json:"cainfo"`
  22987. ErrMsg string `json:"err_msg"`
  22988. InfRefmsgid string `json:"inf_refmsgid"`
  22989. Infcode string `json:"infcode"`
  22990. Output struct {
  22991. } `json:"output"`
  22992. RefmsgTime string `json:"refmsg_time"`
  22993. RespondTime string `json:"respond_time"`
  22994. Signtype interface{} `json:"signtype"`
  22995. WarnMsg interface{} `json:"warn_msg"`
  22996. }
  22997. type ResultSeven struct {
  22998. Cainfo string `json:"cainfo"`
  22999. ErrMsg string `json:"err_msg"`
  23000. InfRefmsgid string `json:"inf_refmsgid"`
  23001. Infcode int64 `json:"infcode"`
  23002. Output struct {
  23003. Setlinfo struct {
  23004. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23005. AcctPay float64 `json:"acct_pay"`
  23006. ActPayDedc float64 `json:"act_pay_dedc"`
  23007. Age float64 `json:"age"`
  23008. Balc float64 `json:"balc"`
  23009. Certno string `json:"certno"`
  23010. ClrOptins string `json:"clr_optins"`
  23011. ClrType string `json:"clr_type"`
  23012. ClrWay string `json:"clr_way"`
  23013. CvlservFlag string `json:"cvlserv_flag"`
  23014. CvlservPay float64 `json:"cvlserv_pay"`
  23015. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23016. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23017. Gend string `json:"gend"`
  23018. HifesPay float64 `json:"hifes_pay"`
  23019. HifmiPay float64 `json:"hifmi_pay"`
  23020. HifpPay float64 `json:"hifp_pay"`
  23021. HospPartAmt float64 `json:"hosp_part_amt"`
  23022. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23023. Insutype string `json:"insutype"`
  23024. MafPay float64 `json:"maf_pay"`
  23025. MdtrtCertType string `json:"mdtrt_cert_type"`
  23026. HifobPay float64 `json:"hifob_pay"`
  23027. MdtrtID string `json:"mdtrt_id"`
  23028. MedType string `json:"med_type"`
  23029. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23030. MedinsSetlID string `json:"medins_setl_id"`
  23031. Naty string `json:"naty"`
  23032. OthPay float64 `json:"oth_pay"`
  23033. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23034. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23035. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23036. PsnCashPay float64 `json:"psn_cash_pay"`
  23037. PsnCertType string `json:"psn_cert_type"`
  23038. PsnName string `json:"psn_name"`
  23039. PsnNo string `json:"psn_no"`
  23040. PsnPartAmt float64 `json:"psn_part_amt"`
  23041. PsnType string `json:"psn_type"`
  23042. SetlID string `json:"setl_id"`
  23043. SetlTime string `json:"setl_time"`
  23044. } `json:"setlinfo"`
  23045. Setldetail interface{} `json:"setldetail"`
  23046. } `json:"output"`
  23047. RefmsgTime string `json:"refmsg_time"`
  23048. RespondTime string `json:"respond_time"`
  23049. Signtype interface{} `json:"signtype"`
  23050. WarnMsg interface{} `json:"warn_msg"`
  23051. }
  23052. type ResultSeven10633 struct {
  23053. Cainfo string `json:"cainfo"`
  23054. ErrMsg string `json:"err_msg"`
  23055. InfRefmsgid string `json:"inf_refmsgid"`
  23056. Infcode int64 `json:"infcode"`
  23057. Output struct {
  23058. Setlinfo struct {
  23059. AcctPay float64 `json:"acct_pay"`
  23060. ActPayDedc float64 `json:"act_pay_dedc"`
  23061. Age float64 `json:"age"`
  23062. Balc float64 `json:"balc"`
  23063. Certno string `json:"certno"`
  23064. ClrOptins string `json:"clr_optins"`
  23065. ClrType string `json:"clr_type"`
  23066. ClrWay string `json:"clr_way"`
  23067. CvlservFlag string `json:"cvlserv_flag"`
  23068. CvlservPay float64 `json:"cvlserv_pay"`
  23069. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23070. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23071. Gend string `json:"gend"`
  23072. HifesPay float64 `json:"hifes_pay"`
  23073. HifmiPay float64 `json:"hifmi_pay"`
  23074. HifpPay float64 `json:"hifp_pay"`
  23075. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23076. Insutype string `json:"insutype"`
  23077. MafPay float64 `json:"maf_pay"`
  23078. MdtrtCertType string `json:"mdtrt_cert_type"`
  23079. HifobPay float64 `json:"hifob_pay"`
  23080. MdtrtID string `json:"mdtrt_id"`
  23081. MedType string `json:"med_type"`
  23082. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23083. MedinsSetlID string `json:"medins_setl_id"`
  23084. Naty string `json:"naty"`
  23085. OthPay float64 `json:"oth_pay"`
  23086. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23087. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23088. PsnCashPay float64 `json:"psn_cash_pay"`
  23089. PsnCertType string `json:"psn_cert_type"`
  23090. PsnName string `json:"psn_name"`
  23091. PsnNo string `json:"psn_no"`
  23092. PsnPartAmt float64 `json:"psn_part_amt"`
  23093. PsnType string `json:"psn_type"`
  23094. SetlID string `json:"setl_id"`
  23095. SetlTime string `json:"setl_time"`
  23096. } `json:"setlinfo"`
  23097. Setldetail interface{} `json:"setldetail"`
  23098. } `json:"output"`
  23099. RefmsgTime string `json:"refmsg_time"`
  23100. RespondTime string `json:"respond_time"`
  23101. Signtype interface{} `json:"signtype"`
  23102. WarnMsg interface{} `json:"warn_msg"`
  23103. }
  23104. type ResultSevenAH struct {
  23105. Cainfo string `json:"cainfo"`
  23106. ErrMsg string `json:"err_msg"`
  23107. InfRefmsgid string `json:"inf_refmsgid"`
  23108. Infcode int64 `json:"infcode"`
  23109. Output struct {
  23110. Setlinfo struct {
  23111. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23112. AcctPay float64 `json:"acct_pay"`
  23113. ActPayDedc float64 `json:"act_pay_dedc"`
  23114. Age float64 `json:"age"`
  23115. Balc float64 `json:"balc"`
  23116. Certno string `json:"certno"`
  23117. ClrOptins string `json:"clr_optins"`
  23118. ClrType string `json:"clr_type"`
  23119. ClrWay string `json:"clr_way"`
  23120. CvlservFlag string `json:"cvlserv_flag"`
  23121. CvlservPay float64 `json:"cvlserv_pay"`
  23122. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23123. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23124. Gend string `json:"gend"`
  23125. HifesPay float64 `json:"hifes_pay"`
  23126. HifmiPay float64 `json:"hifmi_pay"`
  23127. HifpPay float64 `json:"hifp_pay"`
  23128. HospPartAmt float64 `json:"hosp_part_amt"`
  23129. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23130. Insutype string `json:"insutype"`
  23131. MafPay float64 `json:"maf_pay"`
  23132. MdtrtCertType string `json:"mdtrt_cert_type"`
  23133. HifobPay float64 `json:"hifob_pay"`
  23134. MdtrtID string `json:"mdtrt_id"`
  23135. MedType string `json:"med_type"`
  23136. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23137. MedinsSetlID string `json:"medins_setl_id"`
  23138. Naty string `json:"naty"`
  23139. OthPay float64 `json:"oth_pay"`
  23140. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23141. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23142. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23143. PsnCashPay float64 `json:"psn_cash_pay"`
  23144. PsnCertType string `json:"psn_cert_type"`
  23145. PsnName string `json:"psn_name"`
  23146. PsnNo string `json:"psn_no"`
  23147. PsnPartAmt float64 `json:"psn_part_amt"`
  23148. PsnType string `json:"psn_type"`
  23149. SetlID string `json:"setl_id"`
  23150. SetlTime int64 `json:"setl_time"`
  23151. } `json:"setlinfo"`
  23152. Setldetail interface{} `json:"setldetail"`
  23153. } `json:"output"`
  23154. RefmsgTime string `json:"refmsg_time"`
  23155. RespondTime string `json:"respond_time"`
  23156. Signtype interface{} `json:"signtype"`
  23157. WarnMsg interface{} `json:"warn_msg"`
  23158. }
  23159. type ResultSeven10265 struct {
  23160. Cainfo string `json:"cainfo"`
  23161. ErrMsg string `json:"err_msg"`
  23162. InfRefmsgid string `json:"inf_refmsgid"`
  23163. Infcode string `json:"infcode"`
  23164. Output struct {
  23165. Setlinfo struct {
  23166. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23167. AcctPay float64 `json:"acct_pay"`
  23168. ActPayDedc float64 `json:"act_pay_dedc"`
  23169. Age float64 `json:"age"`
  23170. Balc float64 `json:"balc"`
  23171. Certno string `json:"certno"`
  23172. ClrOptins string `json:"clr_optins"`
  23173. ClrType string `json:"clr_type"`
  23174. ClrWay string `json:"clr_way"`
  23175. CvlservFlag string `json:"cvlserv_flag"`
  23176. CvlservPay float64 `json:"cvlserv_pay"`
  23177. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23178. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23179. Gend string `json:"gend"`
  23180. HifesPay float64 `json:"hifes_pay"`
  23181. HifmiPay float64 `json:"hifmi_pay"`
  23182. HifpPay float64 `json:"hifp_pay"`
  23183. HospPartAmt float64 `json:"hosp_part_amt"`
  23184. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23185. Insutype string `json:"insutype"`
  23186. MafPay float64 `json:"maf_pay"`
  23187. MdtrtCertType string `json:"mdtrt_cert_type"`
  23188. HifobPay float64 `json:"hifob_pay"`
  23189. MdtrtID string `json:"mdtrt_id"`
  23190. MedType string `json:"med_type"`
  23191. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23192. MedinsSetlID string `json:"medins_setl_id"`
  23193. Naty string `json:"naty"`
  23194. OthPay float64 `json:"oth_pay"`
  23195. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23196. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23197. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23198. PsnCashPay float64 `json:"psn_cash_pay"`
  23199. PsnCertType string `json:"psn_cert_type"`
  23200. PsnName string `json:"psn_name"`
  23201. PsnNo string `json:"psn_no"`
  23202. PsnPartAmt float64 `json:"psn_part_amt"`
  23203. PsnType string `json:"psn_type"`
  23204. SetlID string `json:"setl_id"`
  23205. SetlTime string `json:"setl_time"`
  23206. } `json:"setlinfo"`
  23207. Setldetail interface{} `json:"setldetail"`
  23208. } `json:"output"`
  23209. RefmsgTime string `json:"refmsg_time"`
  23210. RespondTime string `json:"respond_time"`
  23211. Signtype interface{} `json:"signtype"`
  23212. WarnMsg interface{} `json:"warn_msg"`
  23213. }
  23214. type ResultSeven10265Two struct {
  23215. Cainfo string `json:"cainfo"`
  23216. ErrMsg string `json:"err_msg"`
  23217. InfRefmsgid string `json:"inf_refmsgid"`
  23218. Infcode string `json:"infcode"`
  23219. Output struct {
  23220. Setlinfo struct {
  23221. AcctMulaidPay string `json:"acct_mulaid_pay"`
  23222. AcctPay float64 `json:"acct_pay"`
  23223. ActPayDedc float64 `json:"act_pay_dedc"`
  23224. Age float64 `json:"age"`
  23225. Balc float64 `json:"balc"`
  23226. Certno string `json:"certno"`
  23227. ClrOptins string `json:"clr_optins"`
  23228. ClrType string `json:"clr_type"`
  23229. ClrWay string `json:"clr_way"`
  23230. CvlservFlag string `json:"cvlserv_flag"`
  23231. CvlservPay float64 `json:"cvlserv_pay"`
  23232. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23233. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23234. Gend string `json:"gend"`
  23235. HifesPay float64 `json:"hifes_pay"`
  23236. HifmiPay float64 `json:"hifmi_pay"`
  23237. HifpPay float64 `json:"hifp_pay"`
  23238. HospPartAmt string `json:"hosp_part_amt"`
  23239. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23240. Insutype string `json:"insutype"`
  23241. MafPay float64 `json:"maf_pay"`
  23242. MdtrtCertType string `json:"mdtrt_cert_type"`
  23243. HifobPay float64 `json:"hifob_pay"`
  23244. MdtrtID string `json:"mdtrt_id"`
  23245. MedType string `json:"med_type"`
  23246. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23247. MedinsSetlID string `json:"medins_setl_id"`
  23248. Naty string `json:"naty"`
  23249. OthPay float64 `json:"oth_pay"`
  23250. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23251. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  23252. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23253. PsnCashPay float64 `json:"psn_cash_pay"`
  23254. PsnCertType string `json:"psn_cert_type"`
  23255. PsnName string `json:"psn_name"`
  23256. PsnNo string `json:"psn_no"`
  23257. PsnPartAmt float64 `json:"psn_part_amt"`
  23258. PsnType string `json:"psn_type"`
  23259. SetlID string `json:"setl_id"`
  23260. SetlTime string `json:"setl_time"`
  23261. } `json:"setlinfo"`
  23262. Setldetail interface{} `json:"setldetail"`
  23263. } `json:"output"`
  23264. RefmsgTime string `json:"refmsg_time"`
  23265. RespondTime string `json:"respond_time"`
  23266. Signtype interface{} `json:"signtype"`
  23267. WarnMsg interface{} `json:"warn_msg"`
  23268. }
  23269. type ResultSeven10633Two struct {
  23270. Cainfo string `json:"cainfo"`
  23271. ErrMsg string `json:"err_msg"`
  23272. InfRefmsgid string `json:"inf_refmsgid"`
  23273. Infcode string `json:"infcode"`
  23274. Output struct {
  23275. Setlinfo struct {
  23276. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23277. AcctPay float64 `json:"acct_pay"`
  23278. ActPayDedc float64 `json:"act_pay_dedc"`
  23279. Age float64 `json:"age"`
  23280. Balc float64 `json:"balc"`
  23281. Certno string `json:"certno"`
  23282. ClrOptins string `json:"clr_optins"`
  23283. ClrType string `json:"clr_type"`
  23284. ClrWay string `json:"clr_way"`
  23285. CvlservFlag string `json:"cvlserv_flag"`
  23286. CvlservPay float64 `json:"cvlserv_pay"`
  23287. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23288. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23289. Gend string `json:"gend"`
  23290. HifesPay float64 `json:"hifes_pay"`
  23291. HifmiPay float64 `json:"hifmi_pay"`
  23292. HifpPay float64 `json:"hifp_pay"`
  23293. HospPartAmt float64 `json:"hosp_part_amt"`
  23294. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23295. Insutype string `json:"insutype"`
  23296. MafPay float64 `json:"maf_pay"`
  23297. MdtrtCertType string `json:"mdtrt_cert_type"`
  23298. HifobPay float64 `json:"hifob_pay"`
  23299. MdtrtID string `json:"mdtrt_id"`
  23300. MedType string `json:"med_type"`
  23301. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23302. MedinsSetlID string `json:"medins_setl_id"`
  23303. Naty string `json:"naty"`
  23304. OthPay float64 `json:"oth_pay"`
  23305. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23306. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23307. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23308. PsnCashPay float64 `json:"psn_cash_pay"`
  23309. PsnCertType string `json:"psn_cert_type"`
  23310. PsnName string `json:"psn_name"`
  23311. PsnNo string `json:"psn_no"`
  23312. PsnPartAmt float64 `json:"psn_part_amt"`
  23313. PsnType string `json:"psn_type"`
  23314. SetlID string `json:"setl_id"`
  23315. SetlTime string `json:"setl_time"`
  23316. } `json:"setlinfo"`
  23317. Setldetail interface{} `json:"setldetail"`
  23318. } `json:"output"`
  23319. RefmsgTime string `json:"refmsg_time"`
  23320. RespondTime string `json:"respond_time"`
  23321. Signtype interface{} `json:"signtype"`
  23322. WarnMsg interface{} `json:"warn_msg"`
  23323. }
  23324. type FlexibleFloat float64
  23325. func (f *FlexibleFloat) UnmarshalJSON(data []byte) error {
  23326. var v interface{}
  23327. if err := json.Unmarshal(data, &v); err != nil {
  23328. return err
  23329. }
  23330. switch value := v.(type) {
  23331. case float64:
  23332. *f = FlexibleFloat(value)
  23333. case string:
  23334. if value == "" {
  23335. *f = 0 // 空字符串默认0
  23336. } else {
  23337. num, err := strconv.ParseFloat(value, 64)
  23338. if err != nil {
  23339. return fmt.Errorf("无法解析字符串为浮点数: %v", err)
  23340. }
  23341. *f = FlexibleFloat(num)
  23342. }
  23343. default:
  23344. return fmt.Errorf("不支持的字段类型: %T", value)
  23345. }
  23346. return nil
  23347. }
  23348. type ResultSeven10633Three struct {
  23349. Cainfo string `json:"cainfo"`
  23350. ErrMsg string `json:"err_msg"`
  23351. InfRefmsgid string `json:"inf_refmsgid"`
  23352. Infcode string `json:"infcode"`
  23353. Output struct {
  23354. Setlinfo struct {
  23355. AcctPay float64 `json:"acct_pay"`
  23356. ActPayDedc float64 `json:"act_pay_dedc"`
  23357. Age float64 `json:"age"`
  23358. Balc float64 `json:"balc"`
  23359. Certno string `json:"certno"`
  23360. ClrOptins string `json:"clr_optins"`
  23361. ClrType string `json:"clr_type"`
  23362. ClrWay string `json:"clr_way"`
  23363. CvlservFlag string `json:"cvlserv_flag"`
  23364. CvlservPay float64 `json:"cvlserv_pay"`
  23365. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23366. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23367. Gend string `json:"gend"`
  23368. HifesPay float64 `json:"hifes_pay"`
  23369. HifmiPay float64 `json:"hifmi_pay"`
  23370. HifpPay float64 `json:"hifp_pay"`
  23371. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23372. Insutype string `json:"insutype"`
  23373. MafPay float64 `json:"maf_pay"`
  23374. MdtrtCertType string `json:"mdtrt_cert_type"`
  23375. HifobPay float64 `json:"hifob_pay"`
  23376. MdtrtID string `json:"mdtrt_id"`
  23377. MedType string `json:"med_type"`
  23378. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23379. MedinsSetlID string `json:"medins_setl_id"`
  23380. Naty string `json:"naty"`
  23381. OthPay float64 `json:"oth_pay"`
  23382. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23383. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23384. PsnCashPay float64 `json:"psn_cash_pay"`
  23385. PsnCertType string `json:"psn_cert_type"`
  23386. PsnName string `json:"psn_name"`
  23387. PsnNo string `json:"psn_no"`
  23388. PsnPartAmt float64 `json:"psn_part_amt"`
  23389. PsnType string `json:"psn_type"`
  23390. SetlID string `json:"setl_id"`
  23391. SetlTime string `json:"setl_time"`
  23392. } `json:"setlinfo"`
  23393. Setldetail interface{} `json:"setldetail"`
  23394. } `json:"output"`
  23395. RefmsgTime string `json:"refmsg_time"`
  23396. RespondTime string `json:"respond_time"`
  23397. Signtype interface{} `json:"signtype"`
  23398. WarnMsg interface{} `json:"warn_msg"`
  23399. }
  23400. type GZResultSeven10265Two struct {
  23401. Cainfo string `json:"cainfo"`
  23402. ErrMsg string `json:"err_msg"`
  23403. InfRefmsgid string `json:"inf_refmsgid"`
  23404. Infcode int64 `json:"infcode"`
  23405. Output struct {
  23406. Setlinfo struct {
  23407. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23408. AcctPay float64 `json:"acct_pay"`
  23409. ActPayDedc float64 `json:"act_pay_dedc"`
  23410. Age float64 `json:"age"`
  23411. Balc float64 `json:"balc"`
  23412. Certno string `json:"certno"`
  23413. ClrOptins string `json:"clr_optins"`
  23414. ClrType string `json:"clr_type"`
  23415. ClrWay string `json:"clr_way"`
  23416. CvlservFlag string `json:"cvlserv_flag"`
  23417. CvlservPay float64 `json:"cvlserv_pay"`
  23418. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23419. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23420. Gend string `json:"gend"`
  23421. HifesPay float64 `json:"hifes_pay"`
  23422. HifmiPay float64 `json:"hifmi_pay"`
  23423. HifpPay float64 `json:"hifp_pay"`
  23424. HospPartAmt float64 `json:"hosp_part_amt"`
  23425. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23426. Insutype string `json:"insutype"`
  23427. MafPay float64 `json:"maf_pay"`
  23428. MdtrtCertType string `json:"mdtrt_cert_type"`
  23429. HifobPay float64 `json:"hifob_pay"`
  23430. MdtrtID string `json:"mdtrt_id"`
  23431. MedType string `json:"med_type"`
  23432. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23433. MedinsSetlID string `json:"medins_setl_id"`
  23434. Naty string `json:"naty"`
  23435. OthPay float64 `json:"oth_pay"`
  23436. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23437. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  23438. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23439. PsnCashPay float64 `json:"psn_cash_pay"`
  23440. PsnCertType string `json:"psn_cert_type"`
  23441. PsnName string `json:"psn_name"`
  23442. PsnNo string `json:"psn_no"`
  23443. PsnPartAmt float64 `json:"psn_part_amt"`
  23444. PsnType string `json:"psn_type"`
  23445. SetlID string `json:"setl_id"`
  23446. SetlTime string `json:"setl_time"`
  23447. } `json:"setlinfo"`
  23448. Setldetail interface{} `json:"setldetail"`
  23449. } `json:"output"`
  23450. RefmsgTime string `json:"refmsg_time"`
  23451. RespondTime string `json:"respond_time"`
  23452. Signtype interface{} `json:"signtype"`
  23453. WarnMsg interface{} `json:"warn_msg"`
  23454. }
  23455. type ResultEight struct {
  23456. Cainfo string `json:"cainfo"`
  23457. ErrMsg string `json:"err_msg"`
  23458. InfRefmsgid string `json:"inf_refmsgid"`
  23459. Infcode int64 `json:"infcode"`
  23460. Output struct {
  23461. Stmtinfo struct {
  23462. SetlOptins string `json:"setl_optins"`
  23463. StmtRslt string `json:"stmt_rslt"`
  23464. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  23465. } `json:"stmtinfo"`
  23466. } `json:"output"`
  23467. RefmsgTime string `json:"refmsg_time"`
  23468. RespondTime string `json:"respond_time"`
  23469. Signtype interface{} `json:"signtype"`
  23470. WarnMsg interface{} `json:"warn_msg"`
  23471. }
  23472. type ResultEightFor10188 struct {
  23473. Cainfo string `json:"cainfo"`
  23474. ErrMsg string `json:"err_msg"`
  23475. InfRefmsgid string `json:"inf_refmsgid"`
  23476. Infcode string `json:"infcode"`
  23477. Output struct {
  23478. Stmtinfo struct {
  23479. SetlOptins string `json:"setl_optins"`
  23480. StmtRslt string `json:"stmt_rslt"`
  23481. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  23482. } `json:"stmtinfo"`
  23483. } `json:"output"`
  23484. RefmsgTime string `json:"refmsg_time"`
  23485. RespondTime string `json:"respond_time"`
  23486. Signtype interface{} `json:"signtype"`
  23487. WarnMsg interface{} `json:"warn_msg"`
  23488. }
  23489. type ResultNine struct {
  23490. Cainfo string `json:"cainfo"`
  23491. ErrMsg string `json:"err_msg"`
  23492. InfRefmsgid string `json:"inf_refmsgid"`
  23493. Infcode int64 `json:"infcode"`
  23494. Output struct {
  23495. FileQuryNo string `json:"file_qury_no"`
  23496. } `json:"output"`
  23497. RefmsgTime string `json:"refmsg_time"`
  23498. RespondTime string `json:"respond_time"`
  23499. Signtype interface{} `json:"signtype"`
  23500. WarnMsg interface{} `json:"warn_msg"`
  23501. }
  23502. type ResultTen struct {
  23503. Cainfo string `json:"cainfo"`
  23504. ErrMsg string `json:"err_msg"`
  23505. InfRefmsgid string `json:"inf_refmsgid"`
  23506. Infcode int64 `json:"infcode"`
  23507. Output struct {
  23508. Fileinfo struct {
  23509. DldEndtime string `json:"dld_endtime"`
  23510. FileQuryNo string `json:"file_qury_no"`
  23511. Filename string `json:"filename"`
  23512. } `json:"fileinfo"`
  23513. } `json:"output"`
  23514. RefmsgTime string `json:"refmsg_time"`
  23515. RespondTime string `json:"respond_time"`
  23516. Signtype interface{} `json:"signtype"`
  23517. WarnMsg interface{} `json:"warn_msg"`
  23518. }
  23519. type Result5262 struct {
  23520. ErrMsg string `json:"err_msg"`
  23521. InfRefmsgid string `json:"inf_refmsgid"`
  23522. Infcode int64 `json:"infcode"`
  23523. Output struct {
  23524. PageInfo struct {
  23525. Size int `json:"size"`
  23526. RecordCounts int `json:"record_counts"`
  23527. } `json:"page_info"`
  23528. Idetinfo []interface{} `json:"idetinfo"`
  23529. Result []struct {
  23530. SetlID string `json:"setl_id"`
  23531. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  23532. MdtrtID string `json:"mdtrt_id"`
  23533. InitSetlID string `json:"init_setl_id,omitempty"`
  23534. PsnNo string `json:"psn_no"`
  23535. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  23536. PsnName string `json:"psn_name"`
  23537. PsnCertType string `json:"psn_cert_type"`
  23538. Certno string `json:"certno"`
  23539. Gend string `json:"gend,omitempty"`
  23540. Naty string `json:"naty,omitempty"`
  23541. Brdy string `json:"brdy,omitempty"`
  23542. Age float64 `json:"age,omitempty"`
  23543. Insutype string `json:"insutype,omitempty"`
  23544. PsnType string `json:"psn_type"`
  23545. CvlservFlag string `json:"cvlserv_flag"`
  23546. CvlservLv string `json:"cvlserv_lv,omitempty"`
  23547. SpPsnType string `json:"sp_psn_type,omitempty"`
  23548. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  23549. ClctGrde string `json:"clct_grde,omitempty"`
  23550. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  23551. NwbFlag string `json:"nwb_flag,omitempty"`
  23552. InsuAdmdvs string `json:"insu_admdvs"`
  23553. EmpNo string `json:"emp_no,omitempty"`
  23554. EmpName string `json:"emp_name,omitempty"`
  23555. EmpType string `json:"emp_type,omitempty"`
  23556. EconType string `json:"econ_type,omitempty"`
  23557. AfilIndu string `json:"afil_indu,omitempty"`
  23558. AfilRlts string `json:"afil_rlts,omitempty"`
  23559. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  23560. PayLoc string `json:"pay_loc,omitempty"`
  23561. FixmedinsCode string `json:"fixmedins_code"`
  23562. FixmedinsName string `json:"fixmedins_name"`
  23563. HospLv string `json:"hosp_lv,omitempty"`
  23564. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  23565. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  23566. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  23567. Begndate string `json:"begndate"`
  23568. Enddate string `json:"enddate"`
  23569. SetlTime string `json:"setl_time"`
  23570. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  23571. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  23572. MedType string `json:"med_type"`
  23573. SetlType string `json:"setl_type,omitempty"`
  23574. ClrType string `json:"clr_type,omitempty"`
  23575. ClrWay string `json:"clr_way,omitempty"`
  23576. PsnSetlway string `json:"psn_setlway,omitempty"`
  23577. ClrOptins string `json:"clr_optins,omitempty"`
  23578. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  23579. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  23580. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  23581. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  23582. InscpAmt float64 `json:"inscp_amt,omitempty"`
  23583. DedcStd float64 `json:"dedc_std,omitempty"`
  23584. CrtDedc float64 `json:"crt_dedc,omitempty"`
  23585. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  23586. HifpPay float64 `json:"hifp_pay,omitempty"`
  23587. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  23588. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  23589. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  23590. HifesPay float64 `json:"hifes_pay,omitempty"`
  23591. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  23592. HifobPay float64 `json:"hifob_pay,omitempty"`
  23593. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  23594. MafPay float64 `json:"maf_pay,omitempty"`
  23595. OthfundPay float64 `json:"othfund_pay,omitempty"`
  23596. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  23597. PsnPay float64 `json:"psn_pay,omitempty"`
  23598. AcctPay float64 `json:"acct_pay,omitempty"`
  23599. CashPayamt float64 `json:"cash_payamt,omitempty"`
  23600. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  23601. Balc float64 `json:"balc,omitempty"`
  23602. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  23603. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  23604. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  23605. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  23606. Year string `json:"year,omitempty"`
  23607. DiseNo string `json:"dise_no,omitempty"`
  23608. DiseName string `json:"dise_name,omitempty"`
  23609. Invono string `json:"invono,omitempty"`
  23610. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  23611. ValiFlag string `json:"vali_flag,omitempty"`
  23612. Memo string `json:"memo,omitempty"`
  23613. Rid string `json:"rid"`
  23614. UpdtTime string `json:"updt_time,omitempty"`
  23615. CrterID string `json:"crter_id,omitempty"`
  23616. CrterName string `json:"crter_name,omitempty"`
  23617. CrteTime string `json:"crte_time,omitempty"`
  23618. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  23619. OpterID string `json:"opter_id,omitempty"`
  23620. OpterName string `json:"opter_name,omitempty"`
  23621. OptTime string `json:"opt_time,omitempty"`
  23622. OptinsNo string `json:"optins_no,omitempty"`
  23623. PoolareaNo string `json:"poolarea_no,omitempty"`
  23624. } `json:"result"`
  23625. } `json:"output"`
  23626. RefmsgTime string `json:"refmsg_time"`
  23627. RespondTime string `json:"respond_time"`
  23628. Signtype interface{} `json:"signtype"`
  23629. WarnInfo interface{} `json:"warn_info"`
  23630. }
  23631. type Result5267 struct {
  23632. ErrMsg string `json:"err_msg"`
  23633. InfRefmsgid string `json:"inf_refmsgid"`
  23634. Infcode int64 `json:"infcode"`
  23635. Output struct {
  23636. PageInfo struct {
  23637. Size int `json:"size"`
  23638. RecordCounts int `json:"record_counts"`
  23639. } `json:"pageinfo"`
  23640. Result []struct {
  23641. SetlID string `json:"setl_id"`
  23642. ClrOptins string `json:"clr_optins"`
  23643. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  23644. MdtrtID string `json:"mdtrt_id"`
  23645. InitSetlID string `json:"init_setl_id,omitempty"`
  23646. PsnNo string `json:"psn_no"`
  23647. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  23648. PsnName string `json:"psn_name"`
  23649. PsnCertType string `json:"psn_cert_type"`
  23650. Certno string `json:"certno"`
  23651. Gend string `json:"gend,omitempty"`
  23652. Naty string `json:"naty,omitempty"`
  23653. Brdy string `json:"brdy,omitempty"`
  23654. Age float64 `json:"age,omitempty"`
  23655. Insutype string `json:"insutype,omitempty"`
  23656. PsnType string `json:"psn_type"`
  23657. CvlservFlag string `json:"cvlserv_flag"`
  23658. CvlservLv string `json:"cvlserv_lv,omitempty"`
  23659. SpPsnType string `json:"sp_psn_type,omitempty"`
  23660. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  23661. ClctGrde string `json:"clct_grde,omitempty"`
  23662. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  23663. NwbFlag string `json:"nwb_flag,omitempty"`
  23664. InsuAdmdvs string `json:"insu_admdvs"`
  23665. EmpNo string `json:"emp_no,omitempty"`
  23666. EmpName string `json:"emp_name,omitempty"`
  23667. EmpType string `json:"emp_type,omitempty"`
  23668. EconType string `json:"econ_type,omitempty"`
  23669. AfilIndu string `json:"afil_indu,omitempty"`
  23670. AfilRlts string `json:"afil_rlts,omitempty"`
  23671. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  23672. PayLoc string `json:"pay_loc,omitempty"`
  23673. FixmedinsCode string `json:"fixmedins_code"`
  23674. FixmedinsName string `json:"fixmedins_name"`
  23675. HospLv string `json:"hosp_lv,omitempty"`
  23676. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  23677. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  23678. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  23679. Begndate string `json:"begndate,omitempty"`
  23680. Enddate string `json:"enddate,omitempty"`
  23681. SetlTime string `json:"setl_time,omitempty"`
  23682. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  23683. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  23684. MedType string `json:"med_type"`
  23685. SetlType string `json:"setl_type,omitempty"`
  23686. ClrType string `json:"clr_type,omitempty"`
  23687. ClrWay string `json:"clr_way,omitempty"`
  23688. PsnSetlway string `json:"psn_setlway,omitempty"`
  23689. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  23690. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  23691. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  23692. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  23693. InscpAmt float64 `json:"inscp_amt,omitempty"`
  23694. DedcStd float64 `json:"dedc_std,omitempty"`
  23695. CrtDedc float64 `json:"crt_dedc,omitempty"`
  23696. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  23697. HifpPay float64 `json:"hifp_pay,omitempty"`
  23698. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  23699. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  23700. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  23701. HifesPay float64 `json:"hifes_pay,omitempty"`
  23702. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  23703. HifobPay float64 `json:"hifob_pay,omitempty"`
  23704. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  23705. MafPay float64 `json:"maf_pay,omitempty"`
  23706. OthfundPay float64 `json:"othfund_pay,omitempty"`
  23707. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  23708. PsnPay float64 `json:"psn_pay,omitempty"`
  23709. AcctPay float64 `json:"acct_pay,omitempty"`
  23710. CashPayamt float64 `json:"cash_payamt,omitempty"`
  23711. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  23712. Balc float64 `json:"balc,omitempty"`
  23713. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  23714. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  23715. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  23716. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  23717. Year string `json:"year,omitempty"`
  23718. DiseNo string `json:"dise_no,omitempty"`
  23719. DiseName string `json:"dise_name,omitempty"`
  23720. Invono string `json:"invono,omitempty"`
  23721. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  23722. Memo string `json:"memo,omitempty"`
  23723. UpdtTime string `json:"updt_time,omitempty"`
  23724. OpterID string `json:"opter_id,omitempty"`
  23725. OpterName string `json:"opter_name,omitempty"`
  23726. OptTime string `json:"opt_time,omitempty"`
  23727. OptinsNo string `json:"optins_no,omitempty"`
  23728. PoolareaNo string `json:"poolarea_no,omitempty"`
  23729. } `json:"result"`
  23730. } `json:"output"`
  23731. RefmsgTime string `json:"refmsg_time"`
  23732. RespondTime string `json:"respond_time"`
  23733. Signtype interface{} `json:"signtype"`
  23734. WarnInfo interface{} `json:"warn_info"`
  23735. }
  23736. // type Autogenerated struct {
  23737. // Output struct {
  23738. // Setlinfo struct {
  23739. // SetlTime string `json:"setl_time"`
  23740. // CvlservPay float64 `json:"cvlserv_pay"`
  23741. // Year string `json:"year"`
  23742. // MedType string `json:"med_type"`
  23743. // PsnPay float64 `json:"psn_pay"`
  23744. // OpterID string `json:"opter_id"`
  23745. // Begndate string `json:"begndate"`
  23746. // FlxempeFlag string `json:"flxempe_flag"`
  23747. // HifmiPay float64 `json:"hifmi_pay"`
  23748. // PsnNo string `json:"psn_no"`
  23749. // ActPayDedc float64 `json:"act_pay_dedc"`
  23750. // MedinsSetlID interface{} `json:"medins_setl_id"`
  23751. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23752. // ClrWay string `json:"clr_way"`
  23753. // OthPay float64 `json:"oth_pay"`
  23754. // Gend string `json:"gend"`
  23755. // MdtrtID string `json:"mdtrt_id"`
  23756. // AcctPay float64 `json:"acct_pay"`
  23757. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  23758. // Insutype string `json:"insutype"`
  23759. // Invono interface{} `json:"invono"`
  23760. // Enddate string `json:"enddate"`
  23761. // CashPayamt float64 `json:"cash_payamt"`
  23762. // PsnType string `json:"psn_type"`
  23763. // FixmedinsName string `json:"fixmedins_name"`
  23764. // HifpPay float64 `json:"hifp_pay"`
  23765. // NewFlag interface{} `json:"new_flag"`
  23766. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23767. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  23768. // PayLoc string `json:"pay_loc"`
  23769. // ClrType string `json:"clr_type"`
  23770. // RefdSetlFlag string `json:"refd_setl_flag"`
  23771. // CvlservFlag string `json:"cvlserv_flag"`
  23772. // EmpName string `json:"emp_name"`
  23773. // Brdy string `json:"brdy"`
  23774. // Naty string `json:"naty"`
  23775. // Certno string `json:"certno"`
  23776. // DiseCode string `json:"dise_code"`
  23777. // FixmedinsCode string `json:"fixmedins_code"`
  23778. // DedcHospLv string `json:"dedc_hosp_lv"`
  23779. // OpterName string `json:"opter_name"`
  23780. // Balc float64 `json:"balc"`
  23781. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23782. // PsnCertType string `json:"psn_cert_type"`
  23783. // HifobPay float64 `json:"hifob_pay"`
  23784. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  23785. // HifesPay float64 `json:"hifes_pay"`
  23786. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23787. // OptTime string `json:"opt_time"`
  23788. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23789. // SetlID string `json:"setl_id"`
  23790. // MafPay float64 `json:"maf_pay"`
  23791. // PsnName string `json:"psn_name"`
  23792. // InsuOptins interface{} `json:"insu_optins"`
  23793. // PrefFundPay interface{} `json:"pref_fund_pay"`
  23794. // ClrOptins string `json:"clr_optins"`
  23795. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23796. // DiseName string `json:"dise_name"`
  23797. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23798. // Age float64 `json:"age"`
  23799. // DtrtCertType string `json:"dtrt_cert_type"`
  23800. // HospLv string `json:"hosp_lv"`
  23801. // } `json:"setlinfo"`
  23802. // Setldetail []struct {
  23803. // FundPayType string `json:"fund_pay_type"`
  23804. // FundPayamt float64 `json:"fund_payamt"`
  23805. // SetlProcInfo interface{} `json:"setl_proc_info"`
  23806. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  23807. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  23808. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  23809. // PrefFundPay interface{} `json:"pref_fund_pay"`
  23810. // } `json:"setldetail"`
  23811. // } `json:"output"`
  23812. // Infcode int `json:"infcode"`
  23813. // WarnMsg interface{} `json:"warn_msg"`
  23814. // Cainfo interface{} `json:"cainfo"`
  23815. // ErrMsg interface{} `json:"err_msg"`
  23816. // RefmsgTime string `json:"refmsg_time"`
  23817. // Signtype interface{} `json:"signtype"`
  23818. // RespondTime string `json:"respond_time"`
  23819. // InfRefmsgid string `json:"inf_refmsgid"`
  23820. // }
  23821. type Result002 struct {
  23822. Cainfo interface{} `json:"cainfo"`
  23823. ErrMsg string `json:"err_msg"`
  23824. InfRefmsgid string `json:"inf_refmsgid"`
  23825. Infcode int64 `json:"infcode"`
  23826. Output struct {
  23827. RxFile string `json:"rx_file"`
  23828. SignDigest string `json:"sign_digest"`
  23829. SignCertSn string `json:"sign_cert_sn"`
  23830. SignCertDn string `json:"sign_cert_dn"`
  23831. } `json:"output"`
  23832. RefmsgTime string `json:"refmsg_time"`
  23833. RespondTime string `json:"respond_time"`
  23834. Signtype interface{} `json:"signtype"`
  23835. WarnMsg interface{} `json:"warn_msg"`
  23836. }
  23837. type AhResult002 struct {
  23838. RxFile string `json:"rxFile"`
  23839. SignDigest string `json:"signDigest"`
  23840. SignCertSn string `json:"signCertSn"`
  23841. SignCertDn string `json:"signCertDn"`
  23842. }
  23843. type Result003 struct {
  23844. Cainfo interface{} `json:"cainfo"`
  23845. ErrMsg string `json:"err_msg"`
  23846. InfRefmsgid string `json:"inf_refmsgid"`
  23847. Infcode int64 `json:"infcode"`
  23848. Output struct {
  23849. HiRxno string `json:"hi_rxno"`
  23850. RxStasCodg string `json:"rx_stas_codg"`
  23851. RxStasName string `json:"rx_stas_name"`
  23852. } `json:"output"`
  23853. RefmsgTime string `json:"refmsg_time"`
  23854. RespondTime string `json:"respond_time"`
  23855. Signtype interface{} `json:"signtype"`
  23856. WarnMsg interface{} `json:"warn_msg"`
  23857. }
  23858. type AHResult003 struct {
  23859. HiRxno string `json:"hiRxno"`
  23860. RxStasCodg string `json:"rxStasCodg"`
  23861. RxStasName string `json:"rxStasName"`
  23862. }
  23863. type ResultEleven struct {
  23864. Cainfo string `json:"cainfo"`
  23865. ErrMsg string `json:"err_msg"`
  23866. InfRefmsgid string `json:"inf_refmsgid"`
  23867. Infcode int64 `json:"infcode"`
  23868. Output struct {
  23869. Setlinfo struct {
  23870. SetlTime string `json:"setl_time"`
  23871. CvlservPay float64 `json:"cvlserv_pay"`
  23872. Year string `json:"year"`
  23873. MedType string `json:"med_type"`
  23874. PsnPay float64 `json:"psn_pay"`
  23875. OpterID string `json:"opter_id"`
  23876. Begndate string `json:"begndate"`
  23877. FlxempeFlag string `json:"flxempe_flag"`
  23878. HifmiPay float64 `json:"hifmi_pay"`
  23879. PsnNo string `json:"psn_no"`
  23880. ActPayDedc float64 `json:"act_pay_dedc"`
  23881. MedinsSetlID interface{} `json:"medins_setl_id"`
  23882. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23883. ClrWay string `json:"clr_way"`
  23884. OthPay float64 `json:"oth_pay"`
  23885. Gend string `json:"gend"`
  23886. MdtrtID string `json:"mdtrt_id"`
  23887. AcctPay float64 `json:"acct_pay"`
  23888. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23889. Insutype string `json:"insutype"`
  23890. Invono interface{} `json:"invono"`
  23891. Enddate string `json:"enddate"`
  23892. CashPayamt float64 `json:"cash_payamt"`
  23893. PsnType string `json:"psn_type"`
  23894. FixmedinsName string `json:"fixmedins_name"`
  23895. HifpPay float64 `json:"hifp_pay"`
  23896. NewFlag interface{} `json:"new_flag"`
  23897. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23898. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23899. PayLoc string `json:"pay_loc"`
  23900. ClrType string `json:"clr_type"`
  23901. RefdSetlFlag string `json:"refd_setl_flag"`
  23902. CvlservFlag string `json:"cvlserv_flag"`
  23903. EmpName string `json:"emp_name"`
  23904. Brdy string `json:"brdy"`
  23905. Naty string `json:"naty"`
  23906. Certno string `json:"certno"`
  23907. DiseCode string `json:"dise_code"`
  23908. FixmedinsCode string `json:"fixmedins_code"`
  23909. DedcHospLv string `json:"dedc_hosp_lv"`
  23910. OpterName string `json:"opter_name"`
  23911. Balc float64 `json:"balc"`
  23912. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23913. PsnCertType string `json:"psn_cert_type"`
  23914. HifobPay float64 `json:"hifob_pay"`
  23915. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23916. HifesPay float64 `json:"hifes_pay"`
  23917. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23918. OptTime string `json:"opt_time"`
  23919. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23920. SetlID string `json:"setl_id"`
  23921. MafPay float64 `json:"maf_pay"`
  23922. PsnName string `json:"psn_name"`
  23923. InsuOptins interface{} `json:"insu_optins"`
  23924. PrefFundPay interface{} `json:"pref_fund_pay"`
  23925. ClrOptins string `json:"clr_optins"`
  23926. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23927. DiseName string `json:"dise_name"`
  23928. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23929. Age float64 `json:"age"`
  23930. DtrtCertType string `json:"dtrt_cert_type"`
  23931. HospLv string `json:"hosp_lv"`
  23932. PsnCashPay float64 `json:"psn_cash_pay"`
  23933. } `json:"setlinfo"`
  23934. } `json:"output"`
  23935. RefmsgTime string `json:"refmsg_time"`
  23936. RespondTime string `json:"respond_time"`
  23937. Signtype interface{} `json:"signtype"`
  23938. WarnMsg interface{} `json:"warn_msg"`
  23939. }
  23940. type ResultElevenah struct {
  23941. Cainfo string `json:"cainfo"`
  23942. ErrMsg string `json:"err_msg"`
  23943. InfRefmsgid string `json:"inf_refmsgid"`
  23944. Infcode int64 `json:"infcode"`
  23945. Output struct {
  23946. Setlinfo struct {
  23947. SetlTime int64 `json:"setl_time"`
  23948. CvlservPay float64 `json:"cvlserv_pay"`
  23949. Year string `json:"year"`
  23950. MedType string `json:"med_type"`
  23951. PsnPay float64 `json:"psn_pay"`
  23952. OpterID string `json:"opter_id"`
  23953. Begndate int64 `json:"begndate"`
  23954. FlxempeFlag string `json:"flxempe_flag"`
  23955. HifmiPay float64 `json:"hifmi_pay"`
  23956. PsnNo string `json:"psn_no"`
  23957. ActPayDedc float64 `json:"act_pay_dedc"`
  23958. MedinsSetlID interface{} `json:"medins_setl_id"`
  23959. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23960. ClrWay string `json:"clr_way"`
  23961. OthPay float64 `json:"oth_pay"`
  23962. Gend string `json:"gend"`
  23963. MdtrtID string `json:"mdtrt_id"`
  23964. AcctPay float64 `json:"acct_pay"`
  23965. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23966. Insutype string `json:"insutype"`
  23967. Invono interface{} `json:"invono"`
  23968. Enddate int64 `json:"enddate"`
  23969. CashPayamt float64 `json:"cash_payamt"`
  23970. PsnType string `json:"psn_type"`
  23971. FixmedinsName string `json:"fixmedins_name"`
  23972. HifpPay float64 `json:"hifp_pay"`
  23973. NewFlag interface{} `json:"new_flag"`
  23974. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23975. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23976. PayLoc string `json:"pay_loc"`
  23977. ClrType string `json:"clr_type"`
  23978. RefdSetlFlag string `json:"refd_setl_flag"`
  23979. CvlservFlag string `json:"cvlserv_flag"`
  23980. EmpName string `json:"emp_name"`
  23981. Brdy int64 `json:"brdy"`
  23982. Naty string `json:"naty"`
  23983. Certno string `json:"certno"`
  23984. DiseCode string `json:"dise_code"`
  23985. FixmedinsCode string `json:"fixmedins_code"`
  23986. DedcHospLv string `json:"dedc_hosp_lv"`
  23987. OpterName string `json:"opter_name"`
  23988. Balc float64 `json:"balc"`
  23989. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23990. PsnCertType string `json:"psn_cert_type"`
  23991. HifobPay float64 `json:"hifob_pay"`
  23992. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23993. HifesPay float64 `json:"hifes_pay"`
  23994. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23995. OptTime int64 `json:"opt_time"`
  23996. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23997. SetlID string `json:"setl_id"`
  23998. MafPay float64 `json:"maf_pay"`
  23999. PsnName string `json:"psn_name"`
  24000. InsuOptins interface{} `json:"insu_optins"`
  24001. PrefFundPay interface{} `json:"pref_fund_pay"`
  24002. ClrOptins string `json:"clr_optins"`
  24003. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  24004. DiseName string `json:"dise_name"`
  24005. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  24006. Age float64 `json:"age"`
  24007. DtrtCertType string `json:"dtrt_cert_type"`
  24008. HospLv string `json:"hosp_lv"`
  24009. PsnCashPay float64 `json:"psn_cash_pay"`
  24010. } `json:"setlinfo"`
  24011. } `json:"output"`
  24012. RefmsgTime string `json:"refmsg_time"`
  24013. RespondTime string `json:"respond_time"`
  24014. Signtype interface{} `json:"signtype"`
  24015. WarnMsg interface{} `json:"warn_msg"`
  24016. }
  24017. type ResultEleven10265 struct {
  24018. Cainfo string `json:"cainfo"`
  24019. ErrMsg string `json:"err_msg"`
  24020. InfRefmsgid string `json:"inf_refmsgid"`
  24021. Infcode string `json:"infcode"`
  24022. Output struct {
  24023. Setlinfo struct {
  24024. SetlTime string `json:"setl_time"`
  24025. CvlservPay float64 `json:"cvlserv_pay"`
  24026. Year string `json:"year"`
  24027. MedType string `json:"med_type"`
  24028. PsnPay float64 `json:"psn_pay"`
  24029. OpterID string `json:"opter_id"`
  24030. Begndate string `json:"begndate"`
  24031. FlxempeFlag string `json:"flxempe_flag"`
  24032. HifmiPay float64 `json:"hifmi_pay"`
  24033. PsnNo string `json:"psn_no"`
  24034. ActPayDedc float64 `json:"act_pay_dedc"`
  24035. MedinsSetlID interface{} `json:"medins_setl_id"`
  24036. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  24037. ClrWay string `json:"clr_way"`
  24038. OthPay float64 `json:"oth_pay"`
  24039. Gend string `json:"gend"`
  24040. MdtrtID string `json:"mdtrt_id"`
  24041. AcctPay float64 `json:"acct_pay"`
  24042. InscpScpAmt float64 `json:"inscp_scp_amt"`
  24043. Insutype string `json:"insutype"`
  24044. Invono interface{} `json:"invono"`
  24045. Enddate string `json:"enddate"`
  24046. CashPayamt float64 `json:"cash_payamt"`
  24047. PsnType string `json:"psn_type"`
  24048. FixmedinsName string `json:"fixmedins_name"`
  24049. HifpPay float64 `json:"hifp_pay"`
  24050. NewFlag interface{} `json:"new_flag"`
  24051. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  24052. PreselfpayAmt float64 `json:"preselfpay_amt"`
  24053. PayLoc string `json:"pay_loc"`
  24054. ClrType string `json:"clr_type"`
  24055. RefdSetlFlag string `json:"refd_setl_flag"`
  24056. CvlservFlag string `json:"cvlserv_flag"`
  24057. EmpName string `json:"emp_name"`
  24058. Brdy string `json:"brdy"`
  24059. Naty string `json:"naty"`
  24060. Certno string `json:"certno"`
  24061. DiseCode string `json:"dise_code"`
  24062. FixmedinsCode string `json:"fixmedins_code"`
  24063. DedcHospLv string `json:"dedc_hosp_lv"`
  24064. OpterName string `json:"opter_name"`
  24065. Balc float64 `json:"balc"`
  24066. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  24067. PsnCertType string `json:"psn_cert_type"`
  24068. HifobPay float64 `json:"hifob_pay"`
  24069. MedfeeSumamt float64 `json:"medfee_sumamt"`
  24070. HifesPay float64 `json:"hifes_pay"`
  24071. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24072. OptTime string `json:"opt_time"`
  24073. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  24074. SetlID string `json:"setl_id"`
  24075. MafPay float64 `json:"maf_pay"`
  24076. PsnName string `json:"psn_name"`
  24077. InsuOptins interface{} `json:"insu_optins"`
  24078. PrefFundPay interface{} `json:"pref_fund_pay"`
  24079. ClrOptins string `json:"clr_optins"`
  24080. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  24081. DiseName string `json:"dise_name"`
  24082. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  24083. Age float64 `json:"age"`
  24084. DtrtCertType string `json:"dtrt_cert_type"`
  24085. HospLv string `json:"hosp_lv"`
  24086. PsnCashPay float64 `json:"psn_cash_pay"`
  24087. } `json:"setlinfo"`
  24088. } `json:"output"`
  24089. RefmsgTime string `json:"refmsg_time"`
  24090. RespondTime string `json:"respond_time"`
  24091. Signtype interface{} `json:"signtype"`
  24092. WarnMsg interface{} `json:"warn_msg"`
  24093. }
  24094. type ResultTwelve struct {
  24095. Cainfo string `json:"cainfo"`
  24096. ErrMsg string `json:"err_msg"`
  24097. InfRefmsgid string `json:"inf_refmsgid"`
  24098. Infcode int64 `json:"infcode"`
  24099. Output struct {
  24100. MdtrtId string `json:"mdtrt_id"`
  24101. ChrgBchno string `json:"chrg_bchno"`
  24102. PsnNo string `json:"psn_no"`
  24103. } `json:"output"`
  24104. RefmsgTime string `json:"refmsg_time"`
  24105. RespondTime string `json:"respond_time"`
  24106. Signtype interface{} `json:"signtype"`
  24107. WarnMsg interface{} `json:"warn_msg"`
  24108. }
  24109. type ResultThirteen struct {
  24110. ErrMsg string `json:"err_msg"`
  24111. InfRefmsgid string `json:"inf_refmsgid"`
  24112. Infcode int64 `json:"infcode"`
  24113. Output struct {
  24114. Result struct {
  24115. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  24116. } `json:"result"`
  24117. } `json:"output"`
  24118. RefmsgTime string `json:"refmsg_time"`
  24119. RespondTime string `json:"respond_time"`
  24120. Signtype interface{} `json:"signtype"`
  24121. WarnInfo interface{} `json:"warn_info"`
  24122. }
  24123. type ResultThirteen10265 struct {
  24124. ErrMsg string `json:"err_msg"`
  24125. InfRefmsgid string `json:"inf_refmsgid"`
  24126. Infcode string `json:"infcode"`
  24127. Output struct {
  24128. Result struct {
  24129. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  24130. } `json:"result"`
  24131. } `json:"output"`
  24132. RefmsgTime string `json:"refmsg_time"`
  24133. RespondTime string `json:"respond_time"`
  24134. Signtype interface{} `json:"signtype"`
  24135. WarnInfo interface{} `json:"warn_info"`
  24136. }
  24137. type ResultFourteen struct {
  24138. ErrMsg string `json:"err_msg"`
  24139. InfRefmsgid string `json:"inf_refmsgid"`
  24140. Infcode int64 `json:"infcode"`
  24141. Output struct {
  24142. } `json:"output"`
  24143. RefmsgTime string `json:"refmsg_time"`
  24144. RespondTime string `json:"respond_time"`
  24145. Signtype interface{} `json:"signtype"`
  24146. WarnInfo interface{} `json:"warn_info"`
  24147. }
  24148. type ResultCFYLJG001 struct {
  24149. ErrMsg string `json:"err_msg"`
  24150. InfRefmsgid string `json:"inf_refmsgid"`
  24151. Infcode int64 `json:"infcode"`
  24152. Output struct {
  24153. RxTraceCode string `json:"rx_trace_code"`
  24154. HiRxno string `json:"hi_rxno"`
  24155. } `json:"output"`
  24156. RefmsgTime string `json:"refmsg_time"`
  24157. RespondTime string `json:"respond_time"`
  24158. Signtype interface{} `json:"signtype"`
  24159. WarnInfo interface{} `json:"warn_info"`
  24160. }
  24161. type ResultCFYLJG001AH struct {
  24162. RxTraceCode string `json:"rxTraceCode"`
  24163. HiRxno string `json:"hiRxno"`
  24164. }
  24165. type ResultCFYLJG007 struct {
  24166. ErrMsg string `json:"err_msg"`
  24167. InfRefmsgid string `json:"inf_refmsgid"`
  24168. Infcode int64 `json:"infcode"`
  24169. Output struct {
  24170. HiRxno string `json:"hi_rxno"`
  24171. RxStasName string `json:"rx_stas_name"`
  24172. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  24173. Seltdelts []interface{} `json:"seltdelts"`
  24174. RxUsedStasName string `json:"rx_used_stas_name"`
  24175. RxStasCodg string `json:"rx_stas_codg"`
  24176. } `json:"output"`
  24177. RefmsgTime string `json:"refmsg_time"`
  24178. RespondTime string `json:"respond_time"`
  24179. Signtype interface{} `json:"signtype"`
  24180. WarnInfo interface{} `json:"warn_info"`
  24181. }
  24182. type ResultCFYLJG002 struct {
  24183. ErrMsg string `json:"err_msg"`
  24184. InfRefmsgid string `json:"inf_refmsgid"`
  24185. Infcode int64 `json:"infcode"`
  24186. Output struct {
  24187. RxFile string `json:"rx_file"`
  24188. SignDigest string `json:"sign_digest"`
  24189. SignCertSn string `json:"sign_cert_sn"`
  24190. SignCertDn string `json:"sign_cert_dn"`
  24191. } `json:"output"`
  24192. RefmsgTime string `json:"refmsg_time"`
  24193. RespondTime string `json:"respond_time"`
  24194. Signtype interface{} `json:"signtype"`
  24195. WarnInfo interface{} `json:"warn_info"`
  24196. }
  24197. type ResultCFYLJG003 struct {
  24198. ErrMsg string `json:"err_msg"`
  24199. InfRefmsgid string `json:"inf_refmsgid"`
  24200. Infcode int64 `json:"infcode"`
  24201. Output struct {
  24202. HiRxno string `json:"hi_rxno"`
  24203. RxStasCodg string `json:"rx_stas_codg"`
  24204. RxStasName string `json:"rx_stas_name"`
  24205. } `json:"output"`
  24206. RefmsgTime string `json:"refmsg_time"`
  24207. RespondTime string `json:"respond_time"`
  24208. Signtype interface{} `json:"signtype"`
  24209. WarnInfo interface{} `json:"warn_info"`
  24210. }
  24211. type ResultCFYLJG004 struct {
  24212. ErrMsg string `json:"err_msg"`
  24213. InfRefmsgid string `json:"inf_refmsgid"`
  24214. Infcode int64 `json:"infcode"`
  24215. Output struct {
  24216. HiRxno string `json:"hi_rxno"`
  24217. RxStasCodg string `json:"rx_stas_codg"`
  24218. RxStasName string `json:"rx_stas_name"`
  24219. } `json:"output"`
  24220. RefmsgTime string `json:"refmsg_time"`
  24221. RespondTime string `json:"respond_time"`
  24222. Signtype interface{} `json:"signtype"`
  24223. WarnInfo interface{} `json:"warn_info"`
  24224. }
  24225. type ResultCFYLJG008 struct {
  24226. ErrMsg string `json:"err_msg"`
  24227. InfRefmsgid string `json:"inf_refmsgid"`
  24228. Infcode int64 `json:"infcode"`
  24229. Output struct {
  24230. PoolareaNo string `json:"poolareaNo"`
  24231. AdmdvsName string `json:"admdvsName"`
  24232. Count string `json:"count"`
  24233. } `json:"output"`
  24234. RefmsgTime string `json:"refmsg_time"`
  24235. RespondTime string `json:"respond_time"`
  24236. Signtype interface{} `json:"signtype"`
  24237. WarnInfo interface{} `json:"warn_info"`
  24238. }
  24239. type ResultCFYLJG005 struct {
  24240. ErrMsg string `json:"err_msg"`
  24241. InfRefmsgid string `json:"inf_refmsgid"`
  24242. Infcode int64 `json:"infcode"`
  24243. Output struct {
  24244. HiRxNo string `json:"hi_rxno"`
  24245. FixMedinsCode string `json:"fixmedins_code"`
  24246. FixMedinsName string `json:"fixmedins_name"`
  24247. RxStasCodg string `json:"rx_stas_codg"`
  24248. RxStasName string `json:"rx_stas_name"`
  24249. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  24250. RxUserdStasName string `json:"rx_userd_stas_name"`
  24251. PrscTime string `json:"prsc_time"`
  24252. RxDrugCnt float64 `json:"rx_drug_cnt"`
  24253. RxUsedWayCodg string `json:"rx_used_way_codg"`
  24254. RxUsedWayName string `json:"rx_used_way_name"`
  24255. RxFrquCodg string `json:"rx_frqu_codg"`
  24256. RxFrquName string `json:"rx_frqu_name"`
  24257. RxDosunt string `json:"rx_dosunt"`
  24258. RxDoscnt float64 `json:"rx_doscnt"`
  24259. RxDrordDscr string `json:"rx_drord_dscr"`
  24260. ValiDays int64 `json:"vali_days"`
  24261. ValiEndTime string `json:"vali_end_time"`
  24262. ReptFlag string `json:"rept_flag"`
  24263. MaxReptCnt int64 `json:"max_rept_cnt"`
  24264. ReptdCnt int64 `json:"reptd_cnt"`
  24265. MinInrvDays int64 `json:"min_inrv_days"`
  24266. RxTypeCode string `json:"rx_type_code"`
  24267. RxTypeName string `json:"rx_type_name"`
  24268. LongRxFlag string `json:"long_rx_flag"`
  24269. RxDetlList []struct {
  24270. MedListCodg string `json:"med_list_codg"`
  24271. MedinsListCodg string `json:"medins_list_codg"`
  24272. HospPrepFlag string `json:"hosp_prep_flag"`
  24273. RxItemTypeCode string `json:"rx_item_type_code"`
  24274. RxItemTypeName string `json:"rx_item_type_name"`
  24275. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  24276. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  24277. TcmHerbFoote string `json:"tcmherb_foote"`
  24278. MednTypeCode string `json:"medn_type_code"`
  24279. MednTypeName string `json:"medn_type_name"`
  24280. MainMedcFlag string `json:"main_medc_flag"`
  24281. UrgtFlag string `json:"urgt_flag"`
  24282. BasMednFlag string `json:"bas_medn_flag"`
  24283. ImpDrugFlag string `json:"imp_drug_flag"`
  24284. ProdBarc string `json:"prod_barc"`
  24285. DrugProdname string `json:"drug_prodname"`
  24286. GennameCodg string `json:"genname_codg"`
  24287. DrugGenname string `json:"drug_genname"`
  24288. DrugDosform string `json:"drug_dosform"`
  24289. DrugSpec string `json:"drug_spec"`
  24290. PrdrName string `json:"prdr_name"`
  24291. MedcWayCodg string `json:"medc_way_codg"`
  24292. MedcWayDscr string `json:"medc_way_dscr"`
  24293. MedcBegntime string `json:"medc_begntime"`
  24294. MedcEndtime string `json:"medc_endtime"`
  24295. MedcDays float64 `json:"medc_days"`
  24296. DrugPric float64 `json:"drug_pric"`
  24297. DrugSumamt float64 `json:"drug_sumamt"`
  24298. DrugCnt float64 `json:"drug_cnt"`
  24299. DrugDosunt string `json:"drug_dosunt"`
  24300. SinDoscnt float64 `json:"sin_doscnt"`
  24301. SinDosunt string `json:"sin_dosunt"`
  24302. UsedFrquCodg string `json:"used_frqu_codg"`
  24303. UsedFrquName string `json:"used_frqu_name"`
  24304. DrugTotlcnt string `json:"drug_totlcnt"`
  24305. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  24306. DiseCodg string `json:"dise_codg"`
  24307. HospApprFlag string `json:"hosp_appr_flag"`
  24308. } `json:"rx_detl_list"`
  24309. RxOtpinfo struct {
  24310. MedType string `json:"med_type"`
  24311. IptOtpNo string `json:"ipt_otp_no"`
  24312. OtpIptFlag string `json:"otp_ipt_flag"`
  24313. PatnName string `json:"patn_name"`
  24314. PatnAge float64 `json:"patn_age"`
  24315. PatnHgt float64 `json:"patn_hgt"`
  24316. PatnWt float64 `json:"patn_wt"`
  24317. Gend string `json:"gend"`
  24318. GesoVal float64 `json:"geso_val"`
  24319. NwbFlag string `json:"nwb_flag"`
  24320. NwbAge string `json:"nwb_age"`
  24321. SuckPrdFlag string `json:"suck_prd_flag"`
  24322. AlgsHis string `json:"algs_his"`
  24323. Insutype string `json:"insutype"`
  24324. PrscDeptName string `json:"prsc_dept_name"`
  24325. PrscDrName string `json:"prsc_dr_name"`
  24326. PharName string `json:"phar_name"`
  24327. PharChkTime string `json:"phar_chk_time"`
  24328. MdtrtTime string `json:"mdtrt_time"`
  24329. DiseCodg string `json:"dise_codg"`
  24330. DiseName string `json:"dise_name"`
  24331. SpDiseFlag string `json:"sp_dise_flag"`
  24332. MaindiagCode string `json:"maindiag_code"`
  24333. MaindiagName string `json:"maindiag_name"`
  24334. DiseCondDscr string `json:"dise_cond_dscr"`
  24335. FstdiagFlag string `json:"fstdiag_flag"`
  24336. } `json:"rx_otpinfo"`
  24337. RxDiseList []struct {
  24338. DiagType string `json:"diag_type"`
  24339. MaindiagFlag string `json:"maindiag_flag"`
  24340. DiagSrtNo string `json:"diag_srt_no"`
  24341. DiagCode string `json:"diag_code"`
  24342. DiagName string `json:"diag_name"`
  24343. DiagDept string `json:"diag_dept"`
  24344. DiagDrNo string `json:"diag_dr_no"`
  24345. DiagDrName string `json:"diag_dr_name"`
  24346. DiagTime string `json:"diag_time"`
  24347. TcmDiseCode string `json:"tcm_dise_code"`
  24348. TcmDiseName string `json:"tcm_dise_name"`
  24349. TcmSympCode string `json:"tcmsymp_code"`
  24350. TcmSymp string `json:"tcmsymp"`
  24351. } `json:"rx_dise_list"`
  24352. } `json:"output"`
  24353. RefmsgTime string `json:"refmsg_time"`
  24354. RespondTime string `json:"respond_time"`
  24355. Signtype interface{} `json:"signtype"`
  24356. WarnInfo interface{} `json:"warn_info"`
  24357. }
  24358. type ResultCFYLJG006 struct {
  24359. ErrMsg string `json:"err_msg"`
  24360. InfRefmsgid string `json:"inf_refmsgid"`
  24361. Infcode int64 `json:"infcode"`
  24362. Output struct {
  24363. HiRxNo string `json:"hi_rxno"`
  24364. PharCode string `json:"phar_code"`
  24365. PharName string `json:"phar_name"`
  24366. RxChkOpnn string `json:"rx_chk_opnn"`
  24367. RxChkTime string `json:"rx_chk_time"`
  24368. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  24369. RxChkStasName string `json:"rx_chk_stas_name"`
  24370. RxStasCodg string `json:"rx_stas_codg"`
  24371. RxStasName string `json:"rx_stas_name"`
  24372. } `json:"output"`
  24373. RefmsgTime string `json:"refmsg_time"`
  24374. RespondTime string `json:"respond_time"`
  24375. Signtype interface{} `json:"signtype"`
  24376. WarnInfo interface{} `json:"warn_info"`
  24377. }
  24378. type ResultFourteen10265 struct {
  24379. ErrMsg string `json:"err_msg"`
  24380. InfRefmsgid string `json:"inf_refmsgid"`
  24381. Infcode string `json:"infcode"`
  24382. Output struct {
  24383. } `json:"output"`
  24384. RefmsgTime string `json:"refmsg_time"`
  24385. RespondTime string `json:"respond_time"`
  24386. Signtype interface{} `json:"signtype"`
  24387. WarnInfo interface{} `json:"warn_info"`
  24388. }
  24389. type ResultSixteen struct {
  24390. Cainfo string `json:"cainfo"`
  24391. ErrMsg string `json:"err_msg"`
  24392. InfRefmsgid string `json:"inf_refmsgid"`
  24393. Infcode int64 `json:"infcode"`
  24394. Output struct {
  24395. Setlinfo struct {
  24396. MdtrtID string `json:"mdtrt_id"`
  24397. SetlID string `json:"setl_id"`
  24398. ClrOptins string `json:"clr_optins"`
  24399. SetlTime string `json:"setl_time"`
  24400. MedfeeSumamt float64 `json:"medfee_sumamt"`
  24401. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  24402. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  24403. PreselfpayAmt float64 `json:"preselfpay_amt"`
  24404. InscpScpAmt float64 `json:"inscp_scp_amt"`
  24405. ActPayDedc float64 `json:"act_pay_dedc"`
  24406. HifpPay float64 `json:"hifp_pay"`
  24407. PoolPropSe float64 `json:"pool_prop_selfpay"`
  24408. Lfpay float64 `json:"selfpay"`
  24409. CvlservPay float64 `json:"cvlserv_pay"`
  24410. HifesPay float64 `json:"hifes_pay"`
  24411. HifmiPay float64 `json:"hifmi_pay"`
  24412. HifobPay float64 `json:"hifob_pay"`
  24413. MafPay float64 `json:"maf_pay"`
  24414. OthPay float64 `json:"oth_pay"`
  24415. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24416. PsnPartAmt float64 `json:"psn_part_amt"`
  24417. AcctPay float64 `json:"acct_pay"`
  24418. Balc float64 `json:"balc"`
  24419. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  24420. HospPartAmt float64 `json:"hosp_part_amt"`
  24421. MedinsSetlID string `json:"medins_setl_id"`
  24422. PdnCashPay string `json:"pdn_cash_pay"`
  24423. } `json:"setlinfo"`
  24424. } `json:"output"`
  24425. RefmsgTime string `json:"refmsg_time"`
  24426. RespondTime string `json:"respond_time"`
  24427. Signtype interface{} `json:"signtype"`
  24428. WarnMsg interface{} `json:"warn_msg"`
  24429. }
  24430. type ResultSixteen10265 struct {
  24431. Cainfo string `json:"cainfo"`
  24432. ErrMsg string `json:"err_msg"`
  24433. InfRefmsgid string `json:"inf_refmsgid"`
  24434. Infcode string `json:"infcode"`
  24435. Output struct {
  24436. Setlinfo struct {
  24437. MdtrtID string `json:"mdtrt_id"`
  24438. SetlID string `json:"setl_id"`
  24439. ClrOptins string `json:"clr_optins"`
  24440. SetlTime string `json:"setl_time"`
  24441. MedfeeSumamt float64 `json:"medfee_sumamt"`
  24442. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  24443. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  24444. PreselfpayAmt float64 `json:"preselfpay_amt"`
  24445. InscpScpAmt float64 `json:"inscp_scp_amt"`
  24446. ActPayDedc float64 `json:"act_pay_dedc"`
  24447. HifpPay float64 `json:"hifp_pay"`
  24448. PoolPropSe float64 `json:"pool_prop_selfpay"`
  24449. Lfpay float64 `json:"selfpay"`
  24450. CvlservPay float64 `json:"cvlserv_pay"`
  24451. HifesPay float64 `json:"hifes_pay"`
  24452. HifmiPay float64 `json:"hifmi_pay"`
  24453. HifobPay float64 `json:"hifob_pay"`
  24454. MafPay float64 `json:"maf_pay"`
  24455. OthPay float64 `json:"oth_pay"`
  24456. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24457. PsnPartAmt float64 `json:"psn_part_amt"`
  24458. AcctPay float64 `json:"acct_pay"`
  24459. Balc float64 `json:"balc"`
  24460. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  24461. HospPartAmt float64 `json:"hosp_part_amt"`
  24462. MedinsSetlID string `json:"medins_setl_id"`
  24463. PdnCashPay string `json:"pdn_cash_pay"`
  24464. } `json:"setlinfo"`
  24465. } `json:"output"`
  24466. RefmsgTime string `json:"refmsg_time"`
  24467. RespondTime string `json:"respond_time"`
  24468. Signtype interface{} `json:"signtype"`
  24469. WarnMsg interface{} `json:"warn_msg"`
  24470. }
  24471. type ResultSixteen10265Two struct {
  24472. Cainfo string `json:"cainfo"`
  24473. ErrMsg string `json:"err_msg"`
  24474. InfRefmsgid string `json:"inf_refmsgid"`
  24475. Infcode string `json:"infcode"`
  24476. Output struct {
  24477. Setlinfo interface{} `json:"setlinfo"`
  24478. } `json:"output"`
  24479. RefmsgTime string `json:"refmsg_time"`
  24480. RespondTime string `json:"respond_time"`
  24481. Signtype interface{} `json:"signtype"`
  24482. WarnMsg interface{} `json:"warn_msg"`
  24483. }
  24484. type ResultgzSixteen10265Two struct {
  24485. Cainfo string `json:"cainfo"`
  24486. ErrMsg string `json:"err_msg"`
  24487. InfRefmsgid string `json:"inf_refmsgid"`
  24488. Infcode int64 `json:"infcode"`
  24489. Output struct {
  24490. Setlinfo interface{} `json:"setlinfo"`
  24491. } `json:"output"`
  24492. RefmsgTime string `json:"refmsg_time"`
  24493. RespondTime string `json:"respond_time"`
  24494. Signtype interface{} `json:"signtype"`
  24495. WarnMsg interface{} `json:"warn_msg"`
  24496. }
  24497. type ResultSeventeen struct {
  24498. ErrMsg string `json:"err_msg"`
  24499. InfRefmsgid string `json:"inf_refmsgid"`
  24500. Infcode int64 `json:"infcode"`
  24501. Output struct {
  24502. SetlListId string `json:"setl_list_id"`
  24503. } `json:"output"`
  24504. RefmsgTime string `json:"refmsg_time"`
  24505. RespondTime string `json:"respond_time"`
  24506. Signtype string `json:"signtype"`
  24507. WarnInfo string `json:"warn_info"`
  24508. }
  24509. type ResultSeventeenOther struct {
  24510. ErrMsg string `json:"err_msg"`
  24511. InfRefmsgid string `json:"inf_refmsgid"`
  24512. Infcode string `json:"infcode"`
  24513. Output struct {
  24514. SetlListId string `json:"setl_list_id"`
  24515. } `json:"output"`
  24516. RefmsgTime string `json:"refmsg_time"`
  24517. RespondTime string `json:"respond_time"`
  24518. Signtype string `json:"signtype"`
  24519. WarnInfo string `json:"warn_info"`
  24520. }
  24521. type Result90991 struct {
  24522. ErrMsg string `json:"err_msg"`
  24523. InfRefmsgid string `json:"inf_refmsgid"`
  24524. Infcode int64 `json:"infcode"`
  24525. Output struct {
  24526. Result struct {
  24527. PsnNo string `json:"psn_no"`
  24528. CardStat string `json:"card_stat"`
  24529. Certno string `json:"certno"`
  24530. PsnName string `json:"psn_name"`
  24531. CheckStat string `json:"check_stat"`
  24532. SscnoCheckStat string `json:"sscno_check_stat"`
  24533. } `json:"result"`
  24534. } `json:"output"`
  24535. RefmsgTime string `json:"refmsg_time"`
  24536. RespondTime string `json:"respond_time"`
  24537. Signtype interface{} `json:"signtype"`
  24538. WarnInfo interface{} `json:"warn_info"`
  24539. }
  24540. type Result90100 struct {
  24541. ErrMsg string `json:"err_msg"`
  24542. InfRefmsgid string `json:"inf_refmsgid"`
  24543. Infcode int64 `json:"infcode"`
  24544. Output struct {
  24545. PoolareaNo string `json:"poolarea_no"`
  24546. PoolareaNoName string `json:"poolarea_no_name"`
  24547. Insutype string `json:"insutype"`
  24548. InsutypeName string `json:"insutype_name"`
  24549. ClctType string `json:"clct_type"`
  24550. ClctTypeName string `json:"clct_type_name"`
  24551. ClctFlag string `json:"clct_flag"`
  24552. ClctFlagName string `json:"clct_flag_name"`
  24553. AccrymBegn string `json:"accrym_begn"`
  24554. AccrymEnd string `json:"accrym_end"`
  24555. ClctTime string `json:"clct_time"`
  24556. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  24557. } `json:"output"`
  24558. RefmsgTime string `json:"refmsg_time"`
  24559. RespondTime string `json:"respond_time"`
  24560. Signtype interface{} `json:"signtype"`
  24561. WarnInfo interface{} `json:"warn_info"`
  24562. }
  24563. type Custom struct {
  24564. DetItemFeeSumamt string
  24565. Cut string
  24566. FeedetlSn string
  24567. Price string
  24568. MedListCodg string
  24569. Type int64
  24570. AdviceId int64
  24571. ProjectId int64
  24572. ItemId int64
  24573. }
  24574. type Result5301 struct {
  24575. ErrMsg string `json:"err_msg"`
  24576. InfRefmsgid string `json:"inf_refmsgid"`
  24577. Infcode int64 `json:"infcode"`
  24578. Output struct {
  24579. Result []struct {
  24580. OpspDiseCode string `json:"opsp_dise_code"`
  24581. OpspDiseName string `json:"opsp_dise_name"`
  24582. Begndate string `json:"begndate"`
  24583. Enddate string `json:"enddate"`
  24584. } `json:"feedetail"`
  24585. } `json:"output"`
  24586. RefmsgTime string `json:"refmsg_time"`
  24587. RespondTime string `json:"respond_time"`
  24588. Signtype interface{} `json:"signtype"`
  24589. WarnInfo interface{} `json:"warn_info"`
  24590. }
  24591. type Result5301For10265 struct {
  24592. ErrMsg string `json:"err_msg"`
  24593. InfRefmsgid string `json:"inf_refmsgid"`
  24594. Infcode string `json:"infcode"`
  24595. Output struct {
  24596. Result []struct {
  24597. OpspDiseCode string `json:"opsp_dise_code"`
  24598. OpspDiseName string `json:"opsp_dise_name"`
  24599. Begndate string `json:"begndate"`
  24600. Enddate string `json:"enddate"`
  24601. } `json:"feedetail"`
  24602. } `json:"output"`
  24603. RefmsgTime string `json:"refmsg_time"`
  24604. RespondTime string `json:"respond_time"`
  24605. Signtype interface{} `json:"signtype"`
  24606. WarnInfo interface{} `json:"warn_info"`
  24607. }
  24608. //获取个人信息----挂号-----上传就诊信息
  24609. func (c *HisApiController) GetRegisterInfo() {
  24610. id, _ := c.GetInt64("id")
  24611. record_time := c.GetString("record_time")
  24612. settlementValue, _ := c.GetInt64("settlement_value")
  24613. medical_insurance_card := c.GetString("medical_insurance_card")
  24614. name := c.GetString("name")
  24615. id_card_type, _ := c.GetInt64("id_card_type")
  24616. certificates, _ := c.GetInt64("certificates")
  24617. medical_care, _ := c.GetInt64("medical_care")
  24618. birthday := c.GetString("birthday")
  24619. id_card := c.GetString("id_card")
  24620. register_type, _ := c.GetInt64("register")
  24621. doctor, _ := c.GetInt64("doctor")
  24622. department, _ := c.GetInt64("department")
  24623. gender, _ := c.GetInt64("sex")
  24624. registration_fee, _ := c.GetFloat("registration_fee")
  24625. medical_expenses, _ := c.GetFloat("medical_expenses")
  24626. social_type, _ := c.GetInt64("social_type")
  24627. admin_user_id, _ := c.GetInt64("admin_user_id")
  24628. insuplc_admdvs := c.GetString("insuplc_admdvs")
  24629. insuplc_admdvs_tt := c.GetString("insuplc_admdvs")
  24630. mdtrt_type := c.GetString("mdtrt_type")
  24631. if id_card_type == 5 {
  24632. id_card_type = 4
  24633. }
  24634. timeLayout := "2006-01-02"
  24635. loc, _ := time.LoadLocation("Local")
  24636. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  24637. birthUnix := birthdays.Unix()
  24638. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24639. if err != nil {
  24640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24641. return
  24642. }
  24643. recordDateTime := theTime.Unix()
  24644. adminInfo := c.GetAdminUserInfo()
  24645. var patient service.Patients
  24646. if id == 0 {
  24647. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  24648. } else {
  24649. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  24650. }
  24651. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  24652. if patientPrescription.ID == 0 {
  24653. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  24654. }
  24655. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  24656. if patient.ID == 0 {
  24657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  24658. return
  24659. }
  24660. if len(patient.IdCardNo) == 0 {
  24661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  24662. return
  24663. }
  24664. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  24665. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  24666. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  24667. //就诊结算未完成,不能进行二次挂号
  24668. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  24669. if len(his) >= 1 {
  24670. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  24671. if len(his) >= 1 && order.ID == 0 {
  24672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  24673. return
  24674. }
  24675. }
  24676. var aaaa string
  24677. //var register_log string
  24678. if config.IsOpen == 1 {
  24679. var res ResultTwo
  24680. var res10265 ResultTwo10265
  24681. var PsnNo string
  24682. var PsnCertType string
  24683. var Certno string
  24684. var PsnName string
  24685. var Gend string
  24686. var Naty string
  24687. var Brdy string
  24688. var Age float64
  24689. var infoStr string
  24690. var idetinfoStr string
  24691. var infocode int64
  24692. var verify_number string
  24693. fmt.Println(verify_number)
  24694. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  24695. psn_info, _ := service.GetPsnByPatientId(id)
  24696. PsnNo = psn_info.PsnNo
  24697. PsnCertType = psn_info.PsnCertType
  24698. Certno = psn_info.Certno
  24699. PsnName = psn_info.PsnName
  24700. Gend = psn_info.Gend
  24701. Naty = psn_info.Naty
  24702. Brdy = psn_info.Brdy
  24703. Age = psn_info.Age
  24704. infoStr = psn_info.Insuinfo
  24705. idetinfoStr = psn_info.Idetinfo
  24706. infocode = 0
  24707. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  24708. psn_info, _ := service.GetPsnByPatientId(id)
  24709. PsnNo = psn_info.PsnNo
  24710. PsnCertType = psn_info.PsnCertType
  24711. Certno = psn_info.Certno
  24712. PsnName = psn_info.PsnName
  24713. Gend = psn_info.Gend
  24714. Naty = psn_info.Naty
  24715. Brdy = psn_info.Brdy
  24716. Age = psn_info.Age
  24717. infoStr = psn_info.Insuinfo
  24718. idetinfoStr = psn_info.Idetinfo
  24719. infocode = 0
  24720. verify_number = psn_info.VerifyNumber
  24721. } else if miConfig.MdtrtareaAdmvs == "150404" {
  24722. if id_card_type == 2 {
  24723. //请求内网数据
  24724. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  24725. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24726. "&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
  24727. resp, requestErr := http.Get(api)
  24728. if requestErr != nil {
  24729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24730. return
  24731. }
  24732. body, ioErr := ioutil.ReadAll(resp.Body)
  24733. if ioErr != nil {
  24734. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24736. return
  24737. }
  24738. var respJSON map[string]interface{}
  24739. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24740. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24742. return
  24743. }
  24744. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24745. result_byte, _ := json.Marshal(respJSON)
  24746. result := string(result_byte)
  24747. var dat map[string]interface{}
  24748. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24749. fmt.Println(dat)
  24750. } else {
  24751. fmt.Println(err)
  24752. }
  24753. userJSONBytes, _ := json.Marshal(dat)
  24754. var res ResultTwo
  24755. var resTwo10265 ResultTwo10265
  24756. if miConfig.Code == "H15049901371" {
  24757. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  24758. utils.ErrorLog("解析失败:%v", err)
  24759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24760. return
  24761. }
  24762. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  24763. res.Infcode = Infcode
  24764. res.ErrMsg = resTwo10265.ErrMsg
  24765. res.Output = resTwo10265.Output
  24766. res.InfRefmsgid = resTwo10265.InfRefmsgid
  24767. res.RespondTime = resTwo10265.RespondTime
  24768. res.WarnInfo = resTwo10265.WarnInfo
  24769. } else {
  24770. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24771. utils.ErrorLog("解析失败:%v", err)
  24772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24773. return
  24774. }
  24775. }
  24776. //var insutypes []string
  24777. //var insutype string
  24778. //var is390 int = 0
  24779. //var is310 int = 0
  24780. //for _, item := range res.Output.Iinfo {
  24781. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24782. // insutypes = append(insutypes, item.Insutype)
  24783. // }
  24784. //}
  24785. //if len(insutypes) == 1 {
  24786. // insutype = insutypes[0]
  24787. //} else {
  24788. // for _, i := range insutypes {
  24789. // if i == "390" {
  24790. // is390 = 1
  24791. // }
  24792. //
  24793. // if i == "310" {
  24794. // is310 = 1
  24795. // }
  24796. // }
  24797. //}
  24798. //if is390 == 1 {
  24799. // insutype = "390"
  24800. //}
  24801. //if is310 == 1 {
  24802. // insutype = "310"
  24803. //}
  24804. //if len(insutypes) == 0 {
  24805. // insutype = "310"
  24806. //}
  24807. PsnNo = res.Output.Baseinfo.PsnNo
  24808. PsnCertType = res.Output.Baseinfo.PsnCertType
  24809. Certno = res.Output.Baseinfo.Certno
  24810. PsnName = res.Output.Baseinfo.PsnName
  24811. Gend = res.Output.Baseinfo.Gend
  24812. Naty = res.Output.Baseinfo.Naty
  24813. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24814. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24815. infoStr = string(Iinfos)
  24816. idetinfoStr = string(Idetinfos)
  24817. infocode = res.Infcode
  24818. //infocode = 0
  24819. //verify_number = psn_info.VerifyNumber
  24820. } else {
  24821. psn_info, _ := service.GetPsnByPatientId(id)
  24822. PsnNo = psn_info.PsnNo
  24823. PsnCertType = psn_info.PsnCertType
  24824. Certno = psn_info.Certno
  24825. PsnName = psn_info.PsnName
  24826. Gend = psn_info.Gend
  24827. Naty = psn_info.Naty
  24828. Brdy = psn_info.Brdy
  24829. Age = psn_info.Age
  24830. infoStr = psn_info.Insuinfo
  24831. idetinfoStr = psn_info.Idetinfo
  24832. infocode = 0
  24833. verify_number = psn_info.VerifyNumber
  24834. }
  24835. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24836. if id_card_type == 1 {
  24837. psn_info, _ := service.GetPsnByPatientId(id)
  24838. PsnNo = psn_info.PsnNo
  24839. PsnCertType = psn_info.PsnCertType
  24840. Certno = psn_info.Certno
  24841. PsnName = psn_info.PsnName
  24842. Gend = psn_info.Gend
  24843. Naty = psn_info.Naty
  24844. Brdy = psn_info.Brdy
  24845. Age = psn_info.Age
  24846. infoStr = psn_info.Insuinfo
  24847. idetinfoStr = psn_info.Idetinfo
  24848. infocode = 0
  24849. verify_number = psn_info.VerifyNumber
  24850. } else if id_card_type == 2 {
  24851. 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)
  24852. fmt.Println(errMsgLog)
  24853. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24854. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24855. utils.ErrorLog("解析失败:%v", err)
  24856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24857. return
  24858. }
  24859. PsnNo = res.Output.Baseinfo.PsnNo
  24860. PsnCertType = res.Output.Baseinfo.PsnCertType
  24861. Certno = res.Output.Baseinfo.Certno
  24862. PsnName = res.Output.Baseinfo.PsnName
  24863. Gend = res.Output.Baseinfo.Gend
  24864. Naty = res.Output.Baseinfo.Naty
  24865. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24866. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24867. infoStr = string(Iinfos)
  24868. idetinfoStr = string(Idetinfos)
  24869. infocode = res.Infcode
  24870. }
  24871. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24872. if id_card_type == 1 {
  24873. psn_info, _ := service.GetPsnByPatientId(id)
  24874. PsnNo = psn_info.PsnNo
  24875. PsnCertType = psn_info.PsnCertType
  24876. Certno = psn_info.Certno
  24877. PsnName = psn_info.PsnName
  24878. Gend = psn_info.Gend
  24879. Naty = psn_info.Naty
  24880. Brdy = psn_info.Brdy
  24881. Age = psn_info.Age
  24882. infoStr = psn_info.Insuinfo
  24883. idetinfoStr = psn_info.Idetinfo
  24884. infocode = 0
  24885. verify_number = psn_info.VerifyNumber
  24886. } else if id_card_type == 2 {
  24887. 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, "")
  24888. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24889. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24890. utils.ErrorLog("解析失败:%v", err)
  24891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24892. return
  24893. }
  24894. PsnNo = res.Output.Baseinfo.PsnNo
  24895. PsnCertType = res.Output.Baseinfo.PsnCertType
  24896. Certno = res.Output.Baseinfo.Certno
  24897. PsnName = res.Output.Baseinfo.PsnName
  24898. Gend = res.Output.Baseinfo.Gend
  24899. Naty = res.Output.Baseinfo.Naty
  24900. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24901. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24902. infoStr = string(Iinfos)
  24903. idetinfoStr = string(Idetinfos)
  24904. infocode = res.Infcode
  24905. } else {
  24906. psn_info, _ := service.GetPsnByPatientId(id)
  24907. PsnNo = psn_info.PsnNo
  24908. PsnCertType = psn_info.PsnCertType
  24909. Certno = psn_info.Certno
  24910. PsnName = psn_info.PsnName
  24911. Gend = psn_info.Gend
  24912. Naty = psn_info.Naty
  24913. Brdy = psn_info.Brdy
  24914. Age = psn_info.Age
  24915. infoStr = psn_info.Insuinfo
  24916. idetinfoStr = psn_info.Idetinfo
  24917. infocode = 0
  24918. verify_number = psn_info.VerifyNumber
  24919. }
  24920. } else if miConfig.MdtrtareaAdmvs == "361025" {
  24921. if id_card_type == 1 {
  24922. psn_info, _ := service.GetPsnByPatientId(id)
  24923. PsnNo = psn_info.PsnNo
  24924. PsnCertType = psn_info.PsnCertType
  24925. Certno = psn_info.Certno
  24926. PsnName = psn_info.PsnName
  24927. Gend = psn_info.Gend
  24928. Naty = psn_info.Naty
  24929. Brdy = psn_info.Brdy
  24930. Age = psn_info.Age
  24931. infoStr = psn_info.Insuinfo
  24932. idetinfoStr = psn_info.Idetinfo
  24933. infocode = 0
  24934. verify_number = psn_info.VerifyNumber
  24935. } else if id_card_type == 2 {
  24936. psn_info, _ := service.GetPsnByPatientId(id)
  24937. PsnNo = psn_info.PsnNo
  24938. PsnCertType = psn_info.PsnCertType
  24939. Certno = psn_info.Certno
  24940. PsnName = psn_info.PsnName
  24941. Gend = psn_info.Gend
  24942. Naty = psn_info.Naty
  24943. Brdy = psn_info.Brdy
  24944. Age = psn_info.Age
  24945. infoStr = psn_info.Insuinfo
  24946. idetinfoStr = psn_info.Idetinfo
  24947. infocode = 0
  24948. verify_number = psn_info.VerifyNumber
  24949. } else {
  24950. psn_info, _ := service.GetPsnByPatientId(id)
  24951. PsnNo = psn_info.PsnNo
  24952. PsnCertType = psn_info.PsnCertType
  24953. Certno = psn_info.Certno
  24954. PsnName = psn_info.PsnName
  24955. Gend = psn_info.Gend
  24956. Naty = psn_info.Naty
  24957. Brdy = psn_info.Brdy
  24958. Age = psn_info.Age
  24959. infoStr = psn_info.Insuinfo
  24960. idetinfoStr = psn_info.Idetinfo
  24961. infocode = 0
  24962. verify_number = psn_info.VerifyNumber
  24963. }
  24964. } else if miConfig.MdtrtareaAdmvs == "360100" {
  24965. if id_card_type == 1 {
  24966. psn_info, _ := service.GetPsnByPatientId(id)
  24967. PsnNo = psn_info.PsnNo
  24968. PsnCertType = psn_info.PsnCertType
  24969. Certno = psn_info.Certno
  24970. PsnName = psn_info.PsnName
  24971. Gend = psn_info.Gend
  24972. Naty = psn_info.Naty
  24973. Brdy = psn_info.Brdy
  24974. Age = psn_info.Age
  24975. infoStr = psn_info.Insuinfo
  24976. idetinfoStr = psn_info.Idetinfo
  24977. infocode = 0
  24978. verify_number = psn_info.VerifyNumber
  24979. } else if id_card_type == 2 {
  24980. psn_info, _ := service.GetPsnByPatientId(id)
  24981. PsnNo = psn_info.PsnNo
  24982. PsnCertType = psn_info.PsnCertType
  24983. Certno = psn_info.Certno
  24984. PsnName = psn_info.PsnName
  24985. Gend = psn_info.Gend
  24986. Naty = psn_info.Naty
  24987. Brdy = psn_info.Brdy
  24988. Age = psn_info.Age
  24989. infoStr = psn_info.Insuinfo
  24990. idetinfoStr = psn_info.Idetinfo
  24991. infocode = 0
  24992. verify_number = psn_info.VerifyNumber
  24993. } else {
  24994. psn_info, _ := service.GetPsnByPatientId(id)
  24995. PsnNo = psn_info.PsnNo
  24996. PsnCertType = psn_info.PsnCertType
  24997. Certno = psn_info.Certno
  24998. PsnName = psn_info.PsnName
  24999. Gend = psn_info.Gend
  25000. Naty = psn_info.Naty
  25001. Brdy = psn_info.Brdy
  25002. Age = psn_info.Age
  25003. infoStr = psn_info.Insuinfo
  25004. idetinfoStr = psn_info.Idetinfo
  25005. infocode = 0
  25006. verify_number = psn_info.VerifyNumber
  25007. }
  25008. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  25009. psn_info, _ := service.GetPsnByPatientId(id)
  25010. PsnNo = psn_info.PsnNo
  25011. PsnCertType = psn_info.PsnCertType
  25012. Certno = psn_info.Certno
  25013. PsnName = psn_info.PsnName
  25014. Gend = psn_info.Gend
  25015. Naty = psn_info.Naty
  25016. Brdy = psn_info.Brdy
  25017. Age = psn_info.Age
  25018. infoStr = psn_info.Insuinfo
  25019. idetinfoStr = psn_info.Idetinfo
  25020. infocode = 0
  25021. verify_number = psn_info.VerifyNumber
  25022. idetinfoStr = psn_info.Idetinfo
  25023. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25024. if id_card_type == 1 {
  25025. psn_info, _ := service.GetPsnByPatientId(id)
  25026. PsnNo = psn_info.PsnNo
  25027. PsnCertType = psn_info.PsnCertType
  25028. Certno = psn_info.Certno
  25029. PsnName = psn_info.PsnName
  25030. Gend = psn_info.Gend
  25031. Naty = psn_info.Naty
  25032. Brdy = psn_info.Brdy
  25033. Age = psn_info.Age
  25034. infoStr = psn_info.Insuinfo
  25035. idetinfoStr = psn_info.Idetinfo
  25036. infocode = 0
  25037. verify_number = psn_info.VerifyNumber
  25038. } else if id_card_type == 2 {
  25039. 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)
  25040. saveLog(result, requestLog, "1101", "人员基本信息获取")
  25041. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25042. utils.ErrorLog("解析失败:%v", err)
  25043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25044. return
  25045. }
  25046. PsnNo = res.Output.Baseinfo.PsnNo
  25047. PsnCertType = res.Output.Baseinfo.PsnCertType
  25048. Certno = res.Output.Baseinfo.Certno
  25049. PsnName = res.Output.Baseinfo.PsnName
  25050. Gend = res.Output.Baseinfo.Gend
  25051. Naty = res.Output.Baseinfo.Naty
  25052. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  25053. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  25054. infoStr = string(Iinfos)
  25055. idetinfoStr = string(Idetinfos)
  25056. infocode = res.Infcode
  25057. } else if id_card_type == 4 {
  25058. psn_info, _ := service.GetPsnByPatientId(id)
  25059. PsnNo = psn_info.PsnNo
  25060. PsnCertType = psn_info.PsnCertType
  25061. Certno = psn_info.Certno
  25062. PsnName = psn_info.PsnName
  25063. Gend = psn_info.Gend
  25064. Naty = psn_info.Naty
  25065. Brdy = psn_info.Brdy
  25066. Age = psn_info.Age
  25067. infoStr = psn_info.Insuinfo
  25068. idetinfoStr = psn_info.Idetinfo
  25069. infocode = 0
  25070. verify_number = psn_info.VerifyNumber
  25071. }
  25072. } else if miConfig.MdtrtareaAdmvs == "131023" {
  25073. var result string
  25074. var requestLog string
  25075. 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), "")
  25076. if id_card_type == 4 {
  25077. psn_info, _ := service.GetPsnByPatientId(id)
  25078. PsnNo = psn_info.PsnNo
  25079. PsnCertType = psn_info.PsnCertType
  25080. Certno = psn_info.Certno
  25081. PsnName = psn_info.PsnName
  25082. Gend = psn_info.Gend
  25083. Naty = psn_info.Naty
  25084. Brdy = psn_info.Brdy
  25085. Age = psn_info.Age
  25086. infoStr = psn_info.Insuinfo
  25087. idetinfoStr = psn_info.Idetinfo
  25088. infocode = 0
  25089. verify_number = psn_info.VerifyNumber
  25090. } else {
  25091. saveLog(result, requestLog, "1101", "人员基本信息获取")
  25092. if miConfig.Code == "H15049901371" {
  25093. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  25094. utils.ErrorLog("解析失败:%v", err)
  25095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25096. return
  25097. }
  25098. res.ErrMsg = res10265.ErrMsg
  25099. res.Output = res10265.Output
  25100. res.InfRefmsgid = res10265.InfRefmsgid
  25101. } else {
  25102. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25103. utils.ErrorLog("解析失败:%v", err)
  25104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25105. return
  25106. }
  25107. }
  25108. PsnNo = res.Output.Baseinfo.PsnNo
  25109. PsnCertType = res.Output.Baseinfo.PsnCertType
  25110. Certno = res.Output.Baseinfo.Certno
  25111. PsnName = res.Output.Baseinfo.PsnName
  25112. Gend = res.Output.Baseinfo.Gend
  25113. Naty = res.Output.Baseinfo.Naty
  25114. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  25115. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  25116. infoStr = string(Iinfos)
  25117. idetinfoStr = string(Idetinfos)
  25118. if miConfig.Code == "H15049901371" {
  25119. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  25120. } else {
  25121. infocode = res.Infcode
  25122. }
  25123. }
  25124. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25125. psn_info, _ := service.GetPsnByPatientId(id)
  25126. PsnNo = psn_info.PsnNo
  25127. PsnCertType = psn_info.PsnCertType
  25128. Certno = psn_info.Certno
  25129. PsnName = psn_info.PsnName
  25130. Gend = psn_info.Gend
  25131. Naty = psn_info.Naty
  25132. Brdy = psn_info.Brdy
  25133. Age = psn_info.Age
  25134. infoStr = psn_info.Insuinfo
  25135. idetinfoStr = psn_info.Idetinfo
  25136. infocode = 0
  25137. verify_number = psn_info.VerifyNumber
  25138. } else if miConfig.MdtrtareaAdmvs == "450721" {
  25139. psn_info, _ := service.GetPsnByPatientId(id)
  25140. PsnNo = psn_info.PsnNo
  25141. PsnCertType = psn_info.PsnCertType
  25142. Certno = psn_info.Certno
  25143. PsnName = psn_info.PsnName
  25144. Gend = psn_info.Gend
  25145. Naty = psn_info.Naty
  25146. Brdy = psn_info.Brdy
  25147. Age = psn_info.Age
  25148. infoStr = psn_info.Insuinfo
  25149. idetinfoStr = psn_info.Idetinfo
  25150. infocode = 0
  25151. verify_number = psn_info.VerifyNumber
  25152. } else {
  25153. var result string
  25154. var requestLog string
  25155. //if miConfig.UserOrgId == 10138 {
  25156. if id_card_type != 4 || id_card_type != 1 {
  25157. var insa string
  25158. if len(patient.InsuplcAdmdvs) > 0 {
  25159. insa = patient.InsuplcAdmdvs
  25160. } else {
  25161. insa = miConfig.InsuplcAdmdvs
  25162. }
  25163. //psn_info, _ := service.GetPsnByPatientId(id)
  25164. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  25165. 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)
  25166. }
  25167. //}
  25168. //else {
  25169. // var insa string
  25170. // if len(patient.InsuplcAdmdvs) > 0 {
  25171. // insa = patient.InsuplcAdmdvs
  25172. // } else {
  25173. // insa = miConfig.InsuplcAdmdvs
  25174. // }
  25175. // 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)
  25176. //}
  25177. if id_card_type == 4 || id_card_type == 1 {
  25178. psn_info, _ := service.GetPsnByPatientId(id)
  25179. PsnNo = psn_info.PsnNo
  25180. PsnCertType = psn_info.PsnCertType
  25181. Certno = psn_info.Certno
  25182. PsnName = psn_info.PsnName
  25183. Gend = psn_info.Gend
  25184. Naty = psn_info.Naty
  25185. Brdy = psn_info.Brdy
  25186. Age = psn_info.Age
  25187. infoStr = psn_info.Insuinfo
  25188. idetinfoStr = psn_info.Idetinfo
  25189. infocode = 0
  25190. verify_number = psn_info.VerifyNumber
  25191. } else {
  25192. saveLog(result, requestLog, "1101", "人员基本信息获取")
  25193. if miConfig.Code == "H15049901371" {
  25194. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  25195. utils.ErrorLog("解析失败:%v", err)
  25196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25197. return
  25198. }
  25199. res.ErrMsg = res10265.ErrMsg
  25200. res.Output = res10265.Output
  25201. res.InfRefmsgid = res10265.InfRefmsgid
  25202. } else {
  25203. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25204. utils.ErrorLog("解析失败:%v", err)
  25205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25206. return
  25207. }
  25208. }
  25209. PsnNo = res.Output.Baseinfo.PsnNo
  25210. PsnCertType = res.Output.Baseinfo.PsnCertType
  25211. Certno = res.Output.Baseinfo.Certno
  25212. PsnName = res.Output.Baseinfo.PsnName
  25213. Gend = res.Output.Baseinfo.Gend
  25214. Naty = res.Output.Baseinfo.Naty
  25215. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  25216. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  25217. infoStr = string(Iinfos)
  25218. idetinfoStr = string(Idetinfos)
  25219. if miConfig.Code == "H15049901371" {
  25220. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  25221. } else {
  25222. infocode = res.Infcode
  25223. }
  25224. }
  25225. }
  25226. if infocode == 0 {
  25227. his := models.VMHisPatient{
  25228. Name: name,
  25229. Gender: gender,
  25230. Birthday: birthUnix,
  25231. MedicalTreatmentType: medical_care,
  25232. IdType: certificates,
  25233. IdCardNo: id_card,
  25234. BalanceAccountsType: settlementValue,
  25235. SocialType: social_type,
  25236. MedicalInsuranceNumber: medical_insurance_card,
  25237. RegisterType: register_type,
  25238. RegisterCost: registration_fee,
  25239. TreatmentCost: medical_expenses,
  25240. Status: 1,
  25241. Ctime: time.Now().Unix(),
  25242. Mtime: time.Now().Unix(),
  25243. PsnNo: PsnNo,
  25244. PsnCertType: PsnCertType,
  25245. Certno: Certno,
  25246. PsnName: PsnName,
  25247. Gend: Gend,
  25248. Naty: Naty,
  25249. Brdy: Brdy,
  25250. Age: Age,
  25251. Iinfo: infoStr,
  25252. Idetinfo: idetinfoStr,
  25253. PatientId: patient.ID,
  25254. RecordDate: theTime.Unix(),
  25255. UserOrgId: adminInfo.CurrentOrgId,
  25256. AdminUserId: admin_user_id,
  25257. IsReturn: 1,
  25258. IdCardType: id_card_type,
  25259. Doctor: doctor,
  25260. Departments: department,
  25261. MdtrtGrpType: mdtrt_type,
  25262. }
  25263. timestamp := time.Now().Unix()
  25264. tempTime := time.Unix(timestamp, 0)
  25265. timeFormat := tempTime.Format("20060102150405")
  25266. chrgBchno := rand.Intn(100000) + 10000
  25267. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  25268. his.Number = ipt_otp_no
  25269. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  25270. department, _ := service.GetDepartMentDetail(department)
  25271. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  25272. IdCardNo := ""
  25273. if id_card_type == 1 {
  25274. // IdCardNo = medical_insurance_card
  25275. IdCardNo = patient.IdCardNo
  25276. } else {
  25277. IdCardNo = patient.IdCardNo
  25278. }
  25279. var rf []*ResultFive
  25280. json.Unmarshal([]byte(his.Iinfo), &rf)
  25281. var insutypes []*ResultFive
  25282. var insutype string
  25283. var insuplc_admdvs_temp string
  25284. var is390 int = 0
  25285. var is310 int = 0
  25286. for _, item := range rf {
  25287. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25288. insutypes = append(insutypes, item)
  25289. }
  25290. }
  25291. if len(insutypes) == 1 {
  25292. insutype = insutypes[0].Insutype
  25293. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25294. if insutype == "390" {
  25295. is390 = 1
  25296. }
  25297. if insutype == "310" {
  25298. is310 = 1
  25299. }
  25300. } else {
  25301. for _, i := range insutypes {
  25302. if i.Insutype == "390" {
  25303. is390 = 1
  25304. }
  25305. if i.Insutype == "310" {
  25306. is310 = 1
  25307. }
  25308. }
  25309. }
  25310. if is390 == 1 {
  25311. insutype = "390"
  25312. }
  25313. if is310 == 1 {
  25314. insutype = "310"
  25315. }
  25316. fmt.Println(social_type)
  25317. if social_type > 0 {
  25318. insutype = strconv.FormatInt(social_type, 10)
  25319. }
  25320. var infocode int64
  25321. var resThree ResultThree
  25322. var resThree10265 ResultThree10265
  25323. if len(insuplc_admdvs) == 0 {
  25324. psn_info, _ := service.GetPsnByPatientId(id)
  25325. //if len(psn_info.InsuplcAdmdvs) > 0 {
  25326. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25327. //}
  25328. } else {
  25329. insuplc_admdvs_temp = insuplc_admdvs
  25330. }
  25331. if miConfig.MdtrtareaAdmvs == "421300" {
  25332. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25333. psn_info, _ := service.GetPsnByPatientId(id)
  25334. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25335. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25336. "&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
  25337. resp, requestErr := http.Get(api)
  25338. if requestErr != nil {
  25339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25340. return
  25341. }
  25342. body, ioErr := ioutil.ReadAll(resp.Body)
  25343. if ioErr != nil {
  25344. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25346. return
  25347. }
  25348. var respJSON map[string]interface{}
  25349. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25352. return
  25353. }
  25354. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25355. result, _ := json.Marshal(respJSON)
  25356. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25357. utils.ErrorLog("解析失败:%v", err)
  25358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25359. return
  25360. }
  25361. infocode = resThree.Infcode
  25362. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25363. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25364. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25365. // insuplc_admdvs_temp =
  25366. //}
  25367. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25368. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25369. //}
  25370. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25371. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25372. "&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
  25373. resp, requestErr := http.Get(api)
  25374. if requestErr != nil {
  25375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25376. return
  25377. }
  25378. body, ioErr := ioutil.ReadAll(resp.Body)
  25379. if ioErr != nil {
  25380. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25382. return
  25383. }
  25384. var respJSON map[string]interface{}
  25385. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25388. return
  25389. }
  25390. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25391. result, _ := json.Marshal(respJSON)
  25392. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25393. utils.ErrorLog("解析失败:%v", err)
  25394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25395. return
  25396. }
  25397. infocode = resThree.Infcode
  25398. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25399. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25400. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25401. // insuplc_admdvs_temp =
  25402. //}
  25403. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25404. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25405. //}
  25406. utils.ErrorLog("解析失败:%v", insutype)
  25407. utils.ErrorLog("解析失败:%v", PsnNo)
  25408. utils.ErrorLog("解析失败:%v", Certno)
  25409. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  25410. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  25411. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  25412. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  25413. utils.ErrorLog("解析失败:%v", PsnNo)
  25414. utils.ErrorLog("解析失败:%v", department.Number)
  25415. utils.ErrorLog("解析失败:%v", department.Name)
  25416. utils.ErrorLog("解析失败:%v", roles.UserName)
  25417. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25418. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25419. "&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
  25420. resp, requestErr := http.Get(api)
  25421. if requestErr != nil {
  25422. utils.ErrorLog("解析失败:%v", requestErr)
  25423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25424. return
  25425. }
  25426. body, ioErr := ioutil.ReadAll(resp.Body)
  25427. if ioErr != nil {
  25428. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25430. return
  25431. }
  25432. var respJSON map[string]interface{}
  25433. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25434. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25436. return
  25437. }
  25438. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25439. result, _ := json.Marshal(respJSON)
  25440. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25441. utils.ErrorLog("解析失败:%v", err)
  25442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25443. return
  25444. }
  25445. infocode = resThree.Infcode
  25446. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25447. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25448. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25449. // insuplc_admdvs_temp =
  25450. //}
  25451. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25452. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25453. //}
  25454. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25455. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25456. "&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
  25457. resp, requestErr := http.Get(api)
  25458. if requestErr != nil {
  25459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25460. return
  25461. }
  25462. body, ioErr := ioutil.ReadAll(resp.Body)
  25463. if ioErr != nil {
  25464. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25466. return
  25467. }
  25468. var respJSON map[string]interface{}
  25469. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25470. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25472. return
  25473. }
  25474. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25475. result, _ := json.Marshal(respJSON)
  25476. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25477. utils.ErrorLog("解析失败:%v", err)
  25478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25479. return
  25480. }
  25481. infocode = resThree.Infcode
  25482. } else if miConfig.MdtrtareaAdmvs == "150404" {
  25483. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25484. psn_info, _ := service.GetPsnByPatientId(id)
  25485. var verify_number string
  25486. if id_card_type == 4 {
  25487. verify_number = psn_info.VerifyNumber
  25488. } else if id_card_type == 1 {
  25489. bas := strings.Split(psn_info.CardInfo, "|")
  25490. cardNumber := bas[2]
  25491. verify_number = cardNumber
  25492. }
  25493. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25494. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25495. "&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
  25496. resp, requestErr := http.Get(api)
  25497. if requestErr != nil {
  25498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25499. return
  25500. }
  25501. body, ioErr := ioutil.ReadAll(resp.Body)
  25502. if ioErr != nil {
  25503. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25505. return
  25506. }
  25507. var respJSON map[string]interface{}
  25508. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25509. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25511. return
  25512. }
  25513. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25514. result, _ := json.Marshal(respJSON)
  25515. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25516. // utils.ErrorLog("解析失败:%v", err)
  25517. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25518. // return
  25519. //}
  25520. //infocode = resThree.Infcode
  25521. //result, _ := json.Marshal(respJSON)
  25522. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25523. utils.ErrorLog("解析失败:%v", err)
  25524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25525. return
  25526. }
  25527. resThree.ErrMsg = resThree10265.ErrMsg
  25528. resThree.Output = resThree10265.Output
  25529. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25530. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25531. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  25532. psn_info, _ := service.GetPsnByPatientId(id)
  25533. his.PsnNo = psn_info.PsnNo
  25534. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25535. var cert_no string
  25536. if id_card_type == 3 {
  25537. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  25538. cert_no = IdCardNo
  25539. } else if id_card_type == 4 {
  25540. cert_no = IdCardNo
  25541. psn_info.VerifyNumber = psn_info.VerifyNumber
  25542. } else {
  25543. bas := strings.Split(psn_info.CardInfo, "|")
  25544. cert_no = bas[2]
  25545. }
  25546. var hisPrescription []*models.HisPrescription
  25547. fmt.Println(hisPrescription)
  25548. for _, item := range rf {
  25549. if item.Insutype == insutype {
  25550. //insuplc_admdvs = item.InsuplcAdmdvs
  25551. his.InsuplcAdmdvs = insuplc_admdvs
  25552. }
  25553. }
  25554. his.Insutype = insutype
  25555. var res3101 Result3101
  25556. res3101.Infcode = "0"
  25557. //res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25558. if res3101.Infcode == "0" {
  25559. fmt.Println("33333333")
  25560. if len(res3101.Output.Result) > 0 {
  25561. fmt.Println("222222")
  25562. for _, item := range res3101.Output.Result {
  25563. if len(res3101.ErrMsg) == 0 {
  25564. res3101.ErrMsg = item.VolaCont
  25565. } else {
  25566. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25567. }
  25568. }
  25569. c.ServeSuccessJSON(map[string]interface{}{
  25570. "failed_code": -10,
  25571. "msg": res3101.ErrMsg,
  25572. })
  25573. return
  25574. } else {
  25575. fmt.Println("11111")
  25576. var api string
  25577. if miConfig.MdtrtareaAdmvs == "320830" {
  25578. ipt_otp_no = timeFormat
  25579. api = miConfig.AppSecret + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25580. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25581. "&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
  25582. } else if miConfig.MdtrtareaAdmvs == "320921" {
  25583. ipt_otp_no = timeFormat
  25584. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25585. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25586. "&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
  25587. } else {
  25588. ipt_otp_no = timeFormat
  25589. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25590. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25591. "&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
  25592. }
  25593. resp, requestErr := http.Get(api)
  25594. if requestErr != nil {
  25595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25596. return
  25597. }
  25598. body, ioErr := ioutil.ReadAll(resp.Body)
  25599. if ioErr != nil {
  25600. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25602. return
  25603. }
  25604. var respJSON map[string]interface{}
  25605. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25606. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25608. return
  25609. }
  25610. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25611. result, _ := json.Marshal(respJSON)
  25612. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25613. utils.ErrorLog("解析失败:%v", err)
  25614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25615. return
  25616. }
  25617. resThree.ErrMsg = resThree10265.ErrMsg
  25618. resThree.Output = resThree10265.Output
  25619. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25620. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25621. }
  25622. } else if res3101.Infcode != "0" {
  25623. c.ServeSuccessJSON(map[string]interface{}{
  25624. "failed_code": -10,
  25625. "msg": res3101.ErrMsg,
  25626. })
  25627. return
  25628. }
  25629. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25630. psn_info, _ := service.GetPsnByPatientId(id)
  25631. var cert_no string
  25632. if id_card_type == 1 {
  25633. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25634. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25635. } else if id_card_type == 4 {
  25636. cert_no = psn_info.VerifyNumber
  25637. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25638. } else {
  25639. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25640. cert_no = psn_info.VerifyNumber
  25641. }
  25642. 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)
  25643. saveLog(result, requestLog, "2201", "挂号")
  25644. if miConfig.Code == "H15049901371" {
  25645. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25646. utils.ErrorLog("解析失败:%v", err)
  25647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25648. return
  25649. }
  25650. resThree.ErrMsg = resThree10265.ErrMsg
  25651. resThree.Output = resThree10265.Output
  25652. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25653. } else {
  25654. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25655. utils.ErrorLog("解析失败:%v", err)
  25656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25657. return
  25658. }
  25659. }
  25660. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25661. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  25662. psn_info, _ := service.GetPsnByPatientId(id)
  25663. var result string
  25664. var requestLog string
  25665. if id_card_type == 1 {
  25666. bas := strings.Split(psn_info.CardInfo, "|")
  25667. basNumber := bas[2]
  25668. card_sn := bas[3]
  25669. 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)
  25670. saveLog(result, requestLog, "2201A", "挂号")
  25671. } else if id_card_type == 2 {
  25672. 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, "", "", "", "", "", "")
  25673. saveLog(result, requestLog, "2201A", "挂号")
  25674. } else {
  25675. 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)
  25676. saveLog(result, requestLog, "2201A", "挂号")
  25677. }
  25678. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25679. utils.ErrorLog("解析失败:%v", err)
  25680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25681. return
  25682. }
  25683. infocode = resThree.Infcode
  25684. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  25685. psn_info, _ := service.GetPsnByPatientId(id)
  25686. var result string
  25687. var requestLog string
  25688. if id_card_type == 1 {
  25689. bas := strings.Split(psn_info.CardInfo, "|")
  25690. basNumber := bas[2]
  25691. card_sn := ""
  25692. 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)
  25693. saveLog(result, requestLog, "2201A", "挂号")
  25694. } else if id_card_type == 2 {
  25695. 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, "", "", "", "", "", "")
  25696. saveLog(result, requestLog, "2201A", "挂号")
  25697. } else {
  25698. 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)
  25699. saveLog(result, requestLog, "2201A", "挂号")
  25700. }
  25701. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25702. utils.ErrorLog("解析失败:%v", err)
  25703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25704. return
  25705. }
  25706. infocode = resThree.Infcode
  25707. } else if miConfig.MdtrtareaAdmvs == "360100" { //江西萍乡
  25708. psn_info, _ := service.GetPsnByPatientId(id)
  25709. var result string
  25710. var requestLog string
  25711. if id_card_type == 1 {
  25712. bas := strings.Split(psn_info.CardInfo, "|")
  25713. basNumber := bas[2]
  25714. card_sn := ""
  25715. 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)
  25716. saveLog(result, requestLog, "2201A", "挂号")
  25717. } else if id_card_type == 2 {
  25718. 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, "", "", "", "", "", "")
  25719. saveLog(result, requestLog, "2201A", "挂号")
  25720. } else {
  25721. 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)
  25722. saveLog(result, requestLog, "2201A", "挂号")
  25723. }
  25724. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25725. utils.ErrorLog("解析失败:%v", err)
  25726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25727. return
  25728. }
  25729. infocode = resThree.Infcode
  25730. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25731. psn_info, _ := service.GetPsnByPatientId(id)
  25732. his.PsnNo = psn_info.PsnNo
  25733. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25734. var cert_no string
  25735. if id_card_type == 1 {
  25736. bas := strings.Split(psn_info.CardInfo, "|")
  25737. cert_no = bas[2]
  25738. } else if id_card_type == 4 {
  25739. cert_no = psn_info.VerifyNumber
  25740. psn_info.VerifyNumber = psn_info.VerifyNumber
  25741. IdCardNo = psn_info.VerifyNumber
  25742. } else {
  25743. cert_no = IdCardNo
  25744. psn_info.VerifyNumber = cert_no
  25745. }
  25746. for _, item := range rf {
  25747. if item.Insutype == insutype {
  25748. his.InsuplcAdmdvs = insuplc_admdvs
  25749. }
  25750. }
  25751. his.Insutype = insutype
  25752. var api string
  25753. ipt_otp_no = timeFormat
  25754. 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 +
  25755. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25756. "&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
  25757. resp, requestErr := http.Get(api)
  25758. if requestErr != nil {
  25759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25760. return
  25761. }
  25762. body, ioErr := ioutil.ReadAll(resp.Body)
  25763. if ioErr != nil {
  25764. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25766. return
  25767. }
  25768. var respJSON map[string]interface{}
  25769. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25770. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25772. return
  25773. }
  25774. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25775. if status == "0" {
  25776. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25777. c.ServeSuccessJSON(map[string]interface{}{
  25778. "failed_code": -10,
  25779. "msg": err_msg,
  25780. })
  25781. return
  25782. }
  25783. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25784. result, _ := json.Marshal(respJSON)
  25785. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25786. utils.ErrorLog("解析失败:%v", err)
  25787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25788. return
  25789. }
  25790. infocode = resThree.Infcode
  25791. } else if miConfig.MdtrtareaAdmvs == "340699" {
  25792. psn_info, _ := service.GetPsnByPatientId(id)
  25793. his.PsnNo = psn_info.PsnNo
  25794. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25795. var cert_no string
  25796. if id_card_type == 1 {
  25797. bas := strings.Split(psn_info.CardInfo, "|")
  25798. cert_no = bas[2]
  25799. } else if id_card_type == 4 {
  25800. cert_no = psn_info.VerifyNumber
  25801. psn_info.VerifyNumber = psn_info.VerifyNumber
  25802. IdCardNo = psn_info.VerifyNumber
  25803. } else {
  25804. cert_no = IdCardNo
  25805. psn_info.VerifyNumber = cert_no
  25806. }
  25807. for _, item := range rf {
  25808. if item.Insutype == insutype {
  25809. his.InsuplcAdmdvs = insuplc_admdvs
  25810. patient.InsuplcAdmdvs = insuplc_admdvs
  25811. }
  25812. }
  25813. his.Insutype = insutype
  25814. var api string
  25815. ipt_otp_no = timeFormat
  25816. 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 +
  25817. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25818. "&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
  25819. resp, requestErr := http.Get(api)
  25820. if requestErr != nil {
  25821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25822. return
  25823. }
  25824. body, ioErr := ioutil.ReadAll(resp.Body)
  25825. if ioErr != nil {
  25826. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25828. return
  25829. }
  25830. var respJSON map[string]interface{}
  25831. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25832. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25834. return
  25835. }
  25836. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25837. if status == "0" {
  25838. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25839. c.ServeSuccessJSON(map[string]interface{}{
  25840. "failed_code": -10,
  25841. "msg": err_msg,
  25842. })
  25843. return
  25844. }
  25845. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25846. result, _ := json.Marshal(respJSON)
  25847. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25848. utils.ErrorLog("解析失败:%v", err)
  25849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25850. return
  25851. }
  25852. infocode = resThree.Infcode
  25853. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25854. hour := time.Now().Format("15")
  25855. min := time.Now().Format("04")
  25856. sec := time.Now().Format("05")
  25857. begin := record_time + " " + hour + ":" + min + ":" + sec
  25858. psn_info, _ := service.GetPsnByPatientId(id)
  25859. var result string
  25860. var requestLog string
  25861. if id_card_type == 1 {
  25862. bas := strings.Split(psn_info.CardInfo, "|")
  25863. basNumber := bas[2]
  25864. card_sn := bas[3]
  25865. 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)
  25866. saveLog(result, requestLog, "2201A", "挂号")
  25867. } else if id_card_type == 2 {
  25868. 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)
  25869. saveLog(result, requestLog, "2201A", "挂号")
  25870. } else {
  25871. 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)
  25872. saveLog(result, requestLog, "2201A", "挂号")
  25873. }
  25874. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25875. utils.ErrorLog("解析失败:%v", err)
  25876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25877. return
  25878. }
  25879. infocode = resThree.Infcode
  25880. } else if miConfig.MdtrtareaAdmvs == "131023" {
  25881. psn_info, _ := service.GetPsnByPatientId(id)
  25882. 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)
  25883. saveLog(result, requestLog, "2201A", "挂号")
  25884. if miConfig.Code == "H15049901371" {
  25885. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25886. utils.ErrorLog("解析失败:%v", err)
  25887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25888. return
  25889. }
  25890. resThree.ErrMsg = resThree10265.ErrMsg
  25891. resThree.Output = resThree10265.Output
  25892. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25893. } else {
  25894. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25895. utils.ErrorLog("解析失败:%v", err)
  25896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25897. return
  25898. }
  25899. }
  25900. if miConfig.Code == "H15049901371" {
  25901. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25902. } else {
  25903. infocode = resThree.Infcode
  25904. }
  25905. } else {
  25906. psn_info, _ := service.GetPsnByPatientId(id)
  25907. if id_card_type == 4 || id_card_type == 1 {
  25908. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25909. }
  25910. var rf []*ResultFive
  25911. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  25912. var insutypes []*ResultFive
  25913. var insutype string
  25914. var is390 int = 0
  25915. var is310 int = 0
  25916. for _, item := range rf {
  25917. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25918. insutypes = append(insutypes, item)
  25919. }
  25920. }
  25921. if len(insutypes) == 1 {
  25922. insutype = insutypes[0].Insutype
  25923. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25924. } else {
  25925. for _, i := range insutypes {
  25926. if i.Insutype == "390" {
  25927. is390 = 1
  25928. }
  25929. if i.Insutype == "310" {
  25930. is310 = 1
  25931. }
  25932. }
  25933. }
  25934. if is390 == 1 {
  25935. insutype = "390"
  25936. }
  25937. if is310 == 1 {
  25938. insutype = "310"
  25939. }
  25940. fmt.Println(len(insutypes))
  25941. if len(insutypes) == 0 {
  25942. for index, item := range rf {
  25943. if index == 0 {
  25944. insutype = item.Insutype
  25945. insuplc_admdvs = item.InsuplcAdmdvs
  25946. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25947. }
  25948. }
  25949. fmt.Println(insutype)
  25950. fmt.Println(insuplc_admdvs)
  25951. }
  25952. if social_type > 0 {
  25953. insutype = strconv.FormatInt(social_type, 10)
  25954. }
  25955. fmt.Println("--------")
  25956. fmt.Println(psn_info)
  25957. fmt.Println(psn_info.PsnNo)
  25958. for _, item := range rf {
  25959. if item.Insutype == insutype {
  25960. insutype = item.Insutype
  25961. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25962. }
  25963. }
  25964. if miConfig.MdtrtareaAdmvs == "441202" {
  25965. var hisPrescription []*models.HisPrescription
  25966. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25967. if res3101.Infcode == 0 {
  25968. fmt.Println("33333333")
  25969. if len(res3101.Output.Result) > 0 {
  25970. fmt.Println("222222")
  25971. for _, item := range res3101.Output.Result {
  25972. if len(res3101.ErrMsg) == 0 {
  25973. res3101.ErrMsg = item.VolaCont
  25974. } else {
  25975. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25976. }
  25977. }
  25978. c.ServeSuccessJSON(map[string]interface{}{
  25979. "failed_code": -10,
  25980. "msg": res3101.ErrMsg,
  25981. })
  25982. return
  25983. } else {
  25984. hour := time.Now().Format("15")
  25985. min := time.Now().Format("04")
  25986. sec := time.Now().Format("05")
  25987. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25988. fmt.Println(record_time_two)
  25989. 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)
  25990. saveLog(result, requestLog, "2201A", "挂号")
  25991. if miConfig.Code == "H15049901371" {
  25992. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25993. utils.ErrorLog("解析失败:%v", err)
  25994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25995. return
  25996. }
  25997. resThree.ErrMsg = resThree10265.ErrMsg
  25998. resThree.Output = resThree10265.Output
  25999. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  26000. } else {
  26001. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  26002. utils.ErrorLog("解析失败:%v", err)
  26003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26004. return
  26005. }
  26006. }
  26007. if miConfig.Code == "H15049901371" {
  26008. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  26009. } else {
  26010. infocode = resThree.Infcode
  26011. }
  26012. }
  26013. } else if res3101.Infcode != 0 {
  26014. c.ServeSuccessJSON(map[string]interface{}{
  26015. "failed_code": -10,
  26016. "msg": res3101.ErrMsg,
  26017. })
  26018. return
  26019. }
  26020. } else if miConfig.MdtrtareaAdmvs == "440205" {
  26021. var hisPrescription []*models.HisPrescription
  26022. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  26023. if res3101.Infcode == 0 {
  26024. fmt.Println("33333333")
  26025. if len(res3101.Output.Result) > 0 {
  26026. fmt.Println("222222")
  26027. for _, item := range res3101.Output.Result {
  26028. if len(res3101.ErrMsg) == 0 {
  26029. res3101.ErrMsg = item.VolaCont
  26030. } else {
  26031. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  26032. }
  26033. }
  26034. c.ServeSuccessJSON(map[string]interface{}{
  26035. "failed_code": -10,
  26036. "msg": res3101.ErrMsg,
  26037. })
  26038. return
  26039. } else {
  26040. hour := time.Now().Format("15")
  26041. min := time.Now().Format("04")
  26042. sec := time.Now().Format("05")
  26043. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  26044. fmt.Println(record_time_two)
  26045. 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)
  26046. saveLog(result, requestLog, "2201A", "挂号")
  26047. if miConfig.Code == "H15049901371" {
  26048. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  26049. utils.ErrorLog("解析失败:%v", err)
  26050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26051. return
  26052. }
  26053. resThree.ErrMsg = resThree10265.ErrMsg
  26054. resThree.Output = resThree10265.Output
  26055. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  26056. } else {
  26057. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  26058. utils.ErrorLog("解析失败:%v", err)
  26059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26060. return
  26061. }
  26062. }
  26063. if miConfig.Code == "H15049901371" {
  26064. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  26065. } else {
  26066. infocode = resThree.Infcode
  26067. }
  26068. }
  26069. } else if res3101.Infcode != 0 {
  26070. c.ServeSuccessJSON(map[string]interface{}{
  26071. "failed_code": -10,
  26072. "msg": res3101.ErrMsg,
  26073. })
  26074. return
  26075. }
  26076. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26077. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  26078. psn_info, _ := service.GetPsnByPatientId(id)
  26079. var verify_number string
  26080. if id_card_type == 4 {
  26081. verify_number = psn_info.VerifyNumber
  26082. } else if id_card_type == 1 {
  26083. bas := strings.Split(psn_info.CardInfo, "|")
  26084. cardNumber := bas[2]
  26085. verify_number = cardNumber
  26086. } else {
  26087. verify_number = psn_info.Certno
  26088. }
  26089. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  26090. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  26091. "&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
  26092. resp, requestErr := http.Get(api)
  26093. if requestErr != nil {
  26094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26095. return
  26096. }
  26097. body, ioErr := ioutil.ReadAll(resp.Body)
  26098. if ioErr != nil {
  26099. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26101. return
  26102. }
  26103. var respJSON map[string]interface{}
  26104. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26105. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26107. return
  26108. }
  26109. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26110. result, _ := json.Marshal(respJSON)
  26111. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  26112. utils.ErrorLog("解析失败:%v", err)
  26113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26114. return
  26115. }
  26116. infocode = resThree.Infcode
  26117. } else {
  26118. hour := time.Now().Format("15")
  26119. min := time.Now().Format("04")
  26120. sec := time.Now().Format("05")
  26121. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  26122. if id_card_type == 1 {
  26123. for _, item := range rf {
  26124. if item.Insutype == strconv.FormatInt(social_type, 10) {
  26125. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  26126. insuplc_admdvs_temp = item.InsuplcAdmdvs
  26127. } else if strconv.FormatInt(social_type, 10) == "390" {
  26128. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  26129. } else {
  26130. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  26131. }
  26132. }
  26133. }
  26134. }
  26135. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  26136. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  26137. }
  26138. if id_card_type == 1 {
  26139. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  26140. bas := strings.Split(psn_info.CardInfo, "|")
  26141. basNumber := bas[1]
  26142. IdCardNo = basNumber
  26143. }
  26144. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  26145. IdCardNo = psn_info.VerifyNumber
  26146. }
  26147. if len(insuplc_admdvs_temp) == 0 {
  26148. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  26149. }
  26150. var result string
  26151. var requestLog string
  26152. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" || miConfig.Code == "H44090200998" {
  26153. var hisPrescription []*models.HisPrescription
  26154. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  26155. if res3101.Infcode == 0 {
  26156. if len(res3101.Output.Result) > 0 {
  26157. if len(res3101.Output.Result) > 0 {
  26158. c.ServeSuccessJSON(map[string]interface{}{
  26159. "failed_code": -10,
  26160. "failed_type": 100,
  26161. "warm_type": 1,
  26162. "msg": res3101,
  26163. })
  26164. return
  26165. } else {
  26166. c.ServeSuccessJSON(map[string]interface{}{
  26167. "failed_code": -10,
  26168. "msg": res3101.ErrMsg,
  26169. })
  26170. return
  26171. }
  26172. } else {
  26173. hour := time.Now().Format("15")
  26174. min := time.Now().Format("04")
  26175. sec := time.Now().Format("05")
  26176. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  26177. fmt.Println(record_time_two)
  26178. if his.IdCardType == 2 {
  26179. IdCardNo = psn_info.Certno
  26180. psn_info.VerifyNumber = psn_info.Certno
  26181. } else if his.IdCardType == 4 {
  26182. IdCardNo = psn_info.Certno
  26183. } else {
  26184. bas := strings.Split(psn_info.CardInfo, "|")
  26185. IdCardNo = bas[2]
  26186. }
  26187. aaaa = insutype
  26188. 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)
  26189. saveLog(result, requestLog, "2201A", "挂号")
  26190. if miConfig.Code == "H15049901371" {
  26191. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  26192. utils.ErrorLog("解析失败:%v", err)
  26193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26194. return
  26195. }
  26196. resThree.ErrMsg = resThree10265.ErrMsg
  26197. resThree.Output = resThree10265.Output
  26198. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  26199. } else {
  26200. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  26201. utils.ErrorLog("解析失败:%v", err)
  26202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26203. return
  26204. }
  26205. }
  26206. if miConfig.Code == "H15049901371" {
  26207. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  26208. } else {
  26209. infocode = resThree.Infcode
  26210. }
  26211. }
  26212. } else if res3101.Infcode != 0 {
  26213. c.ServeSuccessJSON(map[string]interface{}{
  26214. "failed_code": -10,
  26215. "msg": res3101.ErrMsg,
  26216. })
  26217. return
  26218. }
  26219. } else {
  26220. psn_info, _ := service.GetPsnByPatientId(id)
  26221. var rf []*ResultFive
  26222. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  26223. //var insutypes []*ResultFive
  26224. var insutype string
  26225. var insutypes []*ResultFive
  26226. var is390 int = 0
  26227. var is310 int = 0
  26228. for _, item := range rf {
  26229. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26230. insutypes = append(insutypes, item)
  26231. }
  26232. }
  26233. if len(insutypes) == 1 {
  26234. insutype = insutypes[0].Insutype
  26235. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  26236. } else {
  26237. for _, i := range insutypes {
  26238. if i.Insutype == "390" {
  26239. is390 = 1
  26240. }
  26241. if i.Insutype == "310" {
  26242. is310 = 1
  26243. }
  26244. }
  26245. }
  26246. if is390 == 1 {
  26247. insutype = "390"
  26248. }
  26249. if is310 == 1 {
  26250. insutype = "310"
  26251. }
  26252. if len(insutypes) == 0 {
  26253. insutype = "310"
  26254. }
  26255. if social_type > 0 {
  26256. insutype = strconv.FormatInt(social_type, 10)
  26257. }
  26258. for _, item := range rf {
  26259. if item.Insutype == insutype {
  26260. insuplc_admdvs_temp = item.InsuplcAdmdvs
  26261. }
  26262. }
  26263. if len(insuplc_admdvs_tt) > 0 {
  26264. insuplc_admdvs_temp = insuplc_admdvs_tt
  26265. }
  26266. 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)
  26267. saveLog(result, requestLog, "2201A", "挂号")
  26268. }
  26269. if miConfig.Code == "H15049901371" {
  26270. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  26271. utils.ErrorLog("解析失败:%v", err)
  26272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26273. return
  26274. }
  26275. resThree.ErrMsg = resThree10265.ErrMsg
  26276. resThree.Output = resThree10265.Output
  26277. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  26278. } else {
  26279. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  26280. utils.ErrorLog("解析失败:%v", err)
  26281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26282. return
  26283. }
  26284. }
  26285. if miConfig.Code == "H15049901371" {
  26286. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  26287. } else {
  26288. infocode = resThree.Infcode
  26289. }
  26290. }
  26291. }
  26292. if infocode == -1 {
  26293. adminUser := c.GetAdminUserInfo()
  26294. errlog := &models.HisOrderError{
  26295. UserOrgId: adminUser.CurrentOrgId,
  26296. Ctime: time.Now().Unix(),
  26297. Mtime: time.Now().Unix(),
  26298. ErrMsg: resThree.ErrMsg,
  26299. Status: 1,
  26300. PatientId: id,
  26301. RecordTime: recordDateTime,
  26302. Stage: 2,
  26303. }
  26304. service.CreateErrMsgLog(errlog)
  26305. c.ServeSuccessJSON(map[string]interface{}{
  26306. "failed_code": -10,
  26307. "msg": resThree.ErrMsg,
  26308. })
  26309. return
  26310. }
  26311. utils.ErrorLog("解析失败:%v", insutype)
  26312. his.Number = resThree.Output.Data.MdtrtID
  26313. his.PsnNo = resThree.Output.Data.PsnNo
  26314. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  26315. his.IdCardNo = patient.IdCardNo
  26316. his.PhoneNumber = patient.Phone
  26317. his.UserOrgId = adminInfo.CurrentOrgId
  26318. his.Insutype = insutype
  26319. if miConfig.Code == "H44030500255" {
  26320. his.Insutype = aaaa
  26321. }
  26322. his.Ctime = time.Now().Unix()
  26323. his.Mtime = time.Now().Unix()
  26324. his.InsuplcAdmdvs = insuplc_admdvs_temp
  26325. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  26326. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26327. }
  26328. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  26329. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26330. }
  26331. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  26332. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26333. }
  26334. his.Status = 1
  26335. his.MdtrtGrpType = mdtrt_type
  26336. service.UpdateHisPatientStatus(&his)
  26337. service.UpdateHisPatient123(&patient)
  26338. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  26339. c.ServeSuccessJSON(map[string]interface{}{
  26340. "his_info": his,
  26341. })
  26342. } else {
  26343. adminUser := c.GetAdminUserInfo()
  26344. errlog := &models.HisOrderError{
  26345. UserOrgId: adminUser.CurrentOrgId,
  26346. Ctime: time.Now().Unix(),
  26347. Mtime: time.Now().Unix(),
  26348. ErrMsg: res.ErrMsg,
  26349. Status: 1,
  26350. PatientId: id,
  26351. RecordTime: recordDateTime,
  26352. Stage: 1,
  26353. }
  26354. service.CreateErrMsgLog(errlog)
  26355. c.ServeSuccessJSON(map[string]interface{}{
  26356. "failed_code": -10,
  26357. "msg": res.ErrMsg,
  26358. })
  26359. return
  26360. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  26361. }
  26362. }
  26363. }
  26364. func (c *HisApiController) GetUploadInfo() {
  26365. id, _ := c.GetInt64("id")
  26366. record_time := c.GetString("record_time")
  26367. his_patient_id, _ := c.GetInt64("his_patient_id")
  26368. order_id, _ := c.GetInt64("order_id")
  26369. pay_way, _ := c.GetInt64("pay_way")
  26370. pay_ways := c.GetString("pay_ways")
  26371. oth_desc := c.GetString("oth_desc")
  26372. pack_num, _ := c.GetInt64("pack_num")
  26373. good_pack_num, _ := c.GetInt64("good_pack_num")
  26374. pay_price, _ := c.GetFloat("pay_price")
  26375. pay_card_no := c.GetString("pay_card_no")
  26376. discount_price, _ := c.GetFloat("discount_price")
  26377. preferential_price, _ := c.GetFloat("preferential_price")
  26378. reality_price, _ := c.GetFloat("reality_price")
  26379. found_price, _ := c.GetFloat("found_price")
  26380. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  26381. private_price, _ := c.GetFloat("private_price")
  26382. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  26383. admin_user_id, _ := c.GetInt64("admin_user_id")
  26384. fapiao_code := c.GetString("fapiao_code")
  26385. fapiao_number := c.GetString("fapiao_number")
  26386. diagnosis_id := c.GetString("diagnosis")
  26387. sick_type, _ := c.GetInt64("sick_type")
  26388. reg_type, _ := c.GetInt64("p_type")
  26389. begin_time := c.GetString("begin_time")
  26390. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  26391. cash_pay := c.GetString("cash_pay")
  26392. band_card_pay := c.GetString("band_card_pay")
  26393. wechat_pay := c.GetString("wechat_pay")
  26394. ali_pay := c.GetString("ali_pay")
  26395. jifen_pay := c.GetString("jifen_pay")
  26396. //jifen_pay := c.GetString("jifen_pay")
  26397. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  26398. fmt.Println(acct_used_flag)
  26399. id_str := c.GetString("ids")
  26400. ids_arr := strings.Split(id_str, ",")
  26401. timeLayout := "2006-01-02"
  26402. loc, _ := time.LoadLocation("Local")
  26403. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26404. if err != nil {
  26405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26406. return
  26407. }
  26408. recordDateTime := theTime.Unix()
  26409. adminUser := c.GetAdminUserInfo()
  26410. var tempOrder models.HisOrder
  26411. tempOrder, _ = service.GetHisOrderByID(order_id)
  26412. var prescriptions []*models.HisPrescription
  26413. var start_time int64
  26414. var end_time int64
  26415. //押金模块
  26416. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  26417. tmp_decimal := c.GetString("tmp_decimal")
  26418. var decimal float64 //本次使用的押金
  26419. var errmsg error
  26420. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  26421. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  26422. return
  26423. }
  26424. if len(tmp_decimal) > 0 {
  26425. if tmp_decimal[0] == 45 {
  26426. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  26427. return
  26428. }
  26429. }
  26430. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  26431. fmt.Println(errs)
  26432. decimal = tt
  26433. //if adminUser.CurrentOrgId == 10106{
  26434. // if len(fapiao_code) == 0{
  26435. // fapiao_code = "144072080589"
  26436. // }
  26437. // if len(fapiao_number) == 0{
  26438. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  26439. // if order.ID == 0{
  26440. // fapiao_number = "00001520"
  26441. // }else{
  26442. // //fapiao_code = "00001520"
  26443. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  26444. // var zero string
  26445. // if fpNumber >= 1000{
  26446. // zero = "0000" + strconv.Itoa(fpNumber)
  26447. // }else if fpNumber >= 10000{
  26448. // zero = "000" + strconv.Itoa(fpNumber)
  26449. // } else if fpNumber >= 100000{
  26450. // zero = "00" + strconv.Itoa(fpNumber)
  26451. // } else if fpNumber >= 1000000{
  26452. // zero = "0" + strconv.Itoa(fpNumber)
  26453. // }else {
  26454. // zero = strconv.Itoa(fpNumber)
  26455. // }
  26456. // fapiao_number = zero
  26457. // }
  26458. // }
  26459. //}
  26460. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26461. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  26462. var patientPrescription models.HisPrescriptionInfo
  26463. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  26464. if patientPrescription.ID == 0 {
  26465. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  26466. }
  26467. //if patientPrescription.Do
  26468. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26469. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26470. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  26471. diagnosis_ids := strings.Split(diagnosis_id, ",")
  26472. var config []*models.HisXtDiagnoseConfig
  26473. for _, item := range diagnosis_ids {
  26474. id, _ := strconv.ParseInt(item, 10, 64)
  26475. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26476. config = append(config, &diagnosisConfig)
  26477. }
  26478. sickConfig, _ := service.FindSickById(sick_type)
  26479. //if tempOrder.ID == 0 {
  26480. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  26481. //}
  26482. if tempOrder.ID == 0 {
  26483. var result string
  26484. var requestLog string
  26485. var res2 ResultSix
  26486. var res3 GZResultSix
  26487. var ressix10265 ResultSix10265
  26488. if miConfig.MdtrtareaAdmvs == "421300" {
  26489. data := make(map[string]interface{})
  26490. client := &http.Client{}
  26491. data["psn_no"] = his.PsnNo
  26492. data["mdtrt_id"] = his.Number
  26493. data["opter"] = roles.UserName
  26494. data["org_name"] = miConfig.OrgName
  26495. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26496. data["doctor_id"] = doctor_info.DoctorNumber
  26497. data["doctor_name"] = doctor_info.UserName
  26498. data["department"] = department.Name
  26499. data["fixmedins_code"] = miConfig.Code
  26500. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26501. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26502. data["secret_key"] = miConfig.SecretKey
  26503. data["sick_code"] = sickConfig.CountryCode
  26504. data["sick_name"] = sickConfig.ClassName
  26505. data["dept"] = strconv.FormatInt(department.ID, 10)
  26506. data["config"] = config
  26507. data["begin_time"] = begin_time
  26508. bytesData, _ := json.Marshal(data)
  26509. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  26510. resp, _ := client.Do(req)
  26511. defer resp.Body.Close()
  26512. body, ioErr := ioutil.ReadAll(resp.Body)
  26513. if ioErr != nil {
  26514. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26516. return
  26517. }
  26518. var respJSON map[string]interface{}
  26519. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26520. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26522. return
  26523. }
  26524. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26525. userJSONBytes, _ := json.Marshal(respJSON)
  26526. fmt.Println("log")
  26527. fmt.Println(string(userJSONBytes))
  26528. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26529. utils.ErrorLog("解析失败:%v", err)
  26530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26531. return
  26532. }
  26533. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26534. data := make(map[string]interface{})
  26535. client := &http.Client{}
  26536. data["psn_no"] = his.PsnNo
  26537. data["mdtrt_id"] = his.Number
  26538. data["opter"] = roles.UserName
  26539. data["org_name"] = miConfig.OrgName
  26540. if reg_type == 11 && his.Insutype == "390" {
  26541. data["med_type"] = "110104"
  26542. } else {
  26543. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26544. }
  26545. data["doctor_id"] = doctor_info.DoctorNumber
  26546. data["doctor_name"] = doctor_info.UserName
  26547. data["department"] = department.Name
  26548. data["fixmedins_code"] = miConfig.Code
  26549. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26550. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26551. data["secret_key"] = miConfig.SecretKey
  26552. data["sick_code"] = sickConfig.CountryCode
  26553. data["sick_name"] = sickConfig.ClassName
  26554. data["dept"] = strconv.FormatInt(department.ID, 10)
  26555. data["config"] = config
  26556. data["begin_time"] = begin_time
  26557. bytesData, _ := json.Marshal(data)
  26558. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  26559. resp, _ := client.Do(req)
  26560. defer resp.Body.Close()
  26561. body, ioErr := ioutil.ReadAll(resp.Body)
  26562. if ioErr != nil {
  26563. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26565. return
  26566. }
  26567. var respJSON map[string]interface{}
  26568. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26569. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26571. return
  26572. }
  26573. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26574. userJSONBytes, _ := json.Marshal(respJSON)
  26575. fmt.Println("log")
  26576. fmt.Println(string(userJSONBytes))
  26577. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26578. utils.ErrorLog("解析失败:%v", err)
  26579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26580. return
  26581. }
  26582. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26583. data := make(map[string]interface{})
  26584. client := &http.Client{}
  26585. data["psn_no"] = his.PsnNo
  26586. data["mdtrt_id"] = his.Number
  26587. data["opter"] = roles.UserName
  26588. data["org_name"] = miConfig.OrgName
  26589. if reg_type == 11 && his.Insutype == "390" {
  26590. data["med_type"] = "110104"
  26591. } else {
  26592. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26593. }
  26594. data["doctor_id"] = doctor_info.DoctorNumber
  26595. data["doctor_name"] = doctor_info.UserName
  26596. data["department"] = department.Name
  26597. data["fixmedins_code"] = miConfig.Code
  26598. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26599. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26600. data["secret_key"] = miConfig.SecretKey
  26601. data["sick_code"] = sickConfig.CountryCode
  26602. data["sick_name"] = sickConfig.ClassName
  26603. data["dept"] = strconv.FormatInt(department.ID, 10)
  26604. data["config"] = config
  26605. data["begin_time"] = begin_time
  26606. bytesData, _ := json.Marshal(data)
  26607. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26608. resp, _ := client.Do(req)
  26609. defer resp.Body.Close()
  26610. body, ioErr := ioutil.ReadAll(resp.Body)
  26611. if ioErr != nil {
  26612. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26614. return
  26615. }
  26616. var respJSON map[string]interface{}
  26617. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26620. return
  26621. }
  26622. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26623. userJSONBytes, _ := json.Marshal(respJSON)
  26624. fmt.Println("log")
  26625. fmt.Println(string(userJSONBytes))
  26626. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26627. utils.ErrorLog("解析失败:%v", err)
  26628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26629. return
  26630. }
  26631. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26632. data := make(map[string]interface{})
  26633. client := &http.Client{}
  26634. data["psn_no"] = his.PsnNo
  26635. data["mdtrt_id"] = his.Number
  26636. data["opter"] = roles.UserName
  26637. data["org_name"] = miConfig.OrgName
  26638. if reg_type == 11 && his.Insutype == "390" {
  26639. data["med_type"] = "110104"
  26640. } else {
  26641. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26642. }
  26643. data["doctor_id"] = doctor_info.DoctorNumber
  26644. data["doctor_name"] = doctor_info.UserName
  26645. data["department"] = department.Name
  26646. data["fixmedins_code"] = miConfig.Code
  26647. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26648. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26649. data["secret_key"] = miConfig.SecretKey
  26650. data["sick_code"] = sickConfig.CountryCode
  26651. data["sick_name"] = sickConfig.ClassName
  26652. data["dept"] = strconv.FormatInt(department.ID, 10)
  26653. data["config"] = config
  26654. data["begin_time"] = begin_time
  26655. bytesData, _ := json.Marshal(data)
  26656. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26657. resp, _ := client.Do(req)
  26658. defer resp.Body.Close()
  26659. body, ioErr := ioutil.ReadAll(resp.Body)
  26660. if ioErr != nil {
  26661. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26663. return
  26664. }
  26665. var respJSON map[string]interface{}
  26666. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26669. return
  26670. }
  26671. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26672. userJSONBytes, _ := json.Marshal(respJSON)
  26673. fmt.Println("log")
  26674. fmt.Println(string(userJSONBytes))
  26675. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26676. utils.ErrorLog("解析失败:%v", err)
  26677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26678. return
  26679. }
  26680. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  26681. utils.ErrorLog("解析失败:%v", doctor_info)
  26682. data := make(map[string]interface{})
  26683. client := &http.Client{}
  26684. data["psn_no"] = his.PsnNo
  26685. data["mdtrt_id"] = his.Number
  26686. data["doctor"] = roles.UserName
  26687. data["department"] = department.Name
  26688. data["org_name"] = miConfig.OrgName
  26689. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26690. data["doctor_id"] = doctor_info.DoctorNumber
  26691. data["new_doctor_name"] = doctor_info.UserName
  26692. data["fixmedins_code"] = miConfig.Code
  26693. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26694. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26695. data["secret_key"] = miConfig.SecretKey
  26696. data["sick_code"] = sickConfig.CountryCode
  26697. data["sick_name"] = sickConfig.ClassName
  26698. data["url"] = miConfig.Url
  26699. data["ak"] = miConfig.AccessKey
  26700. data["begin_time"] = begin_time
  26701. data["cainfo"] = miConfig.Cainfo
  26702. data["dept"] = strconv.FormatInt(department.ID, 10)
  26703. data["config"] = config
  26704. bytesData, _ := json.Marshal(data)
  26705. var req *http.Request
  26706. if miConfig.MdtrtareaAdmvs == "320830" {
  26707. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2203", bytes.NewReader(bytesData))
  26708. //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 +
  26709. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  26710. } else if miConfig.MdtrtareaAdmvs == "320921" {
  26711. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26712. //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 +
  26713. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  26714. } else {
  26715. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26716. }
  26717. resp, _ := client.Do(req)
  26718. defer resp.Body.Close()
  26719. body, ioErr := ioutil.ReadAll(resp.Body)
  26720. if ioErr != nil {
  26721. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26723. return
  26724. }
  26725. var respJSON map[string]interface{}
  26726. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26727. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26729. return
  26730. }
  26731. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26732. userJSONBytes, _ := json.Marshal(respJSON)
  26733. fmt.Println("log")
  26734. fmt.Println(string(userJSONBytes))
  26735. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  26736. utils.ErrorLog("解析失败:%v", err)
  26737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26738. return
  26739. }
  26740. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26741. res2.Output = ressix10265.Output
  26742. res2.ErrMsg = ressix10265.ErrMsg
  26743. res2.Cainfo = ressix10265.Cainfo
  26744. res2.WarnMsg = ressix10265.WarnMsg
  26745. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26746. res2.Infcode = infocode
  26747. } else if miConfig.MdtrtareaAdmvs == "150404" {
  26748. data := make(map[string]interface{})
  26749. client := &http.Client{}
  26750. data["psn_no"] = his.PsnNo
  26751. data["mdtrt_id"] = his.Number
  26752. data["doctor"] = roles.UserName
  26753. data["department"] = department.Name
  26754. data["org_name"] = miConfig.OrgName
  26755. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26756. data["doctor_id"] = doctor_info.DoctorNumber
  26757. data["new_doctor_name"] = doctor_info.UserName
  26758. data["fixmedins_code"] = miConfig.Code
  26759. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26760. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26761. data["secret_key"] = miConfig.SecretKey
  26762. data["sick_code"] = sickConfig.CountryCode
  26763. data["sick_name"] = sickConfig.ClassName
  26764. data["url"] = miConfig.Url
  26765. data["ak"] = miConfig.AccessKey
  26766. data["begin_time"] = begin_time
  26767. data["cainfo"] = miConfig.Cainfo
  26768. data["dept"] = strconv.FormatInt(department.ID, 10)
  26769. data["config"] = config
  26770. bytesData, _ := json.Marshal(data)
  26771. var req *http.Request
  26772. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  26773. resp, _ := client.Do(req)
  26774. defer resp.Body.Close()
  26775. body, ioErr := ioutil.ReadAll(resp.Body)
  26776. if ioErr != nil {
  26777. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26779. return
  26780. }
  26781. var respJSON map[string]interface{}
  26782. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26785. return
  26786. }
  26787. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26788. userJSONBytes, _ := json.Marshal(respJSON)
  26789. fmt.Println("log")
  26790. fmt.Println(string(userJSONBytes))
  26791. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  26792. utils.ErrorLog("解析失败:%v", err)
  26793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26794. return
  26795. }
  26796. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26797. res2.Output = ressix10265.Output
  26798. res2.ErrMsg = ressix10265.ErrMsg
  26799. res2.Cainfo = ressix10265.Cainfo
  26800. res2.WarnMsg = ressix10265.WarnMsg
  26801. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26802. res2.Infcode = infocode
  26803. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26804. 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)
  26805. saveLog(result, requestLog, "2203", "上传就诊信息")
  26806. var respJSON2 map[string]interface{}
  26807. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26810. return
  26811. }
  26812. userJSONBytes2, _ := json.Marshal(respJSON2)
  26813. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26814. utils.ErrorLog("解析失败:%v", err)
  26815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26816. return
  26817. }
  26818. 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)
  26819. fmt.Println(result2)
  26820. fmt.Println(src_request)
  26821. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26822. data := make(map[string]interface{})
  26823. client := &http.Client{}
  26824. data["psn_no"] = his.PsnNo
  26825. data["mdtrt_id"] = his.Number
  26826. data["doctor"] = roles.UserName
  26827. data["department"] = department.Name
  26828. data["org_name"] = miConfig.OrgName
  26829. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26830. data["doctor_id"] = doctor_info.DoctorNumber
  26831. data["new_doctor_name"] = doctor_info.UserName
  26832. data["fixmedins_code"] = miConfig.Code
  26833. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26834. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26835. data["secret_key"] = miConfig.SecretKey
  26836. data["sick_code"] = sickConfig.CountryCode
  26837. data["sick_name"] = sickConfig.ClassName
  26838. data["url"] = miConfig.Url
  26839. data["ak"] = miConfig.AccessKey
  26840. data["begin_time"] = begin_time
  26841. data["cainfo"] = miConfig.Cainfo
  26842. data["dept"] = strconv.FormatInt(department.ID, 10)
  26843. data["config"] = config
  26844. bytesData, _ := json.Marshal(data)
  26845. var req *http.Request
  26846. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  26847. resp, _ := client.Do(req)
  26848. defer resp.Body.Close()
  26849. body, ioErr := ioutil.ReadAll(resp.Body)
  26850. if ioErr != nil {
  26851. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26853. return
  26854. }
  26855. var respJSON map[string]interface{}
  26856. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26857. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26859. return
  26860. }
  26861. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26862. userJSONBytes, _ := json.Marshal(respJSON)
  26863. fmt.Println("log")
  26864. fmt.Println(string(userJSONBytes))
  26865. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26866. utils.ErrorLog("解析失败:%v", err)
  26867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26868. return
  26869. }
  26870. } else {
  26871. if miConfig.MdtrtareaAdmvs == "440781" { //
  26872. 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)
  26873. } else {
  26874. if miConfig.Code == "H15049901371" {
  26875. //赤峰地区国家医保医疗类别
  26876. //职工透析:医疗类别选特殊情况门诊990502
  26877. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26878. var med_type string
  26879. if his.Insutype == "390" {
  26880. if reg_type == 14 {
  26881. med_type = "9933"
  26882. } else if reg_type == 11 {
  26883. med_type = "11"
  26884. }
  26885. } else if his.Insutype == "310" {
  26886. if reg_type == 14 {
  26887. med_type = "990502"
  26888. } else if reg_type == 11 {
  26889. med_type = "11"
  26890. }
  26891. }
  26892. 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)
  26893. } else {
  26894. 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)
  26895. }
  26896. }
  26897. saveLog(result, requestLog, "2203", "上传就诊信息")
  26898. var respJSON2 map[string]interface{}
  26899. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26902. return
  26903. }
  26904. userJSONBytes2, _ := json.Marshal(respJSON2)
  26905. if miConfig.Code == "H15049901371" {
  26906. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  26907. utils.ErrorLog("解析失败:%v", err)
  26908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26909. return
  26910. }
  26911. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26912. res2.Output = ressix10265.Output
  26913. res2.ErrMsg = ressix10265.ErrMsg
  26914. res2.Cainfo = ressix10265.Cainfo
  26915. res2.WarnMsg = ressix10265.WarnMsg
  26916. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26917. res2.Infcode = infocode
  26918. } else {
  26919. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26920. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  26921. utils.ErrorLog("解析失败:%v", err)
  26922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26923. return
  26924. }
  26925. res2.Infcode = res3.Infcode
  26926. } else {
  26927. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26928. utils.ErrorLog("解析失败:%v", err)
  26929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26930. return
  26931. }
  26932. }
  26933. }
  26934. }
  26935. if res2.Infcode == -1 {
  26936. adminUser := c.GetAdminUserInfo()
  26937. errlog := &models.HisOrderError{
  26938. UserOrgId: adminUser.CurrentOrgId,
  26939. Ctime: time.Now().Unix(),
  26940. Mtime: time.Now().Unix(),
  26941. ErrMsg: res2.ErrMsg,
  26942. Status: 1,
  26943. PatientId: id,
  26944. RecordTime: recordDateTime,
  26945. Stage: 3,
  26946. }
  26947. service.CreateErrMsgLog(errlog)
  26948. c.ServeSuccessJSON(map[string]interface{}{
  26949. "failed_code": -10,
  26950. "msg": res2.ErrMsg,
  26951. })
  26952. return
  26953. } else {
  26954. his.Diagnosis = diagnosis_id
  26955. his.SickType = sickConfig.ID
  26956. //var p_type int64
  26957. //if reg_type == 1111 || reg_type == 1112 {
  26958. // p_type = 11
  26959. //
  26960. //}
  26961. his.PType = fmt.Sprintf("%d", reg_type)
  26962. service.UpdateHisPatientThree(&his)
  26963. data := make(map[string]interface{})
  26964. if settle_accounts_type == 1 { //日结
  26965. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  26966. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  26967. } else {
  26968. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  26969. }
  26970. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  26971. data["pre"] = prescriptions
  26972. } else { //月结
  26973. start_time_str := c.GetString("start_time")
  26974. end_time_str := c.GetString("end_time")
  26975. timeLayout := "2006-01-02"
  26976. loc, _ := time.LoadLocation("Local")
  26977. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  26978. if err != nil {
  26979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26980. return
  26981. }
  26982. recordStartTime := theStartTime.Unix()
  26983. start_time = recordStartTime
  26984. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  26985. if err != nil {
  26986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26987. return
  26988. }
  26989. recordEndTime := theEndTime.Unix()
  26990. end_time = recordEndTime
  26991. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  26992. data["pre"] = prescriptions
  26993. }
  26994. timestamp := time.Now().Unix()
  26995. tempTime := time.Unix(timestamp, 0)
  26996. timeFormat := tempTime.Format("20060102150405")
  26997. chrgBchno := rand.Intn(100000) + 10000
  26998. new_chrg_bchno := ""
  26999. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  27000. new_chrg_bchno = chrg_bchno
  27001. strconv.FormatInt(his.PatientId, 10)
  27002. client := &http.Client{}
  27003. if adminUser.CurrentOrgId == 10265 {
  27004. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27005. new_chrg_bchno = "0000"
  27006. }
  27007. }
  27008. data["psn_no"] = his.PsnNo
  27009. data["mdtrt_id"] = his.Number
  27010. data["chrg_bchno"] = new_chrg_bchno
  27011. data["org_name"] = miConfig.OrgName
  27012. data["doctor"] = doctor_info.UserName
  27013. data["doctor_id"] = doctor_info.DoctorNumber
  27014. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  27015. data["fixmedins_code"] = miConfig.Code
  27016. data["dept_code"] = department.Number
  27017. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27018. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27019. data["secret_key"] = miConfig.SecretKey
  27020. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  27021. data["url"] = miConfig.Url
  27022. data["ak"] = miConfig.AccessKey
  27023. data["new_doctor_name"] = patientPrescription.Doctor
  27024. data["diag_code"] = sickConfig.CountryCode
  27025. data["cainfo"] = miConfig.Cainfo
  27026. data["opter"] = roles.UserName
  27027. var ids []int64
  27028. for _, item := range prescriptions {
  27029. ids = append(ids, item.ID)
  27030. }
  27031. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27032. if config.IsOpen == 1 { //对接了医保,走医保流程
  27033. var res ResultFour
  27034. var resFour10265 ResultFour10265
  27035. if miConfig.MdtrtareaAdmvs == "421300" {
  27036. bytesData, _ := json.Marshal(data)
  27037. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  27038. resp, _ := client.Do(req)
  27039. defer resp.Body.Close()
  27040. body, ioErr := ioutil.ReadAll(resp.Body)
  27041. if ioErr != nil {
  27042. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27044. return
  27045. }
  27046. var respJSON map[string]interface{}
  27047. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27048. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27050. return
  27051. }
  27052. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27053. userJSONBytes, _ := json.Marshal(respJSON)
  27054. fmt.Println("log")
  27055. fmt.Println(string(userJSONBytes))
  27056. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27057. utils.ErrorLog("解析失败:%v", err)
  27058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27059. return
  27060. }
  27061. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27062. bytesData, _ := json.Marshal(data)
  27063. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  27064. resp, _ := client.Do(req)
  27065. defer resp.Body.Close()
  27066. body, ioErr := ioutil.ReadAll(resp.Body)
  27067. if ioErr != nil {
  27068. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27070. return
  27071. }
  27072. var respJSON map[string]interface{}
  27073. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27074. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27076. return
  27077. }
  27078. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27079. userJSONBytes, _ := json.Marshal(respJSON)
  27080. fmt.Println("log")
  27081. fmt.Println(string(userJSONBytes))
  27082. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27083. utils.ErrorLog("解析失败:%v", err)
  27084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27085. return
  27086. }
  27087. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27088. bytesData, _ := json.Marshal(data)
  27089. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  27090. resp, _ := client.Do(req)
  27091. defer resp.Body.Close()
  27092. body, ioErr := ioutil.ReadAll(resp.Body)
  27093. if ioErr != nil {
  27094. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27096. return
  27097. }
  27098. var respJSON map[string]interface{}
  27099. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27100. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27102. return
  27103. }
  27104. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27105. userJSONBytes, _ := json.Marshal(respJSON)
  27106. fmt.Println("log")
  27107. fmt.Println(string(userJSONBytes))
  27108. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27109. utils.ErrorLog("解析失败:%v", err)
  27110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27111. return
  27112. }
  27113. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27114. bytesData, _ := json.Marshal(data)
  27115. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  27116. resp, _ := client.Do(req)
  27117. defer resp.Body.Close()
  27118. body, ioErr := ioutil.ReadAll(resp.Body)
  27119. if ioErr != nil {
  27120. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27122. return
  27123. }
  27124. var respJSON map[string]interface{}
  27125. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27128. return
  27129. }
  27130. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27131. userJSONBytes, _ := json.Marshal(respJSON)
  27132. fmt.Println("log")
  27133. fmt.Println(string(userJSONBytes))
  27134. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27135. utils.ErrorLog("解析失败:%v", err)
  27136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27137. return
  27138. }
  27139. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  27140. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  27141. var result3101 Result3101
  27142. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  27143. result3101.Infcode = "0"
  27144. if result3101.Infcode == "0" {
  27145. if len(result3101.Output.Result) > 0 {
  27146. var errMsgs []string
  27147. for _, item := range result3101.Output.Result {
  27148. errMsgs = append(errMsgs, item.VolaCont)
  27149. }
  27150. c.ServeSuccessJSON(map[string]interface{}{
  27151. "failed_code": -10,
  27152. "msg": errMsgs,
  27153. })
  27154. return
  27155. }
  27156. }
  27157. bytesData, _ := json.Marshal(data)
  27158. var req *http.Request
  27159. if miConfig.MdtrtareaAdmvs == "320830" {
  27160. data["diag_code"] = sickConfig.CountryCode
  27161. fmt.Println(data)
  27162. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2204", bytes.NewReader(bytesData))
  27163. } else if miConfig.MdtrtareaAdmvs == "320921" {
  27164. data["diag_code"] = sickConfig.CountryCode
  27165. fmt.Println(data)
  27166. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27167. } else {
  27168. data["diag_code"] = sickConfig.CountryCode
  27169. fmt.Println(data)
  27170. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27171. }
  27172. resp, _ := client.Do(req)
  27173. defer resp.Body.Close()
  27174. body, ioErr := ioutil.ReadAll(resp.Body)
  27175. if ioErr != nil {
  27176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27178. return
  27179. }
  27180. var respJSON map[string]interface{}
  27181. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27184. return
  27185. }
  27186. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27187. userJSONBytes, _ := json.Marshal(respJSON)
  27188. fmt.Println("log")
  27189. fmt.Println(string(userJSONBytes))
  27190. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27191. utils.ErrorLog("解析失败:%v", err)
  27192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27193. return
  27194. }
  27195. res.InfRefmsgid = resFour10265.InfRefmsgid
  27196. res.Output = resFour10265.Output
  27197. res.ErrMsg = resFour10265.ErrMsg
  27198. res.Cainfo = resFour10265.Cainfo
  27199. res.WarnMsg = resFour10265.WarnMsg
  27200. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27201. res.Infcode = infocode
  27202. } else if miConfig.MdtrtareaAdmvs == "150404" {
  27203. var pagesize int = 2
  27204. var start int = 1
  27205. var stop int
  27206. var pagecount int
  27207. var curpage int
  27208. var isSuccess bool = true
  27209. data["doctor_id"] = doctor_info.DoctorNumber
  27210. //总页数,向上取整,注意除之前要先转换类型为float64
  27211. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  27212. for curpage = 1; curpage <= pagecount; curpage++ {
  27213. if curpage == 1 {
  27214. start = 1
  27215. } else {
  27216. start = (curpage-1)*pagesize + 1
  27217. }
  27218. stop = curpage * pagesize
  27219. if stop > len(prescriptions) {
  27220. stop = len(prescriptions)
  27221. }
  27222. //var requestLog string
  27223. data["pre"] = prescriptions[start-1 : stop]
  27224. fmt.Println(data["pre"])
  27225. bytesData, _ := json.Marshal(data)
  27226. var req *http.Request
  27227. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  27228. resp, _ := client.Do(req)
  27229. defer resp.Body.Close()
  27230. body, ioErr := ioutil.ReadAll(resp.Body)
  27231. if ioErr != nil {
  27232. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27234. return
  27235. }
  27236. var respJSON map[string]interface{}
  27237. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27238. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27240. return
  27241. }
  27242. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27243. userJSONBytes, _ := json.Marshal(respJSON)
  27244. fmt.Println("log")
  27245. fmt.Println(string(userJSONBytes))
  27246. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27247. utils.ErrorLog("解析失败:%v", err)
  27248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27249. return
  27250. }
  27251. res.InfRefmsgid = resFour10265.InfRefmsgid
  27252. res.Output = resFour10265.Output
  27253. res.ErrMsg = resFour10265.ErrMsg
  27254. res.Cainfo = resFour10265.Cainfo
  27255. res.WarnMsg = resFour10265.WarnMsg
  27256. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27257. res.Infcode = infocode
  27258. if infocode == 0 {
  27259. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  27260. } else {
  27261. isSuccess = false
  27262. errlog := &models.HisOrderError{
  27263. UserOrgId: adminUser.CurrentOrgId,
  27264. Ctime: time.Now().Unix(),
  27265. Mtime: time.Now().Unix(),
  27266. Number: chrg_bchno,
  27267. ErrMsg: "",
  27268. Status: 1,
  27269. PatientId: id,
  27270. RecordTime: recordDateTime,
  27271. Stage: 4,
  27272. }
  27273. service.CreateErrMsgLog(errlog)
  27274. c.ServeSuccessJSON(map[string]interface{}{
  27275. "failed_code": -10,
  27276. "msg": res.ErrMsg,
  27277. })
  27278. return
  27279. }
  27280. }
  27281. if isSuccess {
  27282. res.Infcode = 0
  27283. }
  27284. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27285. 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)
  27286. var dat map[string]interface{}
  27287. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27288. fmt.Println(dat)
  27289. } else {
  27290. fmt.Println(err)
  27291. }
  27292. saveLog(result, request_log, "2204", "上传费用明细")
  27293. userJSONBytes, _ := json.Marshal(dat)
  27294. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27295. utils.ErrorLog("解析失败:%v", err)
  27296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27297. return
  27298. }
  27299. res.InfRefmsgid = resFour10265.InfRefmsgid
  27300. res.Output = resFour10265.Output
  27301. res.ErrMsg = resFour10265.ErrMsg
  27302. res.Cainfo = resFour10265.Cainfo
  27303. res.WarnMsg = resFour10265.WarnMsg
  27304. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27305. res.Infcode = infocode
  27306. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27307. bytesData, _ := json.Marshal(data)
  27308. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  27309. resp, _ := client.Do(req)
  27310. defer resp.Body.Close()
  27311. body, ioErr := ioutil.ReadAll(resp.Body)
  27312. if ioErr != nil {
  27313. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27315. return
  27316. }
  27317. var respJSON map[string]interface{}
  27318. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27319. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27321. return
  27322. }
  27323. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27324. userJSONBytes, _ := json.Marshal(respJSON)
  27325. fmt.Println("log")
  27326. fmt.Println(string(userJSONBytes))
  27327. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27328. utils.ErrorLog("解析失败:%v", err)
  27329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27330. return
  27331. }
  27332. } else {
  27333. if miConfig.Code == "H15049901371" {
  27334. 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)
  27335. var dat map[string]interface{}
  27336. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27337. fmt.Println(dat)
  27338. } else {
  27339. fmt.Println(err)
  27340. }
  27341. saveLog(result, request_log, "2204", "上传费用明细")
  27342. userJSONBytes, _ := json.Marshal(dat)
  27343. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27344. utils.ErrorLog("解析失败:%v", err)
  27345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27346. return
  27347. }
  27348. res.InfRefmsgid = resFour10265.InfRefmsgid
  27349. res.Output = resFour10265.Output
  27350. res.ErrMsg = resFour10265.ErrMsg
  27351. res.Cainfo = resFour10265.Cainfo
  27352. res.WarnMsg = resFour10265.WarnMsg
  27353. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27354. res.Infcode = infocode
  27355. } else {
  27356. 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)
  27357. var dat map[string]interface{}
  27358. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27359. fmt.Println(dat)
  27360. } else {
  27361. fmt.Println(err)
  27362. }
  27363. saveLog(result, request_log, "2204", "上传费用明细")
  27364. userJSONBytes, _ := json.Marshal(dat)
  27365. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27366. utils.ErrorLog("解析失败:%v", err)
  27367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27368. return
  27369. }
  27370. }
  27371. }
  27372. if res.Infcode == 0 {
  27373. order := &models.HisOrder{
  27374. UserOrgId: adminUser.CurrentOrgId,
  27375. HisPatientId: his.ID,
  27376. PatientId: his.PatientId,
  27377. SettleAccountsDate: recordDateTime,
  27378. MdtrtId: his.Number,
  27379. PsnNo: his.PsnNo,
  27380. MedType: strconv.FormatInt(reg_type, 10),
  27381. Ctime: time.Now().Unix(),
  27382. Mtime: time.Now().Unix(),
  27383. Status: 1,
  27384. Number: chrg_bchno,
  27385. Infcode: res.Infcode,
  27386. WarnMsg: res.WarnMsg,
  27387. Cainfo: res.Cainfo,
  27388. ErrMsg: res.ErrMsg,
  27389. RespondTime: res.RefmsgTime,
  27390. InfRefmsgid: res.InfRefmsgid,
  27391. OrderStatus: 1,
  27392. PayWay: pay_way,
  27393. PayWays: pay_ways,
  27394. OthDesc: oth_desc,
  27395. PayPrice: pay_price,
  27396. PayCardNo: pay_card_no,
  27397. DiscountPrice: discount_price,
  27398. PreferentialPrice: preferential_price,
  27399. RealityPrice: reality_price,
  27400. FoundPrice: found_price,
  27401. MedicalInsurancePrice: medical_insurance_price,
  27402. PrivatePrice: private_price,
  27403. IsMedicineInsurance: 1,
  27404. SettleType: settle_accounts_type,
  27405. SettleStartTime: start_time,
  27406. SettleEndTime: end_time,
  27407. Creator: roles.AdminUserId,
  27408. Modify: roles.AdminUserId,
  27409. FaPiaoNumber: fapiao_number,
  27410. FaPiaoCode: fapiao_code,
  27411. PType: 2,
  27412. Diagnosis: diagnosis_id,
  27413. CashPay: cash_pay,
  27414. WechatPay: wechat_pay,
  27415. AliPay: ali_pay,
  27416. JifenPay: jifen_pay,
  27417. BandCardPay: band_card_pay,
  27418. }
  27419. err = service.CreateOrder(order)
  27420. if err != nil {
  27421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  27422. return
  27423. }
  27424. for _, item := range res.Output.Result {
  27425. temp := strings.Split(item.FeedetlSn, "-")
  27426. var advice_id int64 = 0
  27427. var project_id int64 = 0
  27428. var types int64 = 0
  27429. id, _ := strconv.ParseInt(temp[2], 10, 64)
  27430. types, _ = strconv.ParseInt(temp[1], 10, 64)
  27431. if temp[1] == "1" {
  27432. advice_id = id
  27433. project_id = 0
  27434. } else if temp[1] == "2" {
  27435. advice_id = 0
  27436. project_id = id
  27437. }
  27438. if item.MedChrgitmType == "9" {
  27439. item.MedChrgitmType = "09"
  27440. }
  27441. info := &models.HisOrderInfo{
  27442. OrderNumber: order.Number,
  27443. FeedetlSn: item.FeedetlSn,
  27444. UploadDate: time.Now().Unix(),
  27445. AdviceId: advice_id,
  27446. DetItemFeeSumamt: item.DetItemFeeSumamt,
  27447. Cnt: item.Cnt,
  27448. Pric: float64(item.Pric),
  27449. PatientId: his.PatientId,
  27450. PricUplmtAmt: item.PricUplmtAmt,
  27451. SelfpayProp: item.SelfpayProp,
  27452. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  27453. OverlmtAmt: item.OverlmtAmt,
  27454. PreselfpayAmt: item.PreselfpayAmt,
  27455. BasMednFlag: item.BasMednFlag,
  27456. MedChrgitmType: item.MedChrgitmType,
  27457. HiNegoDrugFlag: item.HiNegoDrugFlag,
  27458. Status: 1,
  27459. Memo: item.Memo,
  27460. Mtime: time.Now().Unix(),
  27461. InscpScpAmt: item.InscpScpAmt,
  27462. DrtReimFlag: item.DrtReimFlag,
  27463. Ctime: time.Now().Unix(),
  27464. ListSpItemFlag: item.ListSpItemFlag,
  27465. ChldMedcFlag: item.ChldMedcFlag,
  27466. LmtUsedFlag: item.LmtUsedFlag,
  27467. ChrgitmLv: item.ChrgitmLv,
  27468. UserOrgId: adminUser.CurrentOrgId,
  27469. HisPatientId: his.ID,
  27470. OrderId: order.ID,
  27471. ProjectId: project_id,
  27472. Type: types,
  27473. }
  27474. service.CreateOrderInfo(info)
  27475. }
  27476. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  27477. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  27478. var total float64
  27479. for _, item := range prescriptions {
  27480. if item.Type == 1 { //药品
  27481. for _, subItem := range item.HisDoctorAdviceInfo {
  27482. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27483. total_one := price * subItem.PrescribingNumber
  27484. total = total + total_one
  27485. }
  27486. }
  27487. if item.Type == 2 { //项目
  27488. for _, subItem := range item.HisPrescriptionProject {
  27489. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  27490. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27491. total_one := price * cnt
  27492. total = total + total_one
  27493. }
  27494. }
  27495. }
  27496. allTotal := fmt.Sprintf("%.2f", total)
  27497. //if adminUser.CurrentOrgId == 9919 {
  27498. //
  27499. // allTotal = fmt.Sprintf("%.2f", total)
  27500. //
  27501. //} else {
  27502. //
  27503. // allTotal = fmt.Sprintf("%.2f", total)
  27504. //
  27505. //}
  27506. if res.Infcode == 0 {
  27507. var rf []*ResultFive
  27508. json.Unmarshal([]byte(his.Iinfo), &rf)
  27509. chrg_bchno := chrg_bchno
  27510. cert_no := his.Certno
  27511. var insutypes []string
  27512. var insutype string
  27513. var is390 int = 0
  27514. var is310 int = 0
  27515. for _, item := range rf {
  27516. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27517. insutypes = append(insutypes, item.Insutype)
  27518. }
  27519. }
  27520. if len(insutypes) == 1 {
  27521. insutype = insutypes[0]
  27522. } else {
  27523. for _, i := range insutypes {
  27524. if i == "390" {
  27525. is390 = 1
  27526. }
  27527. if i == "310" {
  27528. is310 = 1
  27529. }
  27530. }
  27531. }
  27532. if is390 == 1 {
  27533. insutype = "390"
  27534. }
  27535. if is310 == 1 {
  27536. insutype = "310"
  27537. }
  27538. if len(insutypes) == 0 {
  27539. insutype = "310"
  27540. }
  27541. if len(insutypes) == 2 {
  27542. insutype = strconv.FormatInt(his.SocialType, 10)
  27543. }
  27544. insutype = strconv.FormatInt(his.SocialType, 10)
  27545. //insutype = "390"
  27546. if his.IdCardType == 1 {
  27547. // cert_no = his.MedicalInsuranceNumber
  27548. cert_no = his.Certno
  27549. } else {
  27550. cert_no = his.Certno
  27551. }
  27552. var res ResultSeven
  27553. var resSeven10265 ResultSeven10265
  27554. var gzresSeven10265Two GZResultSeven10265Two
  27555. var src_resquest string
  27556. var result2 string
  27557. if miConfig.MdtrtareaAdmvs == "421300" {
  27558. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27559. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27560. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27561. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27562. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27563. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27564. "&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)
  27565. resp, requestErr := http.Get(api)
  27566. if requestErr != nil {
  27567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27568. return
  27569. }
  27570. body, ioErr := ioutil.ReadAll(resp.Body)
  27571. if ioErr != nil {
  27572. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27574. return
  27575. }
  27576. var respJSON map[string]interface{}
  27577. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27578. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27580. return
  27581. }
  27582. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27583. result, _ := json.Marshal(respJSON)
  27584. if miConfig.Code == "H15049901371" {
  27585. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27586. utils.ErrorLog("解析失败:%v", err)
  27587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27588. return
  27589. }
  27590. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27591. res.Output = resSeven10265.Output
  27592. res.ErrMsg = resSeven10265.ErrMsg
  27593. res.Cainfo = resSeven10265.Cainfo
  27594. res.WarnMsg = resSeven10265.WarnMsg
  27595. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27596. res.Infcode = infocode
  27597. } else {
  27598. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27599. utils.ErrorLog("解析失败:%v", err)
  27600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27601. return
  27602. }
  27603. }
  27604. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27605. if reg_type == 11 && his.Insutype == "390" {
  27606. reg_type = 110104
  27607. }
  27608. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27609. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27610. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27611. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27612. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27613. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27614. "&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)
  27615. resp, requestErr := http.Get(api)
  27616. if requestErr != nil {
  27617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27618. return
  27619. }
  27620. body, ioErr := ioutil.ReadAll(resp.Body)
  27621. if ioErr != nil {
  27622. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27624. return
  27625. }
  27626. var respJSON map[string]interface{}
  27627. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27630. return
  27631. }
  27632. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27633. result, _ := json.Marshal(respJSON)
  27634. if miConfig.Code == "H15049901371" {
  27635. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27636. utils.ErrorLog("解析失败:%v", err)
  27637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27638. return
  27639. }
  27640. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27641. res.Output = resSeven10265.Output
  27642. res.ErrMsg = resSeven10265.ErrMsg
  27643. res.Cainfo = resSeven10265.Cainfo
  27644. res.WarnMsg = resSeven10265.WarnMsg
  27645. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27646. res.Infcode = infocode
  27647. } else {
  27648. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27649. utils.ErrorLog("解析失败:%v", err)
  27650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27651. return
  27652. }
  27653. }
  27654. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27655. if reg_type == 11 && his.Insutype == "390" {
  27656. reg_type = 110104
  27657. }
  27658. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27659. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27660. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27661. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27662. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27663. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27664. "&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)
  27665. resp, requestErr := http.Get(api)
  27666. if requestErr != nil {
  27667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27668. return
  27669. }
  27670. body, ioErr := ioutil.ReadAll(resp.Body)
  27671. if ioErr != nil {
  27672. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27674. return
  27675. }
  27676. var respJSON map[string]interface{}
  27677. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27678. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27680. return
  27681. }
  27682. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27683. result, _ := json.Marshal(respJSON)
  27684. if miConfig.Code == "H15049901371" {
  27685. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27686. utils.ErrorLog("解析失败:%v", err)
  27687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27688. return
  27689. }
  27690. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27691. res.Output = resSeven10265.Output
  27692. res.ErrMsg = resSeven10265.ErrMsg
  27693. res.Cainfo = resSeven10265.Cainfo
  27694. res.WarnMsg = resSeven10265.WarnMsg
  27695. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27696. res.Infcode = infocode
  27697. } else {
  27698. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27699. utils.ErrorLog("解析失败:%v", err)
  27700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27701. return
  27702. }
  27703. }
  27704. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27705. if reg_type == 11 && his.Insutype == "390" {
  27706. reg_type = 110104
  27707. }
  27708. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27709. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27710. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27711. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27712. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27713. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27714. "&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)
  27715. resp, requestErr := http.Get(api)
  27716. if requestErr != nil {
  27717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27718. return
  27719. }
  27720. body, ioErr := ioutil.ReadAll(resp.Body)
  27721. if ioErr != nil {
  27722. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27724. return
  27725. }
  27726. var respJSON map[string]interface{}
  27727. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27728. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27730. return
  27731. }
  27732. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27733. result, _ := json.Marshal(respJSON)
  27734. if miConfig.Code == "H15049901371" {
  27735. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27736. utils.ErrorLog("解析失败:%v", err)
  27737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27738. return
  27739. }
  27740. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27741. res.Output = resSeven10265.Output
  27742. res.ErrMsg = resSeven10265.ErrMsg
  27743. res.Cainfo = resSeven10265.Cainfo
  27744. res.WarnMsg = resSeven10265.WarnMsg
  27745. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27746. res.Infcode = infocode
  27747. } else {
  27748. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27749. utils.ErrorLog("解析失败:%v", err)
  27750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27751. return
  27752. }
  27753. }
  27754. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  27755. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  27756. var result3101 Result3101
  27757. //utils.ErrorLog("解析失败:%v", result3101)
  27758. result3101.Infcode = "0"
  27759. if result3101.Infcode == "0" {
  27760. if len(result3101.Output.Result) > 0 {
  27761. var errMsgs []string
  27762. for _, item := range result3101.Output.Result {
  27763. errMsgs = append(errMsgs, item.VolaCont)
  27764. }
  27765. c.ServeSuccessJSON(map[string]interface{}{
  27766. "failed_code": -10,
  27767. "msg": errMsgs,
  27768. })
  27769. return
  27770. } else {
  27771. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27772. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27773. bas := strings.Split(psn_info.CardInfo, "|")
  27774. if his.IdCardType == 1 {
  27775. cert_no = bas[2]
  27776. } else if his.IdCardType == 3 {
  27777. cert_no = his.Certno
  27778. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27779. } else if his.IdCardType == 4 {
  27780. cert_no = his.Certno
  27781. psn_info.VerifyNumber = psn_info.VerifyNumber
  27782. }
  27783. var api string
  27784. if miConfig.MdtrtareaAdmvs == "320830" {
  27785. api = miConfig.AppSecret + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27786. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27787. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27788. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27789. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27790. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27791. "&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)
  27792. } else if miConfig.MdtrtareaAdmvs == "320921" {
  27793. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27794. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27795. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27796. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27797. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27798. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27799. "&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)
  27800. } else {
  27801. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27802. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27803. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27804. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27805. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27806. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27807. "&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)
  27808. }
  27809. resp, requestErr := http.Get(api)
  27810. if requestErr != nil {
  27811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27812. return
  27813. }
  27814. body, ioErr := ioutil.ReadAll(resp.Body)
  27815. if ioErr != nil {
  27816. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27818. return
  27819. }
  27820. var respJSON map[string]interface{}
  27821. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27822. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27824. return
  27825. }
  27826. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27827. result, _ := json.Marshal(respJSON)
  27828. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27829. utils.ErrorLog("解析失败:%v", err)
  27830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27831. return
  27832. }
  27833. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27834. res.Output = resSeven10265.Output
  27835. res.ErrMsg = resSeven10265.ErrMsg
  27836. res.Cainfo = resSeven10265.Cainfo
  27837. res.WarnMsg = resSeven10265.WarnMsg
  27838. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27839. res.Infcode = infocode
  27840. }
  27841. }
  27842. } else if miConfig.MdtrtareaAdmvs == "150404" {
  27843. psn_info, _ := service.GetPsnByPatientId(id)
  27844. var verify_number string
  27845. if psn_info.IdCardType == 4 {
  27846. verify_number = psn_info.VerifyNumber
  27847. } else if psn_info.IdCardType == 1 {
  27848. bas := strings.Split(psn_info.CardInfo, "|")
  27849. cardNumber := bas[2]
  27850. verify_number = cardNumber
  27851. } else {
  27852. psn_info.IdCardType = 2
  27853. verify_number = psn_info.Certno
  27854. }
  27855. var api string
  27856. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27857. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27858. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27859. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27860. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27861. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27862. "&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)
  27863. resp, requestErr := http.Get(api)
  27864. if requestErr != nil {
  27865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27866. return
  27867. }
  27868. body, ioErr := ioutil.ReadAll(resp.Body)
  27869. if ioErr != nil {
  27870. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27872. return
  27873. }
  27874. var respJSON map[string]interface{}
  27875. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27876. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27878. return
  27879. }
  27880. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27881. result, _ := json.Marshal(respJSON)
  27882. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27883. utils.ErrorLog("解析失败:%v", err)
  27884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27885. return
  27886. }
  27887. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27888. res.Output = resSeven10265.Output
  27889. res.ErrMsg = resSeven10265.ErrMsg
  27890. res.Cainfo = resSeven10265.Cainfo
  27891. res.WarnMsg = resSeven10265.WarnMsg
  27892. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27893. res.Infcode = infocode
  27894. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27895. var cert_no string
  27896. if his.IdCardType == 4 {
  27897. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27898. cert_no = psn_info.VerifyNumber
  27899. 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)
  27900. } else if his.IdCardType == 1 {
  27901. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27902. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27903. 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)
  27904. }
  27905. //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)
  27906. var dat map[string]interface{}
  27907. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27908. fmt.Println(dat)
  27909. } else {
  27910. fmt.Println(err)
  27911. }
  27912. saveLog(result2, src_resquest, "2207", "结算")
  27913. userJSONBytes, _ := json.Marshal(dat)
  27914. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27915. utils.ErrorLog("解析失败:%v", err)
  27916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27917. return
  27918. }
  27919. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27920. res.Output = resSeven10265.Output
  27921. res.ErrMsg = resSeven10265.ErrMsg
  27922. res.Cainfo = resSeven10265.Cainfo
  27923. res.WarnMsg = resSeven10265.WarnMsg
  27924. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27925. res.Infcode = infocode
  27926. } else if miConfig.MdtrtareaAdmvs == "450721" {
  27927. res2 := c.GetoleInfo()
  27928. if res2.Infcode == 0 {
  27929. var result string
  27930. var request_log string
  27931. var result_log string
  27932. if res2.Output.MdtrtCertType == "02" {
  27933. 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)
  27934. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27935. } else if res2.Output.MdtrtCertType == "01" {
  27936. 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)
  27937. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27938. } else {
  27939. 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)
  27940. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27941. }
  27942. var dat map[string]interface{}
  27943. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27944. fmt.Println(dat)
  27945. } else {
  27946. fmt.Println(err)
  27947. }
  27948. userJSONBytes, _ := json.Marshal(dat)
  27949. var res5 ResultTwo
  27950. //var resTwo10265 ResultTwo10265
  27951. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  27952. utils.ErrorLog("解析失败:%v", err)
  27953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27954. return
  27955. }
  27956. if res5.Infcode == -1 {
  27957. c.ServeSuccessJSON(map[string]interface{}{
  27958. "failed_code": -10,
  27959. "msg": res5.ErrMsg,
  27960. })
  27961. return
  27962. }
  27963. var insutypes []string
  27964. var insutype string
  27965. var is390 int = 0
  27966. var is310 int = 0
  27967. for _, item := range res5.Output.Iinfo {
  27968. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27969. insutypes = append(insutypes, item.Insutype)
  27970. }
  27971. }
  27972. if len(insutypes) == 1 {
  27973. insutype = insutypes[0]
  27974. } else {
  27975. for _, i := range insutypes {
  27976. if i == "390" {
  27977. is390 = 1
  27978. }
  27979. if i == "310" {
  27980. is310 = 1
  27981. }
  27982. }
  27983. }
  27984. if is390 == 1 {
  27985. insutype = "390"
  27986. }
  27987. if is310 == 1 {
  27988. insutype = "310"
  27989. }
  27990. if len(insutypes) == 0 {
  27991. insutype = "310"
  27992. }
  27993. fmt.Println(insutype)
  27994. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  27995. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  27996. infoStr := string(Iinfos)
  27997. idetinfoStr := string(Idetinfos)
  27998. psn := &models.HisPsn{
  27999. PsnNo: res5.Output.Baseinfo.PsnNo,
  28000. PatientId: id,
  28001. Certno: res5.Output.Baseinfo.Certno,
  28002. Gend: res5.Output.Baseinfo.Gend,
  28003. Naty: res5.Output.Baseinfo.Naty,
  28004. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  28005. PsnName: res5.Output.Baseinfo.PsnName,
  28006. Idetinfo: idetinfoStr,
  28007. Insuinfo: infoStr,
  28008. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  28009. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28010. VerifyNumber: res2.Output.EcToken,
  28011. }
  28012. if res2.Output.MdtrtCertType == "01" {
  28013. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28014. psn.VerifyNumber = res2.Output.EcToken
  28015. } else if res2.Output.MdtrtCertType == "02" {
  28016. psn.VerifyNumber = res2.Output.CardNo
  28017. } else {
  28018. psn.VerifyNumber = res2.Output.MdtrtCertNo
  28019. }
  28020. service.CreateHisPsn(psn)
  28021. if res2.Output.MdtrtCertType == "01" {
  28022. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28023. token := res2.Output.EcToken
  28024. 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, tempOrder.PackNum, tempOrder.GoodPackNum)
  28025. } else if res2.Output.MdtrtCertType == "02" {
  28026. 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, tempOrder.PackNum, tempOrder.GoodPackNum)
  28027. } else {
  28028. 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, tempOrder.PackNum, tempOrder.GoodPackNum)
  28029. }
  28030. var dat2 map[string]interface{}
  28031. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28032. fmt.Println(dat2)
  28033. } else {
  28034. fmt.Println(err)
  28035. }
  28036. userJSONBytes3, _ := json.Marshal(dat2)
  28037. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28038. utils.ErrorLog("解析失败:%v", err)
  28039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28040. return
  28041. }
  28042. saveLog(result2, src_resquest, "2207", "结算")
  28043. } else {
  28044. c.ServeSuccessJSON(map[string]interface{}{
  28045. "failed_code": -10,
  28046. "msg": res2.ErrMsg,
  28047. })
  28048. return
  28049. }
  28050. } else {
  28051. if miConfig.Code == "H15049901371" {
  28052. //赤峰地区国家医保医疗类别
  28053. //职工透析:医疗类别选特殊情况门诊990502
  28054. //居民定额血透门慢: 医疗类别选门诊慢病140104
  28055. var med_type string
  28056. if his.Insutype == "390" {
  28057. if reg_type == 14 {
  28058. med_type = "9933"
  28059. } else if reg_type == 11 {
  28060. med_type = "11"
  28061. }
  28062. } else if his.Insutype == "310" {
  28063. if reg_type == 14 {
  28064. med_type = "990502"
  28065. } else if reg_type == 11 {
  28066. med_type = "11"
  28067. }
  28068. }
  28069. 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, tempOrder.PackNum, tempOrder.GoodPackNum)
  28070. } else {
  28071. if his.IdCardType == 4 {
  28072. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28073. var token string
  28074. token = psn_info.VerifyNumber
  28075. 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, tempOrder.PackNum, tempOrder.GoodPackNum)
  28076. } else {
  28077. if his.IdCardType == 1 {
  28078. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28079. bas := strings.Split(psn_info.CardInfo, "|")
  28080. basNumber := bas[2]
  28081. cert_no = basNumber
  28082. }
  28083. 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, tempOrder.PackNum, tempOrder.GoodPackNum)
  28084. }
  28085. }
  28086. //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)
  28087. var dat map[string]interface{}
  28088. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28089. fmt.Println(dat)
  28090. } else {
  28091. fmt.Println(err)
  28092. }
  28093. saveLog(result2, src_resquest, "2207", "结算")
  28094. userJSONBytes, _ := json.Marshal(dat)
  28095. if miConfig.Code == "H15049901371" {
  28096. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  28097. utils.ErrorLog("解析失败:%v", err)
  28098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28099. return
  28100. }
  28101. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28102. res.Output = resSeven10265.Output
  28103. res.ErrMsg = resSeven10265.ErrMsg
  28104. res.Cainfo = resSeven10265.Cainfo
  28105. res.WarnMsg = resSeven10265.WarnMsg
  28106. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28107. res.Infcode = infocode
  28108. } else {
  28109. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28110. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  28111. utils.ErrorLog("解析失败:%v", err)
  28112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28113. return
  28114. }
  28115. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  28116. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  28117. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  28118. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  28119. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  28120. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  28121. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  28122. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28123. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  28124. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28125. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28126. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28127. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28128. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  28129. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  28130. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  28131. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  28132. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  28133. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  28134. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  28135. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28136. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  28137. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  28138. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  28139. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  28140. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  28141. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  28142. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  28143. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  28144. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  28145. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  28146. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  28147. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  28148. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  28149. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  28150. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  28151. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  28152. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  28153. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28154. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  28155. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  28156. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  28157. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  28158. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  28159. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  28160. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  28161. res.ErrMsg = gzresSeven10265Two.ErrMsg
  28162. res.Cainfo = gzresSeven10265Two.Cainfo
  28163. res.WarnMsg = gzresSeven10265Two.WarnMsg
  28164. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  28165. //res.Infcode = infocode
  28166. } else {
  28167. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28168. utils.ErrorLog("解析失败:%v", err)
  28169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28170. return
  28171. }
  28172. }
  28173. }
  28174. }
  28175. if res.Infcode == -1 {
  28176. errlog := &models.HisOrderError{
  28177. UserOrgId: adminUser.CurrentOrgId,
  28178. Ctime: time.Now().Unix(),
  28179. Mtime: time.Now().Unix(),
  28180. Number: chrg_bchno,
  28181. ErrMsg: res.ErrMsg,
  28182. Status: 1,
  28183. PatientId: id,
  28184. RecordTime: recordDateTime,
  28185. Stage: 6,
  28186. }
  28187. service.CreateErrMsgLog(errlog)
  28188. c.ServeSuccessJSON(map[string]interface{}{
  28189. "failed_code": -10,
  28190. "msg": res.ErrMsg,
  28191. })
  28192. return
  28193. } else {
  28194. sickConfig, _ := service.FindSickById(his.SickType)
  28195. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  28196. order.OrderStatus = 2
  28197. order.Status = 1
  28198. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  28199. order.SetlId = res.Output.Setlinfo.SetlID
  28200. order.PsnNo = res.Output.Setlinfo.PsnNo
  28201. order.PsnName = res.Output.Setlinfo.PsnName
  28202. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  28203. order.Certno = res.Output.Setlinfo.Certno
  28204. order.Gend = res.Output.Setlinfo.Gend
  28205. order.Naty = res.Output.Setlinfo.Naty
  28206. order.Age = res.Output.Setlinfo.Age
  28207. order.Insutype = res.Output.Setlinfo.Insutype
  28208. order.PsnType = res.Output.Setlinfo.PsnType
  28209. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  28210. order.SetlTime = res.Output.Setlinfo.SetlTime
  28211. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  28212. if res.Output.Setlinfo.MedType == "140101" {
  28213. order.MedType = "14"
  28214. } else {
  28215. if res.Output.Setlinfo.MedType == "110104" {
  28216. order.MedType = "11"
  28217. } else {
  28218. order.MedType = res.Output.Setlinfo.MedType
  28219. }
  28220. }
  28221. if reg_type == 1112 {
  28222. order.MedType = "1112"
  28223. }
  28224. if reg_type == 1111 {
  28225. order.MedType = "1111"
  28226. }
  28227. order.ClrType = res.Output.Setlinfo.ClrType
  28228. if adminUser.CurrentOrgId == 10480 {
  28229. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  28230. order.ClrType = "11"
  28231. } else {
  28232. order.ClrType = "9903"
  28233. }
  28234. }
  28235. if adminUser.CurrentOrgId == 10721 {
  28236. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  28237. order.ClrType = "11"
  28238. } else {
  28239. order.ClrType = "9903"
  28240. }
  28241. }
  28242. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  28243. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  28244. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  28245. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  28246. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  28247. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  28248. order.HifpPay = res.Output.Setlinfo.HifpPay
  28249. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  28250. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  28251. order.HifesPay = res.Output.Setlinfo.HifesPay
  28252. order.HifobPay = res.Output.Setlinfo.HifobPay
  28253. order.MafPay = res.Output.Setlinfo.MafPay
  28254. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  28255. order.OthPay = res.Output.Setlinfo.OthPay
  28256. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  28257. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  28258. order.AcctPay = res.Output.Setlinfo.AcctPay
  28259. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  28260. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  28261. order.Balc = res.Output.Setlinfo.Balc
  28262. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  28263. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  28264. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  28265. //order.ClrType = res.Output.Setlinfo.ClrType
  28266. order.ClrWay = res.Output.Setlinfo.ClrWay
  28267. order.Creator = order.Creator
  28268. order.Modify = roles.AdminUserId
  28269. order.RequestLog = src_resquest
  28270. order.FaPiaoNumber = fapiao_number
  28271. order.FaPiaoCode = fapiao_code
  28272. order.SickName = sickConfig.ClassName
  28273. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  28274. //detailStr := string(setlDetail)
  28275. //order.SetlDetail = detailStr
  28276. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  28277. err = service.UpDateOrder(order)
  28278. if err == nil {
  28279. //判断是否使用了押金
  28280. if dec_way == "true" {
  28281. tmpstring := strconv.FormatInt(order.ID, 10)
  28282. order.Decimal = decimal
  28283. service.UpDateOrder(order)
  28284. //扣押金
  28285. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  28286. if errmsg != nil {
  28287. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  28288. return
  28289. }
  28290. }
  28291. c.ServeSuccessJSON(map[string]interface{}{
  28292. "msg": "结算成功",
  28293. })
  28294. } else {
  28295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  28296. return
  28297. }
  28298. }
  28299. } else {
  28300. adminUser := c.GetAdminUserInfo()
  28301. errlog := &models.HisOrderError{
  28302. UserOrgId: adminUser.CurrentOrgId,
  28303. Ctime: time.Now().Unix(),
  28304. Mtime: time.Now().Unix(),
  28305. ErrMsg: res.ErrMsg,
  28306. Status: 1,
  28307. PatientId: id,
  28308. RecordTime: recordDateTime,
  28309. Stage: 4,
  28310. }
  28311. service.CreateErrMsgLog(errlog)
  28312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  28313. return
  28314. }
  28315. } else {
  28316. adminUser := c.GetAdminUserInfo()
  28317. errlog := &models.HisOrderError{
  28318. UserOrgId: adminUser.CurrentOrgId,
  28319. Ctime: time.Now().Unix(),
  28320. Mtime: time.Now().Unix(),
  28321. ErrMsg: res.ErrMsg,
  28322. Status: 1,
  28323. PatientId: id,
  28324. RecordTime: recordDateTime,
  28325. Stage: 4,
  28326. }
  28327. service.CreateErrMsgLog(errlog)
  28328. c.ServeSuccessJSON(map[string]interface{}{
  28329. "failed_code": -10,
  28330. "msg": res.ErrMsg,
  28331. })
  28332. return
  28333. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  28334. //return
  28335. }
  28336. }
  28337. }
  28338. } else if tempOrder.ID > 0 {
  28339. if tempOrder.IsPre == 1 {
  28340. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  28341. var rf []*ResultFive
  28342. json.Unmarshal([]byte(his.Iinfo), &rf)
  28343. chrg_bchno := tempOrder.Number
  28344. cert_no := his.Certno
  28345. var insutypes []string
  28346. var insutype string
  28347. var is390 int = 0
  28348. var is310 int = 0
  28349. for _, item := range rf {
  28350. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28351. insutypes = append(insutypes, item.Insutype)
  28352. }
  28353. }
  28354. if len(insutypes) == 1 {
  28355. insutype = insutypes[0]
  28356. } else {
  28357. for _, i := range insutypes {
  28358. if i == "390" {
  28359. is390 = 1
  28360. }
  28361. if i == "310" {
  28362. is310 = 1
  28363. }
  28364. }
  28365. }
  28366. if is390 == 1 {
  28367. insutype = "390"
  28368. }
  28369. if is310 == 1 {
  28370. insutype = "310"
  28371. }
  28372. if len(insutypes) == 0 {
  28373. insutype = "310"
  28374. }
  28375. if len(insutypes) == 2 {
  28376. insutype = strconv.FormatInt(his.SocialType, 10)
  28377. }
  28378. //insutype = "390"
  28379. if his.IdCardType == 1 {
  28380. // cert_no = his.MedicalInsuranceNumber
  28381. cert_no = his.Certno
  28382. } else {
  28383. cert_no = his.Certno
  28384. }
  28385. var res ResultSeven
  28386. var ahres ResultSevenAH
  28387. var resSeven10265 ResultSeven10265
  28388. var gzresSeven10265Two GZResultSeven10265Two
  28389. var src_resquest string
  28390. var result2 string
  28391. if miConfig.MdtrtareaAdmvs == "450721" {
  28392. res2 := c.GetoleInfo()
  28393. if res2.Infcode == 0 {
  28394. var result string
  28395. var request_log string
  28396. var result_log string
  28397. if res2.Output.MdtrtCertType == "02" {
  28398. 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)
  28399. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28400. } else if res2.Output.MdtrtCertType == "01" {
  28401. 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)
  28402. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28403. } else {
  28404. 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)
  28405. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28406. }
  28407. var dat map[string]interface{}
  28408. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28409. fmt.Println(dat)
  28410. } else {
  28411. fmt.Println(err)
  28412. }
  28413. userJSONBytes, _ := json.Marshal(dat)
  28414. var res5 ResultTwo
  28415. //var resTwo10265 ResultTwo10265
  28416. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  28417. utils.ErrorLog("解析失败:%v", err)
  28418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28419. return
  28420. }
  28421. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  28422. if res5.Infcode == -1 {
  28423. c.ServeSuccessJSON(map[string]interface{}{
  28424. "failed_code": -10,
  28425. "msg": res5.ErrMsg,
  28426. })
  28427. return
  28428. }
  28429. var insutypes []string
  28430. var insutype string
  28431. var is390 int = 0
  28432. var is310 int = 0
  28433. for _, item := range res5.Output.Iinfo {
  28434. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28435. insutypes = append(insutypes, item.Insutype)
  28436. }
  28437. }
  28438. if len(insutypes) == 1 {
  28439. insutype = insutypes[0]
  28440. } else {
  28441. for _, i := range insutypes {
  28442. if i == "390" {
  28443. is390 = 1
  28444. }
  28445. if i == "310" {
  28446. is310 = 1
  28447. }
  28448. }
  28449. }
  28450. if is390 == 1 {
  28451. insutype = "390"
  28452. }
  28453. if is310 == 1 {
  28454. insutype = "310"
  28455. }
  28456. if len(insutypes) == 0 {
  28457. insutype = "310"
  28458. }
  28459. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  28460. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  28461. infoStr := string(Iinfos)
  28462. idetinfoStr := string(Idetinfos)
  28463. psn := &models.HisPsn{
  28464. PsnNo: res5.Output.Baseinfo.PsnNo,
  28465. PatientId: id,
  28466. Certno: res5.Output.Baseinfo.Certno,
  28467. Gend: res5.Output.Baseinfo.Gend,
  28468. Naty: res5.Output.Baseinfo.Naty,
  28469. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  28470. PsnName: res5.Output.Baseinfo.PsnName,
  28471. Idetinfo: idetinfoStr,
  28472. Insuinfo: infoStr,
  28473. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  28474. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28475. VerifyNumber: res2.Output.EcToken,
  28476. }
  28477. service.CreateHisPsn(psn)
  28478. if res2.Output.MdtrtCertType == "01" {
  28479. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28480. token := res2.Output.EcToken
  28481. 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, tempOrder.PackNum, tempOrder.GoodPackNum)
  28482. } else if res2.Output.MdtrtCertType == "02" {
  28483. 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, tempOrder.PackNum, tempOrder.GoodPackNum)
  28484. } else {
  28485. 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, tempOrder.PackNum, tempOrder.GoodPackNum)
  28486. }
  28487. var dat2 map[string]interface{}
  28488. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28489. fmt.Println(dat2)
  28490. } else {
  28491. fmt.Println(err)
  28492. }
  28493. userJSONBytes3, _ := json.Marshal(dat2)
  28494. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28495. utils.ErrorLog("解析失败:%v", err)
  28496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28497. return
  28498. }
  28499. saveLog(result2, src_resquest, "2207", "结算")
  28500. } else {
  28501. c.ServeSuccessJSON(map[string]interface{}{
  28502. "failed_code": -10,
  28503. "msg": res2.ErrMsg,
  28504. })
  28505. return
  28506. }
  28507. } else if miConfig.MdtrtareaAdmvs == "421300" {
  28508. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28509. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28510. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28511. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28512. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28513. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28514. "&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)
  28515. resp, requestErr := http.Get(api)
  28516. if requestErr != nil {
  28517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28518. return
  28519. }
  28520. body, ioErr := ioutil.ReadAll(resp.Body)
  28521. if ioErr != nil {
  28522. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28524. return
  28525. }
  28526. var respJSON map[string]interface{}
  28527. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28528. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28530. return
  28531. }
  28532. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28533. result, _ := json.Marshal(respJSON)
  28534. fmt.Println("log")
  28535. fmt.Println(string(result))
  28536. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28537. utils.ErrorLog("解析失败:%v", err)
  28538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28539. return
  28540. }
  28541. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28542. if reg_type == 11 && his.Insutype == "390" {
  28543. reg_type = 110104
  28544. }
  28545. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28546. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28547. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28548. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28549. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28550. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28551. "&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)
  28552. resp, requestErr := http.Get(api)
  28553. if requestErr != nil {
  28554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28555. return
  28556. }
  28557. body, ioErr := ioutil.ReadAll(resp.Body)
  28558. if ioErr != nil {
  28559. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28561. return
  28562. }
  28563. var respJSON map[string]interface{}
  28564. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28565. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28567. return
  28568. }
  28569. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28570. result, _ := json.Marshal(respJSON)
  28571. fmt.Println("log")
  28572. fmt.Println(string(result))
  28573. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28574. utils.ErrorLog("解析失败:%v", err)
  28575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28576. return
  28577. }
  28578. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28579. if reg_type == 11 && his.Insutype == "390" {
  28580. reg_type = 110104
  28581. }
  28582. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28583. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28584. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28585. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28586. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28587. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28588. "&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)
  28589. resp, requestErr := http.Get(api)
  28590. if requestErr != nil {
  28591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28592. return
  28593. }
  28594. body, ioErr := ioutil.ReadAll(resp.Body)
  28595. if ioErr != nil {
  28596. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28598. return
  28599. }
  28600. var respJSON map[string]interface{}
  28601. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28602. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28604. return
  28605. }
  28606. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28607. result, _ := json.Marshal(respJSON)
  28608. fmt.Println("log")
  28609. fmt.Println(string(result))
  28610. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28611. utils.ErrorLog("解析失败:%v", err)
  28612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28613. return
  28614. }
  28615. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28616. if reg_type == 11 && his.Insutype == "390" {
  28617. reg_type = 110104
  28618. }
  28619. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28620. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28621. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28622. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28623. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28624. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28625. "&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)
  28626. resp, requestErr := http.Get(api)
  28627. if requestErr != nil {
  28628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28629. return
  28630. }
  28631. body, ioErr := ioutil.ReadAll(resp.Body)
  28632. if ioErr != nil {
  28633. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28635. return
  28636. }
  28637. var respJSON map[string]interface{}
  28638. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28639. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28641. return
  28642. }
  28643. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28644. result, _ := json.Marshal(respJSON)
  28645. fmt.Println("log")
  28646. fmt.Println(string(result))
  28647. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28648. utils.ErrorLog("解析失败:%v", err)
  28649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28650. return
  28651. }
  28652. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  28653. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  28654. var result3101 Result3101
  28655. //utils.ErrorLog("解析失败:%v", result3101)
  28656. result3101.Infcode = "0"
  28657. if result3101.Infcode == "0" {
  28658. if len(result3101.Output.Result) > 0 {
  28659. var errMsgs []string
  28660. for _, item := range result3101.Output.Result {
  28661. errMsgs = append(errMsgs, item.VolaCont)
  28662. }
  28663. c.ServeSuccessJSON(map[string]interface{}{
  28664. "failed_code": -10,
  28665. "msg": errMsgs,
  28666. })
  28667. return
  28668. } else {
  28669. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28670. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28671. bas := strings.Split(psn_info.CardInfo, "|")
  28672. if his.IdCardType == 1 {
  28673. cert_no = bas[2]
  28674. } else if his.IdCardType == 3 {
  28675. cert_no = his.Certno
  28676. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28677. } else if his.IdCardType == 4 {
  28678. cert_no = his.Certno
  28679. psn_info.VerifyNumber = psn_info.VerifyNumber
  28680. }
  28681. //江苏地区国家医保医疗类别
  28682. //职工透析:医疗类别选特殊情况门诊9933
  28683. //居民血透门慢: 医疗类别选门诊慢病1402
  28684. //var med_type string
  28685. //if his.Insutype == "310" {
  28686. // if reg_type == 14 {
  28687. // med_type = "9933"
  28688. // } else if reg_type == 11 {
  28689. // med_type = "11"
  28690. //
  28691. // }
  28692. //} else if his.Insutype == "390" {
  28693. // if reg_type == 14 {
  28694. // med_type = "1402"
  28695. // } else if reg_type == 11 {
  28696. // med_type = "11"
  28697. // }
  28698. //}
  28699. var api string
  28700. if miConfig.MdtrtareaAdmvs == "320830" {
  28701. api = miConfig.AppSecret + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28702. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28703. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28704. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28705. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28706. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28707. "&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 + "&pack_num=" + strconv.FormatInt(pack_num, 10) + "&good_pack_num=" + strconv.FormatInt(good_pack_num, 10)
  28708. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28709. } else if miConfig.MdtrtareaAdmvs == "320921" {
  28710. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28711. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28712. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28713. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28714. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28715. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28716. "&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 + "&pack_num=" + strconv.FormatInt(pack_num, 10) + "&good_pack_num=" + strconv.FormatInt(good_pack_num, 10)
  28717. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28718. } else {
  28719. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28720. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28721. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28722. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28723. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28724. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28725. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28726. "&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 + "&pack_num=" + strconv.FormatInt(pack_num, 10) + "&good_pack_num=" + strconv.FormatInt(good_pack_num, 10)
  28727. }
  28728. resp, requestErr := http.Get(api)
  28729. if requestErr != nil {
  28730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28731. return
  28732. }
  28733. body, ioErr := ioutil.ReadAll(resp.Body)
  28734. if ioErr != nil {
  28735. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28737. return
  28738. }
  28739. var respJSON map[string]interface{}
  28740. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28743. return
  28744. }
  28745. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28746. result, _ := json.Marshal(respJSON)
  28747. fmt.Println("log")
  28748. fmt.Println(string(result))
  28749. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  28750. utils.ErrorLog("解析失败:%v", err)
  28751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28752. return
  28753. }
  28754. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28755. res.Output = resSeven10265.Output
  28756. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28757. res.ErrMsg = resSeven10265.ErrMsg
  28758. res.Cainfo = resSeven10265.Cainfo
  28759. res.WarnMsg = resSeven10265.WarnMsg
  28760. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28761. res.Infcode = infocode
  28762. }
  28763. }
  28764. } else if miConfig.MdtrtareaAdmvs == "150404" {
  28765. psn_info, _ := service.GetPsnByPatientId(id)
  28766. var verify_number string
  28767. if psn_info.IdCardType == 4 {
  28768. verify_number = psn_info.VerifyNumber
  28769. } else if psn_info.IdCardType == 1 {
  28770. bas := strings.Split(psn_info.CardInfo, "|")
  28771. cardNumber := bas[2]
  28772. verify_number = cardNumber
  28773. } else {
  28774. verify_number = psn_info.Certno
  28775. psn_info.IdCardType = 2
  28776. }
  28777. var api string
  28778. new_chrg_bchno := chrg_bchno
  28779. if adminUser.CurrentOrgId == 10265 {
  28780. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  28781. new_chrg_bchno = "0000"
  28782. }
  28783. }
  28784. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28785. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  28786. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28787. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28788. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  28789. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28790. "&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 + "&pack_num=" + strconv.FormatInt(pack_num, 10) + "&good_pack_num=" + strconv.FormatInt(good_pack_num, 10)
  28791. resp, requestErr := http.Get(api)
  28792. if requestErr != nil {
  28793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28794. return
  28795. }
  28796. body, ioErr := ioutil.ReadAll(resp.Body)
  28797. if ioErr != nil {
  28798. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28800. return
  28801. }
  28802. var respJSON map[string]interface{}
  28803. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28804. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28806. return
  28807. }
  28808. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28809. result, _ := json.Marshal(respJSON)
  28810. fmt.Println("log")
  28811. fmt.Println(string(result))
  28812. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  28813. utils.ErrorLog("解析失败:%v", err)
  28814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28815. return
  28816. }
  28817. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28818. res.Output = resSeven10265.Output
  28819. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28820. res.ErrMsg = resSeven10265.ErrMsg
  28821. res.Cainfo = resSeven10265.Cainfo
  28822. res.WarnMsg = resSeven10265.WarnMsg
  28823. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28824. res.Infcode = infocode
  28825. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28826. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28827. var cert_no string
  28828. if his.IdCardType == 1 {
  28829. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28830. } else {
  28831. cert_no = psn_info.VerifyNumber
  28832. }
  28833. 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)
  28834. var dat map[string]interface{}
  28835. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28836. fmt.Println(dat)
  28837. } else {
  28838. fmt.Println(err)
  28839. }
  28840. saveLog(result2, src_resquest, "2207", "结算")
  28841. userJSONBytes, _ := json.Marshal(dat)
  28842. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28843. utils.ErrorLog("解析失败:%v", err)
  28844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28845. return
  28846. }
  28847. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28848. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28849. var cert_no string
  28850. var card_sn string
  28851. if his.IdCardType == 1 {
  28852. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28853. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28854. bas := strings.Split(psn_info.CardInfo, "|")
  28855. card_sn = bas[3]
  28856. } else if his.IdCardType == 2 {
  28857. cert_no = his.IdCardNo
  28858. } else {
  28859. cert_no = psn_info.VerifyNumber
  28860. }
  28861. var rf []*ResultFive
  28862. json.Unmarshal([]byte(his.Iinfo), &rf)
  28863. var psn_type string
  28864. for _, item := range rf {
  28865. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28866. psn_type = item.PsnType
  28867. }
  28868. }
  28869. 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, tempOrder.PackNum, tempOrder.GoodPackNum)
  28870. var dat map[string]interface{}
  28871. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28872. fmt.Println(dat)
  28873. } else {
  28874. fmt.Println(err)
  28875. }
  28876. saveLog(result2, src_resquest, "2207", "结算")
  28877. userJSONBytes, _ := json.Marshal(dat)
  28878. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28879. utils.ErrorLog("解析失败:%v", err)
  28880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28881. return
  28882. }
  28883. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28884. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28885. var cert_no string
  28886. var card_sn string
  28887. if his.IdCardType == 1 {
  28888. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28889. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28890. //bas := strings.Split(psn_info.CardInfo, "|")
  28891. card_sn = ""
  28892. } else if his.IdCardType == 2 {
  28893. cert_no = his.IdCardNo
  28894. } else {
  28895. cert_no = psn_info.VerifyNumber
  28896. }
  28897. var rf []*ResultFive
  28898. json.Unmarshal([]byte(his.Iinfo), &rf)
  28899. var psn_type string
  28900. for _, item := range rf {
  28901. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28902. psn_type = item.PsnType
  28903. }
  28904. }
  28905. 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, tempOrder.PackNum, tempOrder.GoodPackNum)
  28906. var dat map[string]interface{}
  28907. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28908. fmt.Println(dat)
  28909. } else {
  28910. fmt.Println(err)
  28911. }
  28912. saveLog(result2, src_resquest, "2207", "结算")
  28913. userJSONBytes, _ := json.Marshal(dat)
  28914. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28915. utils.ErrorLog("解析失败:%v", err)
  28916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28917. return
  28918. }
  28919. } else if miConfig.MdtrtareaAdmvs == "360100" {
  28920. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28921. var cert_no string
  28922. var card_sn string
  28923. if his.IdCardType == 1 {
  28924. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28925. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28926. //bas := strings.Split(psn_info.CardInfo, "|")
  28927. card_sn = ""
  28928. } else if his.IdCardType == 2 {
  28929. cert_no = his.IdCardNo
  28930. } else {
  28931. cert_no = psn_info.VerifyNumber
  28932. }
  28933. var rf []*ResultFive
  28934. json.Unmarshal([]byte(his.Iinfo), &rf)
  28935. var psn_type string
  28936. for _, item := range rf {
  28937. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28938. psn_type = item.PsnType
  28939. }
  28940. }
  28941. 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, tempOrder.PackNum, tempOrder.GoodPackNum)
  28942. var dat map[string]interface{}
  28943. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28944. fmt.Println(dat)
  28945. } else {
  28946. fmt.Println(err)
  28947. }
  28948. saveLog(result2, src_resquest, "2207", "结算")
  28949. userJSONBytes, _ := json.Marshal(dat)
  28950. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28951. utils.ErrorLog("解析失败:%v", err)
  28952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28953. return
  28954. }
  28955. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28956. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28957. if his.IdCardType == 1 {
  28958. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28959. bas := strings.Split(psn_info.CardInfo, "|")
  28960. cert_no = bas[2]
  28961. } else if his.IdCardType == 3 {
  28962. cert_no = his.Certno
  28963. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28964. } else if his.IdCardType == 4 {
  28965. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28966. cert_no = psn_info.VerifyNumber
  28967. psn_info.VerifyNumber = psn_info.VerifyNumber
  28968. } else {
  28969. cert_no = his.Certno
  28970. psn_info.VerifyNumber = his.Certno
  28971. }
  28972. var api string
  28973. var med_type string
  28974. if his.Insutype == "390" {
  28975. if reg_type == 992102 {
  28976. med_type = "992102"
  28977. }
  28978. if reg_type == 1104 {
  28979. med_type = "1104"
  28980. }
  28981. if reg_type == 1104 {
  28982. med_type = "1104"
  28983. }
  28984. if reg_type == 140104 {
  28985. med_type = "140104"
  28986. }
  28987. if reg_type == 140201 {
  28988. med_type = "140201"
  28989. }
  28990. if reg_type == 14 {
  28991. med_type = "14"
  28992. }
  28993. } else if his.Insutype == "310" {
  28994. if reg_type == 1104 {
  28995. med_type = "1104"
  28996. }
  28997. if reg_type == 992102 {
  28998. med_type = "992102"
  28999. }
  29000. if reg_type == 140104 {
  29001. med_type = "140104"
  29002. }
  29003. if reg_type == 140201 {
  29004. med_type = "140201"
  29005. }
  29006. if reg_type == 14 {
  29007. med_type = "14"
  29008. }
  29009. }
  29010. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29011. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29012. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29013. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29014. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29015. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29016. "&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 + "&pack_num=" + strconv.FormatInt(pack_num, 10) + "&good_pack_num=" + strconv.FormatInt(good_pack_num, 10)
  29017. resp, requestErr := http.Get(api)
  29018. if requestErr != nil {
  29019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29020. return
  29021. }
  29022. body, ioErr := ioutil.ReadAll(resp.Body)
  29023. if ioErr != nil {
  29024. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29026. return
  29027. }
  29028. var respJSON map[string]interface{}
  29029. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29030. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29032. return
  29033. }
  29034. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29035. if status == "0" {
  29036. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29037. c.ServeSuccessJSON(map[string]interface{}{
  29038. "failed_code": -10,
  29039. "msg": err_msg,
  29040. })
  29041. return
  29042. }
  29043. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29044. result, _ := json.Marshal(respJSON)
  29045. fmt.Println("log")
  29046. fmt.Println(string(result))
  29047. if err := json.Unmarshal(result, &ahres); err != nil {
  29048. utils.ErrorLog("解析失败:%v", err)
  29049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29050. return
  29051. }
  29052. res.InfRefmsgid = ahres.InfRefmsgid
  29053. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  29054. // 创建对应的Time类型
  29055. t := time.UnixMilli(timestamp)
  29056. // 格式化成指定的日期字符串
  29057. str := t.Format("2006-01-02 15:04:05")
  29058. res.Output.Setlinfo.SetlTime = str
  29059. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  29060. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  29061. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29062. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  29063. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  29064. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  29065. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29066. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  29067. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  29068. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  29069. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  29070. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29071. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  29072. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  29073. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  29074. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  29075. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  29076. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  29077. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29078. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  29079. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  29080. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  29081. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  29082. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  29083. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  29084. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  29085. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  29086. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  29087. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  29088. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  29089. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  29090. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  29091. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  29092. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  29093. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  29094. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  29095. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  29096. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  29097. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  29098. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  29099. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  29100. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  29101. res.Output.Setldetail = ahres.Output.Setldetail
  29102. res.ErrMsg = ahres.ErrMsg
  29103. res.Cainfo = ahres.Cainfo
  29104. res.WarnMsg = ahres.WarnMsg
  29105. res.Infcode = ahres.Infcode
  29106. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  29107. res.Output.Setlinfo.ClrType = "11"
  29108. } else {
  29109. res.Output.Setlinfo.ClrType = "9903"
  29110. }
  29111. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29112. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29113. if his.IdCardType == 1 {
  29114. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29115. bas := strings.Split(psn_info.CardInfo, "|")
  29116. cert_no = bas[2]
  29117. } else if his.IdCardType == 3 {
  29118. cert_no = his.Certno
  29119. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  29120. } else if his.IdCardType == 4 {
  29121. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29122. cert_no = his.Certno
  29123. psn_info.VerifyNumber = psn_info.VerifyNumber
  29124. } else {
  29125. cert_no = his.Certno
  29126. psn_info.VerifyNumber = his.Certno
  29127. }
  29128. var api string
  29129. var med_type string
  29130. if his.Insutype == "390" {
  29131. if reg_type == 1104 {
  29132. med_type = "1104"
  29133. }
  29134. if reg_type == 992102 {
  29135. med_type = "992102"
  29136. }
  29137. if reg_type == 140104 {
  29138. med_type = "140104"
  29139. }
  29140. if reg_type == 14 {
  29141. med_type = "14"
  29142. }
  29143. if reg_type == 140201 {
  29144. med_type = "140201"
  29145. }
  29146. } else if his.Insutype == "310" {
  29147. if reg_type == 1104 {
  29148. med_type = "1104"
  29149. }
  29150. if reg_type == 992102 {
  29151. med_type = "992102"
  29152. }
  29153. if reg_type == 14 {
  29154. med_type = "14"
  29155. }
  29156. if reg_type == 140104 {
  29157. med_type = "140104"
  29158. }
  29159. if reg_type == 140201 {
  29160. med_type = "140201"
  29161. }
  29162. }
  29163. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29164. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29165. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29166. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29167. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29168. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29169. "&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 + "&pack_num=" + strconv.FormatInt(pack_num, 10) + "&good_pack_num=" + strconv.FormatInt(good_pack_num, 10)
  29170. resp, requestErr := http.Get(api)
  29171. if requestErr != nil {
  29172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29173. return
  29174. }
  29175. body, ioErr := ioutil.ReadAll(resp.Body)
  29176. if ioErr != nil {
  29177. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29179. return
  29180. }
  29181. var respJSON map[string]interface{}
  29182. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29183. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29185. return
  29186. }
  29187. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29188. if status == "0" {
  29189. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29190. c.ServeSuccessJSON(map[string]interface{}{
  29191. "failed_code": -10,
  29192. "msg": err_msg,
  29193. })
  29194. return
  29195. }
  29196. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29197. result, _ := json.Marshal(respJSON)
  29198. fmt.Println("log")
  29199. fmt.Println(string(result))
  29200. if err := json.Unmarshal(result, &ahres); err != nil {
  29201. utils.ErrorLog("解析失败:%v", err)
  29202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29203. return
  29204. }
  29205. res.InfRefmsgid = ahres.InfRefmsgid
  29206. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  29207. // 创建对应的Time类型
  29208. t := time.UnixMilli(timestamp)
  29209. // 格式化成指定的日期字符串
  29210. str := t.Format("2006-01-02 15:04:05")
  29211. res.Output.Setlinfo.SetlTime = str
  29212. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  29213. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  29214. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29215. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  29216. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  29217. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  29218. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29219. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  29220. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  29221. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  29222. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  29223. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29224. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  29225. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  29226. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  29227. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  29228. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  29229. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  29230. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29231. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  29232. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  29233. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  29234. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  29235. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  29236. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  29237. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  29238. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  29239. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  29240. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  29241. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  29242. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  29243. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  29244. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  29245. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  29246. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  29247. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  29248. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  29249. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  29250. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  29251. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  29252. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  29253. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  29254. res.Output.Setldetail = ahres.Output.Setldetail
  29255. res.ErrMsg = ahres.ErrMsg
  29256. res.Cainfo = ahres.Cainfo
  29257. res.WarnMsg = ahres.WarnMsg
  29258. res.Infcode = ahres.Infcode
  29259. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  29260. res.Output.Setlinfo.ClrType = "11"
  29261. } else {
  29262. res.Output.Setlinfo.ClrType = "9903"
  29263. }
  29264. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29265. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29266. var cert_no string
  29267. if his.IdCardType == 1 {
  29268. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  29269. } else if his.IdCardType == 2 {
  29270. cert_no = his.IdCardNo
  29271. } else {
  29272. cert_no = psn_info.VerifyNumber
  29273. }
  29274. 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, "", tempOrder.PackNum, tempOrder.GoodPackNum)
  29275. var dat map[string]interface{}
  29276. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29277. fmt.Println(dat)
  29278. } else {
  29279. fmt.Println(err)
  29280. }
  29281. saveLog(result2, src_resquest, "2207", "结算")
  29282. userJSONBytes, _ := json.Marshal(dat)
  29283. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29284. utils.ErrorLog("解析失败:%v", err)
  29285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29286. return
  29287. }
  29288. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29289. psn_info, _ := service.GetPsnByPatientId(id)
  29290. var verify_number string
  29291. if psn_info.IdCardType == 4 {
  29292. verify_number = psn_info.VerifyNumber
  29293. } else if psn_info.IdCardType == 1 {
  29294. bas := strings.Split(psn_info.CardInfo, "|")
  29295. cardNumber := bas[2]
  29296. verify_number = cardNumber
  29297. } else {
  29298. verify_number = psn_info.Certno
  29299. psn_info.IdCardType = 2
  29300. }
  29301. var api string
  29302. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29303. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29304. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29305. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29306. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  29307. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29308. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number + "&pack_num=" + strconv.FormatInt(pack_num, 10) + "&good_pack_num=" + strconv.FormatInt(good_pack_num, 10)
  29309. resp, requestErr := http.Get(api)
  29310. if requestErr != nil {
  29311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29312. return
  29313. }
  29314. body, ioErr := ioutil.ReadAll(resp.Body)
  29315. if ioErr != nil {
  29316. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29318. return
  29319. }
  29320. var respJSON map[string]interface{}
  29321. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29324. return
  29325. }
  29326. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29327. result, _ := json.Marshal(respJSON)
  29328. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29329. utils.ErrorLog("解析失败:%v", err)
  29330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29331. return
  29332. }
  29333. } else {
  29334. var src_resquest string
  29335. if miConfig.Code == "H15049901371" {
  29336. //赤峰地区国家医保医疗类别
  29337. //职工透析:医疗类别选特殊情况门诊990502
  29338. //居民定额血透门慢: 医疗类别选门诊慢病140104
  29339. var med_type string
  29340. if his.Insutype == "390" {
  29341. if reg_type == 14 {
  29342. med_type = "9933"
  29343. } else if reg_type == 11 {
  29344. med_type = "11"
  29345. }
  29346. } else if his.Insutype == "310" {
  29347. if reg_type == 14 {
  29348. med_type = "990502"
  29349. } else if reg_type == 11 {
  29350. med_type = "11"
  29351. }
  29352. }
  29353. 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, tempOrder.PackNum, tempOrder.GoodPackNum)
  29354. } else {
  29355. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" || miConfig.Code == "H44090200998" {
  29356. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  29357. if result3101.Infcode == 0 {
  29358. if len(result3101.Output.Result) > 0 {
  29359. c.ServeSuccessJSON(map[string]interface{}{
  29360. "failed_code": -10,
  29361. "failed_type": 100,
  29362. "warm_type": 2,
  29363. "msg": result3101,
  29364. })
  29365. return
  29366. }
  29367. } else {
  29368. c.ServeSuccessJSON(map[string]interface{}{
  29369. "failed_code": -10,
  29370. "msg": result3101.ErrMsg,
  29371. })
  29372. return
  29373. }
  29374. }
  29375. if his.IdCardType == 4 {
  29376. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29377. token := psn_info.VerifyNumber
  29378. 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, tempOrder.PackNum, tempOrder.GoodPackNum)
  29379. } else {
  29380. 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, tempOrder.PackNum, tempOrder.GoodPackNum)
  29381. }
  29382. }
  29383. var dat map[string]interface{}
  29384. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29385. fmt.Println(dat)
  29386. } else {
  29387. fmt.Println(err)
  29388. }
  29389. saveLog(result2, src_resquest, "2207", "结算")
  29390. userJSONBytes, _ := json.Marshal(dat)
  29391. if miConfig.Code == "H15049901371" {
  29392. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  29393. utils.ErrorLog("解析失败:%v", err)
  29394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29395. return
  29396. }
  29397. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29398. res.Output = resSeven10265.Output
  29399. res.ErrMsg = resSeven10265.ErrMsg
  29400. res.Cainfo = resSeven10265.Cainfo
  29401. res.WarnMsg = resSeven10265.WarnMsg
  29402. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29403. res.Infcode = infocode
  29404. } else {
  29405. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  29406. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  29407. utils.ErrorLog("解析失败:%v", err)
  29408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29409. return
  29410. }
  29411. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  29412. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  29413. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  29414. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  29415. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  29416. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  29417. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  29418. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29419. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  29420. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29421. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29422. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29423. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29424. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  29425. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  29426. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  29427. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  29428. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  29429. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  29430. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  29431. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29432. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  29433. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  29434. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  29435. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  29436. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  29437. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  29438. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  29439. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  29440. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  29441. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  29442. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  29443. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  29444. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  29445. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29446. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  29447. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  29448. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  29449. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29450. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  29451. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  29452. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  29453. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  29454. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  29455. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  29456. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  29457. res.ErrMsg = gzresSeven10265Two.ErrMsg
  29458. res.Cainfo = gzresSeven10265Two.Cainfo
  29459. res.WarnMsg = gzresSeven10265Two.WarnMsg
  29460. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  29461. //res.Infcode = infocode
  29462. } else {
  29463. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29464. utils.ErrorLog("解析失败:%v", err)
  29465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29466. return
  29467. }
  29468. }
  29469. }
  29470. }
  29471. if res.Infcode != 0 {
  29472. errlog := &models.HisOrderError{
  29473. UserOrgId: adminUser.CurrentOrgId,
  29474. Ctime: time.Now().Unix(),
  29475. Mtime: time.Now().Unix(),
  29476. Number: chrg_bchno,
  29477. ErrMsg: res.ErrMsg,
  29478. Status: 1,
  29479. PatientId: id,
  29480. RecordTime: recordDateTime,
  29481. Stage: 6,
  29482. }
  29483. service.CreateErrMsgLog(errlog)
  29484. c.ServeSuccessJSON(map[string]interface{}{
  29485. "failed_code": -10,
  29486. "msg": res.ErrMsg,
  29487. })
  29488. return
  29489. } else {
  29490. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  29491. order.OrderStatus = 2
  29492. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  29493. order.SetlId = res.Output.Setlinfo.SetlID
  29494. order.PsnNo = res.Output.Setlinfo.PsnNo
  29495. order.PsnName = res.Output.Setlinfo.PsnName
  29496. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  29497. order.Certno = res.Output.Setlinfo.Certno
  29498. order.Gend = res.Output.Setlinfo.Gend
  29499. order.Naty = res.Output.Setlinfo.Naty
  29500. order.Age = res.Output.Setlinfo.Age
  29501. order.Insutype = res.Output.Setlinfo.Insutype
  29502. order.PsnType = res.Output.Setlinfo.PsnType
  29503. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  29504. order.SetlTime = res.Output.Setlinfo.SetlTime
  29505. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  29506. order.PayWays = pay_ways
  29507. order.AcctUsedFlag = acct_used_flag
  29508. order.WechatPay = wechat_pay
  29509. order.AliPay = ali_pay
  29510. order.JifenPay = jifen_pay
  29511. order.BandCardPay = band_card_pay
  29512. order.CashPay = cash_pay
  29513. order.OthDesc = oth_desc
  29514. //order.MedType = res.Output.Setlinfo.MedType
  29515. if reg_type == 1112 {
  29516. order.MedType = "1112"
  29517. }
  29518. if reg_type == 1111 {
  29519. order.MedType = "1111"
  29520. }
  29521. order.ClrType = res.Output.Setlinfo.ClrType
  29522. if adminUser.CurrentOrgId == 10480 {
  29523. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  29524. order.ClrType = "11"
  29525. } else {
  29526. order.ClrType = "9903"
  29527. }
  29528. }
  29529. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  29530. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  29531. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  29532. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  29533. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  29534. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  29535. order.HifpPay = res.Output.Setlinfo.HifpPay
  29536. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  29537. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  29538. order.HifesPay = res.Output.Setlinfo.HifesPay
  29539. order.HifobPay = res.Output.Setlinfo.HifobPay
  29540. order.MafPay = res.Output.Setlinfo.MafPay
  29541. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  29542. order.OthPay = res.Output.Setlinfo.OthPay
  29543. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  29544. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  29545. order.AcctPay = res.Output.Setlinfo.AcctPay
  29546. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  29547. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  29548. order.Balc = res.Output.Setlinfo.Balc
  29549. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  29550. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  29551. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  29552. order.ClrWay = res.Output.Setlinfo.ClrWay
  29553. order.Creator = order.Creator
  29554. order.Modify = roles.AdminUserId
  29555. order.RequestLog = src_resquest
  29556. order.Diagnosis = diagnosis_id
  29557. order.FaPiaoNumber = fapiao_number
  29558. order.FaPiaoCode = fapiao_code
  29559. order.PayCardNo = pay_card_no
  29560. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  29561. detailStr := string(setlDetail)
  29562. order.SetlDetail = detailStr
  29563. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  29564. err = service.UpDateOrder(order)
  29565. if err == nil {
  29566. //判断是否使用了押金
  29567. if dec_way == "true" {
  29568. tmpstring := strconv.FormatInt(order.ID, 10)
  29569. //扣押金
  29570. order.Decimal = decimal
  29571. service.UpDateOrder(order)
  29572. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  29573. if errmsg != nil {
  29574. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  29575. return
  29576. }
  29577. }
  29578. c.ServeSuccessJSON(map[string]interface{}{
  29579. "msg": "结算成功",
  29580. })
  29581. } else {
  29582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  29583. return
  29584. }
  29585. }
  29586. }
  29587. }
  29588. }
  29589. // 上传明细-预结算-
  29590. func (c *HisApiController) GetPreUploadInfo() {
  29591. id, _ := c.GetInt64("id")
  29592. record_time := c.GetString("record_time")
  29593. his_patient_id, _ := c.GetInt64("his_patient_id")
  29594. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  29595. admin_user_id, _ := c.GetInt64("admin_user_id")
  29596. diagnosis_id := c.GetString("diagnosis")
  29597. sick_type, _ := c.GetInt64("sick_type")
  29598. reg_type, _ := c.GetInt64("p_type")
  29599. begin_time := c.GetString("begin_time")
  29600. acct_used_flag := c.GetString("acct_used_flag")
  29601. id_str := c.GetString("ids")
  29602. ids_arr := strings.Split(id_str, ",")
  29603. timeLayout := "2006-01-02"
  29604. loc, _ := time.LoadLocation("Local")
  29605. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  29606. if err != nil {
  29607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29608. return
  29609. }
  29610. recordDateTime := theTime.Unix()
  29611. adminUser := c.GetAdminUserInfo()
  29612. diagnosis_ids := strings.Split(diagnosis_id, ",")
  29613. var config []*models.HisXtDiagnoseConfig
  29614. for _, item := range diagnosis_ids {
  29615. id, _ := strconv.ParseInt(item, 10, 64)
  29616. if id > 0 {
  29617. diagnosisConfig, _ := service.FindDiagnoseById(id)
  29618. config = append(config, &diagnosisConfig)
  29619. }
  29620. }
  29621. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  29622. sickConfig, _ := service.FindSickById(sick_type)
  29623. var prescriptions []*models.HisPrescription
  29624. var start_time int64
  29625. var end_time int64
  29626. var isSuccess bool = true
  29627. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29628. fmt.Println(his_patient_id)
  29629. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29630. timestamp := time.Now().Unix()
  29631. tempTime := time.Unix(timestamp, 0)
  29632. timeFormat := tempTime.Format("20060102150405")
  29633. chrgBchno := rand.Intn(100000) + 10000
  29634. new_chrg_bchno := ""
  29635. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  29636. new_chrg_bchno = chrg_bchno
  29637. if adminUser.CurrentOrgId == 10265 {
  29638. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  29639. new_chrg_bchno = "0000"
  29640. }
  29641. }
  29642. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29643. var patientPrescription models.HisPrescriptionInfo
  29644. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29645. if patientPrescription.ID == 0 {
  29646. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  29647. }
  29648. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29649. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  29650. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  29651. strconv.FormatInt(his.PatientId, 10)
  29652. var res2406 Result2406
  29653. //安徽单病种处理
  29654. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  29655. data := make(map[string]interface{})
  29656. client := &http.Client{}
  29657. data["psn_no"] = his.PsnNo
  29658. data["mdtrt_id"] = his.Number
  29659. data["operator"] = roles.UserName
  29660. data["cert_no"] = his.IdCardNo
  29661. data["org_name"] = miConfig.OrgName
  29662. data["psn_name"] = his.Name
  29663. data["ipt_otp_no"] = his.IptOtpNo
  29664. data["ipt_psn_sp_flag_type"] = "0901"
  29665. data["ipt_psn_sp_flag"] = "1"
  29666. data["fixmedins_code"] = miConfig.Code
  29667. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29668. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29669. data["url"] = miConfig.Url
  29670. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  29671. bytesData, _ := json.Marshal(data)
  29672. var req *http.Request
  29673. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  29674. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  29675. resp, _ := client.Do(req)
  29676. defer resp.Body.Close()
  29677. body, ioErr := ioutil.ReadAll(resp.Body)
  29678. if ioErr != nil {
  29679. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29681. return
  29682. }
  29683. var respJSON map[string]interface{}
  29684. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29685. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29687. return
  29688. }
  29689. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29690. if status == "0" {
  29691. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29692. c.ServeSuccessJSON(map[string]interface{}{
  29693. "failed_code": -10,
  29694. "msg": err_msg,
  29695. })
  29696. return
  29697. }
  29698. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29699. userJSONBytes, _ := json.Marshal(respJSON)
  29700. fmt.Println("log")
  29701. fmt.Println(string(userJSONBytes))
  29702. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  29703. utils.ErrorLog("解析失败:%v", err)
  29704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29705. return
  29706. }
  29707. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  29708. data := make(map[string]interface{})
  29709. client := &http.Client{}
  29710. data["psn_no"] = his.PsnNo
  29711. data["mdtrt_id"] = his.Number
  29712. data["operator"] = roles.UserName
  29713. data["cert_no"] = his.IdCardNo
  29714. data["org_name"] = miConfig.OrgName
  29715. data["psn_name"] = his.Name
  29716. data["ipt_otp_no"] = his.IptOtpNo
  29717. data["ipt_psn_sp_flag_type"] = "0901"
  29718. data["ipt_psn_sp_flag"] = "1"
  29719. data["fixmedins_code"] = miConfig.Code
  29720. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29721. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29722. data["url"] = miConfig.Url
  29723. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  29724. bytesData, _ := json.Marshal(data)
  29725. var req *http.Request
  29726. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  29727. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  29728. resp, _ := client.Do(req)
  29729. defer resp.Body.Close()
  29730. body, ioErr := ioutil.ReadAll(resp.Body)
  29731. if ioErr != nil {
  29732. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29734. return
  29735. }
  29736. var respJSON map[string]interface{}
  29737. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29740. return
  29741. }
  29742. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29743. if status == "0" {
  29744. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29745. c.ServeSuccessJSON(map[string]interface{}{
  29746. "failed_code": -10,
  29747. "msg": err_msg,
  29748. })
  29749. return
  29750. }
  29751. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29752. userJSONBytes, _ := json.Marshal(respJSON)
  29753. fmt.Println("log")
  29754. fmt.Println(string(userJSONBytes))
  29755. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  29756. utils.ErrorLog("解析失败:%v", err)
  29757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29758. return
  29759. }
  29760. }
  29761. if res2406.Infcode != 0 {
  29762. adminUser := c.GetAdminUserInfo()
  29763. errlog := &models.HisOrderError{
  29764. UserOrgId: adminUser.CurrentOrgId,
  29765. Ctime: time.Now().Unix(),
  29766. Mtime: time.Now().Unix(),
  29767. ErrMsg: res2406.ErrMsg,
  29768. Status: 1,
  29769. PatientId: id,
  29770. RecordTime: recordDateTime,
  29771. Stage: 3,
  29772. }
  29773. service.CreateErrMsgLog(errlog)
  29774. c.ServeSuccessJSON(map[string]interface{}{
  29775. "failed_code": -10,
  29776. "msg": res2406.ErrMsg,
  29777. })
  29778. return
  29779. }
  29780. var res2 ResultSix
  29781. var res3 GZResultSix
  29782. var resSix10265 ResultSix10265
  29783. //var time_stamp string
  29784. if miConfig.MdtrtareaAdmvs == "421300" {
  29785. data := make(map[string]interface{})
  29786. client := &http.Client{}
  29787. data["psn_no"] = his.PsnNo
  29788. data["mdtrt_id"] = his.Number
  29789. data["department"] = department.Name
  29790. data["org_name"] = miConfig.OrgName
  29791. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29792. data["doctor_id"] = doctor_info.DoctorNumber
  29793. data["doctor_name"] = roles.UserName
  29794. data["fixmedins_code"] = miConfig.Code
  29795. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29796. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29797. data["secret_key"] = miConfig.SecretKey
  29798. data["sick_code"] = sickConfig.CountryCode
  29799. data["sick_name"] = sickConfig.ClassName
  29800. data["begin_time"] = begin_time
  29801. data["dept"] = strconv.FormatInt(department.ID, 10)
  29802. data["config"] = config
  29803. data["opter"] = roles.UserName
  29804. fmt.Println(data)
  29805. bytesData, _ := json.Marshal(data)
  29806. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  29807. resp, _ := client.Do(req)
  29808. defer resp.Body.Close()
  29809. body, ioErr := ioutil.ReadAll(resp.Body)
  29810. if ioErr != nil {
  29811. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29813. return
  29814. }
  29815. var respJSON map[string]interface{}
  29816. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29817. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29819. return
  29820. }
  29821. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29822. userJSONBytes, _ := json.Marshal(respJSON)
  29823. fmt.Println("log")
  29824. fmt.Println(string(userJSONBytes))
  29825. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29826. utils.ErrorLog("解析失败:%v", err)
  29827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29828. return
  29829. }
  29830. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29831. data := make(map[string]interface{})
  29832. client := &http.Client{}
  29833. data["psn_no"] = his.PsnNo
  29834. data["mdtrt_id"] = his.Number
  29835. data["department"] = department.Name
  29836. data["org_name"] = miConfig.OrgName
  29837. if reg_type == 11 && his.Insutype == "390" {
  29838. data["med_type"] = "110104"
  29839. } else {
  29840. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29841. }
  29842. data["doctor_id"] = doctor_info.DoctorNumber
  29843. data["doctor_name"] = roles.UserName
  29844. data["fixmedins_code"] = miConfig.Code
  29845. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29846. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29847. data["secret_key"] = miConfig.SecretKey
  29848. data["sick_code"] = sickConfig.CountryCode
  29849. data["sick_name"] = sickConfig.ClassName
  29850. data["begin_time"] = begin_time
  29851. data["dept"] = strconv.FormatInt(department.ID, 10)
  29852. data["config"] = config
  29853. data["opter"] = roles.UserName
  29854. fmt.Println(data)
  29855. bytesData, _ := json.Marshal(data)
  29856. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  29857. resp, _ := client.Do(req)
  29858. defer resp.Body.Close()
  29859. body, ioErr := ioutil.ReadAll(resp.Body)
  29860. if ioErr != nil {
  29861. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29863. return
  29864. }
  29865. var respJSON map[string]interface{}
  29866. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29867. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29869. return
  29870. }
  29871. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29872. userJSONBytes, _ := json.Marshal(respJSON)
  29873. fmt.Println("log")
  29874. fmt.Println(string(userJSONBytes))
  29875. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29876. utils.ErrorLog("解析失败:%v", err)
  29877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29878. return
  29879. }
  29880. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29881. data := make(map[string]interface{})
  29882. client := &http.Client{}
  29883. data["psn_no"] = his.PsnNo
  29884. data["mdtrt_id"] = his.Number
  29885. data["department"] = department.Name
  29886. data["org_name"] = miConfig.OrgName
  29887. if reg_type == 11 && his.Insutype == "390" {
  29888. data["med_type"] = "110104"
  29889. } else {
  29890. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29891. }
  29892. data["doctor_id"] = doctor_info.DoctorNumber
  29893. data["doctor_name"] = roles.UserName
  29894. data["fixmedins_code"] = miConfig.Code
  29895. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29896. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29897. data["secret_key"] = miConfig.SecretKey
  29898. data["sick_code"] = sickConfig.CountryCode
  29899. data["sick_name"] = sickConfig.ClassName
  29900. data["begin_time"] = begin_time
  29901. data["dept"] = strconv.FormatInt(department.ID, 10)
  29902. data["config"] = config
  29903. data["opter"] = roles.UserName
  29904. fmt.Println(data)
  29905. bytesData, _ := json.Marshal(data)
  29906. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  29907. resp, _ := client.Do(req)
  29908. defer resp.Body.Close()
  29909. body, ioErr := ioutil.ReadAll(resp.Body)
  29910. if ioErr != nil {
  29911. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29913. return
  29914. }
  29915. var respJSON map[string]interface{}
  29916. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29917. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29919. return
  29920. }
  29921. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29922. userJSONBytes, _ := json.Marshal(respJSON)
  29923. fmt.Println("log")
  29924. fmt.Println(string(userJSONBytes))
  29925. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29926. utils.ErrorLog("解析失败:%v", err)
  29927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29928. return
  29929. }
  29930. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29931. data := make(map[string]interface{})
  29932. client := &http.Client{}
  29933. data["psn_no"] = his.PsnNo
  29934. data["mdtrt_id"] = his.Number
  29935. data["department"] = department.Name
  29936. data["org_name"] = miConfig.OrgName
  29937. if reg_type == 11 && his.Insutype == "390" {
  29938. data["med_type"] = "110104"
  29939. } else {
  29940. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29941. }
  29942. data["doctor_id"] = doctor_info.DoctorNumber
  29943. data["doctor_name"] = roles.UserName
  29944. data["fixmedins_code"] = miConfig.Code
  29945. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29946. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29947. data["secret_key"] = miConfig.SecretKey
  29948. data["sick_code"] = sickConfig.CountryCode
  29949. data["sick_name"] = sickConfig.ClassName
  29950. data["begin_time"] = begin_time
  29951. data["dept"] = strconv.FormatInt(department.ID, 10)
  29952. data["config"] = config
  29953. data["opter"] = roles.UserName
  29954. fmt.Println(data)
  29955. bytesData, _ := json.Marshal(data)
  29956. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  29957. resp, _ := client.Do(req)
  29958. defer resp.Body.Close()
  29959. body, ioErr := ioutil.ReadAll(resp.Body)
  29960. if ioErr != nil {
  29961. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29963. return
  29964. }
  29965. var respJSON map[string]interface{}
  29966. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29967. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29969. return
  29970. }
  29971. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29972. userJSONBytes, _ := json.Marshal(respJSON)
  29973. fmt.Println("log")
  29974. fmt.Println(string(userJSONBytes))
  29975. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29976. utils.ErrorLog("解析失败:%v", err)
  29977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29978. return
  29979. }
  29980. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  29981. utils.ErrorLog("解析失败:%v", doctor_info)
  29982. data := make(map[string]interface{})
  29983. client := &http.Client{}
  29984. data["psn_no"] = his.PsnNo
  29985. data["mdtrt_id"] = his.Number
  29986. data["doctor"] = roles.UserName
  29987. data["department"] = department.Name
  29988. data["org_name"] = miConfig.OrgName
  29989. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29990. data["doctor_id"] = doctor_info.DoctorNumber
  29991. data["new_doctor_name"] = doctor_info.UserName
  29992. data["fixmedins_code"] = miConfig.Code
  29993. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29994. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29995. data["secret_key"] = miConfig.SecretKey
  29996. data["sick_code"] = sickConfig.CountryCode
  29997. data["sick_name"] = sickConfig.ClassName
  29998. data["url"] = miConfig.Url
  29999. data["ak"] = miConfig.AccessKey
  30000. data["begin_time"] = begin_time
  30001. data["cainfo"] = miConfig.Cainfo
  30002. data["dept"] = strconv.FormatInt(department.ID, 10)
  30003. data["config"] = config
  30004. bytesData, _ := json.Marshal(data)
  30005. var req *http.Request
  30006. if miConfig.MdtrtareaAdmvs == "320830" {
  30007. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2203", bytes.NewReader(bytesData))
  30008. } else if miConfig.MdtrtareaAdmvs == "320921" {
  30009. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  30010. } else {
  30011. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  30012. }
  30013. resp, _ := client.Do(req)
  30014. defer resp.Body.Close()
  30015. body, ioErr := ioutil.ReadAll(resp.Body)
  30016. if ioErr != nil {
  30017. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30019. return
  30020. }
  30021. var respJSON map[string]interface{}
  30022. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30023. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30025. return
  30026. }
  30027. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  30028. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  30029. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  30030. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30031. userJSONBytes, _ := json.Marshal(respJSON)
  30032. fmt.Println("log")
  30033. fmt.Println(string(userJSONBytes))
  30034. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  30035. utils.ErrorLog("解析失败:%v", err)
  30036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30037. return
  30038. }
  30039. res2.InfRefmsgid = resSix10265.InfRefmsgid
  30040. res2.Output = resSix10265.Output
  30041. res2.ErrMsg = resSix10265.ErrMsg
  30042. res2.Cainfo = resSix10265.Cainfo
  30043. res2.WarnMsg = resSix10265.WarnMsg
  30044. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30045. res2.Infcode = infocode
  30046. } else if miConfig.MdtrtareaAdmvs == "150404" {
  30047. data := make(map[string]interface{})
  30048. client := &http.Client{}
  30049. data["psn_no"] = his.PsnNo
  30050. data["mdtrt_id"] = his.Number
  30051. data["doctor"] = roles.UserName
  30052. data["department"] = department.Name
  30053. data["org_name"] = miConfig.OrgName
  30054. data["med_type"] = strconv.FormatInt(reg_type, 10)
  30055. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  30056. data["fixmedins_code"] = miConfig.Code
  30057. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30058. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30059. data["secret_key"] = miConfig.SecretKey
  30060. data["sick_code"] = sickConfig.CountryCode
  30061. data["sick_name"] = sickConfig.ClassName
  30062. data["begin_time"] = begin_time
  30063. data["dept"] = strconv.FormatInt(department.ID, 10)
  30064. data["config"] = config
  30065. //data["url"] = miConfig.Url
  30066. //data["ak"] = miConfig.AccessKey
  30067. data["cainfo"] = miConfig.Cainfo
  30068. fmt.Println(data)
  30069. bytesData, _ := json.Marshal(data)
  30070. var req *http.Request
  30071. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  30072. resp, _ := client.Do(req)
  30073. defer resp.Body.Close()
  30074. body, ioErr := ioutil.ReadAll(resp.Body)
  30075. if ioErr != nil {
  30076. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30078. return
  30079. }
  30080. var respJSON map[string]interface{}
  30081. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30082. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30084. return
  30085. }
  30086. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  30087. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  30088. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  30089. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30090. userJSONBytes, _ := json.Marshal(respJSON)
  30091. fmt.Println("log")
  30092. fmt.Println(string(userJSONBytes))
  30093. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  30094. utils.ErrorLog("解析失败:%v", err)
  30095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30096. return
  30097. }
  30098. res2.InfRefmsgid = resSix10265.InfRefmsgid
  30099. res2.Output = resSix10265.Output
  30100. res2.ErrMsg = resSix10265.ErrMsg
  30101. res2.Cainfo = resSix10265.Cainfo
  30102. res2.WarnMsg = resSix10265.WarnMsg
  30103. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30104. res2.Infcode = infocode
  30105. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30106. 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)
  30107. saveLog(result, requestLog, "2203", "上传就诊信息")
  30108. var respJSON2 map[string]interface{}
  30109. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30110. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30112. return
  30113. }
  30114. userJSONBytes2, _ := json.Marshal(respJSON2)
  30115. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30116. utils.ErrorLog("解析失败:%v", err)
  30117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30118. return
  30119. }
  30120. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30121. var result string
  30122. var requestLog string
  30123. 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, "")
  30124. saveLog(result, requestLog, "2203", "上传就诊信息")
  30125. var respJSON2 map[string]interface{}
  30126. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30127. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30129. return
  30130. }
  30131. userJSONBytes2, _ := json.Marshal(respJSON2)
  30132. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30133. utils.ErrorLog("解析失败:%v", err)
  30134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30135. return
  30136. }
  30137. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30138. var result string
  30139. var requestLog string
  30140. 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, "")
  30141. saveLog(result, requestLog, "2203", "上传就诊信息")
  30142. var respJSON2 map[string]interface{}
  30143. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30146. return
  30147. }
  30148. userJSONBytes2, _ := json.Marshal(respJSON2)
  30149. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30150. utils.ErrorLog("解析失败:%v", err)
  30151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30152. return
  30153. }
  30154. } else if miConfig.MdtrtareaAdmvs == "360100" {
  30155. var result string
  30156. var requestLog string
  30157. 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, "")
  30158. saveLog(result, requestLog, "2203", "上传就诊信息")
  30159. var respJSON2 map[string]interface{}
  30160. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30161. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30163. return
  30164. }
  30165. userJSONBytes2, _ := json.Marshal(respJSON2)
  30166. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30167. utils.ErrorLog("解析失败:%v", err)
  30168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30169. return
  30170. }
  30171. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30172. data := make(map[string]interface{})
  30173. client := &http.Client{}
  30174. data["psn_no"] = his.PsnNo
  30175. data["mdtrt_id"] = his.Number
  30176. data["operator"] = roles.UserName
  30177. data["department"] = department.Name
  30178. data["org_name"] = miConfig.OrgName
  30179. var med_type string
  30180. if his.Insutype == "390" {
  30181. if reg_type == 992102 {
  30182. med_type = "992102"
  30183. data["sick_code"] = "ZDZ940"
  30184. data["sick_name"] = "慢性肾衰竭"
  30185. }
  30186. if reg_type == 140104 {
  30187. med_type = "140104"
  30188. data["sick_code"] = sickConfig.CountryCode
  30189. data["sick_name"] = sickConfig.ClassName
  30190. }
  30191. if reg_type == 14 {
  30192. med_type = "140104"
  30193. data["sick_code"] = sickConfig.CountryCode
  30194. data["sick_name"] = sickConfig.ClassName
  30195. }
  30196. if reg_type == 1104 {
  30197. med_type = "1104"
  30198. data["sick_code"] = sickConfig.CountryCode
  30199. data["sick_name"] = sickConfig.ClassName
  30200. }
  30201. } else if his.Insutype == "310" {
  30202. if reg_type == 992102 {
  30203. med_type = "992102"
  30204. data["sick_code"] = "ZDZ940"
  30205. data["sick_name"] = "慢性肾衰竭"
  30206. }
  30207. if reg_type == 140104 {
  30208. med_type = "140104"
  30209. data["sick_code"] = sickConfig.CountryCode
  30210. data["sick_name"] = sickConfig.ClassName
  30211. }
  30212. if reg_type == 14 {
  30213. med_type = "14"
  30214. data["sick_code"] = sickConfig.CountryCode
  30215. data["sick_name"] = sickConfig.ClassName
  30216. }
  30217. if reg_type == 1104 {
  30218. med_type = "1104"
  30219. data["sick_code"] = sickConfig.CountryCode
  30220. data["sick_name"] = sickConfig.ClassName
  30221. }
  30222. }
  30223. data["med_type"] = med_type
  30224. data["doctor_number"] = doctor_info.DoctorNumber
  30225. data["doctor_name"] = doctor_info.UserName
  30226. data["fixmedins_code"] = miConfig.Code
  30227. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30228. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30229. data["secret_key"] = miConfig.SecretKey
  30230. data["begin_time"] = begin_time
  30231. data["dept"] = strconv.FormatInt(department.ID, 10)
  30232. data["config"] = config
  30233. data["url"] = miConfig.Url
  30234. data["ak"] = miConfig.AccessKey
  30235. data["cainfo"] = miConfig.Cainfo
  30236. bytesData, _ := json.Marshal(data)
  30237. var req *http.Request
  30238. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  30239. resp, _ := client.Do(req)
  30240. defer resp.Body.Close()
  30241. body, ioErr := ioutil.ReadAll(resp.Body)
  30242. if ioErr != nil {
  30243. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30245. return
  30246. }
  30247. var respJSON map[string]interface{}
  30248. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30249. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30251. return
  30252. }
  30253. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30254. if status == "0" {
  30255. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30256. c.ServeSuccessJSON(map[string]interface{}{
  30257. "failed_code": -10,
  30258. "msg": err_msg,
  30259. })
  30260. return
  30261. }
  30262. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30263. userJSONBytes, _ := json.Marshal(respJSON)
  30264. fmt.Println("log")
  30265. fmt.Println(string(userJSONBytes))
  30266. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30267. utils.ErrorLog("解析失败:%v", err)
  30268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30269. return
  30270. }
  30271. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30272. data := make(map[string]interface{})
  30273. client := &http.Client{}
  30274. data["psn_no"] = his.PsnNo
  30275. data["mdtrt_id"] = his.Number
  30276. data["operator"] = roles.UserName
  30277. data["department"] = department.Name
  30278. data["org_name"] = miConfig.OrgName
  30279. var med_type string
  30280. if his.Insutype == "390" {
  30281. if reg_type == 992102 {
  30282. med_type = "992102"
  30283. data["sick_code"] = sickConfig.CountryCode
  30284. data["sick_name"] = sickConfig.ClassName
  30285. }
  30286. if reg_type == 140104 {
  30287. med_type = "140104"
  30288. data["sick_code"] = sickConfig.CountryCode
  30289. data["sick_name"] = sickConfig.ClassName
  30290. }
  30291. if reg_type == 140201 {
  30292. med_type = "140201"
  30293. data["sick_code"] = sickConfig.CountryCode
  30294. data["sick_name"] = sickConfig.ClassName
  30295. }
  30296. if reg_type == 14 {
  30297. med_type = "14"
  30298. data["sick_code"] = sickConfig.CountryCode
  30299. data["sick_name"] = sickConfig.ClassName
  30300. }
  30301. if reg_type == 11 {
  30302. med_type = "11"
  30303. data["sick_code"] = sickConfig.CountryCode
  30304. data["sick_name"] = sickConfig.ClassName
  30305. }
  30306. } else if his.Insutype == "310" {
  30307. if reg_type == 992102 {
  30308. med_type = "992102"
  30309. data["sick_code"] = sickConfig.CountryCode
  30310. data["sick_name"] = sickConfig.ClassName
  30311. }
  30312. if reg_type == 140104 {
  30313. med_type = "140104"
  30314. data["sick_code"] = sickConfig.CountryCode
  30315. data["sick_name"] = sickConfig.ClassName
  30316. }
  30317. if reg_type == 140201 {
  30318. med_type = "140201"
  30319. data["sick_code"] = sickConfig.CountryCode
  30320. data["sick_name"] = sickConfig.ClassName
  30321. }
  30322. if reg_type == 14 {
  30323. med_type = "14"
  30324. data["sick_code"] = sickConfig.CountryCode
  30325. data["sick_name"] = sickConfig.ClassName
  30326. }
  30327. if reg_type == 11 {
  30328. med_type = "11"
  30329. data["sick_code"] = sickConfig.CountryCode
  30330. data["sick_name"] = sickConfig.ClassName
  30331. }
  30332. }
  30333. data["med_type"] = med_type
  30334. data["doctor_number"] = doctor_info.DoctorNumber
  30335. data["doctor_name"] = doctor_info.UserName
  30336. data["fixmedins_code"] = miConfig.Code
  30337. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30338. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30339. data["secret_key"] = miConfig.SecretKey
  30340. data["begin_time"] = begin_time
  30341. data["dept"] = strconv.FormatInt(department.ID, 10)
  30342. data["config"] = config
  30343. data["url"] = miConfig.Url
  30344. data["ak"] = miConfig.AccessKey
  30345. data["cainfo"] = miConfig.Cainfo
  30346. bytesData, _ := json.Marshal(data)
  30347. var req *http.Request
  30348. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  30349. resp, _ := client.Do(req)
  30350. defer resp.Body.Close()
  30351. body, ioErr := ioutil.ReadAll(resp.Body)
  30352. if ioErr != nil {
  30353. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30355. return
  30356. }
  30357. var respJSON map[string]interface{}
  30358. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30361. return
  30362. }
  30363. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30364. if status == "0" {
  30365. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30366. c.ServeSuccessJSON(map[string]interface{}{
  30367. "failed_code": -10,
  30368. "msg": err_msg,
  30369. })
  30370. return
  30371. }
  30372. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30373. userJSONBytes, _ := json.Marshal(respJSON)
  30374. fmt.Println("log")
  30375. fmt.Println(string(userJSONBytes))
  30376. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30377. utils.ErrorLog("解析失败:%v", err)
  30378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30379. return
  30380. }
  30381. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30382. var result string
  30383. var requestLog string
  30384. 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)
  30385. saveLog(result, requestLog, "2203", "上传就诊信息")
  30386. var respJSON2 map[string]interface{}
  30387. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30388. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30390. return
  30391. }
  30392. userJSONBytes2, _ := json.Marshal(respJSON2)
  30393. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30394. utils.ErrorLog("解析失败:%v", err)
  30395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30396. return
  30397. }
  30398. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30399. data := make(map[string]interface{})
  30400. client := &http.Client{}
  30401. data["psn_no"] = his.PsnNo
  30402. data["mdtrt_id"] = his.Number
  30403. data["doctor"] = roles.UserName
  30404. data["department"] = department.Name
  30405. data["org_name"] = miConfig.OrgName
  30406. data["med_type"] = strconv.FormatInt(reg_type, 10)
  30407. data["doctor_id"] = doctor_info.DoctorNumber
  30408. data["fixmedins_code"] = miConfig.Code
  30409. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30410. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30411. data["secret_key"] = miConfig.SecretKey
  30412. data["sick_code"] = sickConfig.CountryCode
  30413. data["sick_name"] = sickConfig.ClassName
  30414. data["begin_time"] = begin_time
  30415. data["new_doctor_name"] = doctor_info.UserName
  30416. data["dept"] = strconv.FormatInt(department.ID, 10)
  30417. data["config"] = config
  30418. bytesData, _ := json.Marshal(data)
  30419. var req *http.Request
  30420. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  30421. resp, _ := client.Do(req)
  30422. defer resp.Body.Close()
  30423. body, ioErr := ioutil.ReadAll(resp.Body)
  30424. if ioErr != nil {
  30425. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30427. return
  30428. }
  30429. var respJSON map[string]interface{}
  30430. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30431. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30433. return
  30434. }
  30435. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30436. userJSONBytes, _ := json.Marshal(respJSON)
  30437. fmt.Println("log")
  30438. fmt.Println(string(userJSONBytes))
  30439. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30440. utils.ErrorLog("解析失败:%v", err)
  30441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30442. return
  30443. }
  30444. } else {
  30445. var result string
  30446. var requestLog string
  30447. if miConfig.MdtrtareaAdmvs == "440781" { //
  30448. 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)
  30449. } else {
  30450. if miConfig.Code == "H15049901371" {
  30451. //赤峰地区国家医保医疗类别
  30452. //职工透析:医疗类别选特殊情况门诊990502
  30453. //居民定额血透门慢: 医疗类别选门诊慢病140104
  30454. var med_type string
  30455. if his.Insutype == "390" {
  30456. if reg_type == 14 {
  30457. med_type = "9933"
  30458. } else if reg_type == 11 {
  30459. med_type = "11"
  30460. }
  30461. } else if his.Insutype == "310" {
  30462. if reg_type == 14 {
  30463. med_type = "990502"
  30464. } else if reg_type == 11 {
  30465. med_type = "11"
  30466. }
  30467. }
  30468. 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)
  30469. } else {
  30470. 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)
  30471. }
  30472. saveLog(result, requestLog, "2203", "上传就诊信息")
  30473. var respJSON2 map[string]interface{}
  30474. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30475. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30477. return
  30478. }
  30479. userJSONBytes2, _ := json.Marshal(respJSON2)
  30480. if miConfig.Code == "H15049901371" {
  30481. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  30482. utils.ErrorLog("解析失败:%v", err)
  30483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30484. return
  30485. }
  30486. res2.InfRefmsgid = resSix10265.InfRefmsgid
  30487. res2.Output = resSix10265.Output
  30488. res2.ErrMsg = resSix10265.ErrMsg
  30489. res2.Cainfo = resSix10265.Cainfo
  30490. res2.WarnMsg = resSix10265.WarnMsg
  30491. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30492. res2.Infcode = infocode
  30493. } else {
  30494. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30495. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  30496. utils.ErrorLog("解析失败:%v", err)
  30497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30498. return
  30499. }
  30500. res2.Infcode = res3.Infcode
  30501. } else {
  30502. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30503. utils.ErrorLog("解析失败:%v", err)
  30504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30505. return
  30506. }
  30507. }
  30508. }
  30509. }
  30510. }
  30511. if res2.Infcode == -1 {
  30512. adminUser := c.GetAdminUserInfo()
  30513. errlog := &models.HisOrderError{
  30514. UserOrgId: adminUser.CurrentOrgId,
  30515. Ctime: time.Now().Unix(),
  30516. Mtime: time.Now().Unix(),
  30517. ErrMsg: res2.ErrMsg,
  30518. Status: 1,
  30519. PatientId: id,
  30520. RecordTime: recordDateTime,
  30521. Stage: 3,
  30522. }
  30523. service.CreateErrMsgLog(errlog)
  30524. c.ServeSuccessJSON(map[string]interface{}{
  30525. "failed_code": -10,
  30526. "msg": res2.ErrMsg,
  30527. })
  30528. return
  30529. }
  30530. if res2.Infcode != 0 {
  30531. adminUser := c.GetAdminUserInfo()
  30532. errlog := &models.HisOrderError{
  30533. UserOrgId: adminUser.CurrentOrgId,
  30534. Ctime: time.Now().Unix(),
  30535. Mtime: time.Now().Unix(),
  30536. ErrMsg: res2.ErrMsg,
  30537. Status: 1,
  30538. PatientId: id,
  30539. RecordTime: recordDateTime,
  30540. Stage: 3,
  30541. }
  30542. service.CreateErrMsgLog(errlog)
  30543. c.ServeSuccessJSON(map[string]interface{}{
  30544. "failed_code": -10,
  30545. "msg": res2.ErrMsg,
  30546. })
  30547. return
  30548. } else {
  30549. his.Diagnosis = diagnosis_id
  30550. his.SickType = sickConfig.ID
  30551. his.PType = fmt.Sprintf("%d", reg_type)
  30552. service.UpdateHisPatientThree(&his)
  30553. data := make(map[string]interface{})
  30554. if settle_accounts_type == 1 { //日结
  30555. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  30556. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  30557. } else {
  30558. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  30559. }
  30560. data["pre"] = prescriptions
  30561. } else { //月结
  30562. start_time_str := c.GetString("start_time")
  30563. end_time_str := c.GetString("end_time")
  30564. timeLayout := "2006-01-02"
  30565. loc, _ := time.LoadLocation("Local")
  30566. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  30567. if err != nil {
  30568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30569. return
  30570. }
  30571. recordStartTime := theStartTime.Unix()
  30572. start_time = recordStartTime
  30573. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  30574. if err != nil {
  30575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30576. return
  30577. }
  30578. recordEndTime := theEndTime.Unix()
  30579. end_time = recordEndTime
  30580. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  30581. data["pre"] = prescriptions
  30582. }
  30583. client := &http.Client{}
  30584. data["psn_no"] = his.PsnNo
  30585. data["mdtrt_id"] = his.Number
  30586. data["chrg_bchno"] = new_chrg_bchno
  30587. data["org_name"] = miConfig.OrgName
  30588. data["doctor"] = doctor_info.UserName
  30589. data["doctor_id"] = doctor_info.DoctorNumber
  30590. data["dept"] = department.Name
  30591. data["fixmedins_code"] = miConfig.Code
  30592. data["opter"] = roles.UserName
  30593. data["dept_code"] = department.Number
  30594. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30595. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30596. data["secret_key"] = miConfig.SecretKey
  30597. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  30598. data["url"] = miConfig.Url
  30599. data["ak"] = miConfig.AccessKey
  30600. data["new_doctor_name"] = patientPrescription.Doctor
  30601. if his.Insutype == "390" {
  30602. if reg_type == 992102 {
  30603. data["diag_code"] = "ZDZ940"
  30604. }
  30605. if reg_type == 140104 {
  30606. data["diag_code"] = sickConfig.CountryCode
  30607. }
  30608. if reg_type == 140201 {
  30609. data["diag_code"] = sickConfig.CountryCode
  30610. }
  30611. if reg_type == 14 {
  30612. data["diag_code"] = sickConfig.CountryCode
  30613. }
  30614. if reg_type == 1104 {
  30615. data["diag_code"] = sickConfig.CountryCode
  30616. }
  30617. } else if his.Insutype == "310" {
  30618. if miConfig.MdtrtareaAdmvs == "341203" {
  30619. if reg_type == 992102 {
  30620. data["diag_code"] = "ZDZ940"
  30621. }
  30622. if reg_type != 992102 {
  30623. data["diag_code"] = sickConfig.CountryCode
  30624. }
  30625. } else {
  30626. data["diag_code"] = sickConfig.CountryCode
  30627. }
  30628. }
  30629. data["cainfo"] = miConfig.Cainfo
  30630. data["opter"] = roles.UserName
  30631. var ids []int64
  30632. for _, item := range prescriptions {
  30633. ids = append(ids, item.ID)
  30634. }
  30635. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30636. if config.IsOpen == 1 { //对接了医保,走医保流程
  30637. var res ResultFour
  30638. var resFour10265 ResultFour10265
  30639. if miConfig.MdtrtareaAdmvs == "421300" {
  30640. bytesData, _ := json.Marshal(data)
  30641. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  30642. resp, _ := client.Do(req)
  30643. defer resp.Body.Close()
  30644. body, ioErr := ioutil.ReadAll(resp.Body)
  30645. if ioErr != nil {
  30646. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30648. return
  30649. }
  30650. var respJSON map[string]interface{}
  30651. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30652. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30654. return
  30655. }
  30656. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30657. userJSONBytes, _ := json.Marshal(respJSON)
  30658. fmt.Println("log")
  30659. fmt.Println(string(userJSONBytes))
  30660. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30661. utils.ErrorLog("解析失败:%v", err)
  30662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30663. return
  30664. }
  30665. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30666. bytesData, _ := json.Marshal(data)
  30667. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  30668. resp, _ := client.Do(req)
  30669. defer resp.Body.Close()
  30670. body, ioErr := ioutil.ReadAll(resp.Body)
  30671. if ioErr != nil {
  30672. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30674. return
  30675. }
  30676. var respJSON map[string]interface{}
  30677. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30678. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30680. return
  30681. }
  30682. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30683. userJSONBytes, _ := json.Marshal(respJSON)
  30684. fmt.Println("log")
  30685. fmt.Println(string(userJSONBytes))
  30686. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30687. utils.ErrorLog("解析失败:%v", err)
  30688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30689. return
  30690. }
  30691. } else if miConfig.MdtrtareaAdmvs == "420902" {
  30692. bytesData, _ := json.Marshal(data)
  30693. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  30694. resp, _ := client.Do(req)
  30695. defer resp.Body.Close()
  30696. body, ioErr := ioutil.ReadAll(resp.Body)
  30697. if ioErr != nil {
  30698. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30700. return
  30701. }
  30702. var respJSON map[string]interface{}
  30703. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30706. return
  30707. }
  30708. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30709. userJSONBytes, _ := json.Marshal(respJSON)
  30710. fmt.Println("log")
  30711. fmt.Println(string(userJSONBytes))
  30712. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30713. utils.ErrorLog("解析失败:%v", err)
  30714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30715. return
  30716. }
  30717. } else if miConfig.MdtrtareaAdmvs == "421182" {
  30718. bytesData, _ := json.Marshal(data)
  30719. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  30720. resp, _ := client.Do(req)
  30721. defer resp.Body.Close()
  30722. body, ioErr := ioutil.ReadAll(resp.Body)
  30723. if ioErr != nil {
  30724. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30726. return
  30727. }
  30728. var respJSON map[string]interface{}
  30729. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30732. return
  30733. }
  30734. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30735. userJSONBytes, _ := json.Marshal(respJSON)
  30736. fmt.Println("log")
  30737. fmt.Println(string(userJSONBytes))
  30738. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30739. utils.ErrorLog("解析失败:%v", err)
  30740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30741. return
  30742. }
  30743. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  30744. var result3101 Result3101
  30745. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30746. result3101.Infcode = "0"
  30747. if result3101.Infcode == "0" {
  30748. if len(result3101.Output.Result) > 0 {
  30749. var errMsgs []string
  30750. for _, item := range result3101.Output.Result {
  30751. errMsgs = append(errMsgs, item.VolaCont)
  30752. }
  30753. c.ServeSuccessJSON(map[string]interface{}{
  30754. "failed_code": -10,
  30755. "msg": errMsgs,
  30756. })
  30757. return
  30758. } else {
  30759. if miConfig.MdtrtareaAdmvs == "320921" {
  30760. data["doctor_id"] = doctor_info.DoctorNumber
  30761. } else {
  30762. data["doctor_id"] = doctor_info.DoctorNumber
  30763. }
  30764. bytesData, _ := json.Marshal(data)
  30765. var req *http.Request
  30766. if miConfig.MdtrtareaAdmvs == "320830" {
  30767. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2204", bytes.NewReader(bytesData))
  30768. } else if miConfig.MdtrtareaAdmvs == "320921" {
  30769. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30770. } else {
  30771. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30772. }
  30773. resp, _ := client.Do(req)
  30774. defer resp.Body.Close()
  30775. body, ioErr := ioutil.ReadAll(resp.Body)
  30776. if ioErr != nil {
  30777. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30779. return
  30780. }
  30781. var respJSON map[string]interface{}
  30782. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30785. return
  30786. }
  30787. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30788. userJSONBytes, _ := json.Marshal(respJSON)
  30789. fmt.Println("log")
  30790. fmt.Println(string(userJSONBytes))
  30791. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30792. utils.ErrorLog("解析失败:%v", err)
  30793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30794. return
  30795. }
  30796. res.InfRefmsgid = resFour10265.InfRefmsgid
  30797. res.Output = resFour10265.Output
  30798. res.ErrMsg = resFour10265.ErrMsg
  30799. res.Cainfo = resFour10265.Cainfo
  30800. res.WarnMsg = resFour10265.WarnMsg
  30801. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30802. res.Infcode = infocode
  30803. }
  30804. }
  30805. } else if miConfig.MdtrtareaAdmvs == "150404" {
  30806. var pagesize int = 5
  30807. var start int = 1
  30808. var stop int
  30809. var pagecount int
  30810. var curpage int
  30811. data["doctor_id"] = doctor_info.DoctorNumber
  30812. var res2 ResultFour
  30813. //var result res.
  30814. //总页数,向上取整,注意除之前要先转换类型为float64
  30815. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  30816. for curpage = 1; curpage <= pagecount; curpage++ {
  30817. if curpage == 1 {
  30818. start = 1
  30819. } else {
  30820. start = (curpage-1)*pagesize + 1
  30821. }
  30822. stop = curpage * pagesize
  30823. if stop > len(prescriptions) {
  30824. stop = len(prescriptions)
  30825. }
  30826. //var requestLog string
  30827. data["pre"] = prescriptions[start-1 : stop]
  30828. fmt.Println(data["pre"])
  30829. bytesData, _ := json.Marshal(data)
  30830. var req *http.Request
  30831. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  30832. resp, _ := client.Do(req)
  30833. defer resp.Body.Close()
  30834. body, ioErr := ioutil.ReadAll(resp.Body)
  30835. if ioErr != nil {
  30836. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30838. return
  30839. }
  30840. var respJSON map[string]interface{}
  30841. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30842. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30844. return
  30845. }
  30846. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30847. userJSONBytes, _ := json.Marshal(respJSON)
  30848. fmt.Println("log")
  30849. fmt.Println(string(userJSONBytes))
  30850. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30851. utils.ErrorLog("解析失败:%v", err)
  30852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30853. return
  30854. }
  30855. res.InfRefmsgid = resFour10265.InfRefmsgid
  30856. res.Output = resFour10265.Output
  30857. res.ErrMsg = resFour10265.ErrMsg
  30858. res.Cainfo = resFour10265.Cainfo
  30859. res.WarnMsg = resFour10265.WarnMsg
  30860. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30861. res.Infcode = infocode
  30862. if infocode == 0 {
  30863. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  30864. } else {
  30865. isSuccess = false
  30866. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  30867. res.Infcode = -1
  30868. res.ErrMsg = resFour10265.ErrMsg
  30869. errlog := &models.HisOrderError{
  30870. UserOrgId: adminUser.CurrentOrgId,
  30871. Ctime: time.Now().Unix(),
  30872. Mtime: time.Now().Unix(),
  30873. Number: chrg_bchno,
  30874. ErrMsg: "",
  30875. Status: 1,
  30876. PatientId: id,
  30877. RecordTime: recordDateTime,
  30878. Stage: 4,
  30879. }
  30880. service.CreateErrMsgLog(errlog)
  30881. }
  30882. }
  30883. if isSuccess {
  30884. res.Infcode = 0
  30885. res.Output.Result = res2.Output.Result
  30886. } else {
  30887. order := &models.HisOrder{
  30888. UserOrgId: adminUser.CurrentOrgId,
  30889. HisPatientId: his.ID,
  30890. PatientId: his.PatientId,
  30891. SettleAccountsDate: recordDateTime,
  30892. Ctime: time.Now().Unix(),
  30893. Mtime: time.Now().Unix(),
  30894. MdtrtId: his.Number,
  30895. PsnNo: his.PsnNo,
  30896. MedType: strconv.FormatInt(reg_type, 10),
  30897. Status: 1,
  30898. Number: chrg_bchno,
  30899. Infcode: res.Infcode,
  30900. WarnMsg: res.WarnMsg,
  30901. Cainfo: res.Cainfo,
  30902. ErrMsg: res.ErrMsg,
  30903. RespondTime: res.RefmsgTime,
  30904. InfRefmsgid: res.InfRefmsgid,
  30905. OrderStatus: 1,
  30906. IsMedicineInsurance: 1,
  30907. SettleType: settle_accounts_type,
  30908. SettleStartTime: start_time,
  30909. SettleEndTime: end_time,
  30910. Creator: roles.AdminUserId,
  30911. Modify: roles.AdminUserId,
  30912. PType: 2,
  30913. Diagnosis: diagnosis_id,
  30914. }
  30915. err = service.CreateOrder(order)
  30916. if err != nil {
  30917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  30918. return
  30919. }
  30920. c.ServeSuccessJSON(map[string]interface{}{
  30921. "failed_code": -10,
  30922. "msg": res2.ErrMsg,
  30923. })
  30924. return
  30925. }
  30926. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30927. 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)
  30928. var dat map[string]interface{}
  30929. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30930. fmt.Println(dat)
  30931. } else {
  30932. fmt.Println(err)
  30933. }
  30934. saveLog(result, request_log, "2204", "上传费用明细")
  30935. userJSONBytes, _ := json.Marshal(dat)
  30936. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30937. utils.ErrorLog("解析失败:%v", err)
  30938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30939. return
  30940. }
  30941. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30942. 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, "", "")
  30943. var dat map[string]interface{}
  30944. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30945. fmt.Println(dat)
  30946. } else {
  30947. fmt.Println(err)
  30948. }
  30949. saveLog(result, request_log, "2204", "上传费用明细")
  30950. userJSONBytes, _ := json.Marshal(dat)
  30951. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30952. utils.ErrorLog("解析失败:%v", err)
  30953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30954. return
  30955. }
  30956. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30957. 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, "", "")
  30958. var dat map[string]interface{}
  30959. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30960. fmt.Println(dat)
  30961. } else {
  30962. fmt.Println(err)
  30963. }
  30964. saveLog(result, request_log, "2204", "上传费用明细")
  30965. userJSONBytes, _ := json.Marshal(dat)
  30966. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30967. utils.ErrorLog("解析失败:%v", err)
  30968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30969. return
  30970. }
  30971. } else if miConfig.MdtrtareaAdmvs == "360100" {
  30972. 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, "", "")
  30973. var dat map[string]interface{}
  30974. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30975. fmt.Println(dat)
  30976. } else {
  30977. fmt.Println(err)
  30978. }
  30979. saveLog(result, request_log, "2204", "上传费用明细")
  30980. userJSONBytes, _ := json.Marshal(dat)
  30981. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30982. utils.ErrorLog("解析失败:%v", err)
  30983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30984. return
  30985. }
  30986. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30987. bytesData, _ := json.Marshal(data)
  30988. var req *http.Request
  30989. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  30990. resp, _ := client.Do(req)
  30991. defer resp.Body.Close()
  30992. body, ioErr := ioutil.ReadAll(resp.Body)
  30993. if ioErr != nil {
  30994. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30996. return
  30997. }
  30998. var respJSON map[string]interface{}
  30999. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31002. return
  31003. }
  31004. status := respJSON["data"].(map[string]interface{})["status"].(string)
  31005. if status == "0" {
  31006. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  31007. c.ServeSuccessJSON(map[string]interface{}{
  31008. "failed_code": -10,
  31009. "msg": err_msg,
  31010. })
  31011. return
  31012. }
  31013. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31014. userJSONBytes, _ := json.Marshal(respJSON)
  31015. fmt.Println("log")
  31016. fmt.Println(string(userJSONBytes))
  31017. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31018. utils.ErrorLog("解析失败:%v", err)
  31019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31020. return
  31021. }
  31022. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31023. bytesData, _ := json.Marshal(data)
  31024. var req *http.Request
  31025. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  31026. resp, _ := client.Do(req)
  31027. defer resp.Body.Close()
  31028. body, ioErr := ioutil.ReadAll(resp.Body)
  31029. if ioErr != nil {
  31030. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31032. return
  31033. }
  31034. var respJSON map[string]interface{}
  31035. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31036. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31038. return
  31039. }
  31040. status := respJSON["data"].(map[string]interface{})["status"].(string)
  31041. if status == "0" {
  31042. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  31043. c.ServeSuccessJSON(map[string]interface{}{
  31044. "failed_code": -10,
  31045. "msg": err_msg,
  31046. })
  31047. return
  31048. }
  31049. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31050. userJSONBytes, _ := json.Marshal(respJSON)
  31051. fmt.Println("log")
  31052. fmt.Println(string(userJSONBytes))
  31053. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31054. utils.ErrorLog("解析失败:%v", err)
  31055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31056. return
  31057. }
  31058. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31059. 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, "", "")
  31060. var dat map[string]interface{}
  31061. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31062. fmt.Println(dat)
  31063. } else {
  31064. fmt.Println(err)
  31065. }
  31066. saveLog(result, request_log, "2204", "上传费用明细")
  31067. userJSONBytes, _ := json.Marshal(dat)
  31068. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31069. utils.ErrorLog("解析失败:%v", err)
  31070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31071. return
  31072. }
  31073. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31074. bytesData, _ := json.Marshal(data)
  31075. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  31076. resp, _ := client.Do(req)
  31077. defer resp.Body.Close()
  31078. body, ioErr := ioutil.ReadAll(resp.Body)
  31079. if ioErr != nil {
  31080. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31082. return
  31083. }
  31084. var respJSON map[string]interface{}
  31085. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31086. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31088. return
  31089. }
  31090. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31091. userJSONBytes, _ := json.Marshal(respJSON)
  31092. fmt.Println("log")
  31093. fmt.Println(string(userJSONBytes))
  31094. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31095. utils.ErrorLog("解析失败:%v", err)
  31096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31097. return
  31098. }
  31099. } else {
  31100. if miConfig.MdtrtareaAdmvs == "441202" {
  31101. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  31102. if result3101.Infcode == 0 {
  31103. if len(result3101.Output.Result) > 0 {
  31104. var errMsgs []string
  31105. for _, item := range result3101.Output.Result {
  31106. errMsgs = append(errMsgs, item.VolaCont)
  31107. }
  31108. c.ServeSuccessJSON(map[string]interface{}{
  31109. "failed_code": -10,
  31110. "msg": errMsgs,
  31111. })
  31112. return
  31113. } else {
  31114. 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)
  31115. var dat map[string]interface{}
  31116. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31117. fmt.Println(dat)
  31118. } else {
  31119. fmt.Println(err)
  31120. }
  31121. saveLog(result, request_log, "2204", "上传费用明细")
  31122. userJSONBytes, _ := json.Marshal(dat)
  31123. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31124. utils.ErrorLog("解析失败:%v", err)
  31125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31126. return
  31127. }
  31128. }
  31129. } else {
  31130. c.ServeSuccessJSON(map[string]interface{}{
  31131. "failed_code": -10,
  31132. "msg": result3101.ErrMsg,
  31133. })
  31134. return
  31135. }
  31136. } else if miConfig.MdtrtareaAdmvs == "440205" {
  31137. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  31138. if result3101.Infcode == 0 {
  31139. if len(result3101.Output.Result) > 0 {
  31140. var errMsgs []string
  31141. for _, item := range result3101.Output.Result {
  31142. errMsgs = append(errMsgs, item.VolaCont)
  31143. }
  31144. c.ServeSuccessJSON(map[string]interface{}{
  31145. "failed_code": -10,
  31146. "msg": errMsgs,
  31147. })
  31148. return
  31149. } else {
  31150. 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)
  31151. var dat map[string]interface{}
  31152. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31153. fmt.Println(dat)
  31154. } else {
  31155. fmt.Println(err)
  31156. }
  31157. saveLog(result, request_log, "2204", "上传费用明细")
  31158. userJSONBytes, _ := json.Marshal(dat)
  31159. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31160. utils.ErrorLog("解析失败:%v", err)
  31161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31162. return
  31163. }
  31164. }
  31165. } else {
  31166. c.ServeSuccessJSON(map[string]interface{}{
  31167. "failed_code": -10,
  31168. "msg": result3101.ErrMsg,
  31169. })
  31170. return
  31171. }
  31172. } else {
  31173. if miConfig.Code == "H15049901371" {
  31174. 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)
  31175. var dat map[string]interface{}
  31176. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31177. fmt.Println(dat)
  31178. } else {
  31179. fmt.Println(err)
  31180. }
  31181. saveLog(result, request_log, "2204", "上传费用明细")
  31182. userJSONBytes, _ := json.Marshal(dat)
  31183. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  31184. utils.ErrorLog("解析失败:%v", err)
  31185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31186. return
  31187. }
  31188. res.InfRefmsgid = resFour10265.InfRefmsgid
  31189. res.Output = resFour10265.Output
  31190. res.ErrMsg = resFour10265.ErrMsg
  31191. res.Cainfo = resFour10265.Cainfo
  31192. res.WarnMsg = resFour10265.WarnMsg
  31193. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  31194. res.Infcode = infocode
  31195. } else {
  31196. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" || miConfig.Code == "H44090200998" {
  31197. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  31198. if result3101.Infcode == 0 {
  31199. if len(result3101.Output.Result) > 0 {
  31200. c.ServeSuccessJSON(map[string]interface{}{
  31201. "failed_code": -10,
  31202. "failed_type": 100,
  31203. "warm_type": 1,
  31204. "msg": result3101,
  31205. })
  31206. return
  31207. } else {
  31208. 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)
  31209. var dat map[string]interface{}
  31210. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31211. fmt.Println(dat)
  31212. } else {
  31213. fmt.Println(err)
  31214. }
  31215. saveLog(result, request_log, "2204", "上传费用明细")
  31216. userJSONBytes, _ := json.Marshal(dat)
  31217. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31218. utils.ErrorLog("解析失败:%v", err)
  31219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31220. return
  31221. }
  31222. }
  31223. } else {
  31224. c.ServeSuccessJSON(map[string]interface{}{
  31225. "failed_code": -10,
  31226. "msg": result3101.ErrMsg,
  31227. })
  31228. return
  31229. }
  31230. } else {
  31231. 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)
  31232. var dat map[string]interface{}
  31233. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31234. fmt.Println(dat)
  31235. } else {
  31236. fmt.Println(err)
  31237. }
  31238. saveLog(result, request_log, "2204", "上传费用明细")
  31239. userJSONBytes, _ := json.Marshal(dat)
  31240. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31241. utils.ErrorLog("解析失败:%v", err)
  31242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31243. return
  31244. }
  31245. }
  31246. }
  31247. }
  31248. }
  31249. var total_two float64
  31250. if res.Infcode == -1 {
  31251. errlog := &models.HisOrderError{
  31252. UserOrgId: adminUser.CurrentOrgId,
  31253. Ctime: time.Now().Unix(),
  31254. Mtime: time.Now().Unix(),
  31255. Number: chrg_bchno,
  31256. ErrMsg: res.ErrMsg,
  31257. Status: 1,
  31258. PatientId: id,
  31259. RecordTime: recordDateTime,
  31260. Stage: 4,
  31261. }
  31262. service.CreateErrMsgLog(errlog)
  31263. c.ServeSuccessJSON(map[string]interface{}{
  31264. "failed_code": -10,
  31265. "msg": res.ErrMsg,
  31266. })
  31267. return
  31268. }
  31269. var pack_sum int64
  31270. var good_pack_sum int64
  31271. if res.Infcode == 0 {
  31272. for _, item := range prescriptions {
  31273. if item.Type == 1 { //药品
  31274. for _, subitem := range item.HisDoctorAdviceInfo {
  31275. if subitem.PrescribingNumberUnit != subitem.BaseDrugLib.MinUnit { //非拆零
  31276. pack_sum = pack_sum + int64(subitem.PrescribingNumber)
  31277. } else { //拆零
  31278. quotient := int64(subitem.PrescribingNumber) / subitem.BaseDrugLib.MinNumber
  31279. if quotient >= 1 {
  31280. integerValue := int64(quotient)
  31281. pack_sum = pack_sum + integerValue
  31282. }
  31283. }
  31284. }
  31285. }
  31286. if item.Type == 2 {
  31287. for _, subitem := range item.HisPrescriptionProject {
  31288. if subitem.Type == 3 { //耗材
  31289. num, _ := strconv.Atoi(subitem.Count)
  31290. good_pack_sum = good_pack_sum + int64(num)
  31291. }
  31292. }
  31293. }
  31294. }
  31295. order := &models.HisOrder{
  31296. UserOrgId: adminUser.CurrentOrgId,
  31297. HisPatientId: his.ID,
  31298. PatientId: his.PatientId,
  31299. SettleAccountsDate: recordDateTime,
  31300. Ctime: time.Now().Unix(),
  31301. Mtime: time.Now().Unix(),
  31302. MdtrtId: his.Number,
  31303. PsnNo: his.PsnNo,
  31304. MedType: strconv.FormatInt(reg_type, 10),
  31305. Status: 1,
  31306. Number: chrg_bchno,
  31307. Infcode: res.Infcode,
  31308. WarnMsg: res.WarnMsg,
  31309. Cainfo: res.Cainfo,
  31310. ErrMsg: res.ErrMsg,
  31311. RespondTime: res.RefmsgTime,
  31312. InfRefmsgid: res.InfRefmsgid,
  31313. OrderStatus: 1,
  31314. IsMedicineInsurance: 1,
  31315. SettleType: settle_accounts_type,
  31316. SettleStartTime: start_time,
  31317. SettleEndTime: end_time,
  31318. Creator: roles.AdminUserId,
  31319. Modify: roles.AdminUserId,
  31320. PType: 2,
  31321. Diagnosis: diagnosis_id,
  31322. PackNum: pack_sum,
  31323. GoodPackNum: good_pack_sum,
  31324. }
  31325. err = service.CreateOrder(order)
  31326. if err != nil {
  31327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  31328. return
  31329. }
  31330. for _, item := range res.Output.Result {
  31331. temp := strings.Split(item.FeedetlSn, "-")
  31332. var advice_id int64 = 0
  31333. var project_id int64 = 0
  31334. var types int64 = 0
  31335. id, _ := strconv.ParseInt(temp[2], 10, 64)
  31336. types, _ = strconv.ParseInt(temp[1], 10, 64)
  31337. if temp[1] == "1" {
  31338. advice_id = id
  31339. project_id = 0
  31340. } else if temp[1] == "2" {
  31341. advice_id = 0
  31342. project_id = id
  31343. }
  31344. total_two = total_two + item.DetItemFeeSumamt
  31345. info := &models.HisOrderInfo{
  31346. OrderNumber: order.Number,
  31347. FeedetlSn: item.FeedetlSn,
  31348. UploadDate: time.Now().Unix(),
  31349. AdviceId: advice_id,
  31350. DetItemFeeSumamt: item.DetItemFeeSumamt,
  31351. Cnt: item.Cnt,
  31352. Pric: float64(item.Pric),
  31353. PatientId: his.PatientId,
  31354. PricUplmtAmt: item.PricUplmtAmt,
  31355. SelfpayProp: item.SelfpayProp,
  31356. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  31357. OverlmtAmt: item.OverlmtAmt,
  31358. PreselfpayAmt: item.PreselfpayAmt,
  31359. BasMednFlag: item.BasMednFlag,
  31360. MedChrgitmType: item.MedChrgitmType,
  31361. HiNegoDrugFlag: item.HiNegoDrugFlag,
  31362. Status: 1,
  31363. Memo: item.Memo,
  31364. Mtime: time.Now().Unix(),
  31365. InscpScpAmt: item.InscpScpAmt,
  31366. DrtReimFlag: item.DrtReimFlag,
  31367. Ctime: time.Now().Unix(),
  31368. ListSpItemFlag: item.ListSpItemFlag,
  31369. ChldMedcFlag: item.ChldMedcFlag,
  31370. LmtUsedFlag: item.LmtUsedFlag,
  31371. ChrgitmLv: item.ChrgitmLv,
  31372. UserOrgId: adminUser.CurrentOrgId,
  31373. HisPatientId: his.ID,
  31374. OrderId: order.ID,
  31375. ProjectId: project_id,
  31376. Type: types,
  31377. }
  31378. service.CreateOrderInfo(info)
  31379. }
  31380. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  31381. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  31382. var total float64
  31383. for _, item := range prescriptions {
  31384. if item.Type == 1 { //药品
  31385. for _, subItem := range item.HisDoctorAdviceInfo {
  31386. price, _ := strconv.ParseFloat(fmt.Sprintf("%.4f", subItem.Price), 64)
  31387. total_one := price * subItem.PrescribingNumber
  31388. fmt.Println("subItem")
  31389. fmt.Println(subItem.Price)
  31390. fmt.Println("price")
  31391. fmt.Println(price)
  31392. fmt.Println("total_one")
  31393. fmt.Println(total_one)
  31394. total = total + total_one
  31395. fmt.Println(total)
  31396. }
  31397. }
  31398. if item.Type == 2 { //项目
  31399. for _, subItem := range item.HisPrescriptionProject {
  31400. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  31401. price, _ := strconv.ParseFloat(fmt.Sprintf("%.4f", subItem.Price), 64)
  31402. total_one := price * cnt
  31403. total = total + total_one
  31404. }
  31405. }
  31406. }
  31407. allTotal := fmt.Sprintf("%.2f", total)
  31408. if res.Infcode == 0 {
  31409. var rf []*ResultFive
  31410. json.Unmarshal([]byte(his.Iinfo), &rf)
  31411. chrg_bchno := chrg_bchno
  31412. cert_no := his.Certno
  31413. var insutypes []string
  31414. var insutype string
  31415. var is390 int = 0
  31416. var is310 int = 0
  31417. for _, item := range rf {
  31418. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  31419. insutypes = append(insutypes, item.Insutype)
  31420. }
  31421. }
  31422. if len(insutypes) == 1 {
  31423. insutype = insutypes[0]
  31424. } else {
  31425. for _, i := range insutypes {
  31426. if i == "390" {
  31427. is390 = 1
  31428. }
  31429. if i == "310" {
  31430. is310 = 1
  31431. }
  31432. }
  31433. }
  31434. if is390 == 1 {
  31435. insutype = "390"
  31436. }
  31437. if is310 == 1 {
  31438. insutype = "310"
  31439. }
  31440. if len(insutypes) == 0 {
  31441. insutype = "390"
  31442. }
  31443. if len(insutypes) == 2 {
  31444. insutype = strconv.FormatInt(his.SocialType, 10)
  31445. }
  31446. //insutype = "390"
  31447. if his.IdCardType == 1 {
  31448. cert_no = his.MedicalInsuranceNumber
  31449. } else {
  31450. cert_no = his.Certno
  31451. }
  31452. var res ResultSeven
  31453. var res10633 ResultSeven10633
  31454. var ahres ResultSevenAH
  31455. var resSeven10265 ResultSeven10265
  31456. var resSeven10265Two ResultSeven10265Two
  31457. var resSeven10633Three ResultSeven10633Three
  31458. var gzresSeven10265Two GZResultSeven10265Two
  31459. if miConfig.MdtrtareaAdmvs == "421300" {
  31460. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  31461. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31462. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31463. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31464. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31465. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31466. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31467. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31468. resp, requestErr := http.Get(api)
  31469. if requestErr != nil {
  31470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31471. return
  31472. }
  31473. body, ioErr := ioutil.ReadAll(resp.Body)
  31474. if ioErr != nil {
  31475. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31477. return
  31478. }
  31479. var respJSON map[string]interface{}
  31480. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31481. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31483. return
  31484. }
  31485. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31486. result, _ := json.Marshal(respJSON)
  31487. fmt.Println("log")
  31488. fmt.Println(string(result))
  31489. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31490. utils.ErrorLog("解析失败:%v", err)
  31491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31492. return
  31493. }
  31494. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31495. if reg_type == 11 && his.Insutype == "390" {
  31496. reg_type = 110104
  31497. }
  31498. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31499. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31500. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31501. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31502. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31503. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31504. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31505. resp, requestErr := http.Get(api)
  31506. if requestErr != nil {
  31507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31508. return
  31509. }
  31510. body, ioErr := ioutil.ReadAll(resp.Body)
  31511. if ioErr != nil {
  31512. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31514. return
  31515. }
  31516. var respJSON map[string]interface{}
  31517. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31520. return
  31521. }
  31522. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31523. result, _ := json.Marshal(respJSON)
  31524. fmt.Println("log")
  31525. fmt.Println(string(result))
  31526. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31527. utils.ErrorLog("解析失败:%v", err)
  31528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31529. return
  31530. }
  31531. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31532. if reg_type == 11 && his.Insutype == "390" {
  31533. reg_type = 110104
  31534. }
  31535. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31536. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31537. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31538. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31539. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31540. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31541. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31542. resp, requestErr := http.Get(api)
  31543. if requestErr != nil {
  31544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31545. return
  31546. }
  31547. body, ioErr := ioutil.ReadAll(resp.Body)
  31548. if ioErr != nil {
  31549. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31551. return
  31552. }
  31553. var respJSON map[string]interface{}
  31554. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31557. return
  31558. }
  31559. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31560. result, _ := json.Marshal(respJSON)
  31561. fmt.Println("log")
  31562. fmt.Println(string(result))
  31563. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31564. utils.ErrorLog("解析失败:%v", err)
  31565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31566. return
  31567. }
  31568. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31569. if reg_type == 11 && his.Insutype == "390" {
  31570. reg_type = 110104
  31571. }
  31572. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31573. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31574. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31575. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31576. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31577. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31578. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31579. resp, requestErr := http.Get(api)
  31580. if requestErr != nil {
  31581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31582. return
  31583. }
  31584. body, ioErr := ioutil.ReadAll(resp.Body)
  31585. if ioErr != nil {
  31586. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31588. return
  31589. }
  31590. var respJSON map[string]interface{}
  31591. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31592. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31594. return
  31595. }
  31596. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31597. result, _ := json.Marshal(respJSON)
  31598. fmt.Println("log")
  31599. fmt.Println(string(result))
  31600. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31601. utils.ErrorLog("解析失败:%v", err)
  31602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31603. return
  31604. }
  31605. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  31606. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  31607. var result3101 Result3101
  31608. //utils.ErrorLog("解析失败:%v", result3101)
  31609. result3101.Infcode = "0"
  31610. if result3101.Infcode == "0" {
  31611. if len(result3101.Output.Result) > 0 {
  31612. var errMsgs []string
  31613. for _, item := range result3101.Output.Result {
  31614. errMsgs = append(errMsgs, item.VolaCont)
  31615. }
  31616. c.ServeSuccessJSON(map[string]interface{}{
  31617. "failed_code": -10,
  31618. "msg": errMsgs,
  31619. })
  31620. return
  31621. } else {
  31622. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31623. if his.IdCardType != 4 {
  31624. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  31625. bas := strings.Split(psn_info.CardInfo, "|")
  31626. if his.IdCardType == 1 {
  31627. cert_no = bas[2]
  31628. } else {
  31629. cert_no = bas[1]
  31630. }
  31631. } else {
  31632. cert_no = his.Certno
  31633. }
  31634. //江苏地区国家医保医疗类别
  31635. //职工透析:医疗类别选特殊情况门诊9933
  31636. //居民血透门慢: 医疗类别选门诊慢病1402
  31637. //var med_type string
  31638. //if his.Insutype == "310" {
  31639. // if reg_type == 14 {
  31640. // med_type = "9933"
  31641. // } else if reg_type == 11 {
  31642. // med_type = "11"
  31643. //
  31644. // }
  31645. //} else if his.Insutype == "390" {
  31646. // if reg_type == 14 {
  31647. // med_type = "1402"
  31648. // } else if reg_type == 11 {
  31649. // med_type = "11"
  31650. // }
  31651. //}
  31652. var api string
  31653. if miConfig.MdtrtareaAdmvs == "320830" {
  31654. api = miConfig.AppSecret + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31655. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31656. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31657. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31658. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31659. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31660. "&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
  31661. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31662. } else if miConfig.MdtrtareaAdmvs == "320921" {
  31663. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31664. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31665. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31666. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31667. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31668. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31669. "&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
  31670. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31671. } else {
  31672. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31673. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31674. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31675. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31676. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31677. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31678. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31679. "&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
  31680. }
  31681. resp, requestErr := http.Get(api)
  31682. if requestErr != nil {
  31683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31684. return
  31685. }
  31686. body, ioErr := ioutil.ReadAll(resp.Body)
  31687. if ioErr != nil {
  31688. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31690. return
  31691. }
  31692. var respJSON map[string]interface{}
  31693. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31694. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31696. return
  31697. }
  31698. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31699. result, _ := json.Marshal(respJSON)
  31700. fmt.Println("log")
  31701. fmt.Println(string(result))
  31702. {
  31703. if miConfig.MdtrtareaAdmvs == "320830" {
  31704. if strings.HasPrefix(his.InsuplcAdmdvs[0:3], "320") && !strings.HasPrefix(his.InsuplcAdmdvs[0:4], "3208") {
  31705. fmt.Println("log")
  31706. fmt.Println(string(result))
  31707. if err := json.Unmarshal([]byte(result), &resSeven10633Three); err != nil {
  31708. utils.ErrorLog("解析失败:%v", err)
  31709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31710. return
  31711. }
  31712. res10633.InfRefmsgid = resSeven10633Three.InfRefmsgid
  31713. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.AcctMulaidPay, 64)
  31714. res10633.Output.Setlinfo.AcctPay = resSeven10633Three.Output.Setlinfo.AcctPay
  31715. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31716. res10633.Output.Setlinfo.ActPayDedc = resSeven10633Three.Output.Setlinfo.ActPayDedc
  31717. res10633.Output.Setlinfo.Age = resSeven10633Three.Output.Setlinfo.Age
  31718. res10633.Output.Setlinfo.Balc = resSeven10633Three.Output.Setlinfo.Balc
  31719. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31720. res10633.Output.Setlinfo.Certno = resSeven10633Three.Output.Setlinfo.Certno
  31721. res10633.Output.Setlinfo.ClrOptins = resSeven10633Three.Output.Setlinfo.ClrOptins
  31722. res10633.Output.Setlinfo.ClrType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31723. res10633.Output.Setlinfo.ClrWay = resSeven10633Three.Output.Setlinfo.ClrOptins
  31724. res10633.Output.Setlinfo.CvlservFlag = resSeven10633Three.Output.Setlinfo.ClrOptins
  31725. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31726. res10633.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Three.Output.Setlinfo.FulamtOwnpayAmt
  31727. res10633.Output.Setlinfo.FundPaySumamt = resSeven10633Three.Output.Setlinfo.FundPaySumamt
  31728. res10633.Output.Setlinfo.Gend = resSeven10633Three.Output.Setlinfo.Gend
  31729. res10633.Output.Setlinfo.HifesPay = resSeven10633Three.Output.Setlinfo.HifesPay
  31730. res10633.Output.Setlinfo.HifmiPay = resSeven10633Three.Output.Setlinfo.HifmiPay
  31731. res10633.Output.Setlinfo.HifpPay = resSeven10633Three.Output.Setlinfo.HifpPay
  31732. //HospPartAmt, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.HospPartAmt, 64)
  31733. res10633.Output.Setlinfo.InscpScpAmt = resSeven10633Three.Output.Setlinfo.InscpScpAmt
  31734. res10633.Output.Setlinfo.Insutype = resSeven10633Three.Output.Setlinfo.Insutype
  31735. res10633.Output.Setlinfo.MafPay = resSeven10633Three.Output.Setlinfo.MafPay
  31736. res10633.Output.Setlinfo.MdtrtCertType = resSeven10633Three.Output.Setlinfo.MdtrtCertType
  31737. res10633.Output.Setlinfo.HifobPay = resSeven10633Three.Output.Setlinfo.HifobPay
  31738. res10633.Output.Setlinfo.MdtrtID = resSeven10633Three.Output.Setlinfo.MdtrtID
  31739. res10633.Output.Setlinfo.MedType = resSeven10633Three.Output.Setlinfo.MedType
  31740. res10633.Output.Setlinfo.MedfeeSumamt = resSeven10633Three.Output.Setlinfo.MedfeeSumamt
  31741. res10633.Output.Setlinfo.MedinsSetlID = resSeven10633Three.Output.Setlinfo.MedinsSetlID
  31742. res10633.Output.Setlinfo.Naty = resSeven10633Three.Output.Setlinfo.Naty
  31743. res10633.Output.Setlinfo.OthPay = resSeven10633Three.Output.Setlinfo.OthPay
  31744. res10633.Output.Setlinfo.OverlmtSelfpay = resSeven10633Three.Output.Setlinfo.OverlmtSelfpay
  31745. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.PoolPropSelfpay, 64)
  31746. res10633.Output.Setlinfo.PreselfpayAmt = resSeven10633Three.Output.Setlinfo.PreselfpayAmt
  31747. res10633.Output.Setlinfo.PsnCashPay = resSeven10633Three.Output.Setlinfo.PsnCashPay
  31748. res10633.Output.Setlinfo.PsnCertType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31749. res10633.Output.Setlinfo.PsnName = resSeven10633Three.Output.Setlinfo.PsnName
  31750. res10633.Output.Setlinfo.PsnNo = resSeven10633Three.Output.Setlinfo.PsnNo
  31751. res10633.Output.Setlinfo.PsnPartAmt = resSeven10633Three.Output.Setlinfo.PsnPartAmt
  31752. res10633.Output.Setlinfo.PsnType = resSeven10633Three.Output.Setlinfo.PsnType
  31753. res10633.Output.Setlinfo.SetlID = resSeven10633Three.Output.Setlinfo.SetlID
  31754. res10633.Output.Setlinfo.SetlTime = resSeven10633Three.Output.Setlinfo.SetlTime
  31755. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31756. res10633.ErrMsg = resSeven10633Three.ErrMsg
  31757. res10633.Cainfo = resSeven10633Three.Cainfo
  31758. res10633.WarnMsg = resSeven10633Three.WarnMsg
  31759. infocode, _ := strconv.ParseInt(resSeven10633Three.Infcode, 10, 64)
  31760. res10633.Infcode = infocode
  31761. } else {
  31762. if err := json.Unmarshal([]byte(result), &resSeven10633Three); err != nil {
  31763. utils.ErrorLog("解析失败:%v", err)
  31764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31765. return
  31766. }
  31767. res10633.InfRefmsgid = resSeven10633Three.InfRefmsgid
  31768. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  31769. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31770. res10633.Output.Setlinfo.AcctPay = resSeven10633Three.Output.Setlinfo.AcctPay
  31771. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31772. res10633.Output.Setlinfo.ActPayDedc = resSeven10633Three.Output.Setlinfo.ActPayDedc
  31773. res10633.Output.Setlinfo.Age = resSeven10633Three.Output.Setlinfo.Age
  31774. res10633.Output.Setlinfo.Balc = resSeven10633Three.Output.Setlinfo.Balc
  31775. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31776. res10633.Output.Setlinfo.Certno = resSeven10633Three.Output.Setlinfo.Certno
  31777. res10633.Output.Setlinfo.ClrOptins = resSeven10633Three.Output.Setlinfo.ClrOptins
  31778. res10633.Output.Setlinfo.ClrType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31779. res10633.Output.Setlinfo.ClrWay = resSeven10633Three.Output.Setlinfo.ClrOptins
  31780. res10633.Output.Setlinfo.CvlservFlag = resSeven10633Three.Output.Setlinfo.ClrOptins
  31781. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31782. res10633.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Three.Output.Setlinfo.FulamtOwnpayAmt
  31783. res10633.Output.Setlinfo.FundPaySumamt = resSeven10633Three.Output.Setlinfo.FundPaySumamt
  31784. res10633.Output.Setlinfo.Gend = resSeven10633Three.Output.Setlinfo.Gend
  31785. res10633.Output.Setlinfo.HifesPay = resSeven10633Three.Output.Setlinfo.HifesPay
  31786. res10633.Output.Setlinfo.HifmiPay = resSeven10633Three.Output.Setlinfo.HifmiPay
  31787. res10633.Output.Setlinfo.HifpPay = resSeven10633Three.Output.Setlinfo.HifpPay
  31788. res10633.Output.Setlinfo.InscpScpAmt = resSeven10633Three.Output.Setlinfo.InscpScpAmt
  31789. res10633.Output.Setlinfo.Insutype = resSeven10633Three.Output.Setlinfo.Insutype
  31790. res10633.Output.Setlinfo.MafPay = resSeven10633Three.Output.Setlinfo.MafPay
  31791. res10633.Output.Setlinfo.MdtrtCertType = resSeven10633Three.Output.Setlinfo.MdtrtCertType
  31792. res10633.Output.Setlinfo.HifobPay = resSeven10633Three.Output.Setlinfo.HifobPay
  31793. res10633.Output.Setlinfo.MdtrtID = resSeven10633Three.Output.Setlinfo.MdtrtID
  31794. res10633.Output.Setlinfo.MedType = resSeven10633Three.Output.Setlinfo.MedType
  31795. res10633.Output.Setlinfo.MedfeeSumamt = resSeven10633Three.Output.Setlinfo.MedfeeSumamt
  31796. res10633.Output.Setlinfo.MedinsSetlID = resSeven10633Three.Output.Setlinfo.MedinsSetlID
  31797. res10633.Output.Setlinfo.Naty = resSeven10633Three.Output.Setlinfo.Naty
  31798. res10633.Output.Setlinfo.OthPay = resSeven10633Three.Output.Setlinfo.OthPay
  31799. res10633.Output.Setlinfo.OverlmtSelfpay = resSeven10633Three.Output.Setlinfo.OverlmtSelfpay
  31800. res10633.Output.Setlinfo.PreselfpayAmt = resSeven10633Three.Output.Setlinfo.PreselfpayAmt
  31801. res10633.Output.Setlinfo.PsnCashPay = resSeven10633Three.Output.Setlinfo.PsnCashPay
  31802. res10633.Output.Setlinfo.PsnCertType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31803. res10633.Output.Setlinfo.PsnName = resSeven10633Three.Output.Setlinfo.PsnName
  31804. res10633.Output.Setlinfo.PsnNo = resSeven10633Three.Output.Setlinfo.PsnNo
  31805. res10633.Output.Setlinfo.PsnPartAmt = resSeven10633Three.Output.Setlinfo.PsnPartAmt
  31806. res10633.Output.Setlinfo.PsnType = resSeven10633Three.Output.Setlinfo.PsnType
  31807. res10633.Output.Setlinfo.SetlID = resSeven10633Three.Output.Setlinfo.SetlID
  31808. res10633.Output.Setlinfo.SetlTime = resSeven10633Three.Output.Setlinfo.SetlTime
  31809. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31810. res10633.ErrMsg = resSeven10633Three.ErrMsg
  31811. res10633.Cainfo = resSeven10633Three.Cainfo
  31812. res10633.WarnMsg = resSeven10633Three.WarnMsg
  31813. infocode, _ := strconv.ParseInt(resSeven10633Three.Infcode, 10, 64)
  31814. res10633.Infcode = infocode
  31815. }
  31816. } else {
  31817. fmt.Println("log")
  31818. //fmt.Println(string(result))
  31819. if strings.HasPrefix(his.InsuplcAdmdvs[0:3], "320") && !strings.HasPrefix(his.InsuplcAdmdvs[0:4], "3209") {
  31820. if err := json.Unmarshal([]byte(result), &resSeven10633Three); err != nil {
  31821. utils.ErrorLog("解析失败:%v", err)
  31822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31823. return
  31824. }
  31825. res.InfRefmsgid = resSeven10633Three.InfRefmsgid
  31826. res10633.Output.Setlinfo.AcctPay = resSeven10633Three.Output.Setlinfo.AcctPay
  31827. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31828. res10633.Output.Setlinfo.ActPayDedc = resSeven10633Three.Output.Setlinfo.ActPayDedc
  31829. res10633.Output.Setlinfo.Age = resSeven10633Three.Output.Setlinfo.Age
  31830. res10633.Output.Setlinfo.Balc = resSeven10633Three.Output.Setlinfo.Balc
  31831. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31832. res10633.Output.Setlinfo.Certno = resSeven10633Three.Output.Setlinfo.Certno
  31833. res10633.Output.Setlinfo.ClrOptins = resSeven10633Three.Output.Setlinfo.ClrOptins
  31834. res10633.Output.Setlinfo.ClrType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31835. res10633.Output.Setlinfo.ClrWay = resSeven10633Three.Output.Setlinfo.ClrOptins
  31836. res10633.Output.Setlinfo.CvlservFlag = resSeven10633Three.Output.Setlinfo.ClrOptins
  31837. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31838. res10633.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Three.Output.Setlinfo.FulamtOwnpayAmt
  31839. res10633.Output.Setlinfo.FundPaySumamt = resSeven10633Three.Output.Setlinfo.FundPaySumamt
  31840. res10633.Output.Setlinfo.Gend = resSeven10633Three.Output.Setlinfo.Gend
  31841. res10633.Output.Setlinfo.HifesPay = resSeven10633Three.Output.Setlinfo.HifesPay
  31842. res10633.Output.Setlinfo.HifmiPay = resSeven10633Three.Output.Setlinfo.HifmiPay
  31843. res10633.Output.Setlinfo.HifpPay = resSeven10633Three.Output.Setlinfo.HifpPay
  31844. res10633.Output.Setlinfo.InscpScpAmt = resSeven10633Three.Output.Setlinfo.InscpScpAmt
  31845. res10633.Output.Setlinfo.Insutype = resSeven10633Three.Output.Setlinfo.Insutype
  31846. res10633.Output.Setlinfo.MafPay = resSeven10633Three.Output.Setlinfo.MafPay
  31847. res10633.Output.Setlinfo.MdtrtCertType = resSeven10633Three.Output.Setlinfo.MdtrtCertType
  31848. res10633.Output.Setlinfo.HifobPay = resSeven10633Three.Output.Setlinfo.HifobPay
  31849. res10633.Output.Setlinfo.MdtrtID = resSeven10633Three.Output.Setlinfo.MdtrtID
  31850. res10633.Output.Setlinfo.MedType = resSeven10633Three.Output.Setlinfo.MedType
  31851. res10633.Output.Setlinfo.MedfeeSumamt = resSeven10633Three.Output.Setlinfo.MedfeeSumamt
  31852. res10633.Output.Setlinfo.MedinsSetlID = resSeven10633Three.Output.Setlinfo.MedinsSetlID
  31853. res10633.Output.Setlinfo.Naty = resSeven10633Three.Output.Setlinfo.Naty
  31854. res10633.Output.Setlinfo.OthPay = resSeven10633Three.Output.Setlinfo.OthPay
  31855. res10633.Output.Setlinfo.OverlmtSelfpay = resSeven10633Three.Output.Setlinfo.OverlmtSelfpay
  31856. res10633.Output.Setlinfo.PreselfpayAmt = resSeven10633Three.Output.Setlinfo.PreselfpayAmt
  31857. res10633.Output.Setlinfo.PsnCashPay = resSeven10633Three.Output.Setlinfo.PsnCashPay
  31858. res10633.Output.Setlinfo.PsnCertType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31859. res10633.Output.Setlinfo.PsnName = resSeven10633Three.Output.Setlinfo.PsnName
  31860. res10633.Output.Setlinfo.PsnNo = resSeven10633Three.Output.Setlinfo.PsnNo
  31861. res10633.Output.Setlinfo.PsnPartAmt = resSeven10633Three.Output.Setlinfo.PsnPartAmt
  31862. res10633.Output.Setlinfo.PsnType = resSeven10633Three.Output.Setlinfo.PsnType
  31863. res10633.Output.Setlinfo.SetlID = resSeven10633Three.Output.Setlinfo.SetlID
  31864. res10633.Output.Setlinfo.SetlTime = resSeven10633Three.Output.Setlinfo.SetlTime
  31865. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31866. res10633.ErrMsg = resSeven10633Three.ErrMsg
  31867. res10633.Cainfo = resSeven10633Three.Cainfo
  31868. res10633.WarnMsg = resSeven10633Three.WarnMsg
  31869. infocode, _ := strconv.ParseInt(resSeven10633Three.Infcode, 10, 64)
  31870. res10633.Infcode = infocode
  31871. } else {
  31872. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  31873. utils.ErrorLog("解析失败:%v", err)
  31874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31875. return
  31876. }
  31877. res10633.InfRefmsgid = resSeven10633Three.InfRefmsgid
  31878. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  31879. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPayv
  31880. res10633.Output.Setlinfo.AcctPay = resSeven10633Three.Output.Setlinfo.AcctPay
  31881. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31882. res10633.Output.Setlinfo.ActPayDedc = resSeven10633Three.Output.Setlinfo.ActPayDedc
  31883. res10633.Output.Setlinfo.Age = resSeven10633Three.Output.Setlinfo.Age
  31884. res10633.Output.Setlinfo.Balc = resSeven10633Three.Output.Setlinfo.Balc
  31885. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31886. res10633.Output.Setlinfo.Certno = resSeven10633Three.Output.Setlinfo.Certno
  31887. res10633.Output.Setlinfo.ClrOptins = resSeven10633Three.Output.Setlinfo.ClrOptins
  31888. res10633.Output.Setlinfo.ClrType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31889. res10633.Output.Setlinfo.ClrWay = resSeven10633Three.Output.Setlinfo.ClrOptins
  31890. res10633.Output.Setlinfo.CvlservFlag = resSeven10633Three.Output.Setlinfo.ClrOptins
  31891. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31892. res10633.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Three.Output.Setlinfo.FulamtOwnpayAmt
  31893. res10633.Output.Setlinfo.FundPaySumamt = resSeven10633Three.Output.Setlinfo.FundPaySumamt
  31894. res10633.Output.Setlinfo.Gend = resSeven10633Three.Output.Setlinfo.Gend
  31895. res10633.Output.Setlinfo.HifesPay = resSeven10633Three.Output.Setlinfo.HifesPay
  31896. res10633.Output.Setlinfo.HifmiPay = resSeven10633Three.Output.Setlinfo.HifmiPay
  31897. res10633.Output.Setlinfo.HifpPay = resSeven10633Three.Output.Setlinfo.HifpPay
  31898. res10633.Output.Setlinfo.InscpScpAmt = resSeven10633Three.Output.Setlinfo.InscpScpAmt
  31899. res10633.Output.Setlinfo.Insutype = resSeven10633Three.Output.Setlinfo.Insutype
  31900. res10633.Output.Setlinfo.MafPay = resSeven10633Three.Output.Setlinfo.MafPay
  31901. res10633.Output.Setlinfo.MdtrtCertType = resSeven10633Three.Output.Setlinfo.MdtrtCertType
  31902. res10633.Output.Setlinfo.HifobPay = resSeven10633Three.Output.Setlinfo.HifobPay
  31903. res10633.Output.Setlinfo.MdtrtID = resSeven10633Three.Output.Setlinfo.MdtrtID
  31904. res10633.Output.Setlinfo.MedType = resSeven10633Three.Output.Setlinfo.MedType
  31905. res10633.Output.Setlinfo.MedfeeSumamt = resSeven10633Three.Output.Setlinfo.MedfeeSumamt
  31906. res10633.Output.Setlinfo.MedinsSetlID = resSeven10633Three.Output.Setlinfo.MedinsSetlID
  31907. res10633.Output.Setlinfo.Naty = resSeven10633Three.Output.Setlinfo.Naty
  31908. res10633.Output.Setlinfo.OthPay = resSeven10633Three.Output.Setlinfo.OthPay
  31909. res10633.Output.Setlinfo.OverlmtSelfpay = resSeven10633Three.Output.Setlinfo.OverlmtSelfpay
  31910. res10633.Output.Setlinfo.PreselfpayAmt = resSeven10633Three.Output.Setlinfo.PreselfpayAmt
  31911. res10633.Output.Setlinfo.PsnCashPay = resSeven10633Three.Output.Setlinfo.PsnCashPay
  31912. res10633.Output.Setlinfo.PsnCertType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31913. res10633.Output.Setlinfo.PsnName = resSeven10633Three.Output.Setlinfo.PsnName
  31914. res10633.Output.Setlinfo.PsnNo = resSeven10633Three.Output.Setlinfo.PsnNo
  31915. res10633.Output.Setlinfo.PsnPartAmt = resSeven10633Three.Output.Setlinfo.PsnPartAmt
  31916. res10633.Output.Setlinfo.PsnType = resSeven10633Three.Output.Setlinfo.PsnType
  31917. res10633.Output.Setlinfo.SetlID = resSeven10633Three.Output.Setlinfo.SetlID
  31918. res10633.Output.Setlinfo.SetlTime = resSeven10633Three.Output.Setlinfo.SetlTime
  31919. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31920. res10633.ErrMsg = resSeven10633Three.ErrMsg
  31921. res10633.Cainfo = resSeven10633Three.Cainfo
  31922. res10633.WarnMsg = resSeven10633Three.WarnMsg
  31923. infocode, _ := strconv.ParseInt(resSeven10633Three.Infcode, 10, 64)
  31924. res10633.Infcode = infocode
  31925. }
  31926. }
  31927. }
  31928. }
  31929. }
  31930. } else if miConfig.MdtrtareaAdmvs == "150404" {
  31931. psn_info, _ := service.GetPsnByPatientId(id)
  31932. var verify_number string
  31933. if psn_info.IdCardType == 4 {
  31934. verify_number = psn_info.VerifyNumber
  31935. } else if psn_info.IdCardType == 1 {
  31936. bas := strings.Split(psn_info.CardInfo, "|")
  31937. cardNumber := bas[2]
  31938. verify_number = cardNumber
  31939. } else {
  31940. psn_info.IdCardType = 2
  31941. verify_number = psn_info.Certno
  31942. }
  31943. var api string
  31944. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31945. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  31946. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31947. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31948. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  31949. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31950. "&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
  31951. resp, requestErr := http.Get(api)
  31952. if requestErr != nil {
  31953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31954. return
  31955. }
  31956. body, ioErr := ioutil.ReadAll(resp.Body)
  31957. if ioErr != nil {
  31958. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31960. return
  31961. }
  31962. var respJSON map[string]interface{}
  31963. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31964. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31966. return
  31967. }
  31968. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31969. result, _ := json.Marshal(respJSON)
  31970. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  31971. utils.ErrorLog("解析失败:%v", err)
  31972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31973. return
  31974. }
  31975. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31976. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  31977. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  31978. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  31979. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  31980. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  31981. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  31982. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  31983. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  31984. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  31985. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  31986. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  31987. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  31988. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  31989. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  31990. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  31991. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  31992. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  31993. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  31994. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  31995. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31996. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  31997. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  31998. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  31999. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  32000. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  32001. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  32002. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  32003. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  32004. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  32005. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  32006. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  32007. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  32008. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  32009. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  32010. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  32011. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  32012. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  32013. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  32014. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  32015. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  32016. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  32017. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  32018. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  32019. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  32020. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  32021. res.ErrMsg = resSeven10265.ErrMsg
  32022. res.Cainfo = resSeven10265.Cainfo
  32023. res.WarnMsg = resSeven10265.WarnMsg
  32024. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32025. res.Infcode = infocode
  32026. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32027. acct_used_flag := "1"
  32028. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  32029. var result string
  32030. var request_log string
  32031. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  32032. 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)
  32033. } else {
  32034. 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)
  32035. }
  32036. var dat map[string]interface{}
  32037. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32038. fmt.Println(dat)
  32039. } else {
  32040. fmt.Println(err)
  32041. }
  32042. saveLog(result, request_log, "2206", "预结算")
  32043. userJSONBytes, _ := json.Marshal(dat)
  32044. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32045. utils.ErrorLog("解析失败:%v", err)
  32046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32047. return
  32048. }
  32049. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32050. var result string
  32051. var request_log string
  32052. if his.IdCardType == 2 {
  32053. insutype = strconv.FormatInt(his.SocialType, 10)
  32054. 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, "")
  32055. } else if his.IdCardType == 1 {
  32056. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32057. bas := strings.Split(psn_info.CardInfo, "|")
  32058. basNumber := bas[2]
  32059. card_sn := bas[3]
  32060. var rf []*ResultFive
  32061. json.Unmarshal([]byte(his.Iinfo), &rf)
  32062. var psn_type string
  32063. for _, item := range rf {
  32064. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  32065. psn_type = item.PsnType
  32066. }
  32067. }
  32068. insutype = strconv.FormatInt(his.SocialType, 10)
  32069. 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)
  32070. } else {
  32071. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32072. //bas := strings.Split(psn_info.CardInfo, "|")
  32073. //basNumber := bas[2]
  32074. //card_sn := bas[3]
  32075. var rf []*ResultFive
  32076. json.Unmarshal([]byte(his.Iinfo), &rf)
  32077. var psn_type string
  32078. for _, item := range rf {
  32079. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  32080. psn_type = item.PsnType
  32081. }
  32082. }
  32083. insutype = strconv.FormatInt(his.SocialType, 10)
  32084. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32085. 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)
  32086. }
  32087. var dat map[string]interface{}
  32088. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32089. fmt.Println(dat)
  32090. } else {
  32091. fmt.Println(err)
  32092. }
  32093. saveLog(result, request_log, "2206", "预结算")
  32094. userJSONBytes, _ := json.Marshal(dat)
  32095. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32096. utils.ErrorLog("解析失败:%v", err)
  32097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32098. return
  32099. }
  32100. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32101. var result string
  32102. var request_log string
  32103. if his.IdCardType == 2 {
  32104. insutype = strconv.FormatInt(his.SocialType, 10)
  32105. 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, "")
  32106. } else if his.IdCardType == 1 {
  32107. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32108. bas := strings.Split(psn_info.CardInfo, "|")
  32109. basNumber := bas[0]
  32110. card_sn := ""
  32111. var rf []*ResultFive
  32112. json.Unmarshal([]byte(his.Iinfo), &rf)
  32113. var psn_type string
  32114. for _, item := range rf {
  32115. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  32116. psn_type = item.PsnType
  32117. }
  32118. }
  32119. insutype = strconv.FormatInt(his.SocialType, 10)
  32120. 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)
  32121. } else {
  32122. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32123. //bas := strings.Split(psn_info.CardInfo, "|")
  32124. //basNumber := bas[2]
  32125. //card_sn := bas[3]
  32126. var rf []*ResultFive
  32127. json.Unmarshal([]byte(his.Iinfo), &rf)
  32128. var psn_type string
  32129. for _, item := range rf {
  32130. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  32131. psn_type = item.PsnType
  32132. }
  32133. }
  32134. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32135. 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)
  32136. }
  32137. var dat map[string]interface{}
  32138. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32139. fmt.Println(dat)
  32140. } else {
  32141. fmt.Println(err)
  32142. }
  32143. saveLog(result, request_log, "2206", "预结算")
  32144. userJSONBytes, _ := json.Marshal(dat)
  32145. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32146. utils.ErrorLog("解析失败:%v", err)
  32147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32148. return
  32149. }
  32150. } else if miConfig.MdtrtareaAdmvs == "360100" {
  32151. var result string
  32152. var request_log string
  32153. if his.IdCardType == 2 {
  32154. insutype = strconv.FormatInt(his.SocialType, 10)
  32155. 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, "")
  32156. } else if his.IdCardType == 1 {
  32157. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32158. bas := strings.Split(psn_info.CardInfo, "|")
  32159. basNumber := bas[0]
  32160. card_sn := ""
  32161. var rf []*ResultFive
  32162. json.Unmarshal([]byte(his.Iinfo), &rf)
  32163. var psn_type string
  32164. for _, item := range rf {
  32165. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  32166. psn_type = item.PsnType
  32167. }
  32168. }
  32169. insutype = strconv.FormatInt(his.SocialType, 10)
  32170. 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)
  32171. } else {
  32172. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32173. //bas := strings.Split(psn_info.CardInfo, "|")
  32174. //basNumber := bas[2]
  32175. //card_sn := bas[3]
  32176. var rf []*ResultFive
  32177. json.Unmarshal([]byte(his.Iinfo), &rf)
  32178. var psn_type string
  32179. for _, item := range rf {
  32180. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  32181. psn_type = item.PsnType
  32182. }
  32183. }
  32184. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32185. 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)
  32186. }
  32187. var dat map[string]interface{}
  32188. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32189. fmt.Println(dat)
  32190. } else {
  32191. fmt.Println(err)
  32192. }
  32193. saveLog(result, request_log, "2206", "预结算")
  32194. userJSONBytes, _ := json.Marshal(dat)
  32195. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32196. utils.ErrorLog("解析失败:%v", err)
  32197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32198. return
  32199. }
  32200. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32201. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32202. if his.IdCardType == 4 {
  32203. psn_info.VerifyNumber = psn_info.VerifyNumber
  32204. cert_no = psn_info.VerifyNumber
  32205. } else if his.IdCardType == 2 {
  32206. cert_no = psn_info.Certno
  32207. psn_info.VerifyNumber = psn_info.Certno
  32208. } else {
  32209. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  32210. bas := strings.Split(psn_info.CardInfo, "|")
  32211. if his.IdCardType == 1 {
  32212. cert_no = bas[2]
  32213. } else {
  32214. cert_no = bas[1]
  32215. }
  32216. }
  32217. var api string
  32218. var med_type string
  32219. if his.Insutype == "390" {
  32220. if reg_type == 992102 {
  32221. med_type = "992102"
  32222. }
  32223. if reg_type == 140104 {
  32224. med_type = "140104"
  32225. }
  32226. if reg_type == 140201 {
  32227. med_type = "140201"
  32228. }
  32229. if reg_type == 14 {
  32230. med_type = "140104"
  32231. }
  32232. if reg_type == 1104 {
  32233. med_type = "1104"
  32234. }
  32235. } else if his.Insutype == "310" {
  32236. if reg_type == 1104 {
  32237. med_type = "1104"
  32238. }
  32239. if reg_type == 992102 {
  32240. med_type = "992102"
  32241. }
  32242. if reg_type == 140104 {
  32243. med_type = "140104"
  32244. }
  32245. if reg_type == 140201 {
  32246. med_type = "140201"
  32247. }
  32248. if reg_type == 14 {
  32249. med_type = "140104"
  32250. }
  32251. }
  32252. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32253. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32254. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32255. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32256. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32257. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32258. "&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
  32259. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32260. resp, requestErr := http.Get(api)
  32261. if requestErr != nil {
  32262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32263. return
  32264. }
  32265. body, ioErr := ioutil.ReadAll(resp.Body)
  32266. if ioErr != nil {
  32267. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32269. return
  32270. }
  32271. var respJSON map[string]interface{}
  32272. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32275. return
  32276. }
  32277. status := respJSON["data"].(map[string]interface{})["status"].(string)
  32278. if status == "0" {
  32279. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  32280. c.ServeSuccessJSON(map[string]interface{}{
  32281. "failed_code": -10,
  32282. "msg": err_msg,
  32283. })
  32284. return
  32285. }
  32286. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32287. result, _ := json.Marshal(respJSON)
  32288. fmt.Println("log")
  32289. fmt.Println(string(result))
  32290. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  32291. utils.ErrorLog("解析失败:%v", err)
  32292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32293. return
  32294. }
  32295. res.InfRefmsgid = ahres.InfRefmsgid
  32296. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32297. // 创建对应的Time类型
  32298. t := time.UnixMilli(timestamp)
  32299. // 格式化成指定的日期字符串
  32300. str := t.Format("2006-01-02 15:04:05")
  32301. res.Output.Setlinfo.SetlTime = str
  32302. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32303. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32304. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32305. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32306. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32307. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32308. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32309. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32310. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32311. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32312. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32313. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32314. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32315. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32316. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32317. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32318. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32319. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32320. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32321. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32322. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32323. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32324. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32325. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32326. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32327. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32328. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32329. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32330. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32331. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32332. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32333. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32334. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32335. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  32336. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32337. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  32338. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  32339. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  32340. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  32341. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32342. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  32343. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32344. //res.Output.Setldetail = ahres.Output.Setldetail
  32345. res.ErrMsg = ahres.ErrMsg
  32346. res.Cainfo = ahres.Cainfo
  32347. res.WarnMsg = ahres.WarnMsg
  32348. res.Infcode = ahres.Infcode
  32349. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32350. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32351. if his.IdCardType == 4 {
  32352. psn_info.VerifyNumber = psn_info.VerifyNumber
  32353. cert_no = psn_info.Certno
  32354. } else if his.IdCardType == 2 {
  32355. cert_no = psn_info.Certno
  32356. psn_info.VerifyNumber = psn_info.Certno
  32357. } else {
  32358. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  32359. bas := strings.Split(psn_info.CardInfo, "|")
  32360. if his.IdCardType == 1 {
  32361. cert_no = bas[2]
  32362. } else {
  32363. cert_no = bas[1]
  32364. }
  32365. }
  32366. var api string
  32367. var med_type string
  32368. if his.Insutype == "390" {
  32369. if reg_type == 992102 {
  32370. med_type = "992102"
  32371. }
  32372. if reg_type == 140104 {
  32373. med_type = "140104"
  32374. }
  32375. if reg_type == 140201 {
  32376. med_type = "140201"
  32377. }
  32378. if reg_type == 14 {
  32379. med_type = "14"
  32380. }
  32381. } else if his.Insutype == "310" {
  32382. if reg_type == 992102 {
  32383. med_type = "992102"
  32384. }
  32385. if reg_type == 140104 {
  32386. med_type = "140104"
  32387. }
  32388. if reg_type == 140201 {
  32389. med_type = "140201"
  32390. }
  32391. if reg_type == 14 {
  32392. med_type = "14"
  32393. }
  32394. }
  32395. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32396. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32397. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32398. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32399. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32400. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32401. "&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
  32402. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32403. resp, requestErr := http.Get(api)
  32404. if requestErr != nil {
  32405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32406. return
  32407. }
  32408. body, ioErr := ioutil.ReadAll(resp.Body)
  32409. if ioErr != nil {
  32410. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32412. return
  32413. }
  32414. var respJSON map[string]interface{}
  32415. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32416. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32418. return
  32419. }
  32420. status := respJSON["data"].(map[string]interface{})["status"].(string)
  32421. if status == "0" {
  32422. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  32423. c.ServeSuccessJSON(map[string]interface{}{
  32424. "failed_code": -10,
  32425. "msg": err_msg,
  32426. })
  32427. return
  32428. }
  32429. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32430. result, _ := json.Marshal(respJSON)
  32431. fmt.Println("log")
  32432. fmt.Println(string(result))
  32433. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  32434. utils.ErrorLog("解析失败:%v", err)
  32435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32436. return
  32437. }
  32438. res.InfRefmsgid = ahres.InfRefmsgid
  32439. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32440. // 创建对应的Time类型
  32441. t := time.UnixMilli(timestamp)
  32442. // 格式化成指定的日期字符串
  32443. str := t.Format("2006-01-02 15:04:05")
  32444. res.Output.Setlinfo.SetlTime = str
  32445. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32446. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32447. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32448. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32449. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32450. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32451. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32452. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32453. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32454. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32455. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32456. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32457. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32458. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32459. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32460. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32461. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32462. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32463. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32464. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32465. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32466. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32467. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32468. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32469. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32470. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32471. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32472. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32473. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32474. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32475. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32476. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32477. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32478. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  32479. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32480. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  32481. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  32482. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  32483. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  32484. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32485. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  32486. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32487. //res.Output.Setldetail = ahres.Output.Setldetail
  32488. res.ErrMsg = ahres.ErrMsg
  32489. res.Cainfo = ahres.Cainfo
  32490. res.WarnMsg = ahres.WarnMsg
  32491. res.Infcode = ahres.Infcode
  32492. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32493. var result string
  32494. var request_log string
  32495. if his.IdCardType == 2 {
  32496. 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")
  32497. } else if his.IdCardType == 1 {
  32498. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32499. bas := strings.Split(psn_info.CardInfo, "|")
  32500. basNumber := bas[2]
  32501. card_sn := bas[3]
  32502. 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")
  32503. } else {
  32504. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32505. 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")
  32506. }
  32507. var dat map[string]interface{}
  32508. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32509. fmt.Println(dat)
  32510. } else {
  32511. fmt.Println(err)
  32512. }
  32513. saveLog(result, request_log, "2206", "预结算")
  32514. userJSONBytes, _ := json.Marshal(dat)
  32515. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32516. utils.ErrorLog("解析失败:%v", err)
  32517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32518. return
  32519. }
  32520. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32521. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32522. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32523. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32524. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32525. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32526. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32527. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  32528. resp, requestErr := http.Get(api)
  32529. if requestErr != nil {
  32530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32531. return
  32532. }
  32533. body, ioErr := ioutil.ReadAll(resp.Body)
  32534. if ioErr != nil {
  32535. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32537. return
  32538. }
  32539. var respJSON map[string]interface{}
  32540. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32541. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32543. return
  32544. }
  32545. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32546. result, _ := json.Marshal(respJSON)
  32547. fmt.Println("log")
  32548. fmt.Println(string(result))
  32549. if err := json.Unmarshal([]byte(result), &res); err != nil {
  32550. utils.ErrorLog("解析失败:%v", err)
  32551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32552. return
  32553. }
  32554. } else {
  32555. if miConfig.MdtrtareaAdmvs == "441202" {
  32556. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32557. if result3101.Infcode == 0 {
  32558. if len(result3101.Output.Result) > 0 {
  32559. c.ServeSuccessJSON(map[string]interface{}{
  32560. "failed_code": -10,
  32561. "failed_type": 100,
  32562. "msg": result3101.Output.Result,
  32563. })
  32564. return
  32565. } else {
  32566. var result string
  32567. var request_log string
  32568. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32569. allTotal = fmt.Sprintf("%.2f", total_two)
  32570. if his.IdCardType == 4 {
  32571. 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)
  32572. } else {
  32573. 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)
  32574. }
  32575. var dat map[string]interface{}
  32576. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32577. fmt.Println(dat)
  32578. } else {
  32579. fmt.Println(err)
  32580. }
  32581. saveLog(result, request_log, "2206", "预结算")
  32582. //userJSONBytes, _ := json.Marshal(dat)
  32583. //
  32584. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32585. // utils.ErrorLog("解析失败:%v", err)
  32586. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32587. // return
  32588. //}
  32589. userJSONBytes, _ := json.Marshal(dat)
  32590. if miConfig.Code == "H15049901371" {
  32591. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32592. utils.ErrorLog("解析失败:%v", err)
  32593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32594. return
  32595. }
  32596. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32597. res.Output = resSeven10265.Output
  32598. res.ErrMsg = resSeven10265.ErrMsg
  32599. res.Cainfo = resSeven10265.Cainfo
  32600. res.WarnMsg = resSeven10265.WarnMsg
  32601. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32602. res.Infcode = infocode
  32603. } else {
  32604. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32605. utils.ErrorLog("解析失败:%v", err)
  32606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32607. return
  32608. }
  32609. }
  32610. }
  32611. } else {
  32612. c.ServeSuccessJSON(map[string]interface{}{
  32613. "failed_code": -10,
  32614. "msg": result3101.ErrMsg,
  32615. })
  32616. return
  32617. }
  32618. } else if miConfig.MdtrtareaAdmvs == "440205" {
  32619. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32620. if result3101.Infcode == 0 {
  32621. if len(result3101.Output.Result) > 0 {
  32622. var errMsgs []string
  32623. for _, item := range result3101.Output.Result {
  32624. errMsgs = append(errMsgs, item.VolaCont)
  32625. }
  32626. c.ServeSuccessJSON(map[string]interface{}{
  32627. "failed_code": -10,
  32628. "msg": errMsgs,
  32629. })
  32630. return
  32631. } else {
  32632. var result string
  32633. var request_log string
  32634. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32635. allTotal = fmt.Sprintf("%.2f", total_two)
  32636. if his.IdCardType == 4 {
  32637. 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)
  32638. } else {
  32639. 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)
  32640. }
  32641. var dat map[string]interface{}
  32642. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32643. fmt.Println(dat)
  32644. } else {
  32645. fmt.Println(err)
  32646. }
  32647. saveLog(result, request_log, "2206", "预结算")
  32648. //userJSONBytes, _ := json.Marshal(dat)
  32649. //
  32650. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32651. // utils.ErrorLog("解析失败:%v", err)
  32652. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32653. // return
  32654. //}
  32655. userJSONBytes, _ := json.Marshal(dat)
  32656. if miConfig.Code == "H15049901371" {
  32657. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32658. utils.ErrorLog("解析失败:%v", err)
  32659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32660. return
  32661. }
  32662. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32663. res.Output = resSeven10265.Output
  32664. res.ErrMsg = resSeven10265.ErrMsg
  32665. res.Cainfo = resSeven10265.Cainfo
  32666. res.WarnMsg = resSeven10265.WarnMsg
  32667. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32668. res.Infcode = infocode
  32669. } else {
  32670. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32671. utils.ErrorLog("解析失败:%v", err)
  32672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32673. return
  32674. }
  32675. }
  32676. }
  32677. } else {
  32678. c.ServeSuccessJSON(map[string]interface{}{
  32679. "failed_code": -10,
  32680. "msg": result3101.ErrMsg,
  32681. })
  32682. return
  32683. }
  32684. } else {
  32685. var result string
  32686. var request_log string
  32687. var dat map[string]interface{}
  32688. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32689. allTotal = fmt.Sprintf("%.2f", total_two)
  32690. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" || miConfig.Code == "H44090200998" {
  32691. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32692. if result3101.Infcode == 0 {
  32693. if len(result3101.Output.Result) > 0 {
  32694. c.ServeSuccessJSON(map[string]interface{}{
  32695. "failed_code": -10,
  32696. "failed_type": 100,
  32697. "warm_type": 2,
  32698. "msg": result3101,
  32699. })
  32700. return
  32701. } else {
  32702. var result string
  32703. var request_log string
  32704. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32705. allTotal = fmt.Sprintf("%.2f", total_two)
  32706. if his.IdCardType == 4 {
  32707. 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)
  32708. } else {
  32709. if his.IdCardType == 2 {
  32710. cert_no = psn_info.Certno
  32711. psn_info.VerifyNumber = psn_info.Certno
  32712. } else {
  32713. bas := strings.Split(psn_info.CardInfo, "|")
  32714. cert_no = bas[2]
  32715. }
  32716. 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)
  32717. }
  32718. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32719. fmt.Println(dat)
  32720. } else {
  32721. fmt.Println(err)
  32722. }
  32723. saveLog(result, request_log, "2206", "预结算")
  32724. }
  32725. } else {
  32726. c.ServeSuccessJSON(map[string]interface{}{
  32727. "failed_code": -10,
  32728. "msg": result3101.ErrMsg,
  32729. })
  32730. return
  32731. }
  32732. } else {
  32733. if his.IdCardType == 4 {
  32734. 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)
  32735. } else {
  32736. if his.IdCardType == 2 {
  32737. cert_no = psn_info.Certno
  32738. psn_info.VerifyNumber = psn_info.Certno
  32739. } else {
  32740. bas := strings.Split(psn_info.CardInfo, "|")
  32741. cert_no = bas[2]
  32742. }
  32743. 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)
  32744. }
  32745. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32746. fmt.Println(dat)
  32747. } else {
  32748. fmt.Println(err)
  32749. }
  32750. saveLog(result, request_log, "2206", "预结算")
  32751. }
  32752. //userJSONBytes, _ := json.Marshal(dat)
  32753. //
  32754. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32755. // utils.ErrorLog("解析失败:%v", err)
  32756. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32757. // return
  32758. //}
  32759. userJSONBytes, _ := json.Marshal(dat)
  32760. if miConfig.Code == "H15049901371" {
  32761. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32762. utils.ErrorLog("解析失败:%v", err)
  32763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32764. return
  32765. }
  32766. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32767. res.Output = resSeven10265.Output
  32768. res.ErrMsg = resSeven10265.ErrMsg
  32769. res.Cainfo = resSeven10265.Cainfo
  32770. res.WarnMsg = resSeven10265.WarnMsg
  32771. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32772. res.Infcode = infocode
  32773. } else {
  32774. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32775. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  32776. utils.ErrorLog("解析失败:%v", err)
  32777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32778. return
  32779. }
  32780. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  32781. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  32782. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  32783. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  32784. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  32785. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  32786. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  32787. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32788. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  32789. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32790. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32791. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32792. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32793. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  32794. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  32795. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  32796. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  32797. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  32798. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  32799. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  32800. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32801. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  32802. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  32803. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  32804. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  32805. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  32806. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  32807. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  32808. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  32809. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  32810. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  32811. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  32812. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  32813. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  32814. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  32815. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  32816. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  32817. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  32818. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32819. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  32820. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  32821. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  32822. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  32823. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  32824. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  32825. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  32826. res.ErrMsg = gzresSeven10265Two.ErrMsg
  32827. res.Cainfo = gzresSeven10265Two.Cainfo
  32828. res.WarnMsg = gzresSeven10265Two.WarnMsg
  32829. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  32830. //res.Infcode = infocode
  32831. } else {
  32832. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32833. utils.ErrorLog("解析失败:%v", err)
  32834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32835. return
  32836. }
  32837. }
  32838. }
  32839. }
  32840. }
  32841. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  32842. if res10633.Infcode == -1 {
  32843. errlog := &models.HisOrderError{
  32844. UserOrgId: adminUser.CurrentOrgId,
  32845. Ctime: time.Now().Unix(),
  32846. Mtime: time.Now().Unix(),
  32847. Number: chrg_bchno,
  32848. ErrMsg: res10633.ErrMsg,
  32849. Status: 1,
  32850. PatientId: id,
  32851. RecordTime: recordDateTime,
  32852. Stage: 20,
  32853. }
  32854. service.CreateErrMsgLog(errlog)
  32855. c.ServeSuccessJSON(map[string]interface{}{
  32856. "failed_code": -10,
  32857. "msg": res10633.ErrMsg,
  32858. })
  32859. return
  32860. }
  32861. if res10633.Infcode != 0 {
  32862. errlog := &models.HisOrderError{
  32863. UserOrgId: adminUser.CurrentOrgId,
  32864. Ctime: time.Now().Unix(),
  32865. Mtime: time.Now().Unix(),
  32866. Number: chrg_bchno,
  32867. ErrMsg: res10633.ErrMsg,
  32868. Status: 1,
  32869. PatientId: id,
  32870. RecordTime: recordDateTime,
  32871. Stage: 20,
  32872. }
  32873. service.CreateErrMsgLog(errlog)
  32874. c.ServeSuccessJSON(map[string]interface{}{
  32875. "failed_code": -10,
  32876. "msg": res10633.ErrMsg,
  32877. })
  32878. return
  32879. } else {
  32880. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  32881. order.OrderStatus = 1
  32882. order.IsPre = 1
  32883. order.Status = 1
  32884. order.MdtrtId = res10633.Output.Setlinfo.MdtrtID
  32885. order.SetlId = res10633.Output.Setlinfo.SetlID
  32886. order.PsnNo = res10633.Output.Setlinfo.PsnNo
  32887. order.PsnName = res10633.Output.Setlinfo.PsnName
  32888. order.PsnCertType = res10633.Output.Setlinfo.PsnCertType
  32889. order.Certno = res10633.Output.Setlinfo.Certno
  32890. order.Gend = res10633.Output.Setlinfo.Gend
  32891. order.Naty = res10633.Output.Setlinfo.Naty
  32892. order.Age = res10633.Output.Setlinfo.Age
  32893. order.Insutype = res10633.Output.Setlinfo.Insutype
  32894. order.PsnType = res10633.Output.Setlinfo.PsnType
  32895. order.CvlservFlag = res10633.Output.Setlinfo.CvlservFlag
  32896. order.SetlTime = res10633.Output.Setlinfo.SetlTime
  32897. order.AcctUsedFlag = acct_used_flag
  32898. order.MdtrtCertType = res10633.Output.Setlinfo.MdtrtCertType
  32899. if res10633.Output.Setlinfo.MedType == "140101" {
  32900. order.MedType = "14"
  32901. } else {
  32902. if res10633.Output.Setlinfo.MedType == "110104" {
  32903. order.MedType = "11"
  32904. } else {
  32905. order.MedType = res10633.Output.Setlinfo.MedType
  32906. }
  32907. }
  32908. if res10633.Output.Setlinfo.MedType == "992102" {
  32909. order.MedType = "992102"
  32910. }
  32911. if res10633.Output.Setlinfo.MedType == "140104" {
  32912. order.MedType = "140104"
  32913. }
  32914. if res10633.Output.Setlinfo.MedType == "1104" {
  32915. order.MedType = "1104"
  32916. }
  32917. if res10633.Output.Setlinfo.MedType == "140201" {
  32918. order.MedType = "140201"
  32919. }
  32920. if res10633.Output.Setlinfo.MedType == "14" {
  32921. order.MedType = "14"
  32922. }
  32923. if reg_type == 1112 {
  32924. order.MedType = "1112"
  32925. }
  32926. if reg_type == 1111 {
  32927. order.MedType = "1111"
  32928. }
  32929. order.ClrType = res10633.Output.Setlinfo.ClrType
  32930. if adminUser.CurrentOrgId == 10480 {
  32931. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  32932. order.ClrType = "11"
  32933. } else {
  32934. order.ClrType = "9903"
  32935. }
  32936. }
  32937. order.MedfeeSumamt = res10633.Output.Setlinfo.MedfeeSumamt
  32938. order.FulamtOwnpayAmt = res10633.Output.Setlinfo.FulamtOwnpayAmt
  32939. order.OverlmtSelfPay = res10633.Output.Setlinfo.OverlmtSelfpay
  32940. order.PreselfpayAmt = res10633.Output.Setlinfo.PreselfpayAmt
  32941. order.InscpScpAmt = res10633.Output.Setlinfo.InscpScpAmt
  32942. order.ActPayDedc = res10633.Output.Setlinfo.ActPayDedc
  32943. order.HifpPay = res10633.Output.Setlinfo.HifpPay
  32944. order.CvlservPay = res10633.Output.Setlinfo.CvlservPay
  32945. order.HifesPay = res10633.Output.Setlinfo.HifesPay
  32946. order.HifobPay = res10633.Output.Setlinfo.HifobPay
  32947. order.MafPay = res10633.Output.Setlinfo.MafPay
  32948. order.HifmiPay = res10633.Output.Setlinfo.HifmiPay
  32949. order.OthPay = res10633.Output.Setlinfo.OthPay
  32950. order.FundPaySumamt = res10633.Output.Setlinfo.FundPaySumamt
  32951. order.PsnPartAmt = res10633.Output.Setlinfo.PsnPartAmt
  32952. order.AcctPay = res10633.Output.Setlinfo.AcctPay
  32953. order.PsnCashPay = res10633.Output.Setlinfo.PsnCashPay
  32954. order.Balc = res10633.Output.Setlinfo.Balc
  32955. order.MedinsSetlId = res10633.Output.Setlinfo.MedinsSetlID
  32956. order.ClrOptins = res10633.Output.Setlinfo.ClrOptins
  32957. order.ClrWay = res10633.Output.Setlinfo.ClrWay
  32958. order.Creator = order.Creator
  32959. order.Modify = roles.AdminUserId
  32960. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  32961. //detailStr := string(setlDetail)
  32962. //order.SetlDetail = detailStr
  32963. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  32964. err = service.UpDateOrder(order)
  32965. if err == nil {
  32966. c.ServeSuccessJSON(map[string]interface{}{
  32967. "msg": "预结算成功",
  32968. })
  32969. } else {
  32970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  32971. return
  32972. }
  32973. }
  32974. } else {
  32975. if res.Infcode == -1 {
  32976. errlog := &models.HisOrderError{
  32977. UserOrgId: adminUser.CurrentOrgId,
  32978. Ctime: time.Now().Unix(),
  32979. Mtime: time.Now().Unix(),
  32980. Number: chrg_bchno,
  32981. ErrMsg: res.ErrMsg,
  32982. Status: 1,
  32983. PatientId: id,
  32984. RecordTime: recordDateTime,
  32985. Stage: 20,
  32986. }
  32987. service.CreateErrMsgLog(errlog)
  32988. c.ServeSuccessJSON(map[string]interface{}{
  32989. "failed_code": -10,
  32990. "msg": res.ErrMsg,
  32991. })
  32992. return
  32993. }
  32994. if res.Infcode != 0 {
  32995. errlog := &models.HisOrderError{
  32996. UserOrgId: adminUser.CurrentOrgId,
  32997. Ctime: time.Now().Unix(),
  32998. Mtime: time.Now().Unix(),
  32999. Number: chrg_bchno,
  33000. ErrMsg: res.ErrMsg,
  33001. Status: 1,
  33002. PatientId: id,
  33003. RecordTime: recordDateTime,
  33004. Stage: 20,
  33005. }
  33006. service.CreateErrMsgLog(errlog)
  33007. c.ServeSuccessJSON(map[string]interface{}{
  33008. "failed_code": -10,
  33009. "msg": res.ErrMsg,
  33010. })
  33011. return
  33012. } else {
  33013. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  33014. order.OrderStatus = 1
  33015. order.IsPre = 1
  33016. order.Status = 1
  33017. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  33018. order.SetlId = res.Output.Setlinfo.SetlID
  33019. order.PsnNo = res.Output.Setlinfo.PsnNo
  33020. order.PsnName = res.Output.Setlinfo.PsnName
  33021. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  33022. order.Certno = res.Output.Setlinfo.Certno
  33023. order.Gend = res.Output.Setlinfo.Gend
  33024. order.Naty = res.Output.Setlinfo.Naty
  33025. order.Age = res.Output.Setlinfo.Age
  33026. order.Insutype = res.Output.Setlinfo.Insutype
  33027. order.PsnType = res.Output.Setlinfo.PsnType
  33028. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  33029. order.SetlTime = res.Output.Setlinfo.SetlTime
  33030. order.AcctUsedFlag = acct_used_flag
  33031. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  33032. if res.Output.Setlinfo.MedType == "140101" {
  33033. order.MedType = "14"
  33034. } else {
  33035. if res.Output.Setlinfo.MedType == "110104" {
  33036. order.MedType = "11"
  33037. } else {
  33038. order.MedType = res.Output.Setlinfo.MedType
  33039. }
  33040. }
  33041. if res.Output.Setlinfo.MedType == "992102" {
  33042. order.MedType = "992102"
  33043. }
  33044. if res.Output.Setlinfo.MedType == "140104" {
  33045. order.MedType = "140104"
  33046. }
  33047. if res.Output.Setlinfo.MedType == "1104" {
  33048. order.MedType = "1104"
  33049. }
  33050. if res.Output.Setlinfo.MedType == "140201" {
  33051. order.MedType = "140201"
  33052. }
  33053. if res.Output.Setlinfo.MedType == "14" {
  33054. order.MedType = "14"
  33055. }
  33056. if reg_type == 1112 {
  33057. order.MedType = "1112"
  33058. }
  33059. if reg_type == 1111 {
  33060. order.MedType = "1111"
  33061. }
  33062. order.ClrType = res.Output.Setlinfo.ClrType
  33063. if adminUser.CurrentOrgId == 10480 {
  33064. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  33065. order.ClrType = "11"
  33066. } else {
  33067. order.ClrType = "9903"
  33068. }
  33069. }
  33070. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  33071. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  33072. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  33073. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  33074. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  33075. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  33076. order.HifpPay = res.Output.Setlinfo.HifpPay
  33077. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  33078. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  33079. order.HifesPay = res.Output.Setlinfo.HifesPay
  33080. order.HifobPay = res.Output.Setlinfo.HifobPay
  33081. order.MafPay = res.Output.Setlinfo.MafPay
  33082. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  33083. order.OthPay = res.Output.Setlinfo.OthPay
  33084. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  33085. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  33086. order.AcctPay = res.Output.Setlinfo.AcctPay
  33087. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  33088. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  33089. order.Balc = res.Output.Setlinfo.Balc
  33090. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  33091. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  33092. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  33093. order.ClrWay = res.Output.Setlinfo.ClrWay
  33094. order.Creator = order.Creator
  33095. order.Modify = roles.AdminUserId
  33096. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  33097. //detailStr := string(setlDetail)
  33098. //order.SetlDetail = detailStr
  33099. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  33100. err = service.UpDateOrder(order)
  33101. if err == nil {
  33102. c.ServeSuccessJSON(map[string]interface{}{
  33103. "msg": "预结算成功",
  33104. })
  33105. } else {
  33106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  33107. return
  33108. }
  33109. }
  33110. }
  33111. } else {
  33112. adminUser := c.GetAdminUserInfo()
  33113. errlog := &models.HisOrderError{
  33114. UserOrgId: adminUser.CurrentOrgId,
  33115. Ctime: time.Now().Unix(),
  33116. Mtime: time.Now().Unix(),
  33117. ErrMsg: res.ErrMsg,
  33118. Status: 1,
  33119. PatientId: id,
  33120. RecordTime: recordDateTime,
  33121. Stage: 4,
  33122. }
  33123. service.CreateErrMsgLog(errlog)
  33124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  33125. return
  33126. }
  33127. } else {
  33128. if miConfig.MdtrtareaAdmvs == "150404" {
  33129. order := &models.HisOrder{
  33130. UserOrgId: adminUser.CurrentOrgId,
  33131. HisPatientId: his.ID,
  33132. PatientId: his.PatientId,
  33133. SettleAccountsDate: recordDateTime,
  33134. Ctime: time.Now().Unix(),
  33135. Mtime: time.Now().Unix(),
  33136. MdtrtId: his.Number,
  33137. PsnNo: his.PsnNo,
  33138. MedType: strconv.FormatInt(reg_type, 10),
  33139. Status: 1,
  33140. Number: chrg_bchno,
  33141. Infcode: res.Infcode,
  33142. WarnMsg: res.WarnMsg,
  33143. Cainfo: res.Cainfo,
  33144. ErrMsg: res.ErrMsg,
  33145. RespondTime: res.RefmsgTime,
  33146. InfRefmsgid: res.InfRefmsgid,
  33147. OrderStatus: 1,
  33148. IsMedicineInsurance: 1,
  33149. SettleType: settle_accounts_type,
  33150. SettleStartTime: start_time,
  33151. SettleEndTime: end_time,
  33152. Creator: roles.AdminUserId,
  33153. Modify: roles.AdminUserId,
  33154. PType: 2,
  33155. Diagnosis: diagnosis_id,
  33156. }
  33157. err = service.CreateOrder(order)
  33158. if err != nil {
  33159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  33160. return
  33161. }
  33162. }
  33163. adminUser := c.GetAdminUserInfo()
  33164. errlog := &models.HisOrderError{
  33165. UserOrgId: adminUser.CurrentOrgId,
  33166. Ctime: time.Now().Unix(),
  33167. Mtime: time.Now().Unix(),
  33168. ErrMsg: res.ErrMsg,
  33169. Status: 1,
  33170. PatientId: id,
  33171. RecordTime: recordDateTime,
  33172. Stage: 4,
  33173. }
  33174. service.CreateErrMsgLog(errlog)
  33175. c.ServeSuccessJSON(map[string]interface{}{
  33176. "failed_code": -10,
  33177. "msg": res.ErrMsg,
  33178. })
  33179. return
  33180. }
  33181. }
  33182. }
  33183. }
  33184. // 退款
  33185. func (c *HisApiController) Refund() {
  33186. order_id, _ := c.GetInt64("order_id")
  33187. admin_user_id, _ := c.GetInt64("admin_user_id")
  33188. adminUser := c.GetAdminUserInfo()
  33189. var order models.HisOrder
  33190. order, _ = service.GetHisOrderByID(order_id)
  33191. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  33192. if fapiao.ID > 0 {
  33193. c.ServeSuccessJSON(map[string]interface{}{
  33194. "failed_code": -10,
  33195. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  33196. })
  33197. return
  33198. }
  33199. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33200. if order.ID == 0 {
  33201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  33202. return
  33203. }
  33204. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  33205. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33206. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33207. if config.IsOpen == 1 { //对接了医保,走医保流程
  33208. var res ResultSixteen
  33209. var ahres ResultSevenAH
  33210. var resSixteen10265 ResultSixteen10265
  33211. var resSixteen10265Two ResultSixteen10265Two
  33212. var gz ResultgzSixteen10265Two
  33213. var src_resquest string
  33214. var result string
  33215. if miConfig.MdtrtareaAdmvs == "421300" {
  33216. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  33217. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33218. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33219. resp3, requestErr3 := http.Get(api3)
  33220. if requestErr3 != nil {
  33221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33222. return
  33223. }
  33224. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33225. if ioErr3 != nil {
  33226. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33228. return
  33229. }
  33230. var respJSON3 map[string]interface{}
  33231. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33232. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33234. return
  33235. }
  33236. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33237. userJSONBytes3, _ := json.Marshal(respJSON3)
  33238. fmt.Println("log")
  33239. fmt.Println(string(userJSONBytes3))
  33240. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33241. utils.ErrorLog("解析失败:%v", err)
  33242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33243. return
  33244. }
  33245. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33246. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  33247. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33248. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33249. resp3, requestErr3 := http.Get(api3)
  33250. if requestErr3 != nil {
  33251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33252. return
  33253. }
  33254. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33255. if ioErr3 != nil {
  33256. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33258. return
  33259. }
  33260. var respJSON3 map[string]interface{}
  33261. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33262. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33264. return
  33265. }
  33266. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33267. userJSONBytes3, _ := json.Marshal(respJSON3)
  33268. fmt.Println("log")
  33269. fmt.Println(string(userJSONBytes3))
  33270. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33271. utils.ErrorLog("解析失败:%v", err)
  33272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33273. return
  33274. }
  33275. } else if miConfig.MdtrtareaAdmvs == "420902" {
  33276. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  33277. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33278. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33279. resp3, requestErr3 := http.Get(api3)
  33280. if requestErr3 != nil {
  33281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33282. return
  33283. }
  33284. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33285. if ioErr3 != nil {
  33286. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33288. return
  33289. }
  33290. var respJSON3 map[string]interface{}
  33291. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33292. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33294. return
  33295. }
  33296. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33297. userJSONBytes3, _ := json.Marshal(respJSON3)
  33298. fmt.Println("log")
  33299. fmt.Println(string(userJSONBytes3))
  33300. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33301. utils.ErrorLog("解析失败:%v", err)
  33302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33303. return
  33304. }
  33305. } else if miConfig.MdtrtareaAdmvs == "421182" {
  33306. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  33307. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33308. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33309. resp3, requestErr3 := http.Get(api3)
  33310. if requestErr3 != nil {
  33311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33312. return
  33313. }
  33314. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33315. if ioErr3 != nil {
  33316. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33318. return
  33319. }
  33320. var respJSON3 map[string]interface{}
  33321. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33324. return
  33325. }
  33326. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33327. userJSONBytes3, _ := json.Marshal(respJSON3)
  33328. fmt.Println("log")
  33329. fmt.Println(string(userJSONBytes3))
  33330. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33331. utils.ErrorLog("解析失败:%v", err)
  33332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33333. return
  33334. }
  33335. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  33336. var api3 string
  33337. if miConfig.MdtrtareaAdmvs == "320830" {
  33338. api3 = miConfig.AppSecret + "jsyb/2208?psn_no=" + order.PsnNo +
  33339. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33340. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33341. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33342. } else if miConfig.MdtrtareaAdmvs == "320921" {
  33343. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  33344. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33345. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33346. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33347. } else {
  33348. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33349. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  33350. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33351. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33352. }
  33353. resp3, requestErr3 := http.Get(api3)
  33354. if requestErr3 != nil {
  33355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33356. return
  33357. }
  33358. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33359. if ioErr3 != nil {
  33360. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33362. return
  33363. }
  33364. var respJSON3 map[string]interface{}
  33365. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33368. return
  33369. }
  33370. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33371. userJSONBytes3, _ := json.Marshal(respJSON3)
  33372. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  33373. utils.ErrorLog("解析失败:%v", err)
  33374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33375. return
  33376. }
  33377. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33378. res.Output = resSixteen10265.Output
  33379. res.ErrMsg = resSixteen10265.ErrMsg
  33380. res.Cainfo = resSixteen10265.Cainfo
  33381. res.WarnMsg = resSixteen10265.WarnMsg
  33382. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33383. res.Infcode = infocode
  33384. } else if miConfig.MdtrtareaAdmvs == "150404" {
  33385. var api3 string
  33386. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  33387. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33388. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33389. resp3, requestErr3 := http.Get(api3)
  33390. if requestErr3 != nil {
  33391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33392. return
  33393. }
  33394. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33395. if ioErr3 != nil {
  33396. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33398. return
  33399. }
  33400. var respJSON3 map[string]interface{}
  33401. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33402. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33404. return
  33405. }
  33406. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33407. userJSONBytes3, _ := json.Marshal(respJSON3)
  33408. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  33409. utils.ErrorLog("解析失败:%v", err)
  33410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33411. return
  33412. }
  33413. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33414. res.Output = resSixteen10265.Output
  33415. res.ErrMsg = resSixteen10265.ErrMsg
  33416. res.Cainfo = resSixteen10265.Cainfo
  33417. res.WarnMsg = resSixteen10265.WarnMsg
  33418. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33419. res.Infcode = infocode
  33420. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33421. 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)
  33422. var dat map[string]interface{}
  33423. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33424. fmt.Println(dat)
  33425. } else {
  33426. fmt.Println(err)
  33427. }
  33428. saveLog(result, src_resquest, "2208", "退费")
  33429. userJSONBytes, _ := json.Marshal(dat)
  33430. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33431. utils.ErrorLog("解析失败:%v", err)
  33432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33433. return
  33434. }
  33435. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33436. 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, "")
  33437. var dat map[string]interface{}
  33438. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33439. fmt.Println(dat)
  33440. } else {
  33441. fmt.Println(err)
  33442. }
  33443. saveLog(result, src_resquest, "2208", "退费")
  33444. userJSONBytes, _ := json.Marshal(dat)
  33445. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33446. utils.ErrorLog("解析失败:%v", err)
  33447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33448. return
  33449. }
  33450. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33451. 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, "")
  33452. var dat map[string]interface{}
  33453. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33454. fmt.Println(dat)
  33455. } else {
  33456. fmt.Println(err)
  33457. }
  33458. saveLog(result, src_resquest, "2208", "退费")
  33459. userJSONBytes, _ := json.Marshal(dat)
  33460. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33461. utils.ErrorLog("解析失败:%v", err)
  33462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33463. return
  33464. }
  33465. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33466. 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, "")
  33467. var dat map[string]interface{}
  33468. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33469. fmt.Println(dat)
  33470. } else {
  33471. fmt.Println(err)
  33472. }
  33473. saveLog(result, src_resquest, "2208", "退费")
  33474. userJSONBytes, _ := json.Marshal(dat)
  33475. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33476. utils.ErrorLog("解析失败:%v", err)
  33477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33478. return
  33479. }
  33480. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33481. var api3 string
  33482. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  33483. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33484. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33485. resp3, requestErr3 := http.Get(api3)
  33486. if requestErr3 != nil {
  33487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33488. return
  33489. }
  33490. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33491. if ioErr3 != nil {
  33492. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33494. return
  33495. }
  33496. var respJSON3 map[string]interface{}
  33497. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33498. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33500. return
  33501. }
  33502. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33503. if status == "0" {
  33504. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33505. c.ServeSuccessJSON(map[string]interface{}{
  33506. "failed_code": -10,
  33507. "msg": err_msg,
  33508. })
  33509. return
  33510. }
  33511. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33512. userJSONBytes3, _ := json.Marshal(respJSON3)
  33513. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33514. // utils.ErrorLog("解析失败:%v", err)
  33515. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33516. // return
  33517. //}
  33518. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  33519. utils.ErrorLog("解析失败:%v", err)
  33520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33521. return
  33522. }
  33523. res.InfRefmsgid = ahres.InfRefmsgid
  33524. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  33525. // 创建对应的Time类型
  33526. t := time.UnixMilli(timestamp)
  33527. // 格式化成指定的日期字符串
  33528. str := t.Format("2006-01-02 15:04:05")
  33529. res.Output.Setlinfo.SetlTime = str
  33530. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  33531. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  33532. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33533. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  33534. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  33535. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  33536. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  33537. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  33538. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  33539. //
  33540. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  33541. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  33542. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  33543. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33544. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  33545. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  33546. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  33547. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  33548. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  33549. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  33550. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  33551. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  33552. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  33553. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  33554. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  33555. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  33556. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  33557. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  33558. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  33559. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  33560. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  33561. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  33562. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  33563. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  33564. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  33565. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  33566. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  33567. //res.Output.Setldetail = ahres.Output.Setldetail
  33568. res.ErrMsg = ahres.ErrMsg
  33569. res.Cainfo = ahres.Cainfo
  33570. res.WarnMsg = ahres.WarnMsg
  33571. res.Infcode = ahres.Infcode
  33572. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33573. var api3 string
  33574. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  33575. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33576. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33577. resp3, requestErr3 := http.Get(api3)
  33578. if requestErr3 != nil {
  33579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33580. return
  33581. }
  33582. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33583. if ioErr3 != nil {
  33584. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33586. return
  33587. }
  33588. var respJSON3 map[string]interface{}
  33589. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33590. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33592. return
  33593. }
  33594. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33595. if status == "0" {
  33596. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33597. c.ServeSuccessJSON(map[string]interface{}{
  33598. "failed_code": -10,
  33599. "msg": err_msg,
  33600. })
  33601. return
  33602. }
  33603. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33604. userJSONBytes3, _ := json.Marshal(respJSON3)
  33605. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33606. // utils.ErrorLog("解析失败:%v", err)
  33607. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33608. // return
  33609. //}
  33610. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  33611. utils.ErrorLog("解析失败:%v", err)
  33612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33613. return
  33614. }
  33615. res.InfRefmsgid = ahres.InfRefmsgid
  33616. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  33617. // 创建对应的Time类型
  33618. t := time.UnixMilli(timestamp)
  33619. // 格式化成指定的日期字符串
  33620. str := t.Format("2006-01-02 15:04:05")
  33621. res.Output.Setlinfo.SetlTime = str
  33622. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  33623. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  33624. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33625. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  33626. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  33627. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  33628. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  33629. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  33630. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  33631. //
  33632. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  33633. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  33634. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  33635. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33636. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  33637. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  33638. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  33639. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  33640. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  33641. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  33642. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  33643. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  33644. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  33645. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  33646. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  33647. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  33648. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  33649. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  33650. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  33651. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  33652. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  33653. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  33654. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  33655. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  33656. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  33657. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  33658. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  33659. //res.Output.Setldetail = ahres.Output.Setldetail
  33660. res.ErrMsg = ahres.ErrMsg
  33661. res.Cainfo = ahres.Cainfo
  33662. res.WarnMsg = ahres.WarnMsg
  33663. res.Infcode = ahres.Infcode
  33664. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33665. 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, "")
  33666. var dat map[string]interface{}
  33667. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33668. fmt.Println(dat)
  33669. } else {
  33670. fmt.Println(err)
  33671. }
  33672. saveLog(result, src_resquest, "2208", "退费")
  33673. userJSONBytes, _ := json.Marshal(dat)
  33674. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33675. utils.ErrorLog("解析失败:%v", err)
  33676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33677. return
  33678. }
  33679. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33680. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  33681. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33682. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33683. resp3, requestErr3 := http.Get(api3)
  33684. if requestErr3 != nil {
  33685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33686. return
  33687. }
  33688. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33689. if ioErr3 != nil {
  33690. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33692. return
  33693. }
  33694. var respJSON3 map[string]interface{}
  33695. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33696. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33698. return
  33699. }
  33700. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33701. userJSONBytes3, _ := json.Marshal(respJSON3)
  33702. fmt.Println("log")
  33703. fmt.Println(string(userJSONBytes3))
  33704. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33705. utils.ErrorLog("解析失败:%v", err)
  33706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33707. return
  33708. }
  33709. } else {
  33710. if miConfig.Code == "H15049901371" {
  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. if strings.Contains(result, "Post") {
  33720. res.Infcode = -1
  33721. res.ErrMsg = result
  33722. }
  33723. userJSONBytes, _ := json.Marshal(dat)
  33724. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  33725. utils.ErrorLog("解析失败:%v", err)
  33726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33727. return
  33728. }
  33729. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33730. res.Output = resSixteen10265.Output
  33731. res.ErrMsg = resSixteen10265.ErrMsg
  33732. res.Cainfo = resSixteen10265.Cainfo
  33733. res.WarnMsg = resSixteen10265.WarnMsg
  33734. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33735. res.Infcode = infocode
  33736. } else {
  33737. 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)
  33738. var dat map[string]interface{}
  33739. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33740. fmt.Println(dat)
  33741. } else {
  33742. fmt.Println(err)
  33743. }
  33744. saveLog(result, src_resquest, "2208", "退费")
  33745. userJSONBytes, _ := json.Marshal(dat)
  33746. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  33747. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  33748. utils.ErrorLog("解析失败:%v", err)
  33749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33750. return
  33751. }
  33752. res.Infcode = gz.Infcode
  33753. } else {
  33754. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33755. utils.ErrorLog("解析失败:%v", err)
  33756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33757. return
  33758. }
  33759. }
  33760. if strings.Contains(result, "Post") {
  33761. res.Infcode = -1
  33762. res.ErrMsg = result
  33763. }
  33764. }
  33765. }
  33766. if res.Infcode == -1 {
  33767. c.ServeSuccessJSON(map[string]interface{}{
  33768. "failed_code": -10,
  33769. "msg": res.ErrMsg,
  33770. })
  33771. return
  33772. }
  33773. if res.Infcode != -1 {
  33774. var res2 ResultSix
  33775. var resSix10265 ResultSix10265
  33776. if miConfig.MdtrtareaAdmvs == "421300" {
  33777. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33778. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33779. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33780. resp3, requestErr3 := http.Get(api3)
  33781. if requestErr3 != nil {
  33782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33783. return
  33784. }
  33785. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33786. if ioErr3 != nil {
  33787. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33789. return
  33790. }
  33791. var respJSON3 map[string]interface{}
  33792. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33793. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33795. return
  33796. }
  33797. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33798. userJSONBytes3, _ := json.Marshal(respJSON3)
  33799. fmt.Println("log")
  33800. fmt.Println(string(userJSONBytes3))
  33801. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33802. utils.ErrorLog("解析失败:%v", err)
  33803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33804. return
  33805. }
  33806. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33807. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33808. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33809. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33810. resp3, requestErr3 := http.Get(api3)
  33811. if requestErr3 != nil {
  33812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33813. return
  33814. }
  33815. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33816. if ioErr3 != nil {
  33817. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33819. return
  33820. }
  33821. var respJSON3 map[string]interface{}
  33822. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33823. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33825. return
  33826. }
  33827. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33828. userJSONBytes3, _ := json.Marshal(respJSON3)
  33829. fmt.Println("log")
  33830. fmt.Println(string(userJSONBytes3))
  33831. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33832. utils.ErrorLog("解析失败:%v", err)
  33833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33834. return
  33835. }
  33836. } else if miConfig.MdtrtareaAdmvs == "420902" {
  33837. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33838. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33839. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33840. resp3, requestErr3 := http.Get(api3)
  33841. if requestErr3 != nil {
  33842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33843. return
  33844. }
  33845. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33846. if ioErr3 != nil {
  33847. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33849. return
  33850. }
  33851. var respJSON3 map[string]interface{}
  33852. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33853. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33855. return
  33856. }
  33857. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33858. userJSONBytes3, _ := json.Marshal(respJSON3)
  33859. fmt.Println("log")
  33860. fmt.Println(string(userJSONBytes3))
  33861. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33862. utils.ErrorLog("解析失败:%v", err)
  33863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33864. return
  33865. }
  33866. } else if miConfig.MdtrtareaAdmvs == "421182" {
  33867. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33868. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33869. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33870. resp3, requestErr3 := http.Get(api3)
  33871. if requestErr3 != nil {
  33872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33873. return
  33874. }
  33875. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33876. if ioErr3 != nil {
  33877. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33879. return
  33880. }
  33881. var respJSON3 map[string]interface{}
  33882. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33885. return
  33886. }
  33887. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33888. userJSONBytes3, _ := json.Marshal(respJSON3)
  33889. fmt.Println("log")
  33890. fmt.Println(string(userJSONBytes3))
  33891. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33892. utils.ErrorLog("解析失败:%v", err)
  33893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33894. return
  33895. }
  33896. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  33897. var api3 string
  33898. if miConfig.MdtrtareaAdmvs == "320830" {
  33899. api3 = miConfig.AppSecret + "jsyb/2205?psn_no=" + order.PsnNo +
  33900. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + "0000" + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33901. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33902. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33903. } else if miConfig.MdtrtareaAdmvs == "320921" {
  33904. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33905. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33906. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33907. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33908. } else {
  33909. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33910. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33911. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33912. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33913. }
  33914. resp3, requestErr3 := http.Get(api3)
  33915. if requestErr3 != nil {
  33916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33917. return
  33918. }
  33919. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33920. if ioErr3 != nil {
  33921. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33923. return
  33924. }
  33925. var respJSON3 map[string]interface{}
  33926. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33929. return
  33930. }
  33931. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33932. userJSONBytes3, _ := json.Marshal(respJSON3)
  33933. fmt.Println("log")
  33934. fmt.Println(string(userJSONBytes3))
  33935. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33936. utils.ErrorLog("解析失败:%v", err)
  33937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33938. return
  33939. }
  33940. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33941. res2.Output = resSix10265.Output
  33942. res2.ErrMsg = resSix10265.ErrMsg
  33943. res2.Cainfo = resSix10265.Cainfo
  33944. res2.WarnMsg = resSix10265.WarnMsg
  33945. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33946. res2.Infcode = infocode
  33947. } else if miConfig.MdtrtareaAdmvs == "150404" {
  33948. var api3 string
  33949. new_chrg_bchno := order.Number
  33950. if adminUser.CurrentOrgId == 10265 {
  33951. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  33952. new_chrg_bchno = "0000"
  33953. }
  33954. }
  33955. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  33956. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33957. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33958. resp3, requestErr3 := http.Get(api3)
  33959. if requestErr3 != nil {
  33960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33961. return
  33962. }
  33963. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33964. if ioErr3 != nil {
  33965. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33967. return
  33968. }
  33969. var respJSON3 map[string]interface{}
  33970. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33971. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33973. return
  33974. }
  33975. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33976. userJSONBytes3, _ := json.Marshal(respJSON3)
  33977. fmt.Println("log")
  33978. fmt.Println(string(userJSONBytes3))
  33979. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33980. utils.ErrorLog("解析失败:%v", err)
  33981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33982. return
  33983. }
  33984. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33985. res2.Output = resSix10265.Output
  33986. res2.ErrMsg = resSix10265.ErrMsg
  33987. res2.Cainfo = resSix10265.Cainfo
  33988. res2.WarnMsg = resSix10265.WarnMsg
  33989. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33990. res2.Infcode = infocode
  33991. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33992. 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)
  33993. var dat map[string]interface{}
  33994. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33995. fmt.Println(dat)
  33996. } else {
  33997. fmt.Println(err)
  33998. }
  33999. saveLog(result2, src_request, "2205", "撤销明细")
  34000. userJSONBytes, _ := json.Marshal(dat)
  34001. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34002. utils.ErrorLog("解析失败:%v", err)
  34003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34004. return
  34005. }
  34006. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34007. 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, "")
  34008. var dat map[string]interface{}
  34009. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34010. fmt.Println(dat)
  34011. } else {
  34012. fmt.Println(err)
  34013. }
  34014. saveLog(result2, src_request, "2205", "撤销明细")
  34015. userJSONBytes, _ := json.Marshal(dat)
  34016. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34017. utils.ErrorLog("解析失败:%v", err)
  34018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34019. return
  34020. }
  34021. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34022. 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, "")
  34023. var dat map[string]interface{}
  34024. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34025. fmt.Println(dat)
  34026. } else {
  34027. fmt.Println(err)
  34028. }
  34029. saveLog(result2, src_request, "2205", "撤销明细")
  34030. userJSONBytes, _ := json.Marshal(dat)
  34031. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34032. utils.ErrorLog("解析失败:%v", err)
  34033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34034. return
  34035. }
  34036. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34037. 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, "")
  34038. var dat map[string]interface{}
  34039. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34040. fmt.Println(dat)
  34041. } else {
  34042. fmt.Println(err)
  34043. }
  34044. saveLog(result2, src_request, "2205", "撤销明细")
  34045. userJSONBytes, _ := json.Marshal(dat)
  34046. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34047. utils.ErrorLog("解析失败:%v", err)
  34048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34049. return
  34050. }
  34051. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34052. var api3 string
  34053. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  34054. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34055. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34056. resp3, requestErr3 := http.Get(api3)
  34057. if requestErr3 != nil {
  34058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34059. return
  34060. }
  34061. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34062. if ioErr3 != nil {
  34063. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34065. return
  34066. }
  34067. var respJSON3 map[string]interface{}
  34068. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34069. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34071. return
  34072. }
  34073. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34074. if status == "0" {
  34075. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34076. c.ServeSuccessJSON(map[string]interface{}{
  34077. "failed_code": -10,
  34078. "msg": err_msg,
  34079. })
  34080. return
  34081. }
  34082. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34083. userJSONBytes3, _ := json.Marshal(respJSON3)
  34084. fmt.Println("log")
  34085. fmt.Println(string(userJSONBytes3))
  34086. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34087. utils.ErrorLog("解析失败:%v", err)
  34088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34089. return
  34090. }
  34091. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34092. 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, "")
  34093. var dat map[string]interface{}
  34094. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34095. fmt.Println(dat)
  34096. } else {
  34097. fmt.Println(err)
  34098. }
  34099. saveLog(result2, src_request, "2205", "撤销明细")
  34100. userJSONBytes, _ := json.Marshal(dat)
  34101. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34102. utils.ErrorLog("解析失败:%v", err)
  34103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34104. return
  34105. }
  34106. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34107. 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, "")
  34108. var dat map[string]interface{}
  34109. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34110. fmt.Println(dat)
  34111. } else {
  34112. fmt.Println(err)
  34113. }
  34114. saveLog(result2, src_request, "2205", "撤销明细")
  34115. userJSONBytes, _ := json.Marshal(dat)
  34116. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34117. utils.ErrorLog("解析失败:%v", err)
  34118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34119. return
  34120. }
  34121. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34122. 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, "")
  34123. var dat map[string]interface{}
  34124. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34125. fmt.Println(dat)
  34126. } else {
  34127. fmt.Println(err)
  34128. }
  34129. saveLog(result2, src_request, "2205", "撤销明细")
  34130. userJSONBytes, _ := json.Marshal(dat)
  34131. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34132. utils.ErrorLog("解析失败:%v", err)
  34133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34134. return
  34135. }
  34136. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34137. var api3 string
  34138. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  34139. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34140. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34141. resp3, requestErr3 := http.Get(api3)
  34142. if requestErr3 != nil {
  34143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34144. return
  34145. }
  34146. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34147. if ioErr3 != nil {
  34148. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34150. return
  34151. }
  34152. var respJSON3 map[string]interface{}
  34153. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34154. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34156. return
  34157. }
  34158. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34159. if status == "0" {
  34160. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34161. c.ServeSuccessJSON(map[string]interface{}{
  34162. "failed_code": -10,
  34163. "msg": err_msg,
  34164. })
  34165. return
  34166. }
  34167. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34168. userJSONBytes3, _ := json.Marshal(respJSON3)
  34169. fmt.Println("log")
  34170. fmt.Println(string(userJSONBytes3))
  34171. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34172. utils.ErrorLog("解析失败:%v", err)
  34173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34174. return
  34175. }
  34176. } else if miConfig.MdtrtareaAdmvs == "430800" {
  34177. 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, "")
  34178. var dat map[string]interface{}
  34179. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34180. fmt.Println(dat)
  34181. } else {
  34182. fmt.Println(err)
  34183. }
  34184. saveLog(result2, src_request, "2205", "撤销明细")
  34185. userJSONBytes, _ := json.Marshal(dat)
  34186. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34187. utils.ErrorLog("解析失败:%v", err)
  34188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34189. return
  34190. }
  34191. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34192. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  34193. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34194. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34195. resp3, requestErr3 := http.Get(api3)
  34196. if requestErr3 != nil {
  34197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34198. return
  34199. }
  34200. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34201. if ioErr3 != nil {
  34202. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34204. return
  34205. }
  34206. var respJSON3 map[string]interface{}
  34207. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34208. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34210. return
  34211. }
  34212. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34213. userJSONBytes3, _ := json.Marshal(respJSON3)
  34214. fmt.Println("log")
  34215. fmt.Println(string(userJSONBytes3))
  34216. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34217. utils.ErrorLog("解析失败:%v", err)
  34218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34219. return
  34220. }
  34221. } else {
  34222. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  34223. res2.Infcode = 0
  34224. } else {
  34225. 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)
  34226. var dat map[string]interface{}
  34227. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34228. fmt.Println(dat)
  34229. } else {
  34230. fmt.Println(err)
  34231. }
  34232. saveLog(result2, src_request, "2205", "撤销明细")
  34233. userJSONBytes, _ := json.Marshal(dat)
  34234. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34235. utils.ErrorLog("解析失败:%v", err)
  34236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34237. return
  34238. }
  34239. }
  34240. }
  34241. if res2.Infcode == -1 {
  34242. c.ServeSuccessJSON(map[string]interface{}{
  34243. "failed_code": -10,
  34244. "msg": res2.ErrMsg,
  34245. })
  34246. return
  34247. }
  34248. if res2.Infcode == 0 {
  34249. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  34250. if err == nil {
  34251. //当押金不为零时产生退费记录
  34252. if order.Decimal != 0 {
  34253. tmp := strconv.FormatInt(order.ID, 10)
  34254. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  34255. if err != nil {
  34256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34257. return
  34258. }
  34259. }
  34260. c.ServeSuccessJSON(map[string]interface{}{
  34261. "msg": "退费成功",
  34262. })
  34263. } else {
  34264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34265. return
  34266. }
  34267. } else {
  34268. c.ServeSuccessJSON(map[string]interface{}{
  34269. "failed_code": -10,
  34270. "msg": res2.ErrMsg,
  34271. })
  34272. }
  34273. } else {
  34274. c.ServeSuccessJSON(map[string]interface{}{
  34275. "failed_code": -10,
  34276. "msg": res.ErrMsg,
  34277. })
  34278. }
  34279. }
  34280. }
  34281. func (c *HisApiController) RefundNumber() {
  34282. record_time := c.GetString("record_time")
  34283. //patient_id, _ := c.GetInt64("patient_id")
  34284. admin_user_id, _ := c.GetInt64("admin_user_id")
  34285. his_patient_id, _ := c.GetInt64("id")
  34286. timeLayout := "2006-01-02"
  34287. loc, _ := time.LoadLocation("Local")
  34288. adminUser := c.GetAdminUserInfo()
  34289. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34290. fmt.Println(err)
  34291. if err != nil {
  34292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34293. return
  34294. }
  34295. recordDateTime := theTime.Unix()
  34296. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  34297. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  34298. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  34299. //order, _ := service.GetHisOrderByID(order_id)
  34300. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34301. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34302. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34303. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  34304. if count > 0 {
  34305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  34306. return
  34307. }
  34308. if config.IsOpen == 1 { //对接了医保,走医保流程
  34309. var res2 ResultSix
  34310. var res3 GZResultSix
  34311. var resSix10265 ResultSix10265
  34312. if miConfig.MdtrtareaAdmvs == "421300" {
  34313. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  34314. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34315. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34316. resp3, requestErr3 := http.Get(api3)
  34317. if requestErr3 != nil {
  34318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34319. return
  34320. }
  34321. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34322. if ioErr3 != nil {
  34323. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34325. return
  34326. }
  34327. var respJSON3 map[string]interface{}
  34328. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34329. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34331. return
  34332. }
  34333. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34334. userJSONBytes3, _ := json.Marshal(respJSON3)
  34335. fmt.Println("log")
  34336. fmt.Println(string(userJSONBytes3))
  34337. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34338. utils.ErrorLog("解析失败:%v", err)
  34339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34340. return
  34341. }
  34342. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34343. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  34344. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34345. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34346. resp3, requestErr3 := http.Get(api3)
  34347. if requestErr3 != nil {
  34348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34349. return
  34350. }
  34351. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34352. if ioErr3 != nil {
  34353. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34355. return
  34356. }
  34357. var respJSON3 map[string]interface{}
  34358. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34361. return
  34362. }
  34363. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34364. userJSONBytes3, _ := json.Marshal(respJSON3)
  34365. fmt.Println("log")
  34366. fmt.Println(string(userJSONBytes3))
  34367. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34368. utils.ErrorLog("解析失败:%v", err)
  34369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34370. return
  34371. }
  34372. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34373. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  34374. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34375. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34376. resp3, requestErr3 := http.Get(api3)
  34377. if requestErr3 != nil {
  34378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34379. return
  34380. }
  34381. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34382. if ioErr3 != nil {
  34383. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34385. return
  34386. }
  34387. var respJSON3 map[string]interface{}
  34388. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34389. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34391. return
  34392. }
  34393. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34394. userJSONBytes3, _ := json.Marshal(respJSON3)
  34395. fmt.Println("log")
  34396. fmt.Println(string(userJSONBytes3))
  34397. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34398. utils.ErrorLog("解析失败:%v", err)
  34399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34400. return
  34401. }
  34402. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34403. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  34404. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34405. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34406. resp3, requestErr3 := http.Get(api3)
  34407. if requestErr3 != nil {
  34408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34409. return
  34410. }
  34411. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34412. if ioErr3 != nil {
  34413. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34415. return
  34416. }
  34417. var respJSON3 map[string]interface{}
  34418. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34419. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34421. return
  34422. }
  34423. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34424. userJSONBytes3, _ := json.Marshal(respJSON3)
  34425. fmt.Println("log")
  34426. fmt.Println(string(userJSONBytes3))
  34427. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34428. utils.ErrorLog("解析失败:%v", err)
  34429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34430. return
  34431. }
  34432. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  34433. var api3 string
  34434. if miConfig.MdtrtareaAdmvs == "320830" {
  34435. api3 = miConfig.AppSecret + "jsyb/2202?psn_no=" + his.PsnNo +
  34436. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34437. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34438. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34439. } else if miConfig.MdtrtareaAdmvs == "320921" {
  34440. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  34441. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34442. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34443. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34444. } else {
  34445. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34446. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  34447. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34448. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34449. }
  34450. resp3, requestErr3 := http.Get(api3)
  34451. if requestErr3 != nil {
  34452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34453. return
  34454. }
  34455. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34456. if ioErr3 != nil {
  34457. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34459. return
  34460. }
  34461. var respJSON3 map[string]interface{}
  34462. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34463. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34465. return
  34466. }
  34467. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34468. userJSONBytes3, _ := json.Marshal(respJSON3)
  34469. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34470. utils.ErrorLog("解析失败:%v", err)
  34471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34472. return
  34473. }
  34474. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34475. res2.Output = resSix10265.Output
  34476. res2.ErrMsg = resSix10265.ErrMsg
  34477. res2.Cainfo = resSix10265.Cainfo
  34478. res2.WarnMsg = resSix10265.WarnMsg
  34479. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34480. res2.Infcode = infocode
  34481. } else if miConfig.MdtrtareaAdmvs == "150404" {
  34482. var api3 string
  34483. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  34484. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34485. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34486. resp3, requestErr3 := http.Get(api3)
  34487. if requestErr3 != nil {
  34488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34489. return
  34490. }
  34491. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34492. if ioErr3 != nil {
  34493. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34495. return
  34496. }
  34497. var respJSON3 map[string]interface{}
  34498. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34499. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34501. return
  34502. }
  34503. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34504. userJSONBytes3, _ := json.Marshal(respJSON3)
  34505. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34506. utils.ErrorLog("解析失败:%v", err)
  34507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34508. return
  34509. }
  34510. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34511. res2.Output = resSix10265.Output
  34512. res2.ErrMsg = resSix10265.ErrMsg
  34513. res2.Cainfo = resSix10265.Cainfo
  34514. res2.WarnMsg = resSix10265.WarnMsg
  34515. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34516. res2.Infcode = infocode
  34517. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34518. 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)
  34519. var dat map[string]interface{}
  34520. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34521. fmt.Println(dat)
  34522. } else {
  34523. fmt.Println(err)
  34524. }
  34525. saveLog(result, request, "2202", "退号")
  34526. userJSONBytes, _ := json.Marshal(dat)
  34527. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34528. utils.ErrorLog("解析失败:%v", err)
  34529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34530. return
  34531. }
  34532. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34533. 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, "")
  34534. var dat map[string]interface{}
  34535. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34536. fmt.Println(dat)
  34537. } else {
  34538. fmt.Println(err)
  34539. }
  34540. saveLog(result, request, "2202", "退号")
  34541. userJSONBytes, _ := json.Marshal(dat)
  34542. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34543. utils.ErrorLog("解析失败:%v", err)
  34544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34545. return
  34546. }
  34547. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34548. 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, "")
  34549. var dat map[string]interface{}
  34550. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34551. fmt.Println(dat)
  34552. } else {
  34553. fmt.Println(err)
  34554. }
  34555. saveLog(result, request, "2202", "退号")
  34556. userJSONBytes, _ := json.Marshal(dat)
  34557. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34558. utils.ErrorLog("解析失败:%v", err)
  34559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34560. return
  34561. }
  34562. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34563. 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, "")
  34564. var dat map[string]interface{}
  34565. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34566. fmt.Println(dat)
  34567. } else {
  34568. fmt.Println(err)
  34569. }
  34570. saveLog(result, request, "2202", "退号")
  34571. userJSONBytes, _ := json.Marshal(dat)
  34572. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34573. utils.ErrorLog("解析失败:%v", err)
  34574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34575. return
  34576. }
  34577. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34578. var api3 string
  34579. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  34580. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34581. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34582. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34583. resp3, requestErr3 := http.Get(api3)
  34584. if requestErr3 != nil {
  34585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34586. return
  34587. }
  34588. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34589. if ioErr3 != nil {
  34590. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34592. return
  34593. }
  34594. var respJSON3 map[string]interface{}
  34595. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34596. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34598. return
  34599. }
  34600. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34601. if status == "0" {
  34602. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34603. c.ServeSuccessJSON(map[string]interface{}{
  34604. "failed_code": -10,
  34605. "msg": err_msg,
  34606. })
  34607. return
  34608. }
  34609. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34610. userJSONBytes3, _ := json.Marshal(respJSON3)
  34611. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34612. utils.ErrorLog("解析失败:%v", err)
  34613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34614. return
  34615. }
  34616. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  34617. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34618. var api3 string
  34619. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  34620. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34621. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34622. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34623. resp3, requestErr3 := http.Get(api3)
  34624. if requestErr3 != nil {
  34625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34626. return
  34627. }
  34628. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34629. if ioErr3 != nil {
  34630. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34632. return
  34633. }
  34634. var respJSON3 map[string]interface{}
  34635. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34636. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34638. return
  34639. }
  34640. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34641. if status == "0" {
  34642. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34643. c.ServeSuccessJSON(map[string]interface{}{
  34644. "failed_code": -10,
  34645. "msg": err_msg,
  34646. })
  34647. return
  34648. }
  34649. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34650. userJSONBytes3, _ := json.Marshal(respJSON3)
  34651. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34652. utils.ErrorLog("解析失败:%v", err)
  34653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34654. return
  34655. }
  34656. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  34657. } else if miConfig.MdtrtareaAdmvs == "430800" {
  34658. 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, "")
  34659. var dat map[string]interface{}
  34660. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34661. fmt.Println(dat)
  34662. } else {
  34663. fmt.Println(err)
  34664. }
  34665. saveLog(result, request, "2202", "退号")
  34666. userJSONBytes, _ := json.Marshal(dat)
  34667. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34668. utils.ErrorLog("解析失败:%v", err)
  34669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34670. return
  34671. }
  34672. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34673. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  34674. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34675. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34676. resp3, requestErr3 := http.Get(api3)
  34677. if requestErr3 != nil {
  34678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34679. return
  34680. }
  34681. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34682. if ioErr3 != nil {
  34683. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34685. return
  34686. }
  34687. var respJSON3 map[string]interface{}
  34688. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34689. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34691. return
  34692. }
  34693. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34694. userJSONBytes3, _ := json.Marshal(respJSON3)
  34695. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34696. utils.ErrorLog("解析失败:%v", err)
  34697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34698. return
  34699. }
  34700. } else {
  34701. var api3 string
  34702. if miConfig.Code == "H15049901371" {
  34703. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  34704. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34705. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34706. } else {
  34707. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  34708. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34709. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34710. }
  34711. resp3, requestErr3 := http.Get(api3)
  34712. if requestErr3 != nil {
  34713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34714. return
  34715. }
  34716. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34717. if ioErr3 != nil {
  34718. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34720. return
  34721. }
  34722. var respJSON3 map[string]interface{}
  34723. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34724. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34726. return
  34727. }
  34728. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34729. userJSONBytes3, _ := json.Marshal(respJSON3)
  34730. if miConfig.Code == "H15049901371" {
  34731. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34732. utils.ErrorLog("解析失败:%v", err)
  34733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34734. return
  34735. }
  34736. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34737. res2.Output = resSix10265.Output
  34738. res2.ErrMsg = resSix10265.ErrMsg
  34739. res2.Cainfo = resSix10265.Cainfo
  34740. res2.WarnMsg = resSix10265.WarnMsg
  34741. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34742. res2.Infcode = infocode
  34743. } else {
  34744. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  34745. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  34746. utils.ErrorLog("解析失败:%v", err)
  34747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34748. return
  34749. }
  34750. res2.Infcode = res3.Infcode
  34751. } else {
  34752. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34753. utils.ErrorLog("解析失败:%v", err)
  34754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34755. return
  34756. }
  34757. }
  34758. }
  34759. }
  34760. if res2.Infcode == -1 {
  34761. c.ServeSuccessJSON(map[string]interface{}{
  34762. "failed_code": -10,
  34763. "msg": res2.ErrMsg,
  34764. })
  34765. return
  34766. }
  34767. if res2.Infcode == 0 {
  34768. if err == nil {
  34769. c.ServeSuccessJSON(map[string]interface{}{
  34770. "msg": "退号成功",
  34771. })
  34772. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  34773. //service.UpdataOrderStatusTen(his., recordDateTime, adminUser.CurrentOrgId)
  34774. } else {
  34775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34776. return
  34777. }
  34778. }
  34779. } else {
  34780. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  34781. //if err == nil {
  34782. // c.ServeSuccessJSON(map[string]interface{}{
  34783. // "msg": "退费成功",
  34784. // })
  34785. //} else {
  34786. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34787. // return
  34788. //}
  34789. }
  34790. }
  34791. func (c *HisApiController) RefundDetail() {
  34792. order_id, _ := c.GetInt64("order_id")
  34793. admin_user_id, _ := c.GetInt64("admin_user_id")
  34794. //his_patient_id, _ := c.GetInt64("his_patient_id")
  34795. number := c.GetString("number")
  34796. record_time := c.GetString("record_time")
  34797. patient_id, _ := c.GetInt64("patient_id")
  34798. //med_type, _ := c.GetInt64("med_type")
  34799. timeLayout := "2006-01-02"
  34800. loc, _ := time.LoadLocation("Local")
  34801. adminUser := c.GetAdminUserInfo()
  34802. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34803. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34804. fmt.Println(err)
  34805. if err != nil {
  34806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34807. return
  34808. }
  34809. recordDateTime := theTime.Unix()
  34810. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  34811. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  34812. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34813. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34814. var order models.HisOrder
  34815. order, _ = service.GetHisOrderByID(order_id)
  34816. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34817. if config.IsOpen == 1 { //对接了医保,走医保流程
  34818. var res2 ResultSix
  34819. if miConfig.MdtrtareaAdmvs == "421300" {
  34820. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  34821. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34822. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34823. resp3, requestErr3 := http.Get(api3)
  34824. if requestErr3 != nil {
  34825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34826. return
  34827. }
  34828. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34829. if ioErr3 != nil {
  34830. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34832. return
  34833. }
  34834. var respJSON3 map[string]interface{}
  34835. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34838. return
  34839. }
  34840. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34841. userJSONBytes3, _ := json.Marshal(respJSON3)
  34842. fmt.Println("log")
  34843. fmt.Println(string(userJSONBytes3))
  34844. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34845. utils.ErrorLog("解析失败:%v", err)
  34846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34847. return
  34848. }
  34849. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34850. if err == nil {
  34851. c.ServeSuccessJSON(map[string]interface{}{
  34852. "msg": "撤销明细成功",
  34853. })
  34854. return
  34855. } else {
  34856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34857. return
  34858. }
  34859. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34860. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  34861. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34862. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34863. resp3, requestErr3 := http.Get(api3)
  34864. if requestErr3 != nil {
  34865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34866. return
  34867. }
  34868. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34869. if ioErr3 != nil {
  34870. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34872. return
  34873. }
  34874. var respJSON3 map[string]interface{}
  34875. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34876. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34878. return
  34879. }
  34880. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34881. userJSONBytes3, _ := json.Marshal(respJSON3)
  34882. fmt.Println("log")
  34883. fmt.Println(string(userJSONBytes3))
  34884. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34885. utils.ErrorLog("解析失败:%v", err)
  34886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34887. return
  34888. }
  34889. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34890. if err == nil {
  34891. c.ServeSuccessJSON(map[string]interface{}{
  34892. "msg": "撤销明细成功",
  34893. })
  34894. return
  34895. } else {
  34896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34897. return
  34898. }
  34899. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34900. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  34901. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34902. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34903. resp3, requestErr3 := http.Get(api3)
  34904. if requestErr3 != nil {
  34905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34906. return
  34907. }
  34908. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34909. if ioErr3 != nil {
  34910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34912. return
  34913. }
  34914. var respJSON3 map[string]interface{}
  34915. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34918. return
  34919. }
  34920. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34921. userJSONBytes3, _ := json.Marshal(respJSON3)
  34922. fmt.Println("log")
  34923. fmt.Println(string(userJSONBytes3))
  34924. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34925. utils.ErrorLog("解析失败:%v", err)
  34926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34927. return
  34928. }
  34929. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34930. if err == nil {
  34931. c.ServeSuccessJSON(map[string]interface{}{
  34932. "msg": "撤销明细成功",
  34933. })
  34934. return
  34935. } else {
  34936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34937. return
  34938. }
  34939. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34940. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  34941. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34942. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34943. resp3, requestErr3 := http.Get(api3)
  34944. if requestErr3 != nil {
  34945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34946. return
  34947. }
  34948. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34949. if ioErr3 != nil {
  34950. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34952. return
  34953. }
  34954. var respJSON3 map[string]interface{}
  34955. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34956. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34958. return
  34959. }
  34960. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34961. userJSONBytes3, _ := json.Marshal(respJSON3)
  34962. fmt.Println("log")
  34963. fmt.Println(string(userJSONBytes3))
  34964. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34965. utils.ErrorLog("解析失败:%v", err)
  34966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34967. return
  34968. }
  34969. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34970. if err == nil {
  34971. c.ServeSuccessJSON(map[string]interface{}{
  34972. "msg": "撤销明细成功",
  34973. })
  34974. return
  34975. } else {
  34976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34977. return
  34978. }
  34979. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  34980. var resSix10265 ResultSix10265
  34981. var api3 string
  34982. if miConfig.MdtrtareaAdmvs == "320830" {
  34983. api3 = miConfig.AppSecret + "jsyb/2205?psn_no=" + order.PsnNo +
  34984. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + "0000" + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34985. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34986. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34987. } else if miConfig.MdtrtareaAdmvs == "320921" {
  34988. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  34989. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34990. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34991. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34992. } else {
  34993. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34994. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  34995. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34996. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34997. }
  34998. resp3, requestErr3 := http.Get(api3)
  34999. utils.ErrorLog("接口: %v", requestErr3)
  35000. if requestErr3 != nil {
  35001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35002. return
  35003. }
  35004. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  35005. if ioErr3 != nil {
  35006. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  35007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35008. return
  35009. }
  35010. var respJSON3 map[string]interface{}
  35011. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  35012. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35014. return
  35015. }
  35016. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35017. userJSONBytes3, _ := json.Marshal(respJSON3)
  35018. fmt.Println("log")
  35019. fmt.Println(string(userJSONBytes3))
  35020. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  35021. utils.ErrorLog("解析失败:%v", err)
  35022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35023. return
  35024. }
  35025. res2.InfRefmsgid = resSix10265.InfRefmsgid
  35026. res2.Output = resSix10265.Output
  35027. res2.ErrMsg = resSix10265.ErrMsg
  35028. res2.Cainfo = resSix10265.Cainfo
  35029. res2.WarnMsg = resSix10265.WarnMsg
  35030. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35031. res2.Infcode = infocode
  35032. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35033. if err == nil {
  35034. c.ServeSuccessJSON(map[string]interface{}{
  35035. "msg": "撤销明细成功",
  35036. })
  35037. return
  35038. } else {
  35039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35040. return
  35041. }
  35042. } else if miConfig.MdtrtareaAdmvs == "341203" {
  35043. var api3 string
  35044. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  35045. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35046. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35047. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35048. resp3, requestErr3 := http.Get(api3)
  35049. utils.ErrorLog("接口: %v", requestErr3)
  35050. if requestErr3 != nil {
  35051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35052. return
  35053. }
  35054. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  35055. if ioErr3 != nil {
  35056. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  35057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35058. return
  35059. }
  35060. var respJSON3 map[string]interface{}
  35061. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  35062. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35064. return
  35065. }
  35066. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  35067. if status == "0" {
  35068. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  35069. c.ServeSuccessJSON(map[string]interface{}{
  35070. "failed_code": -10,
  35071. "msg": err_msg,
  35072. })
  35073. return
  35074. }
  35075. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35076. userJSONBytes3, _ := json.Marshal(respJSON3)
  35077. fmt.Println("log")
  35078. fmt.Println(string(userJSONBytes3))
  35079. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  35080. utils.ErrorLog("解析失败:%v", err)
  35081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35082. return
  35083. }
  35084. fmt.Println(res2.Infcode)
  35085. if res2.Infcode == -1 {
  35086. c.ServeSuccessJSON(map[string]interface{}{
  35087. "failed_code": -10,
  35088. "msg": res2.ErrMsg,
  35089. })
  35090. return
  35091. }
  35092. if res2.Infcode == 0 {
  35093. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35094. if err == nil {
  35095. c.ServeSuccessJSON(map[string]interface{}{
  35096. "msg": "撤销明细成功",
  35097. })
  35098. return
  35099. } else {
  35100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35101. return
  35102. }
  35103. } else {
  35104. c.ServeSuccessJSON(map[string]interface{}{
  35105. "failed_code": -10,
  35106. "msg": res2.ErrMsg,
  35107. })
  35108. }
  35109. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35110. if err == nil {
  35111. c.ServeSuccessJSON(map[string]interface{}{
  35112. "msg": "撤销明细成功",
  35113. })
  35114. return
  35115. } else {
  35116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35117. return
  35118. }
  35119. } else if miConfig.MdtrtareaAdmvs == "340699" {
  35120. var api3 string
  35121. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  35122. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35123. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35124. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35125. resp3, requestErr3 := http.Get(api3)
  35126. utils.ErrorLog("接口: %v", requestErr3)
  35127. if requestErr3 != nil {
  35128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35129. return
  35130. }
  35131. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  35132. if ioErr3 != nil {
  35133. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  35134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35135. return
  35136. }
  35137. var respJSON3 map[string]interface{}
  35138. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  35139. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35141. return
  35142. }
  35143. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  35144. if status == "0" {
  35145. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  35146. c.ServeSuccessJSON(map[string]interface{}{
  35147. "failed_code": -10,
  35148. "msg": err_msg,
  35149. })
  35150. return
  35151. }
  35152. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35153. userJSONBytes3, _ := json.Marshal(respJSON3)
  35154. fmt.Println("log")
  35155. fmt.Println(string(userJSONBytes3))
  35156. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  35157. utils.ErrorLog("解析失败:%v", err)
  35158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35159. return
  35160. }
  35161. fmt.Println(res2.Infcode)
  35162. if res2.Infcode == -1 {
  35163. c.ServeSuccessJSON(map[string]interface{}{
  35164. "failed_code": -10,
  35165. "msg": res2.ErrMsg,
  35166. })
  35167. return
  35168. }
  35169. if res2.Infcode == 0 {
  35170. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35171. if err == nil {
  35172. c.ServeSuccessJSON(map[string]interface{}{
  35173. "msg": "撤销明细成功",
  35174. })
  35175. return
  35176. } else {
  35177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35178. return
  35179. }
  35180. } else {
  35181. c.ServeSuccessJSON(map[string]interface{}{
  35182. "failed_code": -10,
  35183. "msg": res2.ErrMsg,
  35184. })
  35185. }
  35186. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35187. if err == nil {
  35188. c.ServeSuccessJSON(map[string]interface{}{
  35189. "msg": "撤销明细成功",
  35190. })
  35191. return
  35192. } else {
  35193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35194. return
  35195. }
  35196. } else if miConfig.MdtrtareaAdmvs == "150404" {
  35197. var resSix10265 ResultSix10265
  35198. new_chrg_bchno := order.Number
  35199. if adminUser.CurrentOrgId == 10265 {
  35200. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  35201. new_chrg_bchno = "0000"
  35202. }
  35203. }
  35204. var api3 string
  35205. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  35206. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35207. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35208. resp3, requestErr3 := http.Get(api3)
  35209. if requestErr3 != nil {
  35210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35211. return
  35212. }
  35213. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  35214. if ioErr3 != nil {
  35215. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  35216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35217. return
  35218. }
  35219. var respJSON3 map[string]interface{}
  35220. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  35221. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35223. return
  35224. }
  35225. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35226. userJSONBytes3, _ := json.Marshal(respJSON3)
  35227. fmt.Println("log")
  35228. fmt.Println(string(userJSONBytes3))
  35229. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  35230. utils.ErrorLog("解析失败:%v", err)
  35231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35232. return
  35233. }
  35234. res2.InfRefmsgid = resSix10265.InfRefmsgid
  35235. res2.Output = resSix10265.Output
  35236. res2.ErrMsg = resSix10265.ErrMsg
  35237. res2.Cainfo = resSix10265.Cainfo
  35238. res2.WarnMsg = resSix10265.WarnMsg
  35239. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35240. res2.Infcode = infocode
  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 if miConfig.MdtrtareaAdmvs == "350500" {
  35252. 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)
  35253. var dat map[string]interface{}
  35254. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35255. fmt.Println(dat)
  35256. } else {
  35257. fmt.Println(err)
  35258. }
  35259. saveLog(result2, src_request, "2205", "撤销明细")
  35260. userJSONBytes, _ := json.Marshal(dat)
  35261. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35262. utils.ErrorLog("解析失败:%v", err)
  35263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35264. return
  35265. }
  35266. if res2.Infcode == 0 {
  35267. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35268. if err == nil {
  35269. c.ServeSuccessJSON(map[string]interface{}{
  35270. "msg": "撤销明细成功",
  35271. })
  35272. return
  35273. } else {
  35274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35275. return
  35276. }
  35277. } else {
  35278. c.ServeSuccessJSON(map[string]interface{}{
  35279. "failed_code": -10,
  35280. "msg": res2.ErrMsg,
  35281. })
  35282. }
  35283. } else if miConfig.MdtrtareaAdmvs == "360302" {
  35284. 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, "")
  35285. var dat map[string]interface{}
  35286. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35287. fmt.Println(dat)
  35288. } else {
  35289. fmt.Println(err)
  35290. }
  35291. saveLog(result2, src_request, "2205", "撤销明细")
  35292. userJSONBytes, _ := json.Marshal(dat)
  35293. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35294. utils.ErrorLog("解析失败:%v", err)
  35295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35296. return
  35297. }
  35298. if res2.Infcode == 0 {
  35299. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35300. if err == nil {
  35301. c.ServeSuccessJSON(map[string]interface{}{
  35302. "msg": "撤销明细成功",
  35303. })
  35304. return
  35305. } else {
  35306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35307. return
  35308. }
  35309. } else {
  35310. c.ServeSuccessJSON(map[string]interface{}{
  35311. "failed_code": -10,
  35312. "msg": res2.ErrMsg,
  35313. })
  35314. }
  35315. } else if miConfig.MdtrtareaAdmvs == "361025" {
  35316. 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, "")
  35317. var dat map[string]interface{}
  35318. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35319. fmt.Println(dat)
  35320. } else {
  35321. fmt.Println(err)
  35322. }
  35323. saveLog(result2, src_request, "2205", "撤销明细")
  35324. userJSONBytes, _ := json.Marshal(dat)
  35325. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35326. utils.ErrorLog("解析失败:%v", err)
  35327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35328. return
  35329. }
  35330. if res2.Infcode == 0 {
  35331. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35332. if err == nil {
  35333. c.ServeSuccessJSON(map[string]interface{}{
  35334. "msg": "撤销明细成功",
  35335. })
  35336. return
  35337. } else {
  35338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35339. return
  35340. }
  35341. } else {
  35342. c.ServeSuccessJSON(map[string]interface{}{
  35343. "failed_code": -10,
  35344. "msg": res2.ErrMsg,
  35345. })
  35346. }
  35347. } else if miConfig.MdtrtareaAdmvs == "360100" {
  35348. 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, "")
  35349. var dat map[string]interface{}
  35350. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35351. fmt.Println(dat)
  35352. } else {
  35353. fmt.Println(err)
  35354. }
  35355. saveLog(result2, src_request, "2205", "撤销明细")
  35356. userJSONBytes, _ := json.Marshal(dat)
  35357. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35358. utils.ErrorLog("解析失败:%v", err)
  35359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35360. return
  35361. }
  35362. if res2.Infcode == 0 {
  35363. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35364. if err == nil {
  35365. c.ServeSuccessJSON(map[string]interface{}{
  35366. "msg": "撤销明细成功",
  35367. })
  35368. return
  35369. } else {
  35370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35371. return
  35372. }
  35373. } else {
  35374. c.ServeSuccessJSON(map[string]interface{}{
  35375. "failed_code": -10,
  35376. "msg": res2.ErrMsg,
  35377. })
  35378. }
  35379. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35380. 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, "")
  35381. var dat map[string]interface{}
  35382. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35383. fmt.Println(dat)
  35384. } else {
  35385. fmt.Println(err)
  35386. }
  35387. saveLog(result2, src_request, "2205", "撤销明细")
  35388. userJSONBytes, _ := json.Marshal(dat)
  35389. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35390. utils.ErrorLog("解析失败:%v", err)
  35391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35392. return
  35393. }
  35394. if res2.Infcode == 0 {
  35395. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35396. if err == nil {
  35397. c.ServeSuccessJSON(map[string]interface{}{
  35398. "msg": "撤销明细成功",
  35399. })
  35400. return
  35401. } else {
  35402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35403. return
  35404. }
  35405. } else {
  35406. c.ServeSuccessJSON(map[string]interface{}{
  35407. "failed_code": -10,
  35408. "msg": res2.ErrMsg,
  35409. })
  35410. }
  35411. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35412. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  35413. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35414. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35415. resp2, requestErr2 := http.Get(api2)
  35416. if requestErr2 != nil {
  35417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35418. return
  35419. }
  35420. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35421. if ioErr2 != nil {
  35422. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35424. return
  35425. }
  35426. var respJSON2 map[string]interface{}
  35427. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35428. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35430. return
  35431. }
  35432. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35433. userJSONBytes3, _ := json.Marshal(respJSON2)
  35434. fmt.Println("log")
  35435. fmt.Println(string(userJSONBytes3))
  35436. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  35437. utils.ErrorLog("解析失败:%v", err)
  35438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35439. return
  35440. }
  35441. if res2.Infcode == 0 {
  35442. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35443. if err == nil {
  35444. c.ServeSuccessJSON(map[string]interface{}{
  35445. "msg": "撤销明细成功",
  35446. })
  35447. return
  35448. } else {
  35449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35450. return
  35451. }
  35452. } else {
  35453. c.ServeSuccessJSON(map[string]interface{}{
  35454. "failed_code": -10,
  35455. "msg": res2.ErrMsg,
  35456. })
  35457. }
  35458. } else {
  35459. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  35460. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35461. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  35462. resp2, requestErr2 := http.Get(api2)
  35463. if requestErr2 != nil {
  35464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35465. return
  35466. }
  35467. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35468. if ioErr2 != nil {
  35469. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35471. return
  35472. }
  35473. var respJSON2 map[string]interface{}
  35474. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35475. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35477. return
  35478. }
  35479. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35480. userJSONBytes3, _ := json.Marshal(respJSON2)
  35481. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  35482. utils.ErrorLog("解析失败:%v", err)
  35483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35484. return
  35485. }
  35486. if res2.Infcode == -1 {
  35487. c.ServeSuccessJSON(map[string]interface{}{
  35488. "failed_code": -10,
  35489. "msg": res2.ErrMsg,
  35490. })
  35491. return
  35492. } else {
  35493. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35494. if err == nil {
  35495. c.ServeSuccessJSON(map[string]interface{}{
  35496. "msg": "撤销明细成功",
  35497. })
  35498. return
  35499. } else {
  35500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35501. return
  35502. }
  35503. }
  35504. }
  35505. } else {
  35506. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35507. if err == nil {
  35508. c.ServeSuccessJSON(map[string]interface{}{
  35509. "msg": "退费成功",
  35510. })
  35511. } else {
  35512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35513. return
  35514. }
  35515. }
  35516. }
  35517. // 对账
  35518. func (c *HisApiController) GetCheckAccount() {
  35519. start_time := c.GetString("start_time")
  35520. end_time := c.GetString("end_time")
  35521. insutype := c.GetString("insutype")
  35522. clr_type := c.GetString("clr_type")
  35523. clr_org := c.GetString("clr_optins")
  35524. admin_user_id, _ := c.GetInt64("admin_user_id")
  35525. adminUser := c.GetAdminUserInfo()
  35526. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35527. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35528. if len(clr_org) == 0 {
  35529. clr_org = miConfig.InsuplcAdmdvs
  35530. }
  35531. timeLayout := "2006-01-02"
  35532. loc, _ := time.LoadLocation("Local")
  35533. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  35534. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  35535. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35536. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35537. fixmedins_setl_cnt := int64(len(orders))
  35538. var medfee_sumamt float64
  35539. var acct_pay float64
  35540. var fund_pay_sumamt float64
  35541. for _, item := range orders {
  35542. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35543. acct_pay = acct_pay + item.AcctPay
  35544. if miConfig.MdtrtareaAdmvs == "361025" || miConfig.MdtrtareaAdmvs == "360100" {
  35545. fund_pay_sumamt = fund_pay_sumamt + item.HifpPay + item.HifmiPay + item.MafPay + item.HifobPay + item.HifesPay
  35546. } else {
  35547. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35548. }
  35549. }
  35550. var user_name string
  35551. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35552. if role.ID == 0 {
  35553. user_name = "xxx"
  35554. } else {
  35555. user_name = role.UserName
  35556. }
  35557. var res ResultEight
  35558. var res10188 ResultEightFor10188
  35559. if config.IsOpen == 1 {
  35560. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  35561. api := miConfig.AppSecret + "jsyb/3201?" +
  35562. "insutype=" + insutype +
  35563. "&clr_type=" + clr_type +
  35564. "&setl_optins=" + clr_org +
  35565. "&stmt_begndate=" + start_time +
  35566. "&stm_enddate=" + end_time +
  35567. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35568. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35569. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35570. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35571. "&fixmedins_code=" + miConfig.Code +
  35572. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35573. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35574. "&secret_key=" + miConfig.SecretKey +
  35575. "&org_name=" + miConfig.OrgName +
  35576. "&doctor=" + user_name +
  35577. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35578. fmt.Println(api)
  35579. resp, requestErr := http.Get(api)
  35580. if requestErr != nil {
  35581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35582. return
  35583. }
  35584. body, ioErr := ioutil.ReadAll(resp.Body)
  35585. fmt.Println(body)
  35586. if ioErr != nil {
  35587. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35589. return
  35590. }
  35591. var respJSON map[string]interface{}
  35592. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35593. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35595. return
  35596. }
  35597. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35598. userJSONBytes, _ := json.Marshal(respJSON)
  35599. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35600. utils.ErrorLog("解析失败:%v", err)
  35601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35602. return
  35603. }
  35604. res.InfRefmsgid = res10188.InfRefmsgid
  35605. res.Output = res10188.Output
  35606. res.ErrMsg = res10188.ErrMsg
  35607. res.Cainfo = res10188.Cainfo
  35608. res.WarnMsg = res10188.WarnMsg
  35609. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  35610. res.Infcode = infocode
  35611. } else if miConfig.MdtrtareaAdmvs == "150404" {
  35612. if clr_type != "9903" {
  35613. clr_type = "99" // 就诊 ID(来自2201接口返回)
  35614. }
  35615. if clr_type == "9903" {
  35616. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  35617. }
  35618. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  35619. "insutype=" + insutype +
  35620. "&clr_type=" + clr_type +
  35621. "&setl_optins=" + clr_org +
  35622. "&stmt_begndate=" + start_time +
  35623. "&stm_enddate=" + end_time +
  35624. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35625. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35626. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35627. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35628. "&fixmedins_code=" + miConfig.Code +
  35629. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35630. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35631. "&secret_key=" + miConfig.SecretKey +
  35632. "&org_name=" + miConfig.OrgName +
  35633. "&doctor=" + user_name
  35634. resp, requestErr := http.Get(api)
  35635. if requestErr != nil {
  35636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35637. return
  35638. }
  35639. body, ioErr := ioutil.ReadAll(resp.Body)
  35640. if ioErr != nil {
  35641. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35643. return
  35644. }
  35645. var respJSON map[string]interface{}
  35646. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35647. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35649. return
  35650. }
  35651. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35652. result, _ := json.Marshal(respJSON)
  35653. fmt.Println("log")
  35654. fmt.Println(string(result))
  35655. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  35656. utils.ErrorLog("解析失败:%v", err)
  35657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35658. return
  35659. }
  35660. res.InfRefmsgid = res10188.InfRefmsgid
  35661. res.Output = res10188.Output
  35662. res.ErrMsg = res10188.ErrMsg
  35663. res.Cainfo = res10188.Cainfo
  35664. res.WarnMsg = res10188.WarnMsg
  35665. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  35666. res.Infcode = infocode
  35667. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35668. var baseParams models.BaseParams
  35669. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35670. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35671. baseParams.SecretKey = miConfig.SecretKey
  35672. baseParams.OrgName = miConfig.OrgName
  35673. baseParams.FixmedinsCode = miConfig.Code
  35674. baseParams.EncKey = miConfig.EncKey
  35675. baseParams.AppSecret = miConfig.AppSecret
  35676. baseParams.SignKey = miConfig.SignKey
  35677. baseParams.AppID = miConfig.Code
  35678. baseParams.Doctor = role.UserName
  35679. baseParams.RequestUrl = miConfig.Url
  35680. businessParams := models.BusinessParams{
  35681. Insutype: insutype,
  35682. ClrType: clr_type,
  35683. SetlOptins: clr_org,
  35684. StmtBegndate: start_time,
  35685. StmtEnddate: end_time,
  35686. MedfeeSumamt: medfee_sumamt,
  35687. FundPaySumamt: fund_pay_sumamt,
  35688. AcctPay: acct_pay,
  35689. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35690. }
  35691. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  35692. fmt.Println(requestLog)
  35693. fmt.Println(result)
  35694. fmt.Println(err_msg)
  35695. var dat map[string]interface{}
  35696. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35697. fmt.Println(dat)
  35698. } else {
  35699. fmt.Println(err)
  35700. }
  35701. userJSONBytes, _ := json.Marshal(dat)
  35702. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35703. utils.ErrorLog("解析失败:%v", err)
  35704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35705. return
  35706. }
  35707. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35708. var baseParams models.BaseParams
  35709. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35710. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35711. baseParams.SecretKey = miConfig.SecretKey
  35712. baseParams.OrgName = miConfig.OrgName
  35713. baseParams.FixmedinsCode = miConfig.Code
  35714. baseParams.EncKey = miConfig.EncKey
  35715. baseParams.AppSecret = miConfig.AppSecret
  35716. baseParams.SignKey = miConfig.SignKey
  35717. baseParams.AppID = miConfig.Code
  35718. baseParams.Doctor = role.UserName
  35719. baseParams.RequestUrl = miConfig.Url
  35720. baseParams.AccessKey = miConfig.AccessKey
  35721. businessParams := models.BusinessParams{
  35722. Insutype: insutype,
  35723. ClrType: clr_type,
  35724. SetlOptins: "430822",
  35725. StmtBegndate: start_time,
  35726. StmtEnddate: end_time,
  35727. MedfeeSumamt: medfee_sumamt,
  35728. FundPaySumamt: fund_pay_sumamt,
  35729. AcctPay: acct_pay,
  35730. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35731. }
  35732. 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)
  35733. fmt.Println(requestLog)
  35734. fmt.Println(result)
  35735. var dat map[string]interface{}
  35736. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35737. fmt.Println(dat)
  35738. } else {
  35739. fmt.Println(err)
  35740. }
  35741. userJSONBytes, _ := json.Marshal(dat)
  35742. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35743. utils.ErrorLog("解析失败:%v", err)
  35744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35745. return
  35746. }
  35747. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35748. var baseParams models.BaseParams
  35749. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35750. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35751. baseParams.SecretKey = miConfig.SecretKey
  35752. baseParams.OrgName = miConfig.OrgName
  35753. baseParams.FixmedinsCode = miConfig.Code
  35754. baseParams.EncKey = miConfig.EncKey
  35755. baseParams.AppSecret = miConfig.AppSecret
  35756. baseParams.SignKey = miConfig.SignKey
  35757. baseParams.AppID = miConfig.Code
  35758. baseParams.Doctor = role.UserName
  35759. baseParams.RequestUrl = miConfig.Url
  35760. businessParams := models.BusinessParams{
  35761. Insutype: insutype,
  35762. ClrType: clr_type,
  35763. SetlOptins: clr_org,
  35764. StmtBegndate: start_time,
  35765. StmtEnddate: end_time,
  35766. MedfeeSumamt: medfee_sumamt,
  35767. FundPaySumamt: fund_pay_sumamt,
  35768. AcctPay: acct_pay,
  35769. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35770. }
  35771. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  35772. fmt.Println(requestLog)
  35773. fmt.Println(result)
  35774. fmt.Println(err_msg)
  35775. var dat map[string]interface{}
  35776. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35777. fmt.Println(dat)
  35778. } else {
  35779. fmt.Println(err)
  35780. }
  35781. userJSONBytes, _ := json.Marshal(dat)
  35782. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35783. utils.ErrorLog("解析失败:%v", err)
  35784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35785. return
  35786. }
  35787. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35788. if len(clr_type) == 0 {
  35789. clr_type = "11"
  35790. }
  35791. api := miConfig.Url + "gdyb/ten?" +
  35792. "insutype=" + insutype +
  35793. "&clr_type=" + clr_type +
  35794. "&setl_optins=" + clr_org +
  35795. "&stmt_begndate=" + start_time +
  35796. "&stm_enddate=" + end_time +
  35797. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35798. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35799. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35800. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  35801. "&fixmedins_code=" + miConfig.Code +
  35802. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35803. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35804. "&secret_key=" + miConfig.SecretKey +
  35805. "&org_name=" + miConfig.OrgName +
  35806. "&doctor=" + user_name
  35807. fmt.Println(api)
  35808. resp, requestErr := http.Get(api)
  35809. if requestErr != nil {
  35810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35811. return
  35812. }
  35813. body, ioErr := ioutil.ReadAll(resp.Body)
  35814. fmt.Println(body)
  35815. if ioErr != nil {
  35816. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35818. return
  35819. }
  35820. var respJSON map[string]interface{}
  35821. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35822. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35824. return
  35825. }
  35826. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35827. userJSONBytes, _ := json.Marshal(respJSON)
  35828. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35829. utils.ErrorLog("解析失败:%v", err)
  35830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35831. return
  35832. }
  35833. } else if miConfig.MdtrtareaAdmvs == "360100" {
  35834. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35835. //fixmedins_setl_cnt := int64(len(orders_two))
  35836. //var medfee_sumamt float64
  35837. //var acct_pay float64
  35838. //var fund_pay_sumamt float64
  35839. //for _, item := range orders_two {
  35840. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35841. // acct_pay = acct_pay + item.AcctPay
  35842. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35843. //}
  35844. var baseParams models.BaseParams
  35845. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35846. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35847. baseParams.SecretKey = miConfig.SecretKey
  35848. baseParams.OrgName = miConfig.OrgName
  35849. baseParams.FixmedinsCode = miConfig.Code
  35850. baseParams.EncKey = miConfig.EncKey
  35851. baseParams.AppSecret = miConfig.AppSecret
  35852. baseParams.SignKey = miConfig.SignKey
  35853. baseParams.AppID = miConfig.Code
  35854. baseParams.Doctor = role.UserName
  35855. baseParams.RequestUrl = miConfig.Url
  35856. businessParams := models.BusinessParams{
  35857. Insutype: insutype,
  35858. ClrType: clr_type,
  35859. SetlOptins: "360102",
  35860. StmtBegndate: start_time,
  35861. StmtEnddate: end_time,
  35862. MedfeeSumamt: 0,
  35863. FundPaySumamt: 0,
  35864. AcctPay: 0,
  35865. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35866. }
  35867. 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))
  35868. fmt.Println(requestLog)
  35869. fmt.Println(result)
  35870. var dat map[string]interface{}
  35871. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35872. fmt.Println(dat)
  35873. } else {
  35874. fmt.Println(err)
  35875. }
  35876. userJSONBytes, _ := json.Marshal(dat)
  35877. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35878. utils.ErrorLog("解析失败:%v", err)
  35879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35880. return
  35881. }
  35882. } else if miConfig.MdtrtareaAdmvs == "361025" {
  35883. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35884. //fixmedins_setl_cnt := int64(len(orders_two))
  35885. //var medfee_sumamt float64
  35886. //var acct_pay float64
  35887. //var fund_pay_sumamt float64
  35888. //for _, item := range orders_two {
  35889. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35890. // acct_pay = acct_pay + item.AcctPay
  35891. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35892. //}
  35893. var baseParams models.BaseParams
  35894. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35895. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35896. baseParams.SecretKey = miConfig.SecretKey
  35897. baseParams.OrgName = miConfig.OrgName
  35898. baseParams.FixmedinsCode = miConfig.Code
  35899. baseParams.EncKey = miConfig.EncKey
  35900. baseParams.AppSecret = miConfig.AppSecret
  35901. baseParams.SignKey = miConfig.SignKey
  35902. baseParams.AppID = miConfig.Code
  35903. baseParams.Doctor = role.UserName
  35904. baseParams.RequestUrl = miConfig.Url
  35905. if clr_type == "9903" {
  35906. clr_type = "9994"
  35907. }
  35908. businessParams := models.BusinessParams{
  35909. Insutype: insutype,
  35910. ClrType: clr_type,
  35911. SetlOptins: "361025",
  35912. StmtBegndate: start_time,
  35913. StmtEnddate: end_time,
  35914. MedfeeSumamt: 0,
  35915. FundPaySumamt: 0,
  35916. AcctPay: 0,
  35917. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35918. }
  35919. 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))
  35920. fmt.Println(requestLog)
  35921. fmt.Println(result)
  35922. var dat map[string]interface{}
  35923. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35924. fmt.Println(dat)
  35925. } else {
  35926. fmt.Println(err)
  35927. }
  35928. userJSONBytes, _ := json.Marshal(dat)
  35929. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35930. utils.ErrorLog("解析失败:%v", err)
  35931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35932. return
  35933. }
  35934. } else if miConfig.MdtrtareaAdmvs == "360106" {
  35935. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35936. //fixmedins_setl_cnt := int64(len(orders_two))
  35937. //var medfee_sumamt float64
  35938. //var acct_pay float64
  35939. //var fund_pay_sumamt float64
  35940. //for _, item := range orders_two {
  35941. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35942. // acct_pay = acct_pay + item.AcctPay
  35943. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35944. //}
  35945. var baseParams models.BaseParams
  35946. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35947. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35948. baseParams.SecretKey = miConfig.SecretKey
  35949. baseParams.OrgName = miConfig.OrgName
  35950. baseParams.FixmedinsCode = miConfig.Code
  35951. baseParams.EncKey = miConfig.EncKey
  35952. baseParams.AppSecret = miConfig.AppSecret
  35953. baseParams.SignKey = miConfig.SignKey
  35954. baseParams.AppID = miConfig.Code
  35955. baseParams.Doctor = role.UserName
  35956. baseParams.RequestUrl = miConfig.Url
  35957. if clr_type == "9903" {
  35958. clr_type = "9994"
  35959. }
  35960. businessParams := models.BusinessParams{
  35961. Insutype: insutype,
  35962. ClrType: clr_type,
  35963. SetlOptins: "360102",
  35964. StmtBegndate: start_time,
  35965. StmtEnddate: end_time,
  35966. MedfeeSumamt: 0,
  35967. FundPaySumamt: 0,
  35968. AcctPay: 0,
  35969. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35970. }
  35971. 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))
  35972. fmt.Println(requestLog)
  35973. fmt.Println(result)
  35974. var dat map[string]interface{}
  35975. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35976. fmt.Println(dat)
  35977. } else {
  35978. fmt.Println(err)
  35979. }
  35980. userJSONBytes, _ := json.Marshal(dat)
  35981. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35982. utils.ErrorLog("解析失败:%v", err)
  35983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35984. return
  35985. }
  35986. } else if miConfig.MdtrtareaAdmvs == "341203" {
  35987. var api string
  35988. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  35989. "&clr_type=" + clr_type +
  35990. "&setl_optins=" + clr_org +
  35991. "&stmt_begndate=" + start_time +
  35992. "&stm_enddate=" + end_time +
  35993. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35994. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35995. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35996. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35997. "&fixmedins_code=" + miConfig.Code +
  35998. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35999. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  36000. "&secret_key=" + miConfig.SecretKey +
  36001. "&org_name=" + miConfig.OrgName +
  36002. "&doctor=" + user_name + "&url=" + miConfig.Url
  36003. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36004. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36005. resp, requestErr := http.Get(api)
  36006. if requestErr != nil {
  36007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36008. return
  36009. }
  36010. body, ioErr := ioutil.ReadAll(resp.Body)
  36011. if ioErr != nil {
  36012. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36014. return
  36015. }
  36016. var respJSON map[string]interface{}
  36017. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36018. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36020. return
  36021. }
  36022. status := respJSON["data"].(map[string]interface{})["status"].(string)
  36023. if status == "0" {
  36024. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  36025. c.ServeSuccessJSON(map[string]interface{}{
  36026. "failed_code": -10,
  36027. "msg": err_msg,
  36028. })
  36029. return
  36030. }
  36031. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36032. userJSONBytes, _ := json.Marshal(respJSON)
  36033. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36034. utils.ErrorLog("解析失败:%v", err)
  36035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36036. return
  36037. }
  36038. } else if miConfig.MdtrtareaAdmvs == "340699" {
  36039. var api string
  36040. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  36041. "&clr_type=" + clr_type +
  36042. "&setl_optins=" + clr_org +
  36043. "&stmt_begndate=" + start_time +
  36044. "&stm_enddate=" + end_time +
  36045. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  36046. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  36047. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  36048. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  36049. "&fixmedins_code=" + miConfig.Code +
  36050. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  36051. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  36052. "&secret_key=" + miConfig.SecretKey +
  36053. "&org_name=" + miConfig.OrgName +
  36054. "&doctor=" + user_name + "&url=" + miConfig.Url
  36055. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36056. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36057. resp, requestErr := http.Get(api)
  36058. if requestErr != nil {
  36059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36060. return
  36061. }
  36062. body, ioErr := ioutil.ReadAll(resp.Body)
  36063. if ioErr != nil {
  36064. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36066. return
  36067. }
  36068. var respJSON map[string]interface{}
  36069. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36070. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36072. return
  36073. }
  36074. status := respJSON["data"].(map[string]interface{})["status"].(string)
  36075. if status == "0" {
  36076. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  36077. c.ServeSuccessJSON(map[string]interface{}{
  36078. "failed_code": -10,
  36079. "msg": err_msg,
  36080. })
  36081. return
  36082. }
  36083. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36084. userJSONBytes, _ := json.Marshal(respJSON)
  36085. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36086. utils.ErrorLog("解析失败:%v", err)
  36087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36088. return
  36089. }
  36090. } else {
  36091. if len(clr_type) == 0 {
  36092. clr_type = "11"
  36093. }
  36094. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  36095. "insutype=" + insutype +
  36096. "&clr_type=" + clr_type +
  36097. "&setl_optins=" + clr_org +
  36098. "&stmt_begndate=" + start_time +
  36099. "&stm_enddate=" + end_time +
  36100. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  36101. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  36102. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  36103. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  36104. "&fixmedins_code=" + miConfig.Code +
  36105. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  36106. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  36107. "&secret_key=" + miConfig.SecretKey +
  36108. "&org_name=" + miConfig.OrgName +
  36109. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  36110. fmt.Println(api)
  36111. resp, requestErr := http.Get(api)
  36112. if requestErr != nil {
  36113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36114. return
  36115. }
  36116. body, ioErr := ioutil.ReadAll(resp.Body)
  36117. fmt.Println(body)
  36118. if ioErr != nil {
  36119. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36121. return
  36122. }
  36123. var respJSON map[string]interface{}
  36124. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36127. return
  36128. }
  36129. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36130. userJSONBytes, _ := json.Marshal(respJSON)
  36131. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36132. utils.ErrorLog("解析失败:%v", err)
  36133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36134. return
  36135. }
  36136. }
  36137. if res.Infcode == 0 {
  36138. if res.Output.Stmtinfo.StmtRslt == "0" {
  36139. micc := &models.MedicalInsuranceCostCompare{
  36140. StartTime: startime.Unix(),
  36141. EndTime: endtime.Unix(),
  36142. Insutype: insutype,
  36143. CheckType: 1,
  36144. Num: fixmedins_setl_cnt,
  36145. Mtime: time.Now().Unix(),
  36146. Status: 1,
  36147. UserOrgId: adminUser.CurrentOrgId,
  36148. CostTotal: medfee_sumamt,
  36149. FuncTotal: fund_pay_sumamt,
  36150. PsnPay: acct_pay,
  36151. Creator: admin_user_id,
  36152. Ctime: time.Now().Unix(),
  36153. ClrType: clr_type,
  36154. }
  36155. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  36156. if err == nil {
  36157. c.ServeSuccessJSON(map[string]interface{}{
  36158. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  36159. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  36160. })
  36161. } else {
  36162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36163. }
  36164. } else {
  36165. c.ServeSuccessJSON(map[string]interface{}{
  36166. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  36167. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  36168. })
  36169. }
  36170. } else {
  36171. c.ServeSuccessJSON(map[string]interface{}{
  36172. "failed_code": -10,
  36173. "msg": res.ErrMsg,
  36174. })
  36175. }
  36176. }
  36177. }
  36178. func (c *HisApiController) Check310() {
  36179. adminUser := c.GetAdminUserInfo()
  36180. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36181. var user_name string
  36182. user_name = "高慧裕"
  36183. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  36184. "insutype=" + "310" +
  36185. "&clr_type=" + "" +
  36186. "&setl_optins=" + "441202" +
  36187. "&stmt_begndate=" + "2022-03-01" +
  36188. "&stm_enddate=" + "2022-03-31" +
  36189. "&medfee_sumamt=" + "194930.12" +
  36190. "&fund_pay_sumamt=" + "188741.46" +
  36191. "&acct_pay=" + "0" +
  36192. "&fixmedins_setl_cnt=" + "452" +
  36193. "&fixmedins_code=" + miConfig.Code +
  36194. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  36195. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  36196. "&secret_key=" + miConfig.SecretKey +
  36197. "&org_name=" + miConfig.OrgName +
  36198. "&doctor=" + user_name
  36199. fmt.Println(api)
  36200. resp, requestErr := http.Get(api)
  36201. if requestErr != nil {
  36202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36203. return
  36204. }
  36205. body, ioErr := ioutil.ReadAll(resp.Body)
  36206. fmt.Println(body)
  36207. if ioErr != nil {
  36208. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36210. return
  36211. }
  36212. var respJSON map[string]interface{}
  36213. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36214. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36216. return
  36217. }
  36218. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36219. userJSONBytes, _ := json.Marshal(respJSON)
  36220. var res ResultEight
  36221. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36222. utils.ErrorLog("解析失败:%v", err)
  36223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36224. return
  36225. }
  36226. }
  36227. func (c *HisApiController) Check390() {
  36228. adminUser := c.GetAdminUserInfo()
  36229. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36230. var user_name string
  36231. user_name = "高慧裕"
  36232. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  36233. "insutype=" + "390" +
  36234. "&clr_type=" + "" +
  36235. "&setl_optins=" + "441202" +
  36236. "&stmt_begndate=" + "2022-03-01" +
  36237. "&stm_enddate=" + "2022-03-31" +
  36238. "&medfee_sumamt=" + "1068448.89" +
  36239. "&fund_pay_sumamt=" + "1014677.62" +
  36240. "&acct_pay=" + "0" +
  36241. "&fixmedins_setl_cnt=" + "1950" +
  36242. "&fixmedins_code=" + miConfig.Code +
  36243. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  36244. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  36245. "&secret_key=" + miConfig.SecretKey +
  36246. "&org_name=" + miConfig.OrgName +
  36247. "&doctor=" + user_name
  36248. fmt.Println(api)
  36249. resp, requestErr := http.Get(api)
  36250. if requestErr != nil {
  36251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36252. return
  36253. }
  36254. body, ioErr := ioutil.ReadAll(resp.Body)
  36255. fmt.Println(body)
  36256. if ioErr != nil {
  36257. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36259. return
  36260. }
  36261. var respJSON map[string]interface{}
  36262. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36263. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36265. return
  36266. }
  36267. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36268. userJSONBytes, _ := json.Marshal(respJSON)
  36269. var res ResultEight
  36270. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36271. utils.ErrorLog("解析失败:%v", err)
  36272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36273. return
  36274. }
  36275. }
  36276. // 对账明细
  36277. func (c *HisApiController) GetCheckDetailAccount() {
  36278. start_time := c.GetString("start_time")
  36279. end_time := c.GetString("end_time")
  36280. admin_user_id, _ := c.GetInt64("admin_user_id")
  36281. adminUser := c.GetAdminUserInfo()
  36282. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36283. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36284. timeLayout := "2006-01-02"
  36285. loc, _ := time.LoadLocation("Local")
  36286. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  36287. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  36288. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  36289. rand.Seed(time.Now().UnixNano())
  36290. num := rand.Intn(30000)
  36291. Mkdir(miConfig.OrgName)
  36292. file := strconv.FormatInt(int64(num), 10)
  36293. file_name := file + ".txt"
  36294. zip_name := file + ".zip"
  36295. zip_path := miConfig.OrgName + "/" + zip_name
  36296. file_path := miConfig.OrgName + "/" + file_name
  36297. decimal.DivisionPrecision = 2
  36298. var medfee_sumamt float64
  36299. var psn_cash_pay float64
  36300. var fund_pay_sumamt float64
  36301. fixmedins_setl_cnt := int64(len(orders))
  36302. for _, item := range orders {
  36303. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  36304. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  36305. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  36306. }
  36307. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  36308. defer f.Close()
  36309. if err != nil {
  36310. fmt.Println(err.Error())
  36311. } else {
  36312. for _, item := range orders {
  36313. var refd_setl_flag string
  36314. if item.OrderStatus == 2 {
  36315. refd_setl_flag = "0"
  36316. var str string
  36317. str = item.SetlId + " " +
  36318. item.MdtrtId + " " +
  36319. item.PsnNo + " " +
  36320. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  36321. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  36322. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  36323. _, err = f.Write([]byte(str))
  36324. }
  36325. if item.OrderStatus == 3 {
  36326. var str string
  36327. str = item.SetlId + " " +
  36328. item.MdtrtId + " " +
  36329. item.PsnNo + " " +
  36330. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  36331. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  36332. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  36333. _, err = f.Write([]byte(str))
  36334. var str2 string
  36335. str2 = item.SetlId + " " +
  36336. item.MdtrtId + " " +
  36337. item.PsnNo + " " +
  36338. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  36339. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  36340. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  36341. _, err = f.Write([]byte(str2))
  36342. }
  36343. }
  36344. }
  36345. Zip(file_path, zip_path)
  36346. fmt.Println(ReadFile(zip_path))
  36347. fmt.Println(string(ReadFile(zip_path)))
  36348. if config.IsOpen == 1 {
  36349. var user_name string
  36350. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36351. if role.ID == 0 {
  36352. user_name = "管理员"
  36353. } else {
  36354. user_name = role.UserName
  36355. }
  36356. baseParams := models.BaseParams{
  36357. SecretKey: miConfig.SecretKey,
  36358. FixmedinsCode: miConfig.Code,
  36359. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36360. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36361. OrgName: miConfig.OrgName,
  36362. Doctor: user_name,
  36363. }
  36364. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  36365. var dat map[string]interface{}
  36366. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36367. fmt.Println(dat)
  36368. } else {
  36369. fmt.Println(err)
  36370. }
  36371. userJSONBytes, _ := json.Marshal(dat)
  36372. var res ResultNine
  36373. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36374. utils.ErrorLog("解析失败:%v", err)
  36375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36376. return
  36377. }
  36378. if res.Infcode == 0 {
  36379. fileNo := res.Output.FileQuryNo
  36380. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  36381. "file_qury_no=" + fileNo +
  36382. "&setl_optins=" + "定点医保中心" +
  36383. "&stmt_begndate=" + start_time +
  36384. "&stm_enddate=" + end_time +
  36385. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  36386. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  36387. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  36388. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  36389. "&fixmedins_code=" + miConfig.Code +
  36390. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  36391. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  36392. "&secret_key=" + miConfig.SecretKey +
  36393. "&org_name=" + miConfig.OrgName +
  36394. "&doctor=" + user_name
  36395. resp, requestErr := http.Get(api)
  36396. if requestErr != nil {
  36397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36398. return
  36399. }
  36400. body, ioErr := ioutil.ReadAll(resp.Body)
  36401. if ioErr != nil {
  36402. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36404. return
  36405. }
  36406. var respJSON map[string]interface{}
  36407. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36408. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36410. return
  36411. }
  36412. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36413. userJSONBytes, _ := json.Marshal(respJSON)
  36414. var res ResultTen
  36415. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36416. utils.ErrorLog("解析失败:%v", err)
  36417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36418. return
  36419. }
  36420. if res.Infcode == 0 {
  36421. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  36422. micc := &models.MedicalInsuranceCostCompare{
  36423. StartTime: startime.Unix(),
  36424. EndTime: endtime.Unix(),
  36425. Insutype: "0",
  36426. CheckType: 2,
  36427. Num: fixmedins_setl_cnt,
  36428. Mtime: time.Now().Unix(),
  36429. Status: 1,
  36430. UserOrgId: adminUser.CurrentOrgId,
  36431. CostTotal: medfee_sumamt,
  36432. FuncTotal: fund_pay_sumamt,
  36433. PsnPay: psn_cash_pay,
  36434. Creator: admin_user_id,
  36435. Ctime: time.Now().Unix(),
  36436. }
  36437. service.CreateMedicalInsuranceCostCompareRecord(micc)
  36438. c.ServeSuccessJSON(map[string]interface{}{
  36439. "msg": "明细对账成功",
  36440. })
  36441. }
  36442. } else {
  36443. }
  36444. }
  36445. }
  36446. type CustomOrderInfo struct {
  36447. Name string
  36448. Spec string
  36449. Unit string
  36450. Count float64
  36451. Price float64
  36452. Total float64
  36453. }
  36454. func (c *HisApiController) GetBatchSettleAccounts() {
  36455. admin_user_id, _ := c.GetInt64("admin_user_id")
  36456. order_ids := c.GetString("order_ids")
  36457. order_ids_arr := strings.Split(order_ids, ",")
  36458. data3 := []map[string]interface{}{}
  36459. for _, item := range order_ids_arr {
  36460. id, _ := strconv.ParseInt(item, 10, 64)
  36461. order_id := id
  36462. adminUser := c.GetAdminUserInfo()
  36463. order, _ := service.GetHisOrderByID(order_id)
  36464. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  36465. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  36466. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  36467. orderInfos = append(orderInfos, orderInfos_two...)
  36468. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  36469. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  36470. var diagnosis_ids []string
  36471. if his.ID > 0 {
  36472. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  36473. } else {
  36474. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  36475. }
  36476. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  36477. var dia_config []*models.HisXtDiagnoseConfig
  36478. var name string
  36479. for _, item := range diagnosis_ids {
  36480. id, _ := strconv.ParseInt(item, 10, 64)
  36481. diagnosisConfig, _ := service.FindDiagnoseById(id)
  36482. dia_config = append(dia_config, &diagnosisConfig)
  36483. if len(name) == 0 {
  36484. name = diagnosisConfig.ClassName
  36485. }
  36486. //} else {
  36487. // name = name + "," + diagnosisConfig.ClassName
  36488. //}
  36489. }
  36490. var bedCostTotal float64 = 0 //床位总费
  36491. var bedCostSelfTotal float64 = 0 //床位自费
  36492. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  36493. var bedSelfTotal float64 = 0 //床位部分项目自费
  36494. var bedInscpTotal float64 = 0 //床位部分项目自费
  36495. var operationCostTotal float64 = 0 //手术费
  36496. var operationCostSelfTotal float64 = 0 //手术费
  36497. var operationCostPartSelfTotal float64 = 0 //手术费
  36498. var operationSelfTotal float64 = 0 //床位部分项目自费
  36499. var operationInscpTotal float64 = 0 //床位部分项目自费
  36500. var otherCostTotal float64 = 0 //其他费用
  36501. var otherCostSelfTotal float64 = 0 //其他费用
  36502. var otherCostPartSelfTotal float64 = 0 //其他费用
  36503. var otherSelfTotal float64 = 0 //床位部分项目自费
  36504. var otherInscpTotal float64 = 0 //床位部分项目自费
  36505. var materialCostTotal float64 = 0 //材料费
  36506. var materialCostSelfTotal float64 = 0 //材料费
  36507. var materialCostPartSelfTotal float64 = 0 //材料费
  36508. var materialSelfTotal float64 = 0 //床位部分项目自费
  36509. var materialInscpTotal float64 = 0 //床位部分项目自费
  36510. var westernMedicineCostTotal float64 = 0 //西药费
  36511. var westernMedicineCostSelfTotal float64 = 0 //西药费
  36512. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  36513. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  36514. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  36515. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  36516. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  36517. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  36518. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  36519. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  36520. var checkCostTotal float64 = 0 //检查费
  36521. var checkCostSelfTotal float64 = 0 //检查费
  36522. var checkCostPartSelfTotal float64 = 0 //检查费
  36523. var checkSelfTotal float64 = 0 //床位部分项目自费
  36524. var checkInscpTotal float64 = 0 //床位部分项目自费
  36525. var laboratoryCostTotal float64 = 0 //化验费
  36526. var laboratoryCostSelfTotal float64 = 0 //化验费
  36527. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  36528. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  36529. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  36530. var treatCostTotal float64 = 0 //治疗费用
  36531. var treatCostSelfTotal float64 = 0 //治疗费用
  36532. var treatCostPartSelfTotal float64 = 0 //治疗费用
  36533. var treatSelfTotal float64 = 0 //床位部分项目自费
  36534. var treatInscpTotal float64 = 0 //床位部分项目自费
  36535. decimal.DivisionPrecision = 2
  36536. for _, item := range orderInfos {
  36537. if item.MedChrgitmType == "01" { //床位费
  36538. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36539. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36540. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36541. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36542. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36543. }
  36544. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  36545. if item.MedChrgitmType == "03" { //检查费
  36546. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36547. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36548. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36549. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36550. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36551. }
  36552. } else {
  36553. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  36554. fmt.Println("------------")
  36555. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36556. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36557. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36558. }
  36559. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  36560. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36561. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36562. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36563. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36564. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36565. }
  36566. }
  36567. if item.MedChrgitmType == "04" { //化验费
  36568. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36569. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36570. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36571. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36572. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36573. }
  36574. if item.MedChrgitmType == "05" { //治疗费
  36575. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36576. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36577. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36578. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36579. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36580. }
  36581. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  36582. fmt.Println("------------")
  36583. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36584. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36585. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36586. }
  36587. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  36588. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36589. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36590. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36591. }
  36592. //if item.MedChrgitmType == "06" { //手术费
  36593. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36594. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36595. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36596. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36597. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36598. //
  36599. //}
  36600. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  36601. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36602. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36603. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36604. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36605. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36606. }
  36607. if item.MedChrgitmType == "09" { //西药费
  36608. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36609. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36610. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36611. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36612. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36613. }
  36614. if item.MedChrgitmType == "11" { //中成费
  36615. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36616. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36617. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36618. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36619. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36620. }
  36621. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  36622. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36623. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36624. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36625. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36626. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36627. }
  36628. }
  36629. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36630. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36631. var user_name string
  36632. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36633. if role.ID == 0 {
  36634. user_name = "管理员"
  36635. } else {
  36636. user_name = role.UserName
  36637. }
  36638. baseParams := models.BaseParams{
  36639. SecretKey: miConfig.SecretKey,
  36640. FixmedinsCode: miConfig.Code,
  36641. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36642. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36643. OrgName: miConfig.OrgName,
  36644. Doctor: user_name,
  36645. RequestUrl: miConfig.Url,
  36646. AccessKey: miConfig.AccessKey,
  36647. }
  36648. businessParams := models.BusinessParams{
  36649. PsnNo: order.PsnNo,
  36650. MdtrtId: order.MdtrtId,
  36651. SetlId: order.SetlId,
  36652. }
  36653. var res ResultEleven
  36654. var resEleven10265 ResultEleven10265
  36655. if config.IsOpen == 1 {
  36656. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36657. result := service.Gdyb5203(baseParams, businessParams)
  36658. service.Gdyb5204(baseParams, businessParams)
  36659. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  36660. var dat map[string]interface{}
  36661. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36662. fmt.Println(dat)
  36663. } else {
  36664. fmt.Println(err)
  36665. }
  36666. userJSONBytes, _ := json.Marshal(dat)
  36667. if miConfig.Code == "H15049901371" {
  36668. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  36669. utils.ErrorLog("解析失败:%v", err)
  36670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36671. return
  36672. }
  36673. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36674. res.Output = resEleven10265.Output
  36675. res.ErrMsg = resEleven10265.ErrMsg
  36676. res.Cainfo = resEleven10265.Cainfo
  36677. res.WarnMsg = resEleven10265.WarnMsg
  36678. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36679. res.Infcode = infocode
  36680. } else {
  36681. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36682. utils.ErrorLog("解析失败:%v", err)
  36683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36684. return
  36685. }
  36686. }
  36687. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36688. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  36689. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  36690. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  36691. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  36692. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36693. var doctor_name string
  36694. if roles.ID == 0 {
  36695. doctor_name = "管理员"
  36696. } else {
  36697. doctor_name = roles.UserName
  36698. }
  36699. yiliao_leibie := ""
  36700. switch order.MedType {
  36701. case "11":
  36702. yiliao_leibie = "普通门诊"
  36703. break
  36704. case "12":
  36705. yiliao_leibie = "门诊挂号"
  36706. break
  36707. case "13":
  36708. yiliao_leibie = "急诊"
  36709. break
  36710. case "14":
  36711. yiliao_leibie = "门诊特殊病"
  36712. break
  36713. case "15":
  36714. yiliao_leibie = "门诊统筹"
  36715. break
  36716. case "16":
  36717. yiliao_leibie = "门诊慢性病"
  36718. break
  36719. case "21":
  36720. yiliao_leibie = "普通住院"
  36721. break
  36722. }
  36723. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  36724. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  36725. if res.Infcode == 0 {
  36726. data2 := map[string]interface{}{
  36727. "diagnosis": name,
  36728. "order_infos": orderInfos,
  36729. "number": order.MdtrtId,
  36730. "date": order.SettleAccountsDate,
  36731. "charge_admin": charge_admin,
  36732. "printor_admin": printor_admin,
  36733. "info": res.Output.Setlinfo,
  36734. "order": order,
  36735. "bedCostTotal": bedCostTotal,
  36736. "bedCostSelfTotal": bedCostSelfTotal,
  36737. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  36738. "bedSelfTotal": bedSelfTotal,
  36739. "bedInscpTotal": bedInscpTotal,
  36740. "operationCostTotal": operationCostTotal,
  36741. "operationCostSelfTotal": operationCostSelfTotal,
  36742. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  36743. "operationSelfTotal": operationSelfTotal,
  36744. "operationInscpTotal": operationInscpTotal,
  36745. "otherCostTotal": otherCostTotal,
  36746. "otherCostSelfTotal": otherCostSelfTotal,
  36747. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  36748. "otherSelfTotal": otherSelfTotal,
  36749. "otherInscpTotal": otherInscpTotal,
  36750. "materialCostTotal": materialCostTotal,
  36751. "materialCostSelfTotal": materialCostSelfTotal,
  36752. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  36753. "materialSelfTotal": materialSelfTotal,
  36754. "materialInscpTotal": materialInscpTotal,
  36755. "westernMedicineCostTotal": westernMedicineCostTotal,
  36756. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  36757. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  36758. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  36759. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  36760. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  36761. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  36762. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  36763. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  36764. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  36765. "checkCostTotal": checkCostTotal,
  36766. "checkCostSelfTotal": checkCostSelfTotal,
  36767. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  36768. "checkSelfTotal": checkSelfTotal,
  36769. "checkInscpTotal": checkInscpTotal,
  36770. "laboratoryCostTotal": laboratoryCostTotal,
  36771. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  36772. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  36773. "laboratorySelfTotal": laboratorySelfTotal,
  36774. "laboratoryInscpTotal": laboratoryInscpTotal,
  36775. "treatCostTotal": treatCostTotal,
  36776. "treatCostSelfTotal": treatCostSelfTotal,
  36777. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  36778. "treatSelfTotal": treatSelfTotal,
  36779. "treatInscpTotal": treatInscpTotal,
  36780. "doctor_info": doctor_info,
  36781. "doctor_code": adminRole_two.DoctorCode,
  36782. "doctor_name": doctor_name,
  36783. "health_card_no": order.PsnNo,
  36784. "department": departments.Name,
  36785. "yiliao_leibie": yiliao_leibie,
  36786. "after_money": order.AccountPrice,
  36787. "patient": patient,
  36788. "org_name": miConfig.OrgName,
  36789. "org_code": miConfig.Code,
  36790. "order_number": order.Number,
  36791. "his_hospital": his_hospital,
  36792. "his": his,
  36793. "dia_config": dia_config,
  36794. "psn_cash_pay": order.PsnCashPay,
  36795. //"check_order_info": cus_slice,
  36796. }
  36797. data3 = append(data3, data2)
  36798. }
  36799. }
  36800. }
  36801. c.ServeSuccessJSON(map[string]interface{}{
  36802. "infos": data3,
  36803. })
  36804. }
  36805. func (c *HisApiController) GetSettleAccounts() {
  36806. //id, _ := c.GetInt64("id")
  36807. //record_time := c.GetString("record_time")
  36808. order_id, _ := c.GetInt64("order_id")
  36809. admin_user_id, _ := c.GetInt64("admin_user_id")
  36810. //timeLayout := "2006-01-02"
  36811. //loc, _ := time.LoadLocation("Local")
  36812. //
  36813. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  36814. //if err != nil {
  36815. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  36816. // return
  36817. //}Hbyb5203
  36818. //recordDateTime := theTime.Unix()
  36819. adminUser := c.GetAdminUserInfo()
  36820. order, _ := service.GetHisOrderByID(order_id)
  36821. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  36822. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  36823. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  36824. orderInfos = append(orderInfos, orderInfos_two...)
  36825. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  36826. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  36827. var diagnosis_ids []string
  36828. if his.ID > 0 {
  36829. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  36830. } else {
  36831. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  36832. }
  36833. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  36834. var dia_config []*models.HisXtDiagnoseConfig
  36835. var name string
  36836. for _, item := range diagnosis_ids {
  36837. id, _ := strconv.ParseInt(item, 10, 64)
  36838. diagnosisConfig, _ := service.FindDiagnoseById(id)
  36839. dia_config = append(dia_config, &diagnosisConfig)
  36840. if len(name) == 0 {
  36841. name = diagnosisConfig.ClassName
  36842. } else {
  36843. name = name + "," + diagnosisConfig.ClassName
  36844. }
  36845. }
  36846. if patient.UserOrgId == 10215 {
  36847. name = "慢性肾功能不全(血透治疗)"
  36848. }
  36849. var bedCostTotal float64 = 0 //床位总费
  36850. var bedCostSelfTotal float64 = 0 //床位自费
  36851. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  36852. var bedSelfTotal float64 = 0 //床位部分项目自费
  36853. var bedInscpTotal float64 = 0 //床位部分项目自费
  36854. var operationCostTotal float64 = 0 //手术费
  36855. var operationCostSelfTotal float64 = 0 //手术费
  36856. var operationCostPartSelfTotal float64 = 0 //手术费
  36857. var operationSelfTotal float64 = 0 //床位部分项目自费
  36858. var operationInscpTotal float64 = 0 //床位部分项目自费
  36859. var otherCostTotal float64 = 0 //其他费用
  36860. var otherCostSelfTotal float64 = 0 //其他费用
  36861. var otherCostPartSelfTotal float64 = 0 //其他费用
  36862. var otherSelfTotal float64 = 0 //床位部分项目自费
  36863. var otherInscpTotal float64 = 0 //床位部分项目自费
  36864. var materialCostTotal float64 = 0 //材料费
  36865. var materialCostSelfTotal float64 = 0 //材料费
  36866. var materialCostPartSelfTotal float64 = 0 //材料费
  36867. var materialSelfTotal float64 = 0 //床位部分项目自费
  36868. var materialInscpTotal float64 = 0 //床位部分项目自费
  36869. var westernMedicineCostTotal float64 = 0 //西药费
  36870. var westernMedicineCostSelfTotal float64 = 0 //西药费
  36871. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  36872. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  36873. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  36874. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  36875. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  36876. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  36877. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  36878. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  36879. var checkCostTotal float64 = 0 //检查费
  36880. var checkCostSelfTotal float64 = 0 //检查费
  36881. var checkCostPartSelfTotal float64 = 0 //检查费
  36882. var checkSelfTotal float64 = 0 //床位部分项目自费
  36883. var checkInscpTotal float64 = 0 //床位部分项目自费
  36884. var laboratoryCostTotal float64 = 0 //化验费
  36885. var laboratoryCostSelfTotal float64 = 0 //化验费
  36886. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  36887. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  36888. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  36889. var treatCostTotal float64 = 0 //治疗费用
  36890. var treatCostSelfTotal float64 = 0 //治疗费用
  36891. var treatCostPartSelfTotal float64 = 0 //治疗费用
  36892. var treatSelfTotal float64 = 0 //床位部分项目自费
  36893. var treatInscpTotal float64 = 0 //床位部分项目自费
  36894. var zcCostTotal float64 = 0 //治疗费用
  36895. var zcCostSelfTotal float64 = 0 //治疗费用
  36896. var zcCostPartSelfTotal float64 = 0 //治疗费用
  36897. var zcSelfTotal float64 = 0 //床位部分项目自费
  36898. var zcInscpTotal float64 = 0 //床位部分项目自费
  36899. var huliCostTotal float64 = 0 //治疗费用
  36900. var huliCostSelfTotal float64 = 0 //治疗费用
  36901. var huliCostPartSelfTotal float64 = 0 //治疗费用
  36902. var huliSelfTotal float64 = 0 //床位部分项目自费
  36903. var huliInscpTotal float64 = 0 //床位部分项目自费
  36904. decimal.DivisionPrecision = 2
  36905. for _, item := range orderInfos {
  36906. if item.MedChrgitmType == "01" { //床位费
  36907. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36908. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36909. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36910. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36911. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36912. }
  36913. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  36914. if item.MedChrgitmType == "03" { //检查费
  36915. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36916. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36917. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36918. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36919. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36920. }
  36921. } else {
  36922. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  36923. fmt.Println("------------")
  36924. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36925. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36926. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36927. }
  36928. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  36929. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36930. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36931. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36932. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36933. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36934. }
  36935. }
  36936. if item.MedChrgitmType == "04" { //化验费
  36937. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36938. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36939. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36940. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36941. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36942. }
  36943. if item.MedChrgitmType == "05" { //治疗费
  36944. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36945. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36946. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36947. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36948. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36949. }
  36950. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  36951. fmt.Println("------------")
  36952. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36953. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36954. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36955. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36956. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36957. }
  36958. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  36959. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36960. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36961. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36962. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36963. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36964. }
  36965. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  36966. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36967. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36968. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36969. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36970. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36971. }
  36972. if item.MedChrgitmType == "09" { //西药费
  36973. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36974. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36975. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36976. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36977. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36978. }
  36979. if item.MedChrgitmType == "11" { //中成费
  36980. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36981. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36982. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36983. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36984. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36985. }
  36986. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  36987. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36988. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36989. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36990. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36991. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36992. }
  36993. if item.MedChrgitmType == "02" { //其他费
  36994. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36995. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36996. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36997. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36998. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36999. }
  37000. if item.MedChrgitmType == "07" { //其他费
  37001. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  37002. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  37003. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  37004. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  37005. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  37006. }
  37007. }
  37008. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37009. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37010. var user_name string
  37011. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37012. if role.ID == 0 {
  37013. user_name = "管理员"
  37014. } else {
  37015. user_name = role.UserName
  37016. }
  37017. baseParams := models.BaseParams{
  37018. SecretKey: miConfig.SecretKey,
  37019. FixmedinsCode: miConfig.Code,
  37020. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  37021. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  37022. OrgName: miConfig.OrgName,
  37023. Doctor: user_name,
  37024. RequestUrl: miConfig.Url,
  37025. AccessKey: miConfig.AccessKey,
  37026. }
  37027. businessParams := models.BusinessParams{
  37028. PsnNo: order.PsnNo,
  37029. MdtrtId: order.MdtrtId,
  37030. SetlId: order.SetlId,
  37031. }
  37032. var res ResultEleven
  37033. var resah ResultElevenah
  37034. var resEleven10265 ResultEleven10265
  37035. if config.IsOpen == 1 {
  37036. if miConfig.MdtrtareaAdmvs == "421300" {
  37037. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37038. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37039. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37040. resp, requestErr := http.Get(api)
  37041. if requestErr != nil {
  37042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37043. return
  37044. }
  37045. body, ioErr := ioutil.ReadAll(resp.Body)
  37046. if ioErr != nil {
  37047. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37049. return
  37050. }
  37051. var respJSON map[string]interface{}
  37052. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37053. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37055. return
  37056. }
  37057. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37058. result, _ := json.Marshal(respJSON)
  37059. fmt.Println("log")
  37060. fmt.Println(string(result))
  37061. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37062. utils.ErrorLog("解析失败:%v", err)
  37063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37064. return
  37065. }
  37066. } else if miConfig.MdtrtareaAdmvs == "420200" {
  37067. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37068. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37069. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37070. resp, requestErr := http.Get(api)
  37071. if requestErr != nil {
  37072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37073. return
  37074. }
  37075. body, ioErr := ioutil.ReadAll(resp.Body)
  37076. if ioErr != nil {
  37077. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37079. return
  37080. }
  37081. var respJSON map[string]interface{}
  37082. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37083. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37085. return
  37086. }
  37087. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37088. result, _ := json.Marshal(respJSON)
  37089. fmt.Println("log")
  37090. fmt.Println(string(result))
  37091. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37092. utils.ErrorLog("解析失败:%v", err)
  37093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37094. return
  37095. }
  37096. } else if miConfig.MdtrtareaAdmvs == "420902" {
  37097. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37098. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37099. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37100. resp, requestErr := http.Get(api)
  37101. if requestErr != nil {
  37102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37103. return
  37104. }
  37105. body, ioErr := ioutil.ReadAll(resp.Body)
  37106. if ioErr != nil {
  37107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37109. return
  37110. }
  37111. var respJSON map[string]interface{}
  37112. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37115. return
  37116. }
  37117. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37118. result, _ := json.Marshal(respJSON)
  37119. fmt.Println("log")
  37120. fmt.Println(string(result))
  37121. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37122. utils.ErrorLog("解析失败:%v", err)
  37123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37124. return
  37125. }
  37126. } else if miConfig.MdtrtareaAdmvs == "421182" {
  37127. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37128. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37129. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  37130. resp, requestErr := http.Get(api)
  37131. if requestErr != nil {
  37132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37133. return
  37134. }
  37135. body, ioErr := ioutil.ReadAll(resp.Body)
  37136. if ioErr != nil {
  37137. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37139. return
  37140. }
  37141. var respJSON map[string]interface{}
  37142. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37143. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37145. return
  37146. }
  37147. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37148. result, _ := json.Marshal(respJSON)
  37149. fmt.Println("log")
  37150. fmt.Println(string(result))
  37151. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37152. utils.ErrorLog("解析失败:%v", err)
  37153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37154. return
  37155. }
  37156. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  37157. var api string
  37158. if miConfig.MdtrtareaAdmvs == "320830" {
  37159. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37160. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37161. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  37162. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37163. } else if miConfig.MdtrtareaAdmvs == "320921" {
  37164. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37165. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37166. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  37167. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37168. } else {
  37169. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37170. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37171. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37172. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  37173. }
  37174. resp, requestErr := http.Get(api)
  37175. if requestErr != nil {
  37176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37177. return
  37178. }
  37179. body, ioErr := ioutil.ReadAll(resp.Body)
  37180. if ioErr != nil {
  37181. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37183. return
  37184. }
  37185. var respJSON map[string]interface{}
  37186. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37187. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37189. return
  37190. }
  37191. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37192. result, _ := json.Marshal(respJSON)
  37193. fmt.Println("log")
  37194. fmt.Println(string(result))
  37195. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  37196. utils.ErrorLog("解析失败:%v", err)
  37197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37198. return
  37199. }
  37200. res.InfRefmsgid = resEleven10265.InfRefmsgid
  37201. res.Output = resEleven10265.Output
  37202. res.ErrMsg = resEleven10265.ErrMsg
  37203. res.Cainfo = resEleven10265.Cainfo
  37204. res.WarnMsg = resEleven10265.WarnMsg
  37205. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  37206. res.Infcode = infocode
  37207. } else if miConfig.MdtrtareaAdmvs == "350500" {
  37208. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  37209. saveLog(result, requestLog, "5203", "结算单")
  37210. var dat map[string]interface{}
  37211. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37212. fmt.Println(dat)
  37213. } else {
  37214. fmt.Println(err)
  37215. }
  37216. userJSONBytes, _ := json.Marshal(dat)
  37217. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37218. utils.ErrorLog("解析失败:%v", err)
  37219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37220. return
  37221. }
  37222. } else if miConfig.MdtrtareaAdmvs == "360302" {
  37223. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  37224. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  37225. saveLog(result, requestLog, "5203", "结算单")
  37226. var dat map[string]interface{}
  37227. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37228. fmt.Println(dat)
  37229. } else {
  37230. fmt.Println(err)
  37231. }
  37232. userJSONBytes, _ := json.Marshal(dat)
  37233. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37234. utils.ErrorLog("解析失败:%v", err)
  37235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37236. return
  37237. }
  37238. } else if miConfig.MdtrtareaAdmvs == "361025" {
  37239. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  37240. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  37241. saveLog(result, requestLog, "5203", "结算单")
  37242. var dat map[string]interface{}
  37243. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37244. fmt.Println(dat)
  37245. } else {
  37246. fmt.Println(err)
  37247. }
  37248. userJSONBytes, _ := json.Marshal(dat)
  37249. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37250. utils.ErrorLog("解析失败:%v", err)
  37251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37252. return
  37253. }
  37254. } else if miConfig.MdtrtareaAdmvs == "360100" {
  37255. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  37256. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  37257. saveLog(result, requestLog, "5203", "结算单")
  37258. var dat map[string]interface{}
  37259. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37260. fmt.Println(dat)
  37261. } else {
  37262. fmt.Println(err)
  37263. }
  37264. userJSONBytes, _ := json.Marshal(dat)
  37265. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37266. utils.ErrorLog("解析失败:%v", err)
  37267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37268. return
  37269. }
  37270. } else if miConfig.MdtrtareaAdmvs == "341203" {
  37271. var api string
  37272. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37273. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37274. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  37275. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37276. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37277. resp, requestErr := http.Get(api)
  37278. if requestErr != nil {
  37279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37280. return
  37281. }
  37282. body, ioErr := ioutil.ReadAll(resp.Body)
  37283. if ioErr != nil {
  37284. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37286. return
  37287. }
  37288. var respJSON map[string]interface{}
  37289. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37290. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37292. return
  37293. }
  37294. status := respJSON["data"].(map[string]interface{})["status"].(string)
  37295. if status == "0" {
  37296. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  37297. c.ServeSuccessJSON(map[string]interface{}{
  37298. "failed_code": -10,
  37299. "msg": err_msg,
  37300. })
  37301. return
  37302. }
  37303. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37304. result, _ := json.Marshal(respJSON)
  37305. fmt.Println("log")
  37306. fmt.Println(string(result))
  37307. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  37308. utils.ErrorLog("解析失败:%v", err)
  37309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37310. return
  37311. }
  37312. res.InfRefmsgid = resah.InfRefmsgid
  37313. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37314. // 创建对应的Time类型
  37315. t := time.UnixMilli(timestamp)
  37316. // 格式化成指定的日期字符串
  37317. str := t.Format("2006-01-02 15:04:05")
  37318. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37319. // 创建对应的Time类型
  37320. t3 := time.UnixMilli(timestamp2)
  37321. // 格式化成指定的日期字符串
  37322. str2 := t3.Format("2006-01-02 15:04:05")
  37323. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  37324. // 创建对应的Time类型
  37325. t4 := time.UnixMilli(timestamp3)
  37326. // 格式化成指定的日期字符串
  37327. str3 := t4.Format("2006-01-02 15:04:05")
  37328. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  37329. // 创建对应的Time类型
  37330. t5 := time.UnixMilli(timestamp4)
  37331. // 格式化成指定的日期字符串
  37332. str5 := t5.Format("2006-01-02 15:04:05")
  37333. res.Output.Setlinfo.Brdy = str2
  37334. res.Output.Setlinfo.SetlTime = str
  37335. res.Output.Setlinfo.Begndate = str3
  37336. res.Output.Setlinfo.Enddate = str5
  37337. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  37338. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  37339. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  37340. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  37341. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37342. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37343. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  37344. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  37345. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37346. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  37347. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  37348. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  37349. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  37350. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  37351. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  37352. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  37353. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  37354. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  37355. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37356. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  37357. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  37358. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37359. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  37360. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  37361. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  37362. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  37363. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  37364. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  37365. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  37366. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  37367. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  37368. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  37369. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37370. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  37371. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  37372. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  37373. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  37374. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  37375. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  37376. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  37377. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  37378. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  37379. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  37380. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  37381. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  37382. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  37383. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  37384. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  37385. //res.Output.Setldetail = resah.Output.Setldetail
  37386. res.ErrMsg = resah.ErrMsg
  37387. res.Cainfo = resah.Cainfo
  37388. res.WarnMsg = resah.WarnMsg
  37389. } else if miConfig.MdtrtareaAdmvs == "340699" {
  37390. var api string
  37391. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37392. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37393. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  37394. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37395. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37396. resp, requestErr := http.Get(api)
  37397. if requestErr != nil {
  37398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37399. return
  37400. }
  37401. body, ioErr := ioutil.ReadAll(resp.Body)
  37402. if ioErr != nil {
  37403. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37405. return
  37406. }
  37407. var respJSON map[string]interface{}
  37408. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37409. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37411. return
  37412. }
  37413. status := respJSON["data"].(map[string]interface{})["status"].(string)
  37414. if status == "0" {
  37415. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  37416. c.ServeSuccessJSON(map[string]interface{}{
  37417. "failed_code": -10,
  37418. "msg": err_msg,
  37419. })
  37420. return
  37421. }
  37422. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37423. result, _ := json.Marshal(respJSON)
  37424. fmt.Println("log")
  37425. fmt.Println(string(result))
  37426. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  37427. utils.ErrorLog("解析失败:%v", err)
  37428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37429. return
  37430. }
  37431. res.InfRefmsgid = resah.InfRefmsgid
  37432. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37433. // 创建对应的Time类型
  37434. t := time.UnixMilli(timestamp)
  37435. // 格式化成指定的日期字符串
  37436. str := t.Format("2006-01-02 15:04:05")
  37437. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37438. // 创建对应的Time类型
  37439. t3 := time.UnixMilli(timestamp2)
  37440. // 格式化成指定的日期字符串
  37441. str2 := t3.Format("2006-01-02 15:04:05")
  37442. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  37443. // 创建对应的Time类型
  37444. t4 := time.UnixMilli(timestamp3)
  37445. // 格式化成指定的日期字符串
  37446. str3 := t4.Format("2006-01-02 15:04:05")
  37447. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  37448. // 创建对应的Time类型
  37449. t5 := time.UnixMilli(timestamp4)
  37450. // 格式化成指定的日期字符串
  37451. str5 := t5.Format("2006-01-02 15:04:05")
  37452. res.Output.Setlinfo.Brdy = str2
  37453. res.Output.Setlinfo.SetlTime = str
  37454. res.Output.Setlinfo.Begndate = str3
  37455. res.Output.Setlinfo.Enddate = str5
  37456. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  37457. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  37458. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  37459. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  37460. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37461. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37462. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  37463. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  37464. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37465. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  37466. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  37467. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  37468. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  37469. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  37470. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  37471. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  37472. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  37473. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  37474. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37475. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  37476. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  37477. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37478. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  37479. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  37480. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  37481. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  37482. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  37483. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  37484. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  37485. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  37486. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  37487. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  37488. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37489. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  37490. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  37491. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  37492. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  37493. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  37494. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  37495. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  37496. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  37497. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  37498. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  37499. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  37500. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  37501. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  37502. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  37503. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  37504. //res.Output.Setldetail = resah.Output.Setldetail
  37505. res.ErrMsg = resah.ErrMsg
  37506. res.Cainfo = resah.Cainfo
  37507. res.WarnMsg = resah.WarnMsg
  37508. } else if miConfig.MdtrtareaAdmvs == "430800" {
  37509. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  37510. saveLog(result, requestLog, "5203", "结算单")
  37511. var dat map[string]interface{}
  37512. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37513. fmt.Println(dat)
  37514. } else {
  37515. fmt.Println(err)
  37516. }
  37517. userJSONBytes, _ := json.Marshal(dat)
  37518. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37519. utils.ErrorLog("解析失败:%v", err)
  37520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37521. return
  37522. }
  37523. } else if miConfig.MdtrtareaAdmvs == "150404" {
  37524. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37525. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37526. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37527. resp, requestErr := http.Get(api)
  37528. if requestErr != nil {
  37529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37530. return
  37531. }
  37532. body, ioErr := ioutil.ReadAll(resp.Body)
  37533. if ioErr != nil {
  37534. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37536. return
  37537. }
  37538. var respJSON map[string]interface{}
  37539. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37540. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37542. return
  37543. }
  37544. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37545. result, _ := json.Marshal(respJSON)
  37546. fmt.Println("log")
  37547. fmt.Println(string(result))
  37548. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  37549. utils.ErrorLog("解析失败:%v", err)
  37550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37551. return
  37552. }
  37553. res.InfRefmsgid = resEleven10265.InfRefmsgid
  37554. res.Output = resEleven10265.Output
  37555. res.ErrMsg = resEleven10265.ErrMsg
  37556. res.Cainfo = resEleven10265.Cainfo
  37557. res.WarnMsg = resEleven10265.WarnMsg
  37558. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  37559. res.Infcode = infocode
  37560. } else if miConfig.MdtrtareaAdmvs == "441799" {
  37561. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37562. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37563. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37564. resp, requestErr := http.Get(api)
  37565. if requestErr != nil {
  37566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37567. return
  37568. }
  37569. body, ioErr := ioutil.ReadAll(resp.Body)
  37570. if ioErr != nil {
  37571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37573. return
  37574. }
  37575. var respJSON map[string]interface{}
  37576. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37577. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37579. return
  37580. }
  37581. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37582. result, _ := json.Marshal(respJSON)
  37583. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37584. utils.ErrorLog("解析失败:%v", err)
  37585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37586. return
  37587. }
  37588. } else if miConfig.MdtrtareaAdmvs == "450721" {
  37589. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  37590. //return
  37591. } else {
  37592. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  37593. if len(his.InsuplcAdmdvs) == 0 {
  37594. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  37595. } else {
  37596. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  37597. }
  37598. result := service.Gdyb5203(baseParams, businessParams)
  37599. //service.Gdyb5204(baseParams, businessParams)
  37600. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  37601. var dat map[string]interface{}
  37602. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37603. fmt.Println(dat)
  37604. } else {
  37605. fmt.Println(err)
  37606. }
  37607. userJSONBytes, _ := json.Marshal(dat)
  37608. if miConfig.Code == "H15049901371" {
  37609. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  37610. utils.ErrorLog("解析失败:%v", err)
  37611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37612. return
  37613. }
  37614. res.InfRefmsgid = resEleven10265.InfRefmsgid
  37615. res.Output = resEleven10265.Output
  37616. res.ErrMsg = resEleven10265.ErrMsg
  37617. res.Cainfo = resEleven10265.Cainfo
  37618. res.WarnMsg = resEleven10265.WarnMsg
  37619. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  37620. res.Infcode = infocode
  37621. } else {
  37622. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37623. utils.ErrorLog("解析失败:%v", err)
  37624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37625. return
  37626. }
  37627. }
  37628. }
  37629. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37630. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  37631. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  37632. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  37633. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  37634. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37635. var doctor_name string
  37636. if roles.ID == 0 {
  37637. doctor_name = "管理员"
  37638. } else {
  37639. doctor_name = roles.UserName
  37640. }
  37641. yiliao_leibie := ""
  37642. switch order.MedType {
  37643. case "11":
  37644. yiliao_leibie = "普通门诊"
  37645. break
  37646. case "12":
  37647. yiliao_leibie = "门诊挂号"
  37648. break
  37649. case "13":
  37650. yiliao_leibie = "急诊"
  37651. break
  37652. case "14":
  37653. yiliao_leibie = "门诊特殊病"
  37654. break
  37655. case "15":
  37656. yiliao_leibie = "门诊统筹"
  37657. break
  37658. case "16":
  37659. yiliao_leibie = "门诊慢性病"
  37660. break
  37661. case "21":
  37662. yiliao_leibie = "普通住院"
  37663. break
  37664. }
  37665. //var rf []CustomFundPay
  37666. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  37667. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  37668. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  37669. if res.Infcode == 0 {
  37670. 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 {
  37671. c.ServeSuccessJSON(map[string]interface{}{
  37672. "diagnosis": name,
  37673. "order_infos": orderInfos,
  37674. "number": order.MdtrtId,
  37675. "date": order.SettleAccountsDate,
  37676. "charge_admin": charge_admin,
  37677. "printor_admin": printor_admin,
  37678. "info": res.Output.Setlinfo,
  37679. "order": order,
  37680. "bedCostTotal": bedCostTotal,
  37681. "bedCostSelfTotal": bedCostSelfTotal,
  37682. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  37683. "bedSelfTotal": bedSelfTotal,
  37684. "bedInscpTotal": bedInscpTotal,
  37685. "operationCostTotal": operationCostTotal,
  37686. "operationCostSelfTotal": operationCostSelfTotal,
  37687. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  37688. "operationSelfTotal": operationSelfTotal,
  37689. "operationInscpTotal": operationInscpTotal,
  37690. "otherCostTotal": otherCostTotal,
  37691. "otherCostSelfTotal": otherCostSelfTotal,
  37692. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  37693. "otherSelfTotal": otherSelfTotal,
  37694. "otherInscpTotal": otherInscpTotal,
  37695. "materialCostTotal": materialCostTotal,
  37696. "materialCostSelfTotal": materialCostSelfTotal,
  37697. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  37698. "materialSelfTotal": materialSelfTotal,
  37699. "materialInscpTotal": materialInscpTotal,
  37700. "westernMedicineCostTotal": westernMedicineCostTotal,
  37701. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  37702. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  37703. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  37704. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  37705. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  37706. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  37707. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  37708. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  37709. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  37710. "checkCostTotal": checkCostTotal,
  37711. "checkCostSelfTotal": checkCostSelfTotal,
  37712. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  37713. "checkSelfTotal": checkSelfTotal,
  37714. "checkInscpTotal": checkInscpTotal,
  37715. "laboratoryCostTotal": laboratoryCostTotal,
  37716. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  37717. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  37718. "laboratorySelfTotal": laboratorySelfTotal,
  37719. "laboratoryInscpTotal": laboratoryInscpTotal,
  37720. "treatCostTotal": treatCostTotal,
  37721. "treatCostSelfTotal": treatCostSelfTotal,
  37722. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  37723. "treatSelfTotal": treatSelfTotal,
  37724. "treatInscpTotal": treatInscpTotal,
  37725. "doctor_info": doctor_info,
  37726. "doctor_code": adminRole_two.DoctorCode,
  37727. "doctor_name": doctor_name,
  37728. "health_card_no": order.PsnNo,
  37729. "department": departments.Name,
  37730. "yiliao_leibie": yiliao_leibie,
  37731. "after_money": order.AccountPrice,
  37732. "patient": patient,
  37733. "org_name": miConfig.OrgName,
  37734. "org_code": miConfig.Code,
  37735. "order_number": order.Number,
  37736. "his_hospital": his_hospital,
  37737. "his": his,
  37738. "dia_config": dia_config,
  37739. "psn_cash_pay": order.PsnCashPay,
  37740. "zcCostTotal": zcCostTotal,
  37741. "zcCostSelfTotal": zcCostSelfTotal,
  37742. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  37743. "zcSelfTotal": zcSelfTotal,
  37744. "zcInscpTotal": zcInscpTotal,
  37745. "huliCostTotal": huliCostTotal,
  37746. "huliCostSelfTotal": huliCostSelfTotal,
  37747. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  37748. "huliSelfTotal": huliSelfTotal,
  37749. "huliInscpTotal": huliInscpTotal,
  37750. //"funds": rf,
  37751. //"check_order_info": cus_slice,
  37752. })
  37753. } else {
  37754. c.ServeSuccessJSON(map[string]interface{}{
  37755. "diagnosis": name,
  37756. "order_infos": orderInfos,
  37757. "number": order.MdtrtId,
  37758. "date": order.SettleAccountsDate,
  37759. "charge_admin": charge_admin,
  37760. "printor_admin": printor_admin,
  37761. "info": order,
  37762. "order": order,
  37763. "bedCostTotal": bedCostTotal,
  37764. "bedCostSelfTotal": bedCostSelfTotal,
  37765. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  37766. "bedSelfTotal": bedSelfTotal,
  37767. "bedInscpTotal": bedInscpTotal,
  37768. "operationCostTotal": operationCostTotal,
  37769. "operationCostSelfTotal": operationCostSelfTotal,
  37770. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  37771. "operationSelfTotal": operationSelfTotal,
  37772. "operationInscpTotal": operationInscpTotal,
  37773. "otherCostTotal": otherCostTotal,
  37774. "otherCostSelfTotal": otherCostSelfTotal,
  37775. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  37776. "otherSelfTotal": otherSelfTotal,
  37777. "otherInscpTotal": otherInscpTotal,
  37778. "materialCostTotal": materialCostTotal,
  37779. "materialCostSelfTotal": materialCostSelfTotal,
  37780. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  37781. "materialSelfTotal": materialSelfTotal,
  37782. "materialInscpTotal": materialInscpTotal,
  37783. "westernMedicineCostTotal": westernMedicineCostTotal,
  37784. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  37785. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  37786. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  37787. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  37788. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  37789. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  37790. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  37791. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  37792. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  37793. "checkCostTotal": checkCostTotal,
  37794. "checkCostSelfTotal": checkCostSelfTotal,
  37795. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  37796. "checkSelfTotal": checkSelfTotal,
  37797. "checkInscpTotal": checkInscpTotal,
  37798. "laboratoryCostTotal": laboratoryCostTotal,
  37799. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  37800. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  37801. "laboratorySelfTotal": laboratorySelfTotal,
  37802. "laboratoryInscpTotal": laboratoryInscpTotal,
  37803. "treatCostTotal": treatCostTotal,
  37804. "treatCostSelfTotal": treatCostSelfTotal,
  37805. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  37806. "treatSelfTotal": treatSelfTotal,
  37807. "treatInscpTotal": treatInscpTotal,
  37808. "doctor_info": doctor_info,
  37809. "doctor_code": adminRole_two.DoctorCode,
  37810. "doctor_name": doctor_name,
  37811. "health_card_no": order.PsnNo,
  37812. "department": departments.Name,
  37813. "yiliao_leibie": yiliao_leibie,
  37814. "after_money": order.AccountPrice,
  37815. "patient": patient,
  37816. "org_name": miConfig.OrgName,
  37817. "org_code": miConfig.Code,
  37818. "order_number": order.Number,
  37819. "his_hospital": his_hospital,
  37820. "his": his,
  37821. "dia_config": dia_config,
  37822. "psn_cash_pay": order.PsnCashPay,
  37823. "zcCostTotal": zcCostTotal,
  37824. "zcCostSelfTotal": zcCostSelfTotal,
  37825. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  37826. "zcSelfTotal": zcSelfTotal,
  37827. "zcInscpTotal": zcInscpTotal,
  37828. "huliCostTotal": huliCostTotal,
  37829. "huliCostSelfTotal": huliCostSelfTotal,
  37830. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  37831. "huliSelfTotal": huliSelfTotal,
  37832. "huliInscpTotal": huliInscpTotal,
  37833. //"funds": rf,
  37834. //"check_order_info": cus_slice,
  37835. })
  37836. }
  37837. }
  37838. }
  37839. }
  37840. //func (c *HisApiController) CheckTreatment() {
  37841. // patient_id, _ := c.GetInt64("patient_id")
  37842. // id_card_no := c.GetString("id_card_no")
  37843. // insutype := c.GetString("insutype")
  37844. // med_type := c.GetString("med_type")
  37845. // admin_user_id, _ := c.GetInt64("admin_user_id")
  37846. //
  37847. // adminUser := c.GetAdminUserInfo()
  37848. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  37849. //
  37850. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37851. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37852. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37853. //
  37854. // if miConfig.MdtrtareaAdmvs == "421300" {
  37855. // var res ResultTwo
  37856. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  37857. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  37858. // "&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)
  37859. // resp, requestErr := http.Get(api)
  37860. // if requestErr != nil {
  37861. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37862. // return
  37863. // }
  37864. //
  37865. // body, ioErr := ioutil.ReadAll(resp.Body)
  37866. // if ioErr != nil {
  37867. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37868. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37869. // return
  37870. // }
  37871. // var respJSON map[string]interface{}
  37872. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37873. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37874. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37875. // return
  37876. // }
  37877. //
  37878. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37879. // result, _ := json.Marshal(respJSON)
  37880. //
  37881. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  37882. // utils.ErrorLog("解析失败:%v", err)
  37883. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37884. // return
  37885. // }
  37886. //
  37887. // if res.Infcode == 0 {
  37888. //
  37889. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  37890. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  37891. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  37892. // resp, requestErr := http.Get(api)
  37893. // if requestErr != nil {
  37894. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37895. // return
  37896. // }
  37897. //
  37898. // body, ioErr := ioutil.ReadAll(resp.Body)
  37899. // if ioErr != nil {
  37900. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37901. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37902. // return
  37903. // }
  37904. // var respJSON map[string]interface{}
  37905. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37906. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37907. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37908. // return
  37909. // }
  37910. // var res Result2001
  37911. //
  37912. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37913. // result2, _ := json.Marshal(respJSON)
  37914. //
  37915. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  37916. // utils.ErrorLog("解析失败:%v", err)
  37917. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37918. // return
  37919. // }
  37920. //
  37921. // if res.Infcode == 0 {
  37922. // c.ServeSuccessJSON(map[string]interface{}{
  37923. // "msg": res.Output.Trtinfo,
  37924. // })
  37925. // }
  37926. //
  37927. // } else {
  37928. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37929. // return
  37930. // }
  37931. //
  37932. // } else {
  37933. //
  37934. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  37935. // var dat map[string]interface{}
  37936. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37937. // fmt.Println(dat)
  37938. // } else {
  37939. // fmt.Println(err)
  37940. // }
  37941. // userJSONBytes, _ := json.Marshal(dat)
  37942. // var res ResultTwo
  37943. // var res10265 ResultTwo10265
  37944. // if miConfig.Code == "H15049901371" {
  37945. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  37946. // utils.ErrorLog("解析失败:%v", err)
  37947. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37948. // return
  37949. // }
  37950. // res.ErrMsg = res10265.ErrMsg
  37951. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37952. // res.Infcode = infocode
  37953. // res.Output = res10265.Output
  37954. // res.InfRefmsgid = res10265.InfRefmsgid
  37955. // } else {
  37956. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37957. // utils.ErrorLog("解析失败:%v", err)
  37958. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37959. // return
  37960. // }
  37961. // }
  37962. //
  37963. // var user_name string
  37964. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  37965. // if role.ID == 0 {
  37966. // user_name = "xxx"
  37967. // } else {
  37968. // user_name = role.UserName
  37969. // }
  37970. //
  37971. // baseParams := models.BaseParams{
  37972. // SecretKey: miConfig.SecretKey,
  37973. // FixmedinsCode: miConfig.Code,
  37974. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  37975. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  37976. // OrgName: miConfig.OrgName,
  37977. // Doctor: user_name,
  37978. // }
  37979. //
  37980. // if config.IsOpen == 1 {
  37981. // if miConfig.Code == "H15049901371" {
  37982. // if med_type == "14" {
  37983. // if insutype == "390" {
  37984. // med_type = "9933"
  37985. // } else if insutype == "310" {
  37986. // med_type = "990502"
  37987. // }
  37988. // } else if med_type == "11" {
  37989. // med_type = "11"
  37990. // }
  37991. // }
  37992. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  37993. // var dat map[string]interface{}
  37994. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37995. // fmt.Println(dat)
  37996. // } else {
  37997. // fmt.Println(err)
  37998. // }
  37999. // var res Result2001
  38000. // var res10265 Result2001Org10265
  38001. // if miConfig.Code == "H15049901371" {
  38002. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38003. // utils.ErrorLog("解析失败:%v", err)
  38004. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38005. // return
  38006. // }
  38007. // res.ErrMsg = res10265.ErrMsg
  38008. // res.Output = res10265.Output
  38009. // res.InfRefmsgid = res10265.InfRefmsgid
  38010. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38011. // res.Infcode = infocode
  38012. // } else {
  38013. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  38014. // utils.ErrorLog("解析失败:%v", err)
  38015. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38016. // return
  38017. // }
  38018. // }
  38019. // if res.Infcode == 0 {
  38020. // c.ServeSuccessJSON(map[string]interface{}{
  38021. // "msg": res.Output.Trtinfo,
  38022. // })
  38023. // }
  38024. // }
  38025. // }
  38026. //}
  38027. //func (c *HisApiController) PutRecord() {
  38028. // id, _ := c.GetInt64("id")
  38029. // record_time := c.GetString("record_time")
  38030. // timeLayout := "2006-01-02"
  38031. // loc, _ := time.LoadLocation("Local")
  38032. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  38033. // if err != nil {
  38034. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  38035. // return
  38036. // }
  38037. // recordDateTime := theTime.Unix()
  38038. //
  38039. // adminInfo := c.GetAdminUserInfo()
  38040. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  38041. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  38042. //
  38043. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  38044. //
  38045. // fmt.Println(miConfig.SecretKey)
  38046. //
  38047. // if patient == nil {
  38048. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  38049. // return
  38050. // }
  38051. // if len(patient.IdCardNo) == 0 {
  38052. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  38053. // return
  38054. // }
  38055. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  38056. // if config.IsOpen == 1 {
  38057. // 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
  38058. // resp, requestErr := http.Get(api)
  38059. // if requestErr != nil {
  38060. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38061. // return
  38062. // }
  38063. // defer resp.Body.Close()
  38064. // body, ioErr := ioutil.ReadAll(resp.Body)
  38065. // if ioErr != nil {
  38066. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38067. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38068. // return
  38069. // }
  38070. // var respJSON map[string]interface{}
  38071. //
  38072. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38073. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38074. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38075. // return
  38076. // }
  38077. //
  38078. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38079. // userJSONBytes, _ := json.Marshal(userJSON)
  38080. // var res ResultTwo
  38081. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38082. // utils.ErrorLog("解析失败:%v", err)
  38083. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38084. // return
  38085. // }
  38086. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38087. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  38088. // infoStr := string(Iinfos)
  38089. // idetinfoStr := string(Idetinfos)
  38090. //
  38091. // if res.Infcode == 0 {
  38092. // his := models.VMHisPatient{
  38093. // Status: 1,
  38094. // Ctime: time.Now().Unix(),
  38095. // Mtime: time.Now().Unix(),
  38096. // PsnNo: res.Output.Baseinfo.PsnNo,
  38097. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  38098. // Certno: res.Output.Baseinfo.Certno,
  38099. // PsnName: res.Output.Baseinfo.PsnName,
  38100. // Gend: res.Output.Baseinfo.Gend,
  38101. // Naty: res.Output.Baseinfo.Naty,
  38102. // Brdy: res.Output.Baseinfo.Brdy,
  38103. // Age: res.Output.Baseinfo.Age,
  38104. // Iinfo: infoStr,
  38105. // Idetinfo: idetinfoStr,
  38106. // PatientId: patient.ID,
  38107. // RecordDate: theTime.Unix(),
  38108. // UserOrgId: adminInfo.CurrentOrgId,
  38109. // AdminUserId: adminInfo.AdminUser.Id,
  38110. // IsReturn: 1,
  38111. // }
  38112. //
  38113. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  38114. // //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")
  38115. // //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")
  38116. //
  38117. // //var dat map[string]interface{}
  38118. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38119. // // fmt.Println(dat)
  38120. // //} else {
  38121. // // fmt.Println(err)
  38122. // //}
  38123. //
  38124. // var dat2 map[string]interface{}
  38125. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  38126. // fmt.Println(dat2)
  38127. // } else {
  38128. // fmt.Println(err)
  38129. // }
  38130. //
  38131. // } else {
  38132. // adminUser := c.GetAdminUserInfo()
  38133. // errlog := &models.HisOrderError{
  38134. // UserOrgId: adminUser.CurrentOrgId,
  38135. // Ctime: time.Now().Unix(),
  38136. // Mtime: time.Now().Unix(),
  38137. // ErrMsg: res.ErrMsg,
  38138. // Status: 1,
  38139. // PatientId: id,
  38140. // RecordTime: recordDateTime,
  38141. // Stage: 1,
  38142. // }
  38143. // service.CreateErrMsgLog(errlog)
  38144. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  38145. // return
  38146. // }
  38147. // }
  38148. //
  38149. //}
  38150. //func (c *HisApiController) GetUploadDiag() {
  38151. // id, _ := c.GetInt64("id")
  38152. // record_time := c.GetString("record_time")
  38153. //
  38154. // diagnosis_id, _ := c.GetInt64("diagnosis")
  38155. // sick_type, _ := c.GetInt64("sick_type")
  38156. // reg_type, _ := c.GetInt64("reg_type")
  38157. //
  38158. // timeLayout := "2006-01-02"
  38159. // loc, _ := time.LoadLocation("Local")
  38160. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  38161. // if err != nil {
  38162. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  38163. // return
  38164. // }
  38165. //
  38166. // var patientPrescription models.HisPrescriptionInfo
  38167. // recordDateTime := theTime.Unix()
  38168. // adminInfo := c.GetAdminUserInfo()
  38169. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  38170. //
  38171. // if patientPrescription.ID == 0 {
  38172. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  38173. // }
  38174. //
  38175. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  38176. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  38177. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  38178. // sickConfig, _ := service.FindSickById(sick_type)
  38179. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  38180. //
  38181. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  38182. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  38183. // "&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 +
  38184. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  38185. // resp2, requestErr2 := http.Get(api2)
  38186. // if requestErr2 != nil {
  38187. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38188. // return
  38189. // }
  38190. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  38191. // if ioErr2 != nil {
  38192. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  38193. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38194. // return
  38195. // }
  38196. // var respJSON2 map[string]interface{}
  38197. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  38198. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38199. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38200. // return
  38201. // }
  38202. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38203. // userJSONBytes2, _ := json.Marshal(respJSON2)
  38204. //
  38205. // var res2 ResultSix
  38206. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  38207. // utils.ErrorLog("解析失败:%v", err)
  38208. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38209. // return
  38210. // }
  38211. // if res2.Infcode != 0 {
  38212. // adminUser := c.GetAdminUserInfo()
  38213. // errlog := &models.HisOrderError{
  38214. // UserOrgId: adminUser.CurrentOrgId,
  38215. // Ctime: time.Now().Unix(),
  38216. // Mtime: time.Now().Unix(),
  38217. // ErrMsg: res2.ErrMsg,
  38218. // Status: 1,
  38219. // PatientId: id,
  38220. // RecordTime: recordDateTime,
  38221. // Stage: 3,
  38222. // }
  38223. // service.CreateErrMsgLog(errlog)
  38224. //
  38225. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  38226. // return
  38227. // }
  38228. //
  38229. // c.ServeSuccessJSON(map[string]interface{}{
  38230. // "msg": "上传成功",
  38231. // })
  38232. //
  38233. //}
  38234. type QueryResult struct {
  38235. ID int64
  38236. Name string
  38237. Code string
  38238. List_type_code string
  38239. }
  38240. func (c *HisApiController) GetCheckCode() {
  38241. ids_str := c.GetString("ids")
  38242. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  38243. ids_arr := strings.Split(ids_str, ",")
  38244. var queryResult []QueryResult
  38245. ids := make([]int64, 0)
  38246. for _, item := range ids_arr {
  38247. id, _ := strconv.ParseInt(item, 10, 64)
  38248. ids = append(ids, id)
  38249. }
  38250. if record_type == 1 {
  38251. drugs, _ := service.GetBatchDrugList(ids)
  38252. for _, item := range drugs {
  38253. result := QueryResult{
  38254. ID: item.ID,
  38255. Name: item.DrugName,
  38256. Code: item.MedicalInsuranceNumber,
  38257. List_type_code: "101",
  38258. }
  38259. queryResult = append(queryResult, result)
  38260. }
  38261. } else if record_type == 2 {
  38262. goods, _ := service.GetBatchGoodInformationList(ids)
  38263. fmt.Println(goods)
  38264. for _, item := range goods {
  38265. result := QueryResult{
  38266. ID: item.ID,
  38267. Name: item.GoodName,
  38268. Code: item.SocialSecurityDirectoryCode,
  38269. List_type_code: "301",
  38270. }
  38271. queryResult = append(queryResult, result)
  38272. }
  38273. } else if record_type == 3 {
  38274. projects, _ := service.GetBathchMyPorjecgList(ids)
  38275. for _, item := range projects {
  38276. result := QueryResult{
  38277. ID: item.ID,
  38278. Name: item.ProjectName,
  38279. Code: item.MedicalCode,
  38280. List_type_code: "201",
  38281. }
  38282. queryResult = append(queryResult, result)
  38283. }
  38284. }
  38285. admin_user_id, _ := c.GetInt64("admin_user_id")
  38286. adminUser := c.GetAdminUserInfo()
  38287. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38288. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38289. var user_name string
  38290. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38291. if role.ID == 0 {
  38292. user_name = "管理员"
  38293. } else {
  38294. user_name = role.UserName
  38295. }
  38296. baseParams := models.BaseParams{
  38297. SecretKey: miConfig.SecretKey,
  38298. FixmedinsCode: miConfig.Code,
  38299. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  38300. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  38301. OrgName: miConfig.OrgName,
  38302. Doctor: user_name,
  38303. }
  38304. var result string
  38305. if miConfig.MdtrtareaAdmvs == "430800" {
  38306. for _, item := range queryResult {
  38307. if record_type == 1 {
  38308. 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)
  38309. } else if record_type == 2 {
  38310. fmt.Println(item.Code)
  38311. 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)
  38312. } else if record_type == 3 {
  38313. 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)
  38314. }
  38315. var dat map[string]interface{}
  38316. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38317. fmt.Println(dat)
  38318. } else {
  38319. fmt.Println(err)
  38320. }
  38321. userJSONBytes, _ := json.Marshal(dat)
  38322. var res ResultSix
  38323. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38324. utils.ErrorLog("解析失败:%v", err)
  38325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38326. return
  38327. }
  38328. if res.Infcode == 0 {
  38329. if record_type == 1 {
  38330. service.UpdateBaseDrugById(item.ID)
  38331. } else if record_type == 2 {
  38332. service.UpdateGoodInformaitonByDetail(item.ID)
  38333. } else if record_type == 3 {
  38334. service.UpdateProjectById(item.ID)
  38335. }
  38336. c.ServeSuccessJSON(map[string]interface{}{
  38337. "failed_code": 0,
  38338. "msg": "目录对照成功",
  38339. })
  38340. } else {
  38341. c.ServeSuccessJSON(map[string]interface{}{
  38342. "failed_code": -10,
  38343. "msg": res.ErrMsg,
  38344. })
  38345. }
  38346. }
  38347. } else {
  38348. for _, item := range queryResult {
  38349. var result string
  38350. if record_type == 1 {
  38351. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  38352. } else if record_type == 2 {
  38353. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  38354. } else if record_type == 3 {
  38355. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  38356. }
  38357. var dat map[string]interface{}
  38358. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38359. fmt.Println(dat)
  38360. } else {
  38361. fmt.Println(err)
  38362. }
  38363. userJSONBytes, _ := json.Marshal(dat)
  38364. var res ResultSix
  38365. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38366. utils.ErrorLog("解析失败:%v", err)
  38367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38368. return
  38369. }
  38370. if res.Infcode == 0 {
  38371. if record_type == 1 {
  38372. service.UpdateBaseDrugById(item.ID)
  38373. } else if record_type == 2 {
  38374. service.UpdateGoodInformaitonByDetail(item.ID)
  38375. } else if record_type == 3 {
  38376. service.UpdateProjectById(item.ID)
  38377. }
  38378. c.ServeSuccessJSON(map[string]interface{}{
  38379. "failed_code": 0,
  38380. "msg": "目录对照成功",
  38381. })
  38382. } else {
  38383. c.ServeSuccessJSON(map[string]interface{}{
  38384. "failed_code": -10,
  38385. "msg": res.ErrMsg,
  38386. })
  38387. }
  38388. }
  38389. }
  38390. }
  38391. func (c *HisApiController) UnCheckCode() {
  38392. ids_str := c.GetString("ids")
  38393. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  38394. admin_user_id, _ := c.GetInt64("admin_user_id")
  38395. ids_arr := strings.Split(ids_str, ",")
  38396. var queryResult []QueryResult
  38397. ids := make([]int64, 0)
  38398. for _, item := range ids_arr {
  38399. id, _ := strconv.ParseInt(item, 10, 64)
  38400. ids = append(ids, id)
  38401. }
  38402. if record_type == 1 {
  38403. drugs, _ := service.GetBatchDrugList(ids)
  38404. for _, item := range drugs {
  38405. result := QueryResult{
  38406. ID: item.ID,
  38407. Name: item.DrugName,
  38408. Code: item.MedicalInsuranceNumber,
  38409. List_type_code: "101",
  38410. }
  38411. queryResult = append(queryResult, result)
  38412. }
  38413. } else if record_type == 2 {
  38414. goods, _ := service.GetBatchGoodInformationList(ids)
  38415. for _, item := range goods {
  38416. result := QueryResult{
  38417. ID: item.ID,
  38418. Name: item.GoodName,
  38419. Code: item.SocialSecurityDirectoryCode,
  38420. List_type_code: "301",
  38421. }
  38422. queryResult = append(queryResult, result)
  38423. }
  38424. } else if record_type == 3 {
  38425. projects, _ := service.GetBathchMyPorjecgList(ids)
  38426. for _, item := range projects {
  38427. result := QueryResult{
  38428. ID: item.ID,
  38429. Name: item.ProjectName,
  38430. Code: item.MedicalCode,
  38431. List_type_code: "201",
  38432. }
  38433. queryResult = append(queryResult, result)
  38434. }
  38435. }
  38436. adminUser := c.GetAdminUserInfo()
  38437. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38438. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38439. var user_name string
  38440. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38441. if role.ID == 0 {
  38442. user_name = "xxx"
  38443. } else {
  38444. user_name = role.UserName
  38445. }
  38446. baseParams := &models.BaseParams{
  38447. SecretKey: miConfig.SecretKey,
  38448. FixmedinsCode: miConfig.Code,
  38449. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  38450. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  38451. OrgName: miConfig.OrgName,
  38452. Doctor: user_name,
  38453. }
  38454. if config.IsOpen == 1 {
  38455. if miConfig.MdtrtareaAdmvs == "430800" {
  38456. for _, item := range queryResult {
  38457. var result string
  38458. if record_type == 1 {
  38459. 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)
  38460. } else if record_type == 2 {
  38461. fmt.Println(item.Code)
  38462. 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)
  38463. } else if record_type == 3 {
  38464. 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)
  38465. }
  38466. var dat map[string]interface{}
  38467. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38468. fmt.Println(dat)
  38469. } else {
  38470. fmt.Println(err)
  38471. }
  38472. userJSONBytes, _ := json.Marshal(dat)
  38473. var res ResultSix
  38474. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38475. utils.ErrorLog("解析失败:%v", err)
  38476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38477. return
  38478. }
  38479. if res.Infcode == 0 {
  38480. if record_type == 1 {
  38481. service.UpdateBaseDrugById(item.ID)
  38482. } else if record_type == 2 {
  38483. service.UpdateGoodInformaitonByDetail(item.ID)
  38484. } else if record_type == 3 {
  38485. service.UpdateProjectById(item.ID)
  38486. }
  38487. c.ServeSuccessJSON(map[string]interface{}{
  38488. "failed_code": 0,
  38489. "msg": "目录对照成功",
  38490. })
  38491. } else {
  38492. c.ServeSuccessJSON(map[string]interface{}{
  38493. "failed_code": -10,
  38494. "msg": res.ErrMsg,
  38495. })
  38496. }
  38497. }
  38498. } else {
  38499. for _, item := range queryResult {
  38500. var result string
  38501. if record_type == 1 {
  38502. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38503. } else if record_type == 2 {
  38504. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38505. } else if record_type == 3 {
  38506. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38507. }
  38508. var dat2 map[string]interface{}
  38509. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  38510. fmt.Println(dat2)
  38511. } else {
  38512. fmt.Println(err)
  38513. }
  38514. userJSONBytes, _ := json.Marshal(dat2)
  38515. var res ResultSix
  38516. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38517. utils.ErrorLog("解析失败:%v", err)
  38518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38519. return
  38520. }
  38521. if res.Infcode == 0 {
  38522. if record_type == 1 {
  38523. service.UpdateDrugByIdDetail(item.ID)
  38524. } else if record_type == 2 {
  38525. service.UpdateGoodInfoById(item.ID)
  38526. } else if record_type == 3 {
  38527. service.UpdateMyProjectById(item.ID)
  38528. }
  38529. c.ServeSuccessJSON(map[string]interface{}{
  38530. "failed_code": 0,
  38531. "msg": "撤销目录对照成功",
  38532. })
  38533. } else {
  38534. c.ServeSuccessJSON(map[string]interface{}{
  38535. "failed_code": -10,
  38536. "msg": res.ErrMsg,
  38537. })
  38538. }
  38539. }
  38540. }
  38541. }
  38542. }
  38543. func (c *HisApiController) GetPatientInfo() {
  38544. id_card_no := c.GetString("id_card_no")
  38545. admin_user_id, _ := c.GetInt64("admin_user_id")
  38546. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  38547. if patient.ID == 0 {
  38548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  38549. return
  38550. }
  38551. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  38552. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38553. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  38554. var res ResultTwo
  38555. var res10265 ResultTwo10265
  38556. if config.IsOpen == 1 {
  38557. if miConfig.MdtrtareaAdmvs == "150404" {
  38558. //请求内网数据
  38559. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  38560. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38561. "&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
  38562. resp, requestErr := http.Get(api)
  38563. if requestErr != nil {
  38564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38565. return
  38566. }
  38567. body, ioErr := ioutil.ReadAll(resp.Body)
  38568. if ioErr != nil {
  38569. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38571. return
  38572. }
  38573. var respJSON map[string]interface{}
  38574. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38577. return
  38578. }
  38579. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38580. result_byte, _ := json.Marshal(respJSON)
  38581. result := string(result_byte)
  38582. var dat map[string]interface{}
  38583. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38584. fmt.Println(dat)
  38585. } else {
  38586. fmt.Println(err)
  38587. }
  38588. userJSONBytes, _ := json.Marshal(dat)
  38589. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  38590. utils.ErrorLog("解析失败:%v", err)
  38591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38592. return
  38593. }
  38594. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38595. res.Infcode = Infcode
  38596. res.ErrMsg = res10265.ErrMsg
  38597. res.Output = res10265.Output
  38598. res.InfRefmsgid = res10265.InfRefmsgid
  38599. res.RespondTime = res10265.RespondTime
  38600. res.WarnInfo = res10265.WarnInfo
  38601. } else {
  38602. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  38603. var dat map[string]interface{}
  38604. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38605. fmt.Println(dat)
  38606. } else {
  38607. fmt.Println(err)
  38608. }
  38609. userJSONBytes, _ := json.Marshal(dat)
  38610. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38611. utils.ErrorLog("解析失败:%v", err)
  38612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38613. return
  38614. }
  38615. }
  38616. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38617. // utils.ErrorLog("解析失败:%v", err)
  38618. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38619. // return
  38620. //}
  38621. for index, item := range res.Output.Iinfo {
  38622. if item.PsnInsuStas == "2" {
  38623. fmt.Println("--------")
  38624. res.Output.Iinfo[index].Insutype = "300"
  38625. res.Output.Iinfo[index].PsnInsuStas = "1"
  38626. }
  38627. }
  38628. fmt.Println(res.Output.Iinfo)
  38629. if res.Infcode != 0 {
  38630. c.ServeSuccessJSON(map[string]interface{}{
  38631. "failed_code": -10,
  38632. "msg": res.ErrMsg,
  38633. })
  38634. } else {
  38635. c.ServeSuccessJSON(map[string]interface{}{
  38636. "failed_code": 0,
  38637. "info": res,
  38638. })
  38639. }
  38640. }
  38641. }
  38642. func (c *HisApiController) PsnPutOnRecord() {
  38643. record_type, _ := c.GetInt64("type")
  38644. patient_id, _ := c.GetInt64("patient_id")
  38645. admin_user_id, _ := c.GetInt64("admin_user_id")
  38646. start_time := c.GetString("start_time")
  38647. end_time := c.GetString("end_time")
  38648. adminUser := c.GetAdminUserInfo()
  38649. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38650. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38651. var patients []*models.Patients
  38652. if record_type == 1 { //全部备案
  38653. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  38654. patients = append(patients, patient...)
  38655. } else { //单个备案
  38656. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  38657. patients = append(patients, patient)
  38658. }
  38659. var user_name string
  38660. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38661. if role.ID == 0 {
  38662. user_name = "xxx"
  38663. } else {
  38664. user_name = role.UserName
  38665. }
  38666. if config.IsOpen == 1 {
  38667. for _, item := range patients {
  38668. 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
  38669. resp, requestErr := http.Get(api)
  38670. if requestErr != nil {
  38671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38672. return
  38673. }
  38674. defer resp.Body.Close()
  38675. body, ioErr := ioutil.ReadAll(resp.Body)
  38676. if ioErr != nil {
  38677. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38679. return
  38680. }
  38681. var respJSON map[string]interface{}
  38682. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38683. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38685. return
  38686. }
  38687. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38688. userJSONBytes, _ := json.Marshal(userJSON)
  38689. var res ResultTwo
  38690. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38691. utils.ErrorLog("解析失败:%v", err)
  38692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38693. return
  38694. }
  38695. if res.Infcode == 0 {
  38696. 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)
  38697. var dat map[string]interface{}
  38698. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38699. fmt.Println(dat)
  38700. } else {
  38701. fmt.Println(err)
  38702. }
  38703. userJSONBytes, _ := json.Marshal(dat)
  38704. var res2 ResultThirteen
  38705. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  38706. utils.ErrorLog("解析失败:%v", err)
  38707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38708. return
  38709. }
  38710. if res2.Infcode == 0 {
  38711. psnResult := &models.GdybPsnRecord{
  38712. UserOrgId: adminUser.CurrentOrgId,
  38713. PatientId: item.ID,
  38714. PsnNo: res.Output.Baseinfo.PsnNo,
  38715. Ctime: time.Now().Unix(),
  38716. Mtime: time.Now().Unix(),
  38717. Status: 1,
  38718. IsCancel: 1,
  38719. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  38720. }
  38721. service.CreatePsnRecord(psnResult)
  38722. } else {
  38723. c.ServeSuccessJSON(map[string]interface{}{
  38724. "failed_code": -10,
  38725. "msg": res2.ErrMsg,
  38726. })
  38727. return
  38728. }
  38729. }
  38730. }
  38731. }
  38732. }
  38733. func (c *HisApiController) PsnUnPutOnRecord() {
  38734. id, _ := c.GetInt64("id")
  38735. //record_type, _ := c.GetInt64("type")
  38736. admin_user_id, _ := c.GetInt64("admin_user_id")
  38737. adminUser := c.GetAdminUserInfo()
  38738. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38739. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38740. var user_name string
  38741. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38742. if role.ID == 0 {
  38743. user_name = "xxx"
  38744. } else {
  38745. user_name = role.UserName
  38746. }
  38747. psn_record, _ := service.GetPsnRecordById(id)
  38748. if psn_record.ID == 0 {
  38749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  38750. return
  38751. }
  38752. if config.IsOpen == 1 {
  38753. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  38754. var dat map[string]interface{}
  38755. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38756. fmt.Println(dat)
  38757. } else {
  38758. fmt.Println(err)
  38759. }
  38760. userJSONBytes, _ := json.Marshal(dat)
  38761. var res ResultFourteen
  38762. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38763. utils.ErrorLog("解析失败:%v", err)
  38764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38765. return
  38766. }
  38767. if res.Infcode == 0 {
  38768. psn_record.IsCancel = 2
  38769. service.CreatePsnRecord(&psn_record)
  38770. } else {
  38771. c.ServeSuccessJSON(map[string]interface{}{
  38772. "failed_code": -10,
  38773. "msg": res.ErrMsg,
  38774. })
  38775. return
  38776. }
  38777. }
  38778. }
  38779. func (c *HisApiController) PsnPutNCDSOnRecord() {
  38780. patient_id, _ := c.GetInt64("patient_id")
  38781. insutype_two := c.GetString("insutype")
  38782. psn_no := c.GetString("psn_no")
  38783. doctor_id, _ := c.GetInt64("doctor_id")
  38784. sick_id, _ := c.GetInt64("sick_id")
  38785. department_id, _ := c.GetInt64("department_id")
  38786. start_time := c.GetString("start_time")
  38787. end_time := c.GetString("end_time")
  38788. check_time := c.GetString("check_time")
  38789. hospital_code := c.GetString("hospital_code")
  38790. hospital_name := c.GetString("hospital_name")
  38791. adminUser := c.GetAdminUserInfo()
  38792. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  38793. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38794. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38795. sick, _ := service.FindSickById(sick_id)
  38796. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  38797. if len(hospital_code) == 0 {
  38798. hospital_code = miConfig.Code
  38799. }
  38800. if len(hospital_name) == 0 {
  38801. hospital_name = miConfig.OrgName
  38802. }
  38803. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  38804. var res ResultTwo
  38805. var res10265 ResultTwo10265
  38806. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  38807. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  38808. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  38809. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38810. "&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
  38811. resp, requestErr := http.Get(api)
  38812. if requestErr != nil {
  38813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38814. return
  38815. }
  38816. body, ioErr := ioutil.ReadAll(resp.Body)
  38817. if ioErr != nil {
  38818. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38820. return
  38821. }
  38822. var respJSON map[string]interface{}
  38823. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38826. return
  38827. }
  38828. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38829. result, _ := json.Marshal(respJSON)
  38830. fmt.Println("log")
  38831. fmt.Println(string(result))
  38832. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38833. utils.ErrorLog("解析失败:%v", err)
  38834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38835. return
  38836. }
  38837. res.ErrMsg = res10265.ErrMsg
  38838. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38839. res.Infcode = infocode
  38840. res.Output = res10265.Output
  38841. res.InfRefmsgid = res10265.InfRefmsgid
  38842. } else {
  38843. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  38844. if miConfig.Code == "H15049901371" {
  38845. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38846. utils.ErrorLog("解析失败:%v", err)
  38847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38848. return
  38849. }
  38850. res.ErrMsg = res10265.ErrMsg
  38851. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38852. res.Infcode = infocode
  38853. res.Output = res10265.Output
  38854. res.InfRefmsgid = res10265.InfRefmsgid
  38855. } else {
  38856. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38857. utils.ErrorLog("解析失败:%v", err)
  38858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38859. return
  38860. }
  38861. }
  38862. }
  38863. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38864. infoStr := string(Iinfos)
  38865. var rf []*ResultFive
  38866. json.Unmarshal([]byte(infoStr), &rf)
  38867. var insuplc_admdvs string
  38868. var insutype string
  38869. var is390 int = 0
  38870. var is310 int = 0
  38871. var insutypes []*ResultFive
  38872. for _, item := range rf {
  38873. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  38874. insutypes = append(insutypes, item)
  38875. }
  38876. }
  38877. if len(insutypes) == 1 {
  38878. insutype = insutypes[0].Insutype
  38879. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  38880. } else {
  38881. for _, i := range insutypes {
  38882. if i.Insutype == "390" {
  38883. is390 = 1
  38884. }
  38885. if i.Insutype == "310" {
  38886. is310 = 1
  38887. }
  38888. }
  38889. }
  38890. if is390 == 1 {
  38891. insutype = "390"
  38892. }
  38893. if is310 == 1 {
  38894. insutype = "310"
  38895. }
  38896. if len(insutypes) == 2 {
  38897. insutype = insutype_two
  38898. }
  38899. if len(insutypes) == 0 {
  38900. insutype = "310"
  38901. }
  38902. insutype = insutype_two
  38903. fmt.Println(insutype)
  38904. for _, item := range rf {
  38905. fmt.Println(item.Insutype)
  38906. fmt.Println(insutype)
  38907. if item.Insutype == insutype {
  38908. fmt.Println(item.Insutype)
  38909. fmt.Println(insutype)
  38910. insuplc_admdvs = item.InsuplcAdmdvs
  38911. }
  38912. }
  38913. fmt.Println(insuplc_admdvs)
  38914. var res2 ResultThirteen
  38915. var res10265_2 ResultThirteen10265
  38916. if config.IsOpen == 1 {
  38917. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  38918. } else {
  38919. if miConfig.MdtrtareaAdmvs == "150404" {
  38920. //
  38921. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  38922. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38923. // "&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
  38924. //resp, requestErr := http.Get(api)
  38925. //if requestErr != nil {
  38926. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38927. // return
  38928. //}
  38929. //
  38930. //body, ioErr := ioutil.ReadAll(resp.Body)
  38931. //if ioErr != nil {
  38932. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38933. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38934. // return
  38935. //}
  38936. //var respJSON map[string]interface{}
  38937. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38938. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38939. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38940. // return
  38941. //}
  38942. //
  38943. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38944. //result, _ := json.Marshal(respJSON)
  38945. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  38946. // utils.ErrorLog("解析失败:%v", err)
  38947. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38948. // return
  38949. //}
  38950. //infocode = resThree.Infcode
  38951. //result, _ := json.Marshal(respJSON)
  38952. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  38953. // utils.ErrorLog("解析失败:%v", err)
  38954. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38955. // return
  38956. //}
  38957. //
  38958. //resThree.ErrMsg = resThree10265.ErrMsg
  38959. //
  38960. //resThree.Output = resThree10265.Output
  38961. //
  38962. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  38963. //
  38964. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  38965. //
  38966. } else {
  38967. 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)
  38968. var dat map[string]interface{}
  38969. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38970. fmt.Println(dat)
  38971. } else {
  38972. fmt.Println(err)
  38973. }
  38974. userJSONBytes, _ := json.Marshal(dat)
  38975. if miConfig.Code == "H15049901371" {
  38976. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  38977. utils.ErrorLog("解析失败:%v", err)
  38978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38979. return
  38980. }
  38981. res2.ErrMsg = res10265_2.ErrMsg
  38982. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  38983. res2.Infcode = infocode
  38984. res2.Output = res10265_2.Output
  38985. res2.InfRefmsgid = res10265_2.InfRefmsgid
  38986. } else {
  38987. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  38988. utils.ErrorLog("解析失败:%v", err)
  38989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38990. return
  38991. }
  38992. }
  38993. }
  38994. }
  38995. if res2.Infcode == 0 {
  38996. psnResult := &models.GdybPsnNcdsRecord{
  38997. UserOrgId: adminUser.CurrentOrgId,
  38998. PatientId: patient.ID,
  38999. PsnNo: psn_no,
  39000. DoctorId: doctor.AdminUserId,
  39001. DepartmentId: department_id,
  39002. SickType: sick_id,
  39003. Insutype: insutype,
  39004. Ctime: time.Now().Unix(),
  39005. Mtime: time.Now().Unix(),
  39006. Status: 1,
  39007. IsCancel: 1,
  39008. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  39009. }
  39010. service.CreatePsnNCDSRecord(psnResult)
  39011. c.ServeSuccessJSON(map[string]interface{}{
  39012. "failed_code": 0,
  39013. "msg": "备案成功",
  39014. "result": psnResult,
  39015. })
  39016. } else {
  39017. c.ServeSuccessJSON(map[string]interface{}{
  39018. "failed_code": -10,
  39019. "msg": res2.ErrMsg,
  39020. })
  39021. return
  39022. }
  39023. }
  39024. }
  39025. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  39026. id, _ := c.GetInt64("id")
  39027. admin_user_id, _ := c.GetInt64("admin_user_id")
  39028. adminUser := c.GetAdminUserInfo()
  39029. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39030. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39031. //config, _ := service.Ge(adminUser.CurrentOrgId)
  39032. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  39033. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39034. //var user_name string
  39035. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39036. //if role.ID == 0 {
  39037. // user_name = "xxx"
  39038. //} else {
  39039. // user_name = role.UserName
  39040. //}
  39041. psn_record, _ := service.GetPsnNCDSRecordById(id)
  39042. if psn_record.ID == 0 {
  39043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  39044. return
  39045. }
  39046. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  39047. var res ResultTwo
  39048. var res10265 ResultTwo10265
  39049. if miConfig.Code == "H15049901371" {
  39050. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  39051. utils.ErrorLog("解析失败:%v", err)
  39052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39053. return
  39054. }
  39055. res.ErrMsg = res10265.ErrMsg
  39056. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39057. res.Infcode = infocode
  39058. res.Output = res10265.Output
  39059. res.InfRefmsgid = res10265.InfRefmsgid
  39060. } else {
  39061. if err := json.Unmarshal([]byte(result), &res); err != nil {
  39062. utils.ErrorLog("解析失败:%v", err)
  39063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39064. return
  39065. }
  39066. }
  39067. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39068. infoStr := string(Iinfos)
  39069. var rf []*ResultFive
  39070. json.Unmarshal([]byte(infoStr), &rf)
  39071. var insuplc_admdvs string
  39072. var insutype string
  39073. var is390 int = 0
  39074. var is310 int = 0
  39075. var insutypes []*ResultFive
  39076. for _, item := range rf {
  39077. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  39078. insutypes = append(insutypes, item)
  39079. }
  39080. }
  39081. if len(insutypes) == 1 {
  39082. insutype = insutypes[0].Insutype
  39083. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  39084. } else {
  39085. for _, i := range insutypes {
  39086. if i.Insutype == "390" {
  39087. is390 = 1
  39088. }
  39089. if i.Insutype == "310" {
  39090. is310 = 1
  39091. }
  39092. }
  39093. }
  39094. if is390 == 1 {
  39095. insutype = "390"
  39096. }
  39097. if is310 == 1 {
  39098. insutype = "310"
  39099. }
  39100. if len(insutypes) == 0 {
  39101. insutype = "310"
  39102. }
  39103. insutype = psn_record.Insutype
  39104. for _, item := range rf {
  39105. if item.Insutype == insutype {
  39106. insuplc_admdvs = item.InsuplcAdmdvs
  39107. }
  39108. }
  39109. if config.IsOpen == 1 {
  39110. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  39111. var dat map[string]interface{}
  39112. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39113. fmt.Println(dat)
  39114. } else {
  39115. fmt.Println(err)
  39116. }
  39117. userJSONBytes, _ := json.Marshal(dat)
  39118. var res ResultFourteen
  39119. var res10265 ResultFourteen10265
  39120. if miConfig.Code == "H15049901371" {
  39121. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  39122. utils.ErrorLog("解析失败:%v", err)
  39123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39124. return
  39125. }
  39126. res.ErrMsg = res10265.ErrMsg
  39127. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39128. res.Infcode = infocode
  39129. res.Output = res10265.Output
  39130. res.InfRefmsgid = res10265.InfRefmsgid
  39131. } else {
  39132. if err := json.Unmarshal([]byte(result), &res); err != nil {
  39133. utils.ErrorLog("解析失败:%v", err)
  39134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39135. return
  39136. }
  39137. }
  39138. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39139. // utils.ErrorLog("解析失败:%v", err)
  39140. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39141. // return
  39142. //}
  39143. if res.Infcode == 0 {
  39144. psn_record.IsCancel = 2
  39145. service.CreatePsnNCDSRecord(&psn_record)
  39146. c.ServeSuccessJSON(map[string]interface{}{
  39147. "failed_code": 0,
  39148. "msg": "撤销备案成功",
  39149. })
  39150. } else {
  39151. c.ServeSuccessJSON(map[string]interface{}{
  39152. "failed_code": -10,
  39153. "msg": res.ErrMsg,
  39154. })
  39155. return
  39156. }
  39157. }
  39158. }
  39159. func (c *HisApiController) TestTest() {
  39160. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  39161. fmt.Println(patient.Iinfo)
  39162. }
  39163. type CustomData struct {
  39164. MsgId string
  39165. PsnNo string
  39166. Info string
  39167. }
  39168. func (c *HisApiController) ReversalData() {
  39169. var customData []*CustomData
  39170. custom := &CustomData{
  39171. MsgId: "H44022900158202103301714472004",
  39172. PsnNo: "44020000001101329945",
  39173. Info: "2207",
  39174. }
  39175. customData = append(customData, custom)
  39176. custom1 := &CustomData{
  39177. MsgId: "H4402290015820210330172057803",
  39178. PsnNo: "44020000001101161813",
  39179. Info: "2207",
  39180. }
  39181. customData = append(customData, custom1)
  39182. custom2 := &CustomData{
  39183. MsgId: "H44022900158202103301705198813",
  39184. PsnNo: "44190000133097375417",
  39185. Info: "2207",
  39186. }
  39187. customData = append(customData, custom2)
  39188. custom3 := &CustomData{
  39189. MsgId: "H44022900158202103301715524756",
  39190. PsnNo: "44020000001100187221",
  39191. Info: "2207",
  39192. }
  39193. customData = append(customData, custom3)
  39194. custom4 := &CustomData{
  39195. MsgId: "H44022900158202103301730376224",
  39196. PsnNo: "44020000001101959155",
  39197. Info: "2207",
  39198. }
  39199. customData = append(customData, custom4)
  39200. custom5 := &CustomData{
  39201. MsgId: "H44022900158202103301748008725",
  39202. PsnNo: "44020000001104246641",
  39203. Info: "2207",
  39204. }
  39205. customData = append(customData, custom5)
  39206. custom6 := &CustomData{
  39207. MsgId: "H44022900158202103301718096755",
  39208. PsnNo: "44020000001102211860",
  39209. Info: "2207",
  39210. }
  39211. customData = append(customData, custom6)
  39212. custom7 := &CustomData{
  39213. MsgId: "H44022900158202103301736551640",
  39214. PsnNo: "44020000001102687718",
  39215. Info: "2207",
  39216. }
  39217. customData = append(customData, custom7)
  39218. custom8 := &CustomData{
  39219. MsgId: "H44022900158202103301743097676",
  39220. PsnNo: "44020000001102127785",
  39221. Info: "2207",
  39222. }
  39223. customData = append(customData, custom8)
  39224. custom9 := &CustomData{
  39225. MsgId: "H44022900158202103301712304203",
  39226. PsnNo: "44020000001101518097",
  39227. Info: "2207",
  39228. }
  39229. customData = append(customData, custom9)
  39230. custom10 := &CustomData{
  39231. MsgId: "H44022900158202103301738448785",
  39232. PsnNo: "44020000001100500813",
  39233. Info: "2207",
  39234. }
  39235. customData = append(customData, custom10)
  39236. custom11 := &CustomData{
  39237. MsgId: "H44022900158202103301732455843",
  39238. PsnNo: "44020000001102690557",
  39239. Info: "2207",
  39240. }
  39241. customData = append(customData, custom11)
  39242. custom12 := &CustomData{
  39243. MsgId: "H44022900158202103301745421708",
  39244. PsnNo: "44020000001102211928",
  39245. Info: "2207",
  39246. }
  39247. customData = append(customData, custom12)
  39248. custom1212 := &CustomData{
  39249. MsgId: "H440229001582021033017351627",
  39250. PsnNo: "44020000001102481733",
  39251. Info: "2207",
  39252. }
  39253. customData = append(customData, custom1212)
  39254. custom13 := &CustomData{
  39255. MsgId: "H44022900158202103301740327951",
  39256. PsnNo: "44020000001103174866",
  39257. Info: "2207",
  39258. }
  39259. customData = append(customData, custom13)
  39260. custom14 := &CustomData{
  39261. MsgId: "H4402290015820210330174922668",
  39262. PsnNo: "44020000001102927272",
  39263. Info: "2207",
  39264. }
  39265. customData = append(customData, custom14)
  39266. custom15 := &CustomData{
  39267. MsgId: "H44022900158202103301752362273",
  39268. PsnNo: "44020000001102942890",
  39269. Info: "2207",
  39270. }
  39271. customData = append(customData, custom15)
  39272. custom16 := &CustomData{
  39273. MsgId: "H44022900158202103301751082917",
  39274. PsnNo: "44020000001101662162",
  39275. Info: "2207",
  39276. }
  39277. customData = append(customData, custom16)
  39278. custom17 := &CustomData{
  39279. MsgId: "H44022900158202103301754147728",
  39280. PsnNo: "44020000000229014511",
  39281. Info: "2207",
  39282. }
  39283. customData = append(customData, custom17)
  39284. adminUser := c.GetAdminUserInfo()
  39285. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39286. for _, item := range customData {
  39287. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  39288. fmt.Println(result)
  39289. }
  39290. }
  39291. func (c *HisApiController) GetAllopatry() {
  39292. year := c.GetString("year")
  39293. month := c.GetString("month")
  39294. admin_user_id, _ := c.GetInt64("admin_user_id")
  39295. adminUser := c.GetAdminUserInfo()
  39296. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39297. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39298. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  39299. var dat map[string]interface{}
  39300. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39301. fmt.Println(dat)
  39302. } else {
  39303. fmt.Println(err)
  39304. }
  39305. userJSONBytes, _ := json.Marshal(dat)
  39306. var res models.Result9001
  39307. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39308. utils.ErrorLog("解析失败:%v", err)
  39309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39310. return
  39311. }
  39312. fmt.Println(res.Output.Signinoutb)
  39313. fmt.Println(res.Output.Signinoutb.SignNo)
  39314. fmt.Println(string(userJSONBytes))
  39315. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  39316. var dat3 map[string]interface{}
  39317. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  39318. fmt.Println(dat3)
  39319. } else {
  39320. fmt.Println(err)
  39321. }
  39322. userJSONBytes3, _ := json.Marshal(dat3)
  39323. var res3 models.Result3260
  39324. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  39325. utils.ErrorLog("解析失败:%v", err)
  39326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39327. return
  39328. }
  39329. var curpage int
  39330. var pagesize int = 100
  39331. var start int = 1
  39332. //var stop int
  39333. //pagecount := 10
  39334. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  39335. var res22 []models.Result3260
  39336. for curpage = 1; curpage <= pagecount; curpage++ {
  39337. if curpage == 1 {
  39338. start = 0
  39339. } else {
  39340. start = (curpage-1)*pagesize + 1
  39341. }
  39342. fmt.Println(start)
  39343. //stop = curpage * pagesize
  39344. //if stop > int(res3.Output.Totalrow) {
  39345. // stop =int(res3.Output.Totalrow)
  39346. //}
  39347. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  39348. var dat2 map[string]interface{}
  39349. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  39350. fmt.Println(dat)
  39351. } else {
  39352. fmt.Println(err)
  39353. }
  39354. userJSONBytes2, _ := json.Marshal(dat2)
  39355. var res2 models.Result3260
  39356. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  39357. utils.ErrorLog("解析失败:%v", err)
  39358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39359. return
  39360. }
  39361. if res2.Infcode == 0 {
  39362. res22 = append(res22, res2)
  39363. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  39364. //var dat2 map[string]interface{}
  39365. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  39366. // fmt.Println(dat)
  39367. //} else {
  39368. // fmt.Println(err)
  39369. //}
  39370. //c.ServeSuccessJSON(map[string]interface{}{
  39371. // "list": res2.Output.Data,
  39372. //})
  39373. //continue
  39374. }
  39375. }
  39376. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  39377. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  39378. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  39379. //var dat2 map[string]interface{}
  39380. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  39381. // fmt.Println(dat)
  39382. //} else {
  39383. // fmt.Println(err)
  39384. //}
  39385. //userJSONBytes2, _ := json.Marshal(dat2)
  39386. //var res2 models.Result3260
  39387. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  39388. // utils.ErrorLog("解析失败:%v", err)
  39389. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39390. // return
  39391. //}
  39392. //if res2.Infcode == 0 {
  39393. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  39394. // var dat2 map[string]interface{}
  39395. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  39396. // fmt.Println(dat)
  39397. // } else {
  39398. // fmt.Println(err)
  39399. // }
  39400. // c.ServeSuccessJSON(map[string]interface{}{
  39401. // "list": res2.Output.Data,
  39402. // })
  39403. //}
  39404. }
  39405. func (c *HisApiController) ComfirmAllopatry() {
  39406. year := c.GetString("year")
  39407. month := c.GetString("month")
  39408. admin_user_id, _ := c.GetInt64("admin_user_id")
  39409. adminUser := c.GetAdminUserInfo()
  39410. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39411. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39412. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  39413. var dat map[string]interface{}
  39414. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39415. fmt.Println(dat)
  39416. } else {
  39417. fmt.Println(err)
  39418. }
  39419. userJSONBytes, _ := json.Marshal(dat)
  39420. var res models.Result9001
  39421. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39422. utils.ErrorLog("解析失败:%v", err)
  39423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39424. return
  39425. }
  39426. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  39427. var dat2 map[string]interface{}
  39428. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  39429. fmt.Println(dat)
  39430. } else {
  39431. fmt.Println(err)
  39432. }
  39433. userJSONBytes2, _ := json.Marshal(dat2)
  39434. var res2 models.Result3260
  39435. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  39436. utils.ErrorLog("解析失败:%v", err)
  39437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39438. return
  39439. }
  39440. //if res2.Infcode == 0 {
  39441. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  39442. // var dat map[string]interface{}
  39443. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39444. // fmt.Println(dat)
  39445. // } else {
  39446. // fmt.Println(err)
  39447. // }
  39448. // userJSONBytes, _ := json.Marshal(dat)
  39449. // var res3 models.Result3261
  39450. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  39451. // utils.ErrorLog("解析失败:%v", err)
  39452. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39453. // return
  39454. // }
  39455. //
  39456. // if res3.Infcode == 0 {
  39457. // record := &models.HisYidiClearRecord{
  39458. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39459. // Ctime: time.Now().Unix(),
  39460. // Mtime: time.Now().Unix(),
  39461. // Status: 1,
  39462. // MsgId: msgId,
  39463. // }
  39464. // service.SaveClearRecord(record)
  39465. // c.ServeSuccessJSON(map[string]interface{}{
  39466. // "msg": "提取成功",
  39467. // })
  39468. // }
  39469. //}
  39470. }
  39471. func (c *HisApiController) RefundAllopatry() {
  39472. year := c.GetString("year")
  39473. month := c.GetString("month")
  39474. //id, _ := c.GetInt64("id")
  39475. admin_user_id, _ := c.GetInt64("admin_user_id")
  39476. adminUser := c.GetAdminUserInfo()
  39477. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39478. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39479. //record, _ := service.GetClearRecordById(id)
  39480. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  39481. var dat map[string]interface{}
  39482. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  39483. fmt.Println(dat)
  39484. } else {
  39485. fmt.Println(err)
  39486. }
  39487. userJSONBytes, _ := json.Marshal(dat)
  39488. var res models.Result9001
  39489. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39490. utils.ErrorLog("解析失败:%v", err)
  39491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39492. return
  39493. }
  39494. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  39495. var dat2 map[string]interface{}
  39496. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  39497. fmt.Println(dat)
  39498. } else {
  39499. fmt.Println(err)
  39500. }
  39501. userJSONBytes2, _ := json.Marshal(dat2)
  39502. var empty ResultFourteen
  39503. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  39504. utils.ErrorLog("解析失败:%v", err)
  39505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39506. return
  39507. }
  39508. if empty.Infcode == 0 {
  39509. c.ServeSuccessJSON(map[string]interface{}{
  39510. "msg": "撤销成功",
  39511. })
  39512. return
  39513. }
  39514. }
  39515. func (c *HisApiController) ReversalOtherData() {
  39516. var customData []*CustomData
  39517. custom := &CustomData{
  39518. MsgId: "H44022900158202103301714472004",
  39519. PsnNo: "44020000001101329945",
  39520. Info: "2208",
  39521. }
  39522. customData = append(customData, custom)
  39523. custom1 := &CustomData{
  39524. MsgId: "H4402290015820210330172057803",
  39525. PsnNo: "44020000001101161813",
  39526. Info: "2208",
  39527. }
  39528. customData = append(customData, custom1)
  39529. custom2 := &CustomData{
  39530. MsgId: "H44022900158202103301705198813",
  39531. PsnNo: "44190000133097375417",
  39532. Info: "2208",
  39533. }
  39534. customData = append(customData, custom2)
  39535. custom3 := &CustomData{
  39536. MsgId: "H44022900158202103301715524756",
  39537. PsnNo: "44020000001100187221",
  39538. Info: "2208",
  39539. }
  39540. customData = append(customData, custom3)
  39541. custom4 := &CustomData{
  39542. MsgId: "H44022900158202103301730376224",
  39543. PsnNo: "44020000001101959155",
  39544. Info: "2208",
  39545. }
  39546. customData = append(customData, custom4)
  39547. custom5 := &CustomData{
  39548. MsgId: "H44022900158202103301748008725",
  39549. PsnNo: "44020000001104246641",
  39550. Info: "2208",
  39551. }
  39552. customData = append(customData, custom5)
  39553. custom6 := &CustomData{
  39554. MsgId: "H44022900158202103301718096755",
  39555. PsnNo: "44020000001102211860",
  39556. Info: "2208",
  39557. }
  39558. customData = append(customData, custom6)
  39559. custom7 := &CustomData{
  39560. MsgId: "H44022900158202103301736551640",
  39561. PsnNo: "44020000001102687718",
  39562. Info: "2208",
  39563. }
  39564. customData = append(customData, custom7)
  39565. custom8 := &CustomData{
  39566. MsgId: "H44022900158202103301743097676",
  39567. PsnNo: "44020000001102127785",
  39568. Info: "2208",
  39569. }
  39570. customData = append(customData, custom8)
  39571. custom9 := &CustomData{
  39572. MsgId: "H44022900158202103301712304203",
  39573. PsnNo: "44020000001101518097",
  39574. Info: "2208",
  39575. }
  39576. customData = append(customData, custom9)
  39577. custom10 := &CustomData{
  39578. MsgId: "H44022900158202103301738448785",
  39579. PsnNo: "44020000001100500813",
  39580. Info: "2208",
  39581. }
  39582. customData = append(customData, custom10)
  39583. custom11 := &CustomData{
  39584. MsgId: "H44022900158202103301732455843",
  39585. PsnNo: "44020000001102690557",
  39586. Info: "2208",
  39587. }
  39588. customData = append(customData, custom11)
  39589. custom12 := &CustomData{
  39590. MsgId: "H44022900158202103301745421708",
  39591. PsnNo: "44020000001102211928",
  39592. Info: "2208",
  39593. }
  39594. customData = append(customData, custom12)
  39595. custom1212 := &CustomData{
  39596. MsgId: "H440229001582021033017351627",
  39597. PsnNo: "44020000001102481733",
  39598. Info: "2208",
  39599. }
  39600. customData = append(customData, custom1212)
  39601. custom13 := &CustomData{
  39602. MsgId: "H44022900158202103301740327951",
  39603. PsnNo: "44020000001103174866",
  39604. Info: "2208",
  39605. }
  39606. customData = append(customData, custom13)
  39607. custom14 := &CustomData{
  39608. MsgId: "H4402290015820210330174922668",
  39609. PsnNo: "44020000001102927272",
  39610. Info: "2208",
  39611. }
  39612. customData = append(customData, custom14)
  39613. custom15 := &CustomData{
  39614. MsgId: "H44022900158202103301752362273",
  39615. PsnNo: "44020000001102942890",
  39616. Info: "2208",
  39617. }
  39618. customData = append(customData, custom15)
  39619. custom16 := &CustomData{
  39620. MsgId: "H44022900158202103301751082917",
  39621. PsnNo: "44020000001101662162",
  39622. Info: "2208",
  39623. }
  39624. customData = append(customData, custom16)
  39625. custom17 := &CustomData{
  39626. MsgId: "H44022900158202103301754147728",
  39627. PsnNo: "44020000000229014511",
  39628. Info: "2208",
  39629. }
  39630. customData = append(customData, custom17)
  39631. adminUser := c.GetAdminUserInfo()
  39632. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39633. for _, item := range customData {
  39634. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  39635. fmt.Println(result)
  39636. }
  39637. }
  39638. func PathExists(path string) (bool, error) {
  39639. _, err := os.Stat(path)
  39640. if err == nil {
  39641. return true, nil
  39642. }
  39643. if os.IsNotExist(err) {
  39644. return false, nil
  39645. }
  39646. return false, err
  39647. }
  39648. // 创建文件夹
  39649. func Mkdir(dir string) {
  39650. // 创建文件夹
  39651. exist, err := PathExists(dir)
  39652. if err != nil {
  39653. fmt.Println(err.Error())
  39654. } else {
  39655. if exist {
  39656. fmt.Println(dir + "文件夹已存在!")
  39657. } else {
  39658. // 文件夹名称,权限
  39659. err := os.Mkdir(dir, os.ModePerm)
  39660. if err != nil {
  39661. fmt.Println(dir+"文件夹创建失败:", err.Error())
  39662. } else {
  39663. fmt.Println(dir + "文件夹创建成功!")
  39664. }
  39665. }
  39666. }
  39667. }
  39668. // 压缩文件
  39669. func Zip(srcFile string, destZip string) error {
  39670. zipfile, err := os.Create(destZip)
  39671. if err != nil {
  39672. return err
  39673. }
  39674. defer zipfile.Close()
  39675. archive := zip.NewWriter(zipfile)
  39676. defer archive.Close()
  39677. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  39678. if err != nil {
  39679. return err
  39680. }
  39681. header, err := zip.FileInfoHeader(info)
  39682. if err != nil {
  39683. return err
  39684. }
  39685. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  39686. // header.Name = path
  39687. if info.IsDir() {
  39688. header.Name += "/"
  39689. } else {
  39690. header.Method = zip.Deflate
  39691. }
  39692. writer, err := archive.CreateHeader(header)
  39693. if err != nil {
  39694. return err
  39695. }
  39696. if !info.IsDir() {
  39697. file, err := os.Open(path)
  39698. if err != nil {
  39699. return err
  39700. }
  39701. defer file.Close()
  39702. _, err = io.Copy(writer, file)
  39703. }
  39704. return err
  39705. })
  39706. return err
  39707. }
  39708. func ReadFile(filePath string) []byte {
  39709. f, err := os.Open(filePath)
  39710. if err != nil {
  39711. fmt.Println("read file fail", err)
  39712. return nil
  39713. }
  39714. defer f.Close()
  39715. fd, err := ioutil.ReadAll(f)
  39716. if err != nil {
  39717. fmt.Println("read to fd fail", err)
  39718. return nil
  39719. }
  39720. return fd
  39721. }
  39722. func saveLogq(result string, request string, infno string, desc string) {
  39723. dir := "日志"
  39724. utils.Mkdir(dir)
  39725. month := time.Unix(1557042972, 0).Format("1")
  39726. year := time.Now().Format("2006")
  39727. month = time.Now().Format("01")
  39728. day := time.Now().Format("02")
  39729. hour := time.Now().Format("15")
  39730. min := time.Now().Format("04")
  39731. sec := time.Now().Format("05")
  39732. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  39733. file := year + month + day + "_log"
  39734. file_name := file + ".txt"
  39735. file_path := "日志" + "/" + file_name
  39736. exist, _ := utils.PathExists(file_path)
  39737. if exist { //存在
  39738. fmt.Println("存在")
  39739. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  39740. if err != nil {
  39741. fmt.Println("read fail")
  39742. }
  39743. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  39744. n, _ := f.Seek(0, 2)
  39745. _, err = f.WriteAt([]byte(content), n)
  39746. } else { //不存在
  39747. fmt.Println("文件不存在,创建文件")
  39748. f, err := os.Create("日志" + "/" + file_name)
  39749. defer f.Close()
  39750. if err != nil {
  39751. } else {
  39752. _, err = f.Write([]byte("记录日志"))
  39753. }
  39754. }
  39755. }
  39756. func saveLog(result string, request string, infno string, desc string) {
  39757. org_id, _ := beego.AppConfig.Int64("org_id")
  39758. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39759. dir := miConfig.OrgName + "日志"
  39760. utils.Mkdir(dir)
  39761. month := time.Unix(1557042972, 0).Format("1")
  39762. year := time.Now().Format("2006")
  39763. month = time.Now().Format("01")
  39764. day := time.Now().Format("02")
  39765. hour := time.Now().Format("15")
  39766. min := time.Now().Format("04")
  39767. sec := time.Now().Format("05")
  39768. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  39769. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  39770. file_name := file + ".txt"
  39771. file_path := miConfig.OrgName + "日志" + "/" + file_name
  39772. exist, _ := utils.PathExists(file_path)
  39773. if exist { //存在
  39774. fmt.Println("存在")
  39775. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  39776. if err != nil {
  39777. fmt.Println("read fail")
  39778. }
  39779. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  39780. n, _ := f.Seek(0, 2)
  39781. _, err = f.WriteAt([]byte(content), n)
  39782. } else { //不存在
  39783. fmt.Println("文件不存在,创建文件")
  39784. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  39785. defer f.Close()
  39786. if err != nil {
  39787. } else {
  39788. _, err = f.Write([]byte("记录日志"))
  39789. }
  39790. }
  39791. }
  39792. type Charset string
  39793. const (
  39794. UTF8 = Charset("UTF-8")
  39795. GB18030 = Charset("GB18030")
  39796. )
  39797. func ConvertToString(src string, srcCode string, tagCode string) string {
  39798. srcCoder := mahonia.NewDecoder(srcCode)
  39799. srcResult := srcCoder.ConvertString(src)
  39800. tagCoder := mahonia.NewDecoder(tagCode)
  39801. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  39802. result := string(cdata)
  39803. return result
  39804. }
  39805. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  39806. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39807. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39808. var token string
  39809. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  39810. var api string
  39811. if miConfig.MdtrtareaAdmvs == "320830" {
  39812. api = miConfig.AppSecret + "jsyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39813. "&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
  39814. fmt.Println(api)
  39815. } else if miConfig.MdtrtareaAdmvs == "320921" {
  39816. 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 +
  39817. "&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
  39818. fmt.Println(api)
  39819. } else {
  39820. 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 +
  39821. "&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
  39822. }
  39823. resp, requestErr := http.Get(api)
  39824. if requestErr != nil {
  39825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39826. return ""
  39827. }
  39828. body, ioErr := ioutil.ReadAll(resp.Body)
  39829. if ioErr != nil {
  39830. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39832. return ""
  39833. }
  39834. var respJSON map[string]interface{}
  39835. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39838. return ""
  39839. }
  39840. var status string
  39841. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39842. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39843. var res ResultTwo //1101结果
  39844. var res10265 ResultTwo10265 //1101结果
  39845. if status == "0" { //读卡成功
  39846. var card_info string //卡信息
  39847. var busi_card_info string
  39848. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39849. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39850. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39851. fmt.Println(card_info)
  39852. fmt.Println(busi_card_info)
  39853. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39854. result, _ := json.Marshal(respJSON)
  39855. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  39856. utils.ErrorLog("解析失败:%v", err)
  39857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39858. return ""
  39859. }
  39860. res.ErrMsg = res10265.ErrMsg
  39861. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39862. res.Infcode = infocode
  39863. res.Output = res10265.Output
  39864. res.InfRefmsgid = res10265.InfRefmsgid
  39865. if res.Infcode == 0 {
  39866. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39867. if err == gorm.ErrRecordNotFound {
  39868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39869. return ""
  39870. } else if err != nil {
  39871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39872. return ""
  39873. } else {
  39874. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39875. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39876. infoStr := string(Iinfos)
  39877. idetinfoStr := string(Idetinfos)
  39878. psn := &models.HisPsn{
  39879. PsnNo: res.Output.Baseinfo.PsnNo,
  39880. PatientId: patient.ID,
  39881. Certno: res.Output.Baseinfo.Certno,
  39882. Gend: res.Output.Baseinfo.Gend,
  39883. Naty: res.Output.Baseinfo.Naty,
  39884. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39885. PsnName: res.Output.Baseinfo.PsnName,
  39886. Idetinfo: idetinfoStr,
  39887. Insuinfo: infoStr,
  39888. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39889. CardInfo: card_info,
  39890. VerifyNumber: token,
  39891. }
  39892. service.CreateHisPsn(psn)
  39893. return token
  39894. }
  39895. }
  39896. } else {
  39897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39898. return ""
  39899. }
  39900. } else { //读卡失败
  39901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39902. return ""
  39903. }
  39904. return token
  39905. }
  39906. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  39907. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39908. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39909. var token string
  39910. var api string
  39911. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39912. "&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
  39913. fmt.Println(api)
  39914. resp, requestErr := http.Get(api)
  39915. if requestErr != nil {
  39916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39917. return ""
  39918. }
  39919. body, ioErr := ioutil.ReadAll(resp.Body)
  39920. if ioErr != nil {
  39921. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39923. return ""
  39924. }
  39925. var respJSON map[string]interface{}
  39926. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39929. return ""
  39930. }
  39931. var status string
  39932. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39933. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39934. var res ResultTwo //1101结果
  39935. if status == "1" { //读卡成功
  39936. var card_info string //卡信息
  39937. var busi_card_info string
  39938. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39939. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39940. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39941. fmt.Println(card_info)
  39942. fmt.Println(busi_card_info)
  39943. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39944. result, _ := json.Marshal(respJSON)
  39945. if err := json.Unmarshal([]byte(result), &res); err != nil {
  39946. utils.ErrorLog("解析失败:%v", err)
  39947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39948. return ""
  39949. }
  39950. if res.Infcode == 0 {
  39951. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39952. if err == gorm.ErrRecordNotFound {
  39953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39954. return ""
  39955. } else if err != nil {
  39956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39957. return ""
  39958. } else {
  39959. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39960. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39961. infoStr := string(Iinfos)
  39962. idetinfoStr := string(Idetinfos)
  39963. psn := &models.HisPsn{
  39964. PsnNo: res.Output.Baseinfo.PsnNo,
  39965. PatientId: patient.ID,
  39966. Certno: res.Output.Baseinfo.Certno,
  39967. Gend: res.Output.Baseinfo.Gend,
  39968. Naty: res.Output.Baseinfo.Naty,
  39969. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39970. PsnName: res.Output.Baseinfo.PsnName,
  39971. Idetinfo: idetinfoStr,
  39972. Insuinfo: infoStr,
  39973. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39974. CardInfo: card_info,
  39975. VerifyNumber: token,
  39976. }
  39977. service.CreateHisPsn(psn)
  39978. return token
  39979. }
  39980. }
  39981. } else {
  39982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39983. return ""
  39984. }
  39985. return token
  39986. }
  39987. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  39988. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39989. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39990. var token string
  39991. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  39992. var api string
  39993. if miConfig.MdtrtareaAdmvs == "320830" {
  39994. api = miConfig.AppSecret + "jsyb/readcardface?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39995. "&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
  39996. fmt.Println(api)
  39997. } else if miConfig.MdtrtareaAdmvs == "320921" {
  39998. 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 +
  39999. "&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
  40000. fmt.Println(api)
  40001. } else {
  40002. 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 +
  40003. "&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
  40004. }
  40005. resp, requestErr := http.Get(api)
  40006. if requestErr != nil {
  40007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40008. return ""
  40009. }
  40010. body, ioErr := ioutil.ReadAll(resp.Body)
  40011. if ioErr != nil {
  40012. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40014. return ""
  40015. }
  40016. var respJSON map[string]interface{}
  40017. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  40018. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40020. return ""
  40021. }
  40022. var status string
  40023. status = respJSON["data"].(map[string]interface{})["status"].(string)
  40024. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  40025. var res ResultTwo //1101结果
  40026. var res10265 ResultTwo10265 //1101结果
  40027. if status == "0" { //读卡成功
  40028. var card_info string //卡信息
  40029. var busi_card_info string
  40030. token = respJSON["data"].(map[string]interface{})["token"].(string)
  40031. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  40032. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  40033. fmt.Println(card_info)
  40034. fmt.Println(busi_card_info)
  40035. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  40036. result, _ := json.Marshal(respJSON)
  40037. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  40038. utils.ErrorLog("解析失败:%v", err)
  40039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40040. return ""
  40041. }
  40042. res.ErrMsg = res10265.ErrMsg
  40043. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  40044. res.Infcode = infocode
  40045. res.Output = res10265.Output
  40046. res.InfRefmsgid = res10265.InfRefmsgid
  40047. if res.Infcode == 0 {
  40048. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  40049. if err == gorm.ErrRecordNotFound {
  40050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  40051. return ""
  40052. } else if err != nil {
  40053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  40054. return ""
  40055. } else {
  40056. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  40057. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  40058. infoStr := string(Iinfos)
  40059. idetinfoStr := string(Idetinfos)
  40060. psn := &models.HisPsn{
  40061. PsnNo: res.Output.Baseinfo.PsnNo,
  40062. PatientId: patient.ID,
  40063. Certno: res.Output.Baseinfo.Certno,
  40064. Gend: res.Output.Baseinfo.Gend,
  40065. Naty: res.Output.Baseinfo.Naty,
  40066. PsnCertType: res.Output.Baseinfo.PsnCertType,
  40067. PsnName: res.Output.Baseinfo.PsnName,
  40068. Idetinfo: idetinfoStr,
  40069. Insuinfo: infoStr,
  40070. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  40071. CardInfo: card_info,
  40072. VerifyNumber: token,
  40073. }
  40074. service.CreateHisPsn(psn)
  40075. return token
  40076. }
  40077. }
  40078. } else {
  40079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  40080. return ""
  40081. }
  40082. } else { //读卡失败
  40083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  40084. return ""
  40085. }
  40086. return token
  40087. }
  40088. func DeleteExtraSpaceTwo(s string) string {
  40089. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  40090. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  40091. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  40092. reg, _ := regexp.Compile(regstr) //编译正则表达式
  40093. s2 := make([]byte, len(s1)) //定义字符数组切片
  40094. copy(s2, s1) //将字符串复制到切片
  40095. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  40096. for len(spc_index) > 0 { //找到适配项
  40097. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  40098. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  40099. }
  40100. return string(s2)
  40101. }
  40102. func Remove0000(s string) string {
  40103. str := make([]rune, 0, len(s))
  40104. for _, v := range []rune(s) {
  40105. if v == 0 {
  40106. continue
  40107. }
  40108. str = append(str, v)
  40109. }
  40110. return string(str)
  40111. }
  40112. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  40113. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  40114. readCard := DllDef.MustFindProc("EcQuery")
  40115. pCardInfo := make([]byte, 8192)
  40116. pBusiCardInfo := make([]byte, 8192)
  40117. data := make(map[string]interface{})
  40118. //pData := make(map[string]interface{})
  40119. inputData := make(map[string]interface{})
  40120. inputData["orgId"] = code
  40121. inputData["businessType"] = "01101"
  40122. inputData["operatorId"] = operator_id
  40123. inputData["operatorName"] = operator_name
  40124. inputData["officeId"] = "001"
  40125. inputData["officeName"] = "血透室"
  40126. //
  40127. data["data"] = inputData
  40128. data["transType"] = "ec.query"
  40129. data["orgId"] = code
  40130. bytesData, _ := json.Marshal(data)
  40131. pCardInfo = bytesData
  40132. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  40133. fmt.Println(ret2)
  40134. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  40135. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  40136. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  40137. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  40138. if ret2 != 0 {
  40139. return "", ""
  40140. }
  40141. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  40142. }
  40143. func DeleteExtraSpace(s string) string {
  40144. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  40145. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  40146. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  40147. reg, _ := regexp.Compile(regstr) //编译正则表达式
  40148. s2 := make([]byte, len(s1)) //定义字符数组切片
  40149. copy(s2, s1) //将字符串复制到切片
  40150. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  40151. for len(spc_index) > 0 { //找到适配项
  40152. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  40153. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  40154. }
  40155. return string(s2)
  40156. }
  40157. // 对账
  40158. func (c *HisApiController) Post3202() {
  40159. start_time := c.GetString("start_time")
  40160. end_time := c.GetString("end_time")
  40161. //insutype := c.GetString("insutype")
  40162. clr_type := c.GetString("clr_type")
  40163. clr_org := c.GetString("clr_optins")
  40164. admin_user_id, _ := c.GetInt64("admin_user_id")
  40165. adminUser := c.GetAdminUserInfo()
  40166. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40167. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40168. if len(clr_org) == 0 {
  40169. clr_org = miConfig.MdtrtareaAdmvs
  40170. }
  40171. timeLayout := "2006-01-02"
  40172. loc, _ := time.LoadLocation("Local")
  40173. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40174. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40175. var orders []*models.HisOrder
  40176. if clr_org == "421300" {
  40177. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40178. } else if clr_org == "420902" {
  40179. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40180. } else {
  40181. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40182. }
  40183. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40184. //fixmedins_setl_cnt := int64(len(orders))
  40185. var medfee_sumamt float64
  40186. var acct_pay float64
  40187. var fund_pay_sumamt float64
  40188. for _, item := range orders {
  40189. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40190. acct_pay = acct_pay + item.AcctPay
  40191. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  40192. }
  40193. //var medfee_sumamt_two float64
  40194. //var acct_pay_two float64
  40195. //var fund_pay_sumamt_two float64
  40196. //for _, item := range orders_two {
  40197. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  40198. // acct_pay_two = acct_pay_two + item.AcctPay
  40199. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  40200. //}
  40201. //var user_name string
  40202. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40203. //if role.ID == 0 {
  40204. // user_name = "xxx"
  40205. //} else {
  40206. // user_name = role.UserName
  40207. //}
  40208. var res ResultSix
  40209. if config.IsOpen == 1 {
  40210. var bps []*models.BusinessParamsTwo
  40211. var bp models.BusinessParamsTwo
  40212. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40213. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  40214. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  40215. bp.MedfeeSumamt = medfee_sumamt_str
  40216. bp.AcctPay = acct_pay_str
  40217. bp.FundPaySumamt = fund_pay_sumamt_str
  40218. bp.Insutype = ""
  40219. bp.StmtBegndate = start_time
  40220. bp.ClrType = clr_type
  40221. bp.SetlOptins = clr_org
  40222. bp.StmtEnddate = end_time
  40223. bps = append(bps, &bp)
  40224. data := make(map[string]interface{})
  40225. data["bps"] = bps
  40226. data["org_name"] = miConfig.OrgName
  40227. data["doctor"] = role.UserName
  40228. data["fixmedins_code"] = miConfig.Code
  40229. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40230. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40231. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40232. if miConfig.MdtrtareaAdmvs == "421300" {
  40233. client := &http.Client{}
  40234. bytesData, _ := json.Marshal(data)
  40235. req, _ := http.NewRequest("POST", "http://192.168.124.4: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 == "420200" {
  40259. client := &http.Client{}
  40260. bytesData, _ := json.Marshal(data)
  40261. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"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 == "421182" {
  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 miConfig.MdtrtareaAdmvs == "420902" {
  40311. client := &http.Client{}
  40312. bytesData, _ := json.Marshal(data)
  40313. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  40314. resp, _ := client.Do(req)
  40315. defer resp.Body.Close()
  40316. body, ioErr := ioutil.ReadAll(resp.Body)
  40317. if ioErr != nil {
  40318. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40320. return
  40321. }
  40322. var respJSON map[string]interface{}
  40323. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40324. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40326. return
  40327. }
  40328. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40329. userJSONBytes, _ := json.Marshal(respJSON)
  40330. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40331. utils.ErrorLog("解析失败:%v", err)
  40332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40333. return
  40334. }
  40335. }
  40336. if res.Infcode == 0 {
  40337. c.ServeSuccessJSON(map[string]interface{}{
  40338. "msg": "发起成功",
  40339. })
  40340. } else {
  40341. c.ServeSuccessJSON(map[string]interface{}{
  40342. "failed_code": -10,
  40343. "msg": res.ErrMsg,
  40344. })
  40345. }
  40346. }
  40347. }
  40348. func (c *HisApiController) Post3204a() {
  40349. start_time := c.GetString("start_time")
  40350. end_time := c.GetString("end_time")
  40351. //insutype := c.GetString("insutype")
  40352. clr_type := c.GetString("clr_type")
  40353. clr_org := c.GetString("clr_optins")
  40354. admin_user_id, _ := c.GetInt64("admin_user_id")
  40355. adminUser := c.GetAdminUserInfo()
  40356. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40357. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40358. if len(clr_org) == 0 {
  40359. clr_org = miConfig.MdtrtareaAdmvs
  40360. }
  40361. timeLayout := "2006-01-02"
  40362. loc, _ := time.LoadLocation("Local")
  40363. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40364. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40365. var orders []*models.HisOrder
  40366. if clr_org == "421300" {
  40367. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40368. } else if clr_org == "420902" {
  40369. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40370. } else {
  40371. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40372. }
  40373. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40374. //fixmedins_setl_cnt := int64(len(orders))
  40375. var medfee_sumamt float64
  40376. var acct_pay float64
  40377. var fund_pay_sumamt float64
  40378. for _, item := range orders {
  40379. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40380. acct_pay = acct_pay + item.AcctPay
  40381. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  40382. }
  40383. //var medfee_sumamt_two float64
  40384. //var acct_pay_two float64
  40385. //var fund_pay_sumamt_two float64
  40386. //for _, item := range orders_two {
  40387. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  40388. // acct_pay_two = acct_pay_two + item.AcctPay
  40389. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  40390. //}
  40391. //var user_name string
  40392. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40393. //if role.ID == 0 {
  40394. // user_name = "xxx"
  40395. //} else {
  40396. // user_name = role.UserName
  40397. //}
  40398. var res ResultSix
  40399. if config.IsOpen == 1 {
  40400. var bps []*models.BusinessParamsTwo
  40401. var bp models.BusinessParamsTwo
  40402. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40403. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  40404. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  40405. bp.MedfeeSumamt = medfee_sumamt_str
  40406. bp.AcctPay = acct_pay_str
  40407. bp.FundPaySumamt = fund_pay_sumamt_str
  40408. bp.Insutype = ""
  40409. bp.StmtBegndate = start_time
  40410. bp.ClrType = clr_type
  40411. bp.SetlOptins = clr_org
  40412. bp.StmtEnddate = end_time
  40413. bps = append(bps, &bp)
  40414. data := make(map[string]interface{})
  40415. data["bps"] = bps
  40416. data["org_name"] = miConfig.OrgName
  40417. data["doctor"] = role.UserName
  40418. data["fixmedins_code"] = miConfig.Code
  40419. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40420. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40421. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40422. if miConfig.MdtrtareaAdmvs == "421300" {
  40423. client := &http.Client{}
  40424. bytesData, _ := json.Marshal(data)
  40425. req, _ := http.NewRequest("POST", "http://192.168.124.4: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 == "420200" {
  40449. client := &http.Client{}
  40450. bytesData, _ := json.Marshal(data)
  40451. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"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 == "421182" {
  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 miConfig.MdtrtareaAdmvs == "420902" {
  40501. client := &http.Client{}
  40502. bytesData, _ := json.Marshal(data)
  40503. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  40504. resp, _ := client.Do(req)
  40505. defer resp.Body.Close()
  40506. body, ioErr := ioutil.ReadAll(resp.Body)
  40507. if ioErr != nil {
  40508. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40510. return
  40511. }
  40512. var respJSON map[string]interface{}
  40513. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40514. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40516. return
  40517. }
  40518. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40519. userJSONBytes, _ := json.Marshal(respJSON)
  40520. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40521. utils.ErrorLog("解析失败:%v", err)
  40522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40523. return
  40524. }
  40525. }
  40526. if res.Infcode == 0 {
  40527. c.ServeSuccessJSON(map[string]interface{}{
  40528. "msg": "撤销成功",
  40529. })
  40530. } else {
  40531. c.ServeSuccessJSON(map[string]interface{}{
  40532. "failed_code": -10,
  40533. "msg": res.ErrMsg,
  40534. })
  40535. }
  40536. }
  40537. }
  40538. func (c *HisApiController) Post3204() {
  40539. admin_user_id, _ := c.GetInt64("admin_user_id")
  40540. id := c.GetString("id")
  40541. adminUser := c.GetAdminUserInfo()
  40542. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40543. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40544. //clr_org := miConfig.MdtrtareaAdmvs
  40545. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40546. var res ResultSix
  40547. if config.IsOpen == 1 {
  40548. data := make(map[string]interface{})
  40549. data["id"] = id
  40550. data["org_name"] = miConfig.OrgName
  40551. data["doctor"] = role.UserName
  40552. data["fixmedins_code"] = miConfig.Code
  40553. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40554. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40555. client := &http.Client{}
  40556. bytesData, _ := json.Marshal(data)
  40557. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  40558. resp, _ := client.Do(req)
  40559. defer resp.Body.Close()
  40560. body, ioErr := ioutil.ReadAll(resp.Body)
  40561. if ioErr != nil {
  40562. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40564. return
  40565. }
  40566. var respJSON map[string]interface{}
  40567. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40568. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40570. return
  40571. }
  40572. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40573. userJSONBytes, _ := json.Marshal(respJSON)
  40574. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40575. utils.ErrorLog("解析失败:%v", err)
  40576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40577. return
  40578. }
  40579. if res.Infcode == 0 {
  40580. c.ServeSuccessJSON(map[string]interface{}{
  40581. "msg": "发起成功",
  40582. })
  40583. } else {
  40584. c.ServeSuccessJSON(map[string]interface{}{
  40585. "failed_code": -10,
  40586. "msg": res.ErrMsg,
  40587. })
  40588. }
  40589. }
  40590. }
  40591. func (c *HisApiController) Post8404() {
  40592. admin_user_id, _ := c.GetInt64("admin_user_id")
  40593. month := c.GetString("month")
  40594. adminUser := c.GetAdminUserInfo()
  40595. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40596. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40597. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40598. var res ResultSix
  40599. if config.IsOpen == 1 {
  40600. data := make(map[string]interface{})
  40601. data["month"] = month
  40602. data["org_name"] = miConfig.OrgName
  40603. data["doctor"] = role.UserName
  40604. data["fixmedins_code"] = miConfig.Code
  40605. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40606. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40607. client := &http.Client{}
  40608. bytesData, _ := json.Marshal(data)
  40609. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  40610. resp, _ := client.Do(req)
  40611. defer resp.Body.Close()
  40612. body, ioErr := ioutil.ReadAll(resp.Body)
  40613. if ioErr != nil {
  40614. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40616. return
  40617. }
  40618. var respJSON map[string]interface{}
  40619. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40620. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40622. return
  40623. }
  40624. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40625. userJSONBytes, _ := json.Marshal(respJSON)
  40626. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40627. utils.ErrorLog("解析失败:%v", err)
  40628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40629. return
  40630. }
  40631. if res.Infcode == 0 {
  40632. c.ServeSuccessJSON(map[string]interface{}{
  40633. "msg": "查询成功",
  40634. })
  40635. } else {
  40636. c.ServeSuccessJSON(map[string]interface{}{
  40637. "failed_code": -10,
  40638. "msg": res.ErrMsg,
  40639. })
  40640. }
  40641. }
  40642. }
  40643. func (c *HisApiController) Post3202b() {
  40644. start_time := c.GetString("start_time")
  40645. end_time := c.GetString("end_time")
  40646. //insutype := c.GetString("insutype")
  40647. clr_type := c.GetString("clr_type")
  40648. clr_org := c.GetString("clr_optins")
  40649. admin_user_id, _ := c.GetInt64("admin_user_id")
  40650. adminUser := c.GetAdminUserInfo()
  40651. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40652. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40653. if len(clr_org) == 0 {
  40654. clr_org = miConfig.MdtrtareaAdmvs
  40655. }
  40656. timeLayout := "2006-01-02"
  40657. loc, _ := time.LoadLocation("Local")
  40658. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40659. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40660. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40661. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40662. //fixmedins_setl_cnt := int64(len(orders))
  40663. var medfee_sumamt float64
  40664. var acct_pay float64
  40665. var fund_pay_sumamt float64
  40666. for _, item := range orders {
  40667. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40668. acct_pay = acct_pay + item.AcctPay
  40669. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  40670. }
  40671. //var medfee_sumamt_two float64
  40672. //var acct_pay_two float64
  40673. //var fund_pay_sumamt_two float64
  40674. //for _, item := range orders_two {
  40675. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  40676. // acct_pay_two = acct_pay_two + item.AcctPay
  40677. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  40678. //}
  40679. //var user_name string
  40680. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40681. //if role.ID == 0 {
  40682. // user_name = "xxx"
  40683. //} else {
  40684. // user_name = role.UserName
  40685. //}
  40686. var res ResultSix
  40687. if config.IsOpen == 1 {
  40688. var bps []*models.BusinessParamsTwo
  40689. var bp models.BusinessParamsTwo
  40690. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40691. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  40692. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  40693. bp.MedfeeSumamt = medfee_sumamt_str
  40694. bp.AcctPay = acct_pay_str
  40695. bp.FundPaySumamt = fund_pay_sumamt_str
  40696. bp.Insutype = "390"
  40697. bp.StmtBegndate = start_time
  40698. bp.ClrType = clr_type
  40699. bp.SetlOptins = clr_org
  40700. bp.StmtEnddate = end_time
  40701. bps = append(bps, &bp)
  40702. data := make(map[string]interface{})
  40703. data["bps"] = bps
  40704. data["org_name"] = miConfig.OrgName
  40705. data["doctor"] = role.UserName
  40706. data["fixmedins_code"] = miConfig.Code
  40707. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40708. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40709. if miConfig.MdtrtareaAdmvs == "421300" {
  40710. client := &http.Client{}
  40711. bytesData, _ := json.Marshal(data)
  40712. req, _ := http.NewRequest("POST", "http://192.168.124.4: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 == "420200" {
  40736. client := &http.Client{}
  40737. bytesData, _ := json.Marshal(data)
  40738. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"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 miConfig.MdtrtareaAdmvs == "421182" {
  40762. client := &http.Client{}
  40763. bytesData, _ := json.Marshal(data)
  40764. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  40765. resp, _ := client.Do(req)
  40766. defer resp.Body.Close()
  40767. body, ioErr := ioutil.ReadAll(resp.Body)
  40768. if ioErr != nil {
  40769. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40771. return
  40772. }
  40773. var respJSON map[string]interface{}
  40774. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40775. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40777. return
  40778. }
  40779. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40780. userJSONBytes, _ := json.Marshal(respJSON)
  40781. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40782. utils.ErrorLog("解析失败:%v", err)
  40783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40784. return
  40785. }
  40786. }
  40787. if res.Infcode == 0 {
  40788. c.ServeSuccessJSON(map[string]interface{}{
  40789. "msg": "发起成功",
  40790. })
  40791. } else {
  40792. c.ServeSuccessJSON(map[string]interface{}{
  40793. "failed_code": -10,
  40794. "msg": res.ErrMsg,
  40795. })
  40796. }
  40797. }
  40798. }
  40799. func (c *HisApiController) Post1608() {
  40800. start_time := c.GetString("start_time")
  40801. end_time := c.GetString("end_time")
  40802. admin_user_id, _ := c.GetInt64("admin_user_id")
  40803. adminUser := c.GetAdminUserInfo()
  40804. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40805. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40806. timeLayout := "2006-01-02"
  40807. loc, _ := time.LoadLocation("Local")
  40808. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40809. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40810. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40811. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40812. fixmedins_setl_cnt := int64(len(orders))
  40813. var medfee_sumamt float64
  40814. var func_smamt float64
  40815. for _, item := range orders {
  40816. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40817. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  40818. }
  40819. times := strings.Split(start_time, "-")
  40820. time_tows := strings.Split(end_time, "-")
  40821. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40822. var res ResultSix
  40823. if config.IsOpen == 1 {
  40824. //var bps []*models.BusinessParamsTwo
  40825. //var bp models.BusinessParamsTwo
  40826. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40827. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  40828. data := make(map[string]interface{})
  40829. data["org_name"] = miConfig.OrgName
  40830. data["doctor"] = role.UserName
  40831. data["func_smamt"] = func_smamt_str
  40832. data["fixmedins_code"] = miConfig.Code
  40833. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40834. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40835. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  40836. data["medfee_sumamt"] = medfee_sumamt_str
  40837. data["start_time"] = times[0] + times[1] + times[2]
  40838. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  40839. if miConfig.MdtrtareaAdmvs == "421300" {
  40840. client := &http.Client{}
  40841. bytesData, _ := json.Marshal(data)
  40842. req, _ := http.NewRequest("POST", "http://192.168.124.4: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 == "420200" {
  40866. client := &http.Client{}
  40867. bytesData, _ := json.Marshal(data)
  40868. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"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 miConfig.MdtrtareaAdmvs == "421182" {
  40892. client := &http.Client{}
  40893. bytesData, _ := json.Marshal(data)
  40894. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  40895. resp, _ := client.Do(req)
  40896. defer resp.Body.Close()
  40897. body, ioErr := ioutil.ReadAll(resp.Body)
  40898. if ioErr != nil {
  40899. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40901. return
  40902. }
  40903. var respJSON map[string]interface{}
  40904. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40907. return
  40908. }
  40909. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40910. userJSONBytes, _ := json.Marshal(respJSON)
  40911. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40912. utils.ErrorLog("解析失败:%v", err)
  40913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40914. return
  40915. }
  40916. }
  40917. if res.Infcode == 0 {
  40918. c.ServeSuccessJSON(map[string]interface{}{
  40919. "msg": "发起成功",
  40920. })
  40921. } else {
  40922. c.ServeSuccessJSON(map[string]interface{}{
  40923. "failed_code": -10,
  40924. "msg": res.ErrMsg,
  40925. })
  40926. }
  40927. }
  40928. }
  40929. // 5.11.1.1【5262】结算信息按时间段查询
  40930. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  40931. admin_user_id, _ := c.GetInt64("admin_user_id")
  40932. adminUser := c.GetAdminUserInfo()
  40933. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40934. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40935. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40936. var res Result5262
  40937. if config.IsOpen == 1 {
  40938. if miConfig.MdtrtareaAdmvs == "421300" {
  40939. data := make(map[string]interface{})
  40940. data["bps"] = bp
  40941. data["org_name"] = miConfig.OrgName
  40942. data["doctor"] = role.UserName
  40943. data["fixmedins_code"] = miConfig.Code
  40944. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40945. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40946. data["page"] = strconv.FormatInt(page, 10)
  40947. data["limit"] = strconv.FormatInt(limit, 10)
  40948. fmt.Println(data)
  40949. client := &http.Client{}
  40950. bytesData, _ := json.Marshal(data)
  40951. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  40952. resp, _ := client.Do(req)
  40953. defer resp.Body.Close()
  40954. body, ioErr := ioutil.ReadAll(resp.Body)
  40955. if ioErr != nil {
  40956. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40958. return
  40959. }
  40960. var respJSON map[string]interface{}
  40961. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40962. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40964. return
  40965. }
  40966. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40967. userJSONBytes, _ := json.Marshal(respJSON)
  40968. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40969. utils.ErrorLog("解析失败:%v", err)
  40970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40971. return
  40972. }
  40973. }
  40974. if miConfig.MdtrtareaAdmvs == "420200" {
  40975. data := make(map[string]interface{})
  40976. data["bps"] = bp
  40977. data["org_name"] = miConfig.OrgName
  40978. data["doctor"] = role.UserName
  40979. data["fixmedins_code"] = miConfig.Code
  40980. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40981. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40982. data["page"] = strconv.FormatInt(page, 10)
  40983. data["limit"] = strconv.FormatInt(limit, 10)
  40984. fmt.Println(data)
  40985. client := &http.Client{}
  40986. bytesData, _ := json.Marshal(data)
  40987. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  40988. resp, _ := client.Do(req)
  40989. defer resp.Body.Close()
  40990. body, ioErr := ioutil.ReadAll(resp.Body)
  40991. if ioErr != nil {
  40992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40994. return
  40995. }
  40996. var respJSON map[string]interface{}
  40997. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41000. return
  41001. }
  41002. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  41003. userJSONBytes, _ := json.Marshal(respJSON)
  41004. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  41005. utils.ErrorLog("解析失败:%v", err)
  41006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41007. return
  41008. }
  41009. }
  41010. if miConfig.MdtrtareaAdmvs == "421182" {
  41011. data := make(map[string]interface{})
  41012. data["bps"] = bp
  41013. data["org_name"] = miConfig.OrgName
  41014. data["doctor"] = role.UserName
  41015. data["fixmedins_code"] = miConfig.Code
  41016. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  41017. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  41018. data["page"] = strconv.FormatInt(page, 10)
  41019. data["limit"] = strconv.FormatInt(limit, 10)
  41020. fmt.Println(data)
  41021. client := &http.Client{}
  41022. bytesData, _ := json.Marshal(data)
  41023. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  41024. resp, _ := client.Do(req)
  41025. defer resp.Body.Close()
  41026. body, ioErr := ioutil.ReadAll(resp.Body)
  41027. if ioErr != nil {
  41028. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41030. return
  41031. }
  41032. var respJSON map[string]interface{}
  41033. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41036. return
  41037. }
  41038. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  41039. userJSONBytes, _ := json.Marshal(respJSON)
  41040. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  41041. utils.ErrorLog("解析失败:%v", err)
  41042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41043. return
  41044. }
  41045. }
  41046. if miConfig.MdtrtareaAdmvs == "420902" {
  41047. data := make(map[string]interface{})
  41048. data["bps"] = bp
  41049. data["org_name"] = miConfig.OrgName
  41050. data["doctor"] = role.UserName
  41051. data["fixmedins_code"] = miConfig.Code
  41052. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  41053. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  41054. data["page"] = strconv.FormatInt(page, 10)
  41055. data["limit"] = strconv.FormatInt(limit, 10)
  41056. fmt.Println(data)
  41057. client := &http.Client{}
  41058. bytesData, _ := json.Marshal(data)
  41059. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  41060. resp, _ := client.Do(req)
  41061. defer resp.Body.Close()
  41062. body, ioErr := ioutil.ReadAll(resp.Body)
  41063. if ioErr != nil {
  41064. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41066. return
  41067. }
  41068. var respJSON map[string]interface{}
  41069. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41070. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41072. return
  41073. }
  41074. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  41075. userJSONBytes, _ := json.Marshal(respJSON)
  41076. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  41077. utils.ErrorLog("解析失败:%v", err)
  41078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41079. return
  41080. }
  41081. }
  41082. if res.Infcode == 0 {
  41083. c.ServeSuccessJSON(map[string]interface{}{
  41084. "order": res.Output.Result,
  41085. "total": res.Output.PageInfo.RecordCounts,
  41086. })
  41087. } else {
  41088. c.ServeSuccessJSON(map[string]interface{}{
  41089. "failed_code": -10,
  41090. "msg": res.ErrMsg,
  41091. })
  41092. }
  41093. }
  41094. }
  41095. // 5.11.1.2【5267】异地结算信息时间段查询
  41096. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  41097. admin_user_id, _ := c.GetInt64("admin_user_id")
  41098. adminUser := c.GetAdminUserInfo()
  41099. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  41100. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  41101. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  41102. var res Result5267
  41103. if config.IsOpen == 1 {
  41104. if miConfig.MdtrtareaAdmvs == "421300" {
  41105. data := make(map[string]interface{})
  41106. data["bps"] = bp
  41107. data["org_name"] = miConfig.OrgName
  41108. data["doctor"] = role.UserName
  41109. data["fixmedins_code"] = miConfig.Code
  41110. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  41111. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  41112. data["page"] = page
  41113. data["limit"] = limit
  41114. fmt.Println(data)
  41115. client := &http.Client{}
  41116. bytesData, _ := json.Marshal(data)
  41117. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  41118. resp, _ := client.Do(req)
  41119. defer resp.Body.Close()
  41120. body, ioErr := ioutil.ReadAll(resp.Body)
  41121. if ioErr != nil {
  41122. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41124. return
  41125. }
  41126. var respJSON map[string]interface{}
  41127. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41130. return
  41131. }
  41132. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  41133. userJSONBytes, _ := json.Marshal(respJSON)
  41134. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  41135. utils.ErrorLog("解析失败:%v", err)
  41136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41137. return
  41138. }
  41139. }
  41140. if miConfig.MdtrtareaAdmvs == "420200" {
  41141. data := make(map[string]interface{})
  41142. data["bps"] = bp
  41143. data["org_name"] = miConfig.OrgName
  41144. data["doctor"] = role.UserName
  41145. data["fixmedins_code"] = miConfig.Code
  41146. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  41147. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  41148. data["page"] = page
  41149. data["limit"] = limit
  41150. fmt.Println(data)
  41151. client := &http.Client{}
  41152. bytesData, _ := json.Marshal(data)
  41153. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  41154. resp, _ := client.Do(req)
  41155. defer resp.Body.Close()
  41156. body, ioErr := ioutil.ReadAll(resp.Body)
  41157. if ioErr != nil {
  41158. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41160. return
  41161. }
  41162. var respJSON map[string]interface{}
  41163. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41166. return
  41167. }
  41168. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  41169. userJSONBytes, _ := json.Marshal(respJSON)
  41170. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  41171. utils.ErrorLog("解析失败:%v", err)
  41172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41173. return
  41174. }
  41175. }
  41176. if miConfig.MdtrtareaAdmvs == "421182" {
  41177. data := make(map[string]interface{})
  41178. data["bps"] = bp
  41179. data["org_name"] = miConfig.OrgName
  41180. data["doctor"] = role.UserName
  41181. data["fixmedins_code"] = miConfig.Code
  41182. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  41183. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  41184. data["page"] = page
  41185. data["limit"] = limit
  41186. fmt.Println(data)
  41187. client := &http.Client{}
  41188. bytesData, _ := json.Marshal(data)
  41189. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  41190. resp, _ := client.Do(req)
  41191. defer resp.Body.Close()
  41192. body, ioErr := ioutil.ReadAll(resp.Body)
  41193. if ioErr != nil {
  41194. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41196. return
  41197. }
  41198. var respJSON map[string]interface{}
  41199. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41202. return
  41203. }
  41204. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  41205. userJSONBytes, _ := json.Marshal(respJSON)
  41206. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  41207. utils.ErrorLog("解析失败:%v", err)
  41208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41209. return
  41210. }
  41211. }
  41212. if res.Infcode == 0 {
  41213. c.ServeSuccessJSON(map[string]interface{}{
  41214. "order": res.Output.Result,
  41215. "total": res.Output.PageInfo.RecordCounts,
  41216. })
  41217. } else {
  41218. c.ServeSuccessJSON(map[string]interface{}{
  41219. "failed_code": -10,
  41220. "msg": res.ErrMsg,
  41221. })
  41222. }
  41223. }
  41224. }
  41225. func (c *HisApiController) Post3501() {
  41226. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41227. data := make(map[string]interface{})
  41228. var struct3501s []models.Struct3501
  41229. var struct3501 models.Struct3501
  41230. struct3501.OrgName = miConfig.OrgName
  41231. struct3501.AccessKey = miConfig.AccessKey
  41232. struct3501.RequestUrl = miConfig.Url
  41233. struct3501.SecretKey = miConfig.SecretKey
  41234. struct3501.ManuDate = "2022-08-17"
  41235. struct3501.FixmedinsBchno = ""
  41236. struct3501.ManuLotnum = ""
  41237. struct3501.RxFlag = "0"
  41238. struct3501.ExpyEnd = "2022-08-17"
  41239. struct3501.Invdate = "2022-08-17"
  41240. struct3501.InvCnt = "20.25"
  41241. struct3501.Memo = ""
  41242. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41243. struct3501.FixmedinsHilistId = miConfig.Code
  41244. struct3501.FixmedinsHilistName = miConfig.OrgName
  41245. struct3501s = append(struct3501s, struct3501)
  41246. data["struct_3501s"] = struct3501s
  41247. client := &http.Client{}
  41248. bytesData, _ := json.Marshal(data)
  41249. var req *http.Request
  41250. if miConfig.MdtrtareaAdmvs == "320830" {
  41251. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  41252. } else if miConfig.MdtrtareaAdmvs == "320921" {
  41253. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41254. } else {
  41255. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41256. }
  41257. resp, _ := client.Do(req)
  41258. defer resp.Body.Close()
  41259. body, ioErr := ioutil.ReadAll(resp.Body)
  41260. if ioErr != nil {
  41261. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41263. return
  41264. }
  41265. var respJSON map[string]interface{}
  41266. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41269. return
  41270. }
  41271. var res ResultSix
  41272. var resSix10265 ResultSix10265 //1101结果
  41273. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41274. result, _ := json.Marshal(respJSON)
  41275. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41276. utils.ErrorLog("解析失败:%v", err)
  41277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41278. return
  41279. }
  41280. res.InfRefmsgid = resSix10265.InfRefmsgid
  41281. res.Output = resSix10265.Output
  41282. res.ErrMsg = resSix10265.ErrMsg
  41283. res.Cainfo = resSix10265.Cainfo
  41284. res.WarnMsg = resSix10265.WarnMsg
  41285. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41286. res.Infcode = infocode
  41287. if infocode == 0 {
  41288. c.ServeSuccessJSON(map[string]interface{}{
  41289. "msg": "上传成功",
  41290. })
  41291. return
  41292. } else {
  41293. c.ServeSuccessJSON(map[string]interface{}{
  41294. "failed_code": -10,
  41295. "msg": res.ErrMsg,
  41296. })
  41297. return
  41298. }
  41299. }
  41300. func (c *HisApiController) Post3502() {
  41301. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41302. data := make(map[string]interface{})
  41303. var struct3502s []models.Struct3502
  41304. var struct3502 models.Struct3502
  41305. struct3502.OrgName = miConfig.OrgName
  41306. struct3502.AccessKey = miConfig.AccessKey
  41307. struct3502.RequestUrl = miConfig.Url
  41308. struct3502.SecretKey = miConfig.SecretKey
  41309. struct3502.ManuDate = "2022-08-15"
  41310. struct3502.FixmedinsBchno = ""
  41311. struct3502.ManuLotnum = ""
  41312. struct3502.RxFlag = "0"
  41313. struct3502.ExpyEnd = "2022-08-15"
  41314. struct3502.Invdate = "2022-08-15"
  41315. struct3502.InvCnt = "20.25"
  41316. struct3502.Memo = ""
  41317. struct3502.MedListCodg = "XB01ABD056B002020200517"
  41318. struct3502.FixmedinsHilistId = miConfig.Code
  41319. struct3502.FixmedinsHilistName = miConfig.OrgName
  41320. struct3502s = append(struct3502s, struct3502)
  41321. data["struct_3502s"] = struct3502s
  41322. client := &http.Client{}
  41323. bytesData, _ := json.Marshal(data)
  41324. var req *http.Request
  41325. if miConfig.MdtrtareaAdmvs == "320830" {
  41326. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  41327. } else if miConfig.MdtrtareaAdmvs == "320921" {
  41328. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41329. } else {
  41330. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41331. }
  41332. resp, _ := client.Do(req)
  41333. defer resp.Body.Close()
  41334. body, ioErr := ioutil.ReadAll(resp.Body)
  41335. if ioErr != nil {
  41336. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41338. return
  41339. }
  41340. var respJSON map[string]interface{}
  41341. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41344. return
  41345. }
  41346. var res ResultSix
  41347. var resSix10265 ResultSix10265 //1101结果
  41348. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41349. result, _ := json.Marshal(respJSON)
  41350. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41351. utils.ErrorLog("解析失败:%v", err)
  41352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41353. return
  41354. }
  41355. res.InfRefmsgid = resSix10265.InfRefmsgid
  41356. res.Output = resSix10265.Output
  41357. res.ErrMsg = resSix10265.ErrMsg
  41358. res.Cainfo = resSix10265.Cainfo
  41359. res.WarnMsg = resSix10265.WarnMsg
  41360. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41361. res.Infcode = infocode
  41362. if infocode == 0 {
  41363. c.ServeSuccessJSON(map[string]interface{}{
  41364. "msg": "上传成功",
  41365. })
  41366. return
  41367. } else {
  41368. c.ServeSuccessJSON(map[string]interface{}{
  41369. "failed_code": -10,
  41370. "msg": res.ErrMsg,
  41371. })
  41372. return
  41373. }
  41374. }
  41375. func (c *HisApiController) Post3503() {
  41376. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41377. data := make(map[string]interface{})
  41378. var struct3501s []models.Struct3501
  41379. var struct3501 models.Struct3501
  41380. struct3501.OrgName = miConfig.OrgName
  41381. struct3501.AccessKey = miConfig.AccessKey
  41382. struct3501.RequestUrl = miConfig.Url
  41383. struct3501.SecretKey = miConfig.SecretKey
  41384. struct3501.ManuDate = "2022-08-15"
  41385. struct3501.FixmedinsBchno = ""
  41386. struct3501.ManuLotnum = ""
  41387. struct3501.RxFlag = "0"
  41388. struct3501.ExpyEnd = "2022-08-15"
  41389. struct3501.Invdate = "2022-08-15"
  41390. struct3501.InvCnt = "20.25"
  41391. struct3501.Memo = ""
  41392. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41393. struct3501.FixmedinsHilistId = miConfig.Code
  41394. struct3501.FixmedinsHilistName = miConfig.OrgName
  41395. struct3501s = append(struct3501s, struct3501)
  41396. data["struct_3501s"] = struct3501s
  41397. client := &http.Client{}
  41398. bytesData, _ := json.Marshal(data)
  41399. var req *http.Request
  41400. if miConfig.MdtrtareaAdmvs == "320921" {
  41401. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41402. } else {
  41403. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41404. }
  41405. resp, _ := client.Do(req)
  41406. defer resp.Body.Close()
  41407. body, ioErr := ioutil.ReadAll(resp.Body)
  41408. if ioErr != nil {
  41409. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41411. return
  41412. }
  41413. var respJSON map[string]interface{}
  41414. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41415. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41417. return
  41418. }
  41419. var res ResultSix
  41420. var resSix10265 ResultSix10265 //1101结果
  41421. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41422. result, _ := json.Marshal(respJSON)
  41423. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41424. utils.ErrorLog("解析失败:%v", err)
  41425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41426. return
  41427. }
  41428. res.InfRefmsgid = resSix10265.InfRefmsgid
  41429. res.Output = resSix10265.Output
  41430. res.ErrMsg = resSix10265.ErrMsg
  41431. res.Cainfo = resSix10265.Cainfo
  41432. res.WarnMsg = resSix10265.WarnMsg
  41433. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41434. res.Infcode = infocode
  41435. if infocode == 0 {
  41436. c.ServeSuccessJSON(map[string]interface{}{
  41437. "msg": "上传成功",
  41438. })
  41439. return
  41440. } else {
  41441. c.ServeSuccessJSON(map[string]interface{}{
  41442. "failed_code": -10,
  41443. "msg": res.ErrMsg,
  41444. })
  41445. return
  41446. }
  41447. }
  41448. func (c *HisApiController) Post3504() {
  41449. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41450. data := make(map[string]interface{})
  41451. var struct3501s []models.Struct3501
  41452. var struct3501 models.Struct3501
  41453. struct3501.OrgName = miConfig.OrgName
  41454. struct3501.AccessKey = miConfig.AccessKey
  41455. struct3501.RequestUrl = miConfig.Url
  41456. struct3501.SecretKey = miConfig.SecretKey
  41457. struct3501.ManuDate = "2022-08-15"
  41458. struct3501.FixmedinsBchno = ""
  41459. struct3501.ManuLotnum = ""
  41460. struct3501.RxFlag = "0"
  41461. struct3501.ExpyEnd = "2022-08-15"
  41462. struct3501.Invdate = "2022-08-15"
  41463. struct3501.InvCnt = "20.25"
  41464. struct3501.Memo = ""
  41465. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41466. struct3501.FixmedinsHilistId = miConfig.Code
  41467. struct3501.FixmedinsHilistName = miConfig.OrgName
  41468. struct3501s = append(struct3501s, struct3501)
  41469. data["struct_3501s"] = struct3501s
  41470. client := &http.Client{}
  41471. bytesData, _ := json.Marshal(data)
  41472. var req *http.Request
  41473. if miConfig.MdtrtareaAdmvs == "320921" {
  41474. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41475. } else {
  41476. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41477. }
  41478. resp, _ := client.Do(req)
  41479. defer resp.Body.Close()
  41480. body, ioErr := ioutil.ReadAll(resp.Body)
  41481. if ioErr != nil {
  41482. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41484. return
  41485. }
  41486. var respJSON map[string]interface{}
  41487. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41488. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41490. return
  41491. }
  41492. var res ResultSix
  41493. var resSix10265 ResultSix10265 //1101结果
  41494. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41495. result, _ := json.Marshal(respJSON)
  41496. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41497. utils.ErrorLog("解析失败:%v", err)
  41498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41499. return
  41500. }
  41501. res.InfRefmsgid = resSix10265.InfRefmsgid
  41502. res.Output = resSix10265.Output
  41503. res.ErrMsg = resSix10265.ErrMsg
  41504. res.Cainfo = resSix10265.Cainfo
  41505. res.WarnMsg = resSix10265.WarnMsg
  41506. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41507. res.Infcode = infocode
  41508. if infocode == 0 {
  41509. c.ServeSuccessJSON(map[string]interface{}{
  41510. "msg": "上传成功",
  41511. })
  41512. return
  41513. } else {
  41514. c.ServeSuccessJSON(map[string]interface{}{
  41515. "failed_code": -10,
  41516. "msg": res.ErrMsg,
  41517. })
  41518. return
  41519. }
  41520. }
  41521. func (c *HisApiController) Post3505() {
  41522. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41523. data := make(map[string]interface{})
  41524. var struct3501s []models.Struct3501
  41525. var struct3501 models.Struct3501
  41526. struct3501.OrgName = miConfig.OrgName
  41527. struct3501.AccessKey = miConfig.AccessKey
  41528. struct3501.RequestUrl = miConfig.Url
  41529. struct3501.SecretKey = miConfig.SecretKey
  41530. struct3501.ManuDate = "2022-08-15"
  41531. struct3501.FixmedinsBchno = ""
  41532. struct3501.ManuLotnum = ""
  41533. struct3501.RxFlag = "0"
  41534. struct3501.ExpyEnd = "2022-08-15"
  41535. struct3501.Invdate = "2022-08-15"
  41536. struct3501.InvCnt = "20.25"
  41537. struct3501.Memo = ""
  41538. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41539. struct3501.FixmedinsHilistId = miConfig.Code
  41540. struct3501.FixmedinsHilistName = miConfig.OrgName
  41541. struct3501s = append(struct3501s, struct3501)
  41542. data["struct_3501s"] = struct3501s
  41543. client := &http.Client{}
  41544. bytesData, _ := json.Marshal(data)
  41545. var req *http.Request
  41546. if miConfig.MdtrtareaAdmvs == "320921" {
  41547. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41548. } else {
  41549. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41550. }
  41551. resp, _ := client.Do(req)
  41552. defer resp.Body.Close()
  41553. body, ioErr := ioutil.ReadAll(resp.Body)
  41554. if ioErr != nil {
  41555. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41557. return
  41558. }
  41559. var respJSON map[string]interface{}
  41560. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41561. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41563. return
  41564. }
  41565. var res ResultSix
  41566. var resSix10265 ResultSix10265 //1101结果
  41567. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41568. result, _ := json.Marshal(respJSON)
  41569. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41570. utils.ErrorLog("解析失败:%v", err)
  41571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41572. return
  41573. }
  41574. res.InfRefmsgid = resSix10265.InfRefmsgid
  41575. res.Output = resSix10265.Output
  41576. res.ErrMsg = resSix10265.ErrMsg
  41577. res.Cainfo = resSix10265.Cainfo
  41578. res.WarnMsg = resSix10265.WarnMsg
  41579. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41580. res.Infcode = infocode
  41581. if infocode == 0 {
  41582. c.ServeSuccessJSON(map[string]interface{}{
  41583. "msg": "上传成功",
  41584. })
  41585. return
  41586. } else {
  41587. c.ServeSuccessJSON(map[string]interface{}{
  41588. "failed_code": -10,
  41589. "msg": res.ErrMsg,
  41590. })
  41591. return
  41592. }
  41593. }
  41594. func (c *HisApiController) Post3506() {
  41595. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41596. data := make(map[string]interface{})
  41597. var struct3501s []models.Struct3501
  41598. var struct3501 models.Struct3501
  41599. struct3501.OrgName = miConfig.OrgName
  41600. struct3501.AccessKey = miConfig.AccessKey
  41601. struct3501.RequestUrl = miConfig.Url
  41602. struct3501.SecretKey = miConfig.SecretKey
  41603. struct3501.ManuDate = "2022-08-15"
  41604. struct3501.FixmedinsBchno = ""
  41605. struct3501.ManuLotnum = ""
  41606. struct3501.RxFlag = "0"
  41607. struct3501.ExpyEnd = "2022-08-15"
  41608. struct3501.Invdate = "2022-08-15"
  41609. struct3501.InvCnt = "20.25"
  41610. struct3501.Memo = ""
  41611. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41612. struct3501.FixmedinsHilistId = miConfig.Code
  41613. struct3501.FixmedinsHilistName = miConfig.OrgName
  41614. struct3501s = append(struct3501s, struct3501)
  41615. data["struct_3501s"] = struct3501s
  41616. client := &http.Client{}
  41617. bytesData, _ := json.Marshal(data)
  41618. var req *http.Request
  41619. if miConfig.MdtrtareaAdmvs == "320921" {
  41620. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41621. } else {
  41622. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41623. }
  41624. resp, _ := client.Do(req)
  41625. defer resp.Body.Close()
  41626. body, ioErr := ioutil.ReadAll(resp.Body)
  41627. if ioErr != nil {
  41628. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41630. return
  41631. }
  41632. var respJSON map[string]interface{}
  41633. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41634. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41636. return
  41637. }
  41638. var res ResultSix
  41639. var resSix10265 ResultSix10265 //1101结果
  41640. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41641. result, _ := json.Marshal(respJSON)
  41642. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41643. utils.ErrorLog("解析失败:%v", err)
  41644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41645. return
  41646. }
  41647. res.InfRefmsgid = resSix10265.InfRefmsgid
  41648. res.Output = resSix10265.Output
  41649. res.ErrMsg = resSix10265.ErrMsg
  41650. res.Cainfo = resSix10265.Cainfo
  41651. res.WarnMsg = resSix10265.WarnMsg
  41652. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41653. res.Infcode = infocode
  41654. if infocode == 0 {
  41655. c.ServeSuccessJSON(map[string]interface{}{
  41656. "msg": "上传成功",
  41657. })
  41658. return
  41659. } else {
  41660. c.ServeSuccessJSON(map[string]interface{}{
  41661. "failed_code": -10,
  41662. "msg": res.ErrMsg,
  41663. })
  41664. return
  41665. }
  41666. }
  41667. func (c *HisApiController) Post3507() {
  41668. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41669. data := make(map[string]interface{})
  41670. var struct3501s []models.Struct3501
  41671. var struct3501 models.Struct3501
  41672. struct3501.OrgName = miConfig.OrgName
  41673. struct3501.AccessKey = miConfig.AccessKey
  41674. struct3501.RequestUrl = miConfig.Url
  41675. struct3501.SecretKey = miConfig.SecretKey
  41676. struct3501.ManuDate = "2022-08-15"
  41677. struct3501.FixmedinsBchno = ""
  41678. struct3501.ManuLotnum = ""
  41679. struct3501.RxFlag = "0"
  41680. struct3501.ExpyEnd = "2022-08-15"
  41681. struct3501.Invdate = "2022-08-15"
  41682. struct3501.InvCnt = "20.25"
  41683. struct3501.Memo = ""
  41684. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41685. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  41686. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  41687. struct3501s = append(struct3501s, struct3501)
  41688. data["struct_3501s"] = struct3501s
  41689. client := &http.Client{}
  41690. bytesData, _ := json.Marshal(data)
  41691. var req *http.Request
  41692. if miConfig.MdtrtareaAdmvs == "320921" {
  41693. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41694. } else {
  41695. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41696. }
  41697. resp, _ := client.Do(req)
  41698. defer resp.Body.Close()
  41699. body, ioErr := ioutil.ReadAll(resp.Body)
  41700. if ioErr != nil {
  41701. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41703. return
  41704. }
  41705. var respJSON map[string]interface{}
  41706. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41707. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41709. return
  41710. }
  41711. var res ResultSix
  41712. var resSix10265 ResultSix10265 //1101结果
  41713. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41714. result, _ := json.Marshal(respJSON)
  41715. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41716. utils.ErrorLog("解析失败:%v", err)
  41717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41718. return
  41719. }
  41720. res.InfRefmsgid = resSix10265.InfRefmsgid
  41721. res.Output = resSix10265.Output
  41722. res.ErrMsg = resSix10265.ErrMsg
  41723. res.Cainfo = resSix10265.Cainfo
  41724. res.WarnMsg = resSix10265.WarnMsg
  41725. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41726. res.Infcode = infocode
  41727. if infocode == 0 {
  41728. c.ServeSuccessJSON(map[string]interface{}{
  41729. "msg": "上传成功",
  41730. })
  41731. return
  41732. } else {
  41733. c.ServeSuccessJSON(map[string]interface{}{
  41734. "failed_code": -10,
  41735. "msg": res.ErrMsg,
  41736. })
  41737. return
  41738. }
  41739. }
  41740. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  41741. // WebSocket服务器地址
  41742. serverURL := "ws://127.0.0.1:8899"
  41743. // 解析WebSocket服务器地址
  41744. u, err := url.Parse(serverURL)
  41745. if err != nil {
  41746. }
  41747. // 建立WebSocket连接
  41748. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41749. if err != nil {
  41750. }
  41751. defer conn.Close()
  41752. input2 := make(map[string]interface{})
  41753. input := make(map[string]interface{})
  41754. inputData := make(map[string]interface{})
  41755. inputData["orgId"] = code
  41756. inputData["businessType"] = "01101"
  41757. inputData["operatorId"] = operator_id
  41758. inputData["operatorName"] = operator_name
  41759. inputData["officeId"] = "001"
  41760. inputData["officeName"] = "血透室"
  41761. inputData["deviceType"] = ""
  41762. input["data"] = inputData
  41763. input["orgId"] = code
  41764. input["transType"] = "ec.query"
  41765. //if md == ""
  41766. if md[:4] == "4403" {
  41767. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41768. } else if md[:4] == "4401" {
  41769. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41770. } else {
  41771. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41772. }
  41773. input2["indata"] = input
  41774. fmt.Println(input2)
  41775. bytesData, _ := json.Marshal(input2)
  41776. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41777. if err != nil {
  41778. fmt.Println(err)
  41779. }
  41780. // 接收消息
  41781. _, receivedMessage, err := conn.ReadMessage()
  41782. if err != nil {
  41783. fmt.Println(err)
  41784. }
  41785. return "", string(receivedMessage)
  41786. }
  41787. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  41788. // WebSocket服务器地址
  41789. serverURL := "ws://127.0.0.1:8899"
  41790. // 解析WebSocket服务器地址
  41791. u, err := url.Parse(serverURL)
  41792. if err != nil {
  41793. }
  41794. // 建立WebSocket连接
  41795. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41796. if err != nil {
  41797. }
  41798. defer conn.Close()
  41799. input2 := make(map[string]interface{})
  41800. input := make(map[string]interface{})
  41801. inputData := make(map[string]interface{})
  41802. inputData["orgId"] = code
  41803. inputData["businessType"] = "01101"
  41804. inputData["operatorId"] = operator_id
  41805. inputData["operatorName"] = operator_name
  41806. inputData["officeId"] = "001"
  41807. inputData["officeName"] = "血透室"
  41808. inputData["deviceType"] = ""
  41809. input["data"] = inputData
  41810. input["orgId"] = code
  41811. input["transType"] = "ec.query"
  41812. //if md == ""
  41813. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  41814. input2["indata"] = input
  41815. fmt.Println(input2)
  41816. bytesData, _ := json.Marshal(input2)
  41817. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41818. if err != nil {
  41819. fmt.Println(err)
  41820. }
  41821. // 接收消息
  41822. _, receivedMessage, err := conn.ReadMessage()
  41823. if err != nil {
  41824. fmt.Println(err)
  41825. }
  41826. return "", string(receivedMessage)
  41827. }
  41828. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  41829. // WebSocket服务器地址
  41830. serverURL := "ws://127.0.0.1:8899"
  41831. // 解析WebSocket服务器地址
  41832. u, err := url.Parse(serverURL)
  41833. if err != nil {
  41834. }
  41835. // 建立WebSocket连接
  41836. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41837. if err != nil {
  41838. }
  41839. defer conn.Close()
  41840. input2 := make(map[string]interface{})
  41841. input := make(map[string]interface{})
  41842. inputData := make(map[string]interface{})
  41843. inputData["orgId"] = code
  41844. inputData["businessType"] = "01301"
  41845. inputData["operatorId"] = operator_id
  41846. inputData["operatorName"] = operator_name
  41847. inputData["officeId"] = "001"
  41848. inputData["officeName"] = "血透室"
  41849. inputData["deviceType"] = ""
  41850. input["data"] = inputData
  41851. input["orgId"] = code
  41852. input["transType"] = "ec.query"
  41853. //if md == ""
  41854. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  41855. input2["indata"] = input
  41856. fmt.Println(input2)
  41857. bytesData, _ := json.Marshal(input2)
  41858. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41859. if err != nil {
  41860. fmt.Println(err)
  41861. }
  41862. // 接收消息
  41863. _, receivedMessage, err := conn.ReadMessage()
  41864. if err != nil {
  41865. fmt.Println(err)
  41866. }
  41867. return "", string(receivedMessage)
  41868. }
  41869. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  41870. // WebSocket服务器地址
  41871. serverURL := "ws://127.0.0.1:8899"
  41872. // 解析WebSocket服务器地址
  41873. u, err := url.Parse(serverURL)
  41874. if err != nil {
  41875. }
  41876. // 建立WebSocket连接
  41877. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41878. if err != nil {
  41879. }
  41880. defer conn.Close()
  41881. input2 := make(map[string]interface{})
  41882. input := make(map[string]interface{})
  41883. inputData := make(map[string]interface{})
  41884. inputData["orgId"] = code
  41885. inputData["businessType"] = "01103"
  41886. inputData["operatorId"] = operator_id
  41887. inputData["operatorName"] = operator_name
  41888. inputData["officeId"] = "001"
  41889. inputData["officeName"] = "血透室"
  41890. inputData["deviceType"] = ""
  41891. input["data"] = inputData
  41892. input["orgId"] = code
  41893. input["transType"] = "ec.query"
  41894. //if md ==
  41895. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  41896. input2["indata"] = input
  41897. fmt.Println(input2)
  41898. bytesData, _ := json.Marshal(input2)
  41899. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41900. if err != nil {
  41901. fmt.Println(err)
  41902. }
  41903. // 接收消息
  41904. _, receivedMessage, err := conn.ReadMessage()
  41905. if err != nil {
  41906. fmt.Println(err)
  41907. }
  41908. return "", string(receivedMessage)
  41909. }
  41910. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  41911. // WebSocket服务器地址
  41912. serverURL := "ws://127.0.0.1:8899"
  41913. // 解析WebSocket服务器地址
  41914. u, err := url.Parse(serverURL)
  41915. if err != nil {
  41916. }
  41917. // 建立WebSocket连接
  41918. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41919. if err != nil {
  41920. }
  41921. defer conn.Close()
  41922. input2 := make(map[string]interface{})
  41923. input := make(map[string]interface{})
  41924. inputData := make(map[string]interface{})
  41925. inputData["orgId"] = code
  41926. inputData["businessType"] = "01101"
  41927. inputData["operatorId"] = operator_id
  41928. inputData["operatorName"] = operator_name
  41929. inputData["officeId"] = "001"
  41930. inputData["officeName"] = "血透室"
  41931. inputData["deviceType"] = ""
  41932. input["data"] = inputData
  41933. input["orgId"] = code
  41934. input["transType"] = "ec.query"
  41935. //if md == ""
  41936. if md[:4] == "4403" {
  41937. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41938. } else if md[:4] == "4401" {
  41939. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41940. } else {
  41941. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41942. }
  41943. input2["indata"] = input
  41944. fmt.Println(input2)
  41945. bytesData, _ := json.Marshal(input2)
  41946. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41947. if err != nil {
  41948. fmt.Println(err)
  41949. }
  41950. // 接收消息
  41951. _, receivedMessage, err := conn.ReadMessage()
  41952. if err != nil {
  41953. fmt.Println(err)
  41954. }
  41955. return "", string(receivedMessage)
  41956. }
  41957. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  41958. // WebSocket服务器地址
  41959. serverURL := "ws://127.0.0.1:8899"
  41960. // 解析WebSocket服务器地址
  41961. u, err := url.Parse(serverURL)
  41962. if err != nil {
  41963. }
  41964. // 建立WebSocket连接
  41965. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41966. if err != nil {
  41967. }
  41968. defer conn.Close()
  41969. input2 := make(map[string]interface{})
  41970. input := make(map[string]interface{})
  41971. inputData := make(map[string]interface{})
  41972. inputData["orgId"] = code
  41973. inputData["businessType"] = "01301"
  41974. inputData["operatorId"] = operator_id
  41975. inputData["operatorName"] = operator_name
  41976. inputData["officeId"] = "001"
  41977. inputData["officeName"] = "血透室"
  41978. inputData["deviceType"] = ""
  41979. input["data"] = inputData
  41980. input["orgId"] = code
  41981. input["transType"] = "ec.query"
  41982. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41983. input2["indata"] = input
  41984. bytesData, _ := json.Marshal(input2)
  41985. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41986. if err != nil {
  41987. fmt.Println(err)
  41988. }
  41989. // 接收消息
  41990. _, receivedMessage, err := conn.ReadMessage()
  41991. if err != nil {
  41992. fmt.Println(err)
  41993. }
  41994. return "", string(receivedMessage)
  41995. }
  41996. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  41997. newArr = make([]string, 0)
  41998. for i := 0; i < len(arr); i++ {
  41999. repeat := false
  42000. for j := i + 1; j < len(arr); j++ {
  42001. if arr[i] == arr[j] {
  42002. repeat = true
  42003. break
  42004. }
  42005. }
  42006. if !repeat {
  42007. newArr = append(newArr, arr[i])
  42008. }
  42009. }
  42010. return
  42011. }
  42012. func getBirthdateAndAge(idNumber string) (string, int, error) {
  42013. if len(idNumber) != 18 {
  42014. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  42015. }
  42016. // 提取出生日期
  42017. year, err := strconv.Atoi(idNumber[6:10])
  42018. if err != nil {
  42019. return "", 0, err
  42020. }
  42021. month, err := strconv.Atoi(idNumber[10:12])
  42022. if err != nil {
  42023. return "", 0, err
  42024. }
  42025. day, err := strconv.Atoi(idNumber[12:14])
  42026. if err != nil {
  42027. return "", 0, err
  42028. }
  42029. // 格式化生日字符串
  42030. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  42031. birthdateFormatted := birthdate.Format("2006-01-02")
  42032. // 计算年龄
  42033. today := time.Now()
  42034. age := today.Year() - birthdate.Year()
  42035. if today.YearDay() < birthdate.YearDay() {
  42036. age--
  42037. }
  42038. return birthdateFormatted, age, nil
  42039. }
  42040. // 从身份证号码中提取出生年月日
  42041. func getBirthDateFromIDCard(idCard string) (string, error) {
  42042. // 身份证号码长度应为18位
  42043. if len(idCard) != 18 {
  42044. return "", fmt.Errorf("身份证号码长度应为18位")
  42045. }
  42046. // 提取出生日期部分 (YYYYMMDD)
  42047. birthDateStr := idCard[6:14]
  42048. // 解析出生日期
  42049. birthDate, err := time.Parse("20060102", birthDateStr)
  42050. if err != nil {
  42051. return "", fmt.Errorf("解析出生日期失败: %v", err)
  42052. }
  42053. // 格式化出生日期为 YYYY-MM-DD
  42054. formattedDate := birthDate.Format("2006-01-02")
  42055. return formattedDate, nil
  42056. }