his_api_controller.go 1.4MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. //"github.com/tjfoc/gmsm/sm3"
  8. "math"
  9. //"crypto/x509/pkix"
  10. "encoding/json"
  11. "fmt"
  12. "gdyb/controllers"
  13. "gdyb/enums"
  14. "gdyb/models"
  15. "gdyb/service"
  16. "gdyb/utils"
  17. "github.com/astaxie/beego"
  18. "github.com/axgle/mahonia"
  19. "github.com/go-ole/go-ole/oleutil"
  20. "github.com/gorilla/websocket"
  21. "github.com/jinzhu/gorm"
  22. "github.com/shopspring/decimal"
  23. "io"
  24. "io/ioutil"
  25. //"math"
  26. "math/rand"
  27. "net/http"
  28. "net/url"
  29. "os"
  30. "path/filepath"
  31. "regexp"
  32. "strconv"
  33. "strings"
  34. "syscall"
  35. "time"
  36. "unsafe"
  37. "github.com/go-ole/go-ole"
  38. )
  39. type HisApiController struct {
  40. controllers.BaseAuthAPIController
  41. }
  42. func HisManagerApiRegistRouters() {
  43. //挂号
  44. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  45. //上传就诊信息-上传明细-结算
  46. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  47. //查询
  48. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  49. //对总账
  50. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  51. //对明细
  52. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  53. //退费,退明细
  54. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  55. //退号
  56. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  57. //退明细
  58. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  59. //上传就诊信息-上传明细-预结算
  60. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  61. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  62. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  63. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  64. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  65. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  66. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  67. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  68. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  69. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  70. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  71. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  72. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  73. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  74. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  75. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  76. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  77. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  78. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  79. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  80. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  81. beego.Router("/api/check", &HisApiController{}, "get:Check")
  82. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  83. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  84. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  85. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  86. beego.Router("/api/3204a", &HisApiController{}, "get:Post3204a")
  87. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  88. beego.Router("/api/8404", &HisApiController{}, "get:Post8404")
  89. beego.Router("/api/3204", &HisApiController{}, "get:Post3204")
  90. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  91. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  92. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  93. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  94. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  95. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  96. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  97. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  98. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  99. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  100. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  101. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  102. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  103. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  104. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  105. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  106. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  107. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  108. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  109. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  110. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  111. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  112. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  113. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  114. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  115. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  116. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  117. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  118. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  119. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  120. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  121. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  122. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  123. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  124. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  125. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  126. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  127. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  128. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  129. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  130. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  131. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  132. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  133. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  134. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  135. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  136. beego.Router("/api/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/3508", &HisApiController{}, "get:Get3508")
  161. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  162. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  163. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  164. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  165. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  166. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  167. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  168. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  169. }
  170. func (c *HisApiController) Get3508() {
  171. admin_user_id, _ := c.GetInt64("admin_user_id")
  172. drug_id, _ := c.GetInt64("id")
  173. start_time := c.GetString("start_time")
  174. end_time := c.GetString("end_time")
  175. adminUser := c.GetAdminUserInfo()
  176. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  177. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  178. drug, _ := service.GetDrugByID(drug_id)
  179. var struct3508 models.Struct3508
  180. struct3508.OrgName = miConfig.OrgName
  181. struct3508.FixmedinsCode = miConfig.Code
  182. struct3508.AccessKey = miConfig.AccessKey
  183. struct3508.Opter = curRoles.UserName
  184. struct3508.RequestUrl = miConfig.Url
  185. struct3508.Url = miConfig.Url
  186. struct3508.AppId = miConfig.Cainfo
  187. struct3508.AppSecret = miConfig.AppSecret
  188. struct3508.Enckey = miConfig.EncKey
  189. struct3508.SignKey = miConfig.SignKey
  190. struct3508.SecretKey = miConfig.SecretKey
  191. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  192. struct3508.Begndate = start_time
  193. struct3508.Enddate = end_time
  194. result1, result2, _ := service.FJyb3508(struct3508)
  195. saveLog(result1, result2, "3508", "3508")
  196. var res models.Result3508
  197. var respJSON2 map[string]interface{}
  198. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  199. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  201. return
  202. }
  203. userJSONBytes2, _ := json.Marshal(respJSON2)
  204. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  205. utils.ErrorLog("解析失败:%v", err)
  206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  207. return
  208. }
  209. if res.Infcode == -1 {
  210. c.ServeSuccessJSON(map[string]interface{}{
  211. "failed_code": -10,
  212. "msg": res.ErrMsg,
  213. })
  214. } else {
  215. c.ServeSuccessJSON(map[string]interface{}{
  216. "info": res.Output,
  217. })
  218. }
  219. }
  220. func (c *HisApiController) Get3509() {
  221. admin_user_id, _ := c.GetInt64("admin_user_id")
  222. drug_id, _ := c.GetInt64("id")
  223. start_time := c.GetString("start_time")
  224. end_time := c.GetString("end_time")
  225. adminUser := c.GetAdminUserInfo()
  226. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  227. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  228. drug, _ := service.GetDrugByID(drug_id)
  229. var struct3508 models.Struct3509
  230. struct3508.OrgName = miConfig.OrgName
  231. struct3508.FixmedinsCode = miConfig.Code
  232. struct3508.AccessKey = miConfig.AccessKey
  233. struct3508.Opter = curRoles.UserName
  234. struct3508.RequestUrl = miConfig.Url
  235. struct3508.Url = miConfig.Url
  236. struct3508.AppId = miConfig.Cainfo
  237. struct3508.AppSecret = miConfig.AppSecret
  238. struct3508.Enckey = miConfig.EncKey
  239. struct3508.SignKey = miConfig.SignKey
  240. struct3508.SecretKey = miConfig.SecretKey
  241. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  242. struct3508.Begndate = start_time
  243. struct3508.Enddate = end_time
  244. result1, result2, _ := service.FJyb3509(struct3508)
  245. saveLog(result1, result2, "3509", "3509")
  246. var res models.Result3509
  247. var respJSON2 map[string]interface{}
  248. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  249. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  251. return
  252. }
  253. userJSONBytes2, _ := json.Marshal(respJSON2)
  254. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  255. utils.ErrorLog("解析失败:%v", err)
  256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  257. return
  258. }
  259. if res.Infcode == -1 {
  260. c.ServeSuccessJSON(map[string]interface{}{
  261. "failed_code": -10,
  262. "msg": res.ErrMsg,
  263. })
  264. } else {
  265. c.ServeSuccessJSON(map[string]interface{}{
  266. "info": res.Output,
  267. })
  268. }
  269. }
  270. func (c *HisApiController) Get3510() {
  271. admin_user_id, _ := c.GetInt64("admin_user_id")
  272. drug_id, _ := c.GetInt64("id")
  273. start_time := c.GetString("start_time")
  274. end_time := c.GetString("end_time")
  275. adminUser := c.GetAdminUserInfo()
  276. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  277. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  278. drug, _ := service.GetDrugByID(drug_id)
  279. var struct3508 models.Struct3510
  280. struct3508.FixmedinsCode = miConfig.Code
  281. struct3508.OrgName = miConfig.OrgName
  282. struct3508.AccessKey = miConfig.AccessKey
  283. struct3508.Opter = curRoles.UserName
  284. struct3508.RequestUrl = miConfig.Url
  285. struct3508.Url = miConfig.Url
  286. struct3508.AppId = miConfig.Cainfo
  287. struct3508.AppSecret = miConfig.AppSecret
  288. struct3508.Enckey = miConfig.EncKey
  289. struct3508.SignKey = miConfig.SignKey
  290. struct3508.SecretKey = miConfig.SecretKey
  291. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  292. struct3508.Begndate = start_time
  293. struct3508.Enddate = end_time
  294. result1, result2, _ := service.FJyb3510(struct3508)
  295. saveLog(result1, result2, "3510", "3510")
  296. var res models.Result3510
  297. var respJSON2 map[string]interface{}
  298. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  301. return
  302. }
  303. userJSONBytes2, _ := json.Marshal(respJSON2)
  304. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  305. utils.ErrorLog("解析失败:%v", err)
  306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  307. return
  308. }
  309. if res.Infcode == -1 {
  310. c.ServeSuccessJSON(map[string]interface{}{
  311. "failed_code": -10,
  312. "msg": res.ErrMsg,
  313. })
  314. } else {
  315. c.ServeSuccessJSON(map[string]interface{}{
  316. "info": res.Output,
  317. })
  318. }
  319. }
  320. func (c *HisApiController) Get3511() {
  321. admin_user_id, _ := c.GetInt64("admin_user_id")
  322. drug_id, _ := c.GetInt64("id")
  323. start_time := c.GetString("start_time")
  324. end_time := c.GetString("end_time")
  325. adminUser := c.GetAdminUserInfo()
  326. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  327. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  328. drug, _ := service.GetDrugByID(drug_id)
  329. var struct3508 models.Struct3511
  330. struct3508.FixmedinsCode = miConfig.Code
  331. struct3508.OrgName = miConfig.OrgName
  332. struct3508.AccessKey = miConfig.AccessKey
  333. struct3508.Opter = curRoles.UserName
  334. struct3508.RequestUrl = miConfig.Url
  335. struct3508.Url = miConfig.Url
  336. struct3508.AppId = miConfig.Cainfo
  337. struct3508.AppSecret = miConfig.AppSecret
  338. struct3508.Enckey = miConfig.EncKey
  339. struct3508.SignKey = miConfig.SignKey
  340. struct3508.SecretKey = miConfig.SecretKey
  341. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  342. struct3508.Begndate = start_time
  343. struct3508.Enddate = end_time
  344. result1, result2, _ := service.FJyb3511(struct3508)
  345. saveLog(result1, result2, "3511", "3511")
  346. var res models.Result3511
  347. var respJSON2 map[string]interface{}
  348. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  349. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  351. return
  352. }
  353. userJSONBytes2, _ := json.Marshal(respJSON2)
  354. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  355. utils.ErrorLog("解析失败:%v", err)
  356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  357. return
  358. }
  359. if res.Infcode == -1 {
  360. c.ServeSuccessJSON(map[string]interface{}{
  361. "failed_code": -10,
  362. "msg": res.ErrMsg,
  363. })
  364. } else {
  365. c.ServeSuccessJSON(map[string]interface{}{
  366. "info": res.Output,
  367. })
  368. }
  369. }
  370. func (c *HisApiController) Get3512() {
  371. admin_user_id, _ := c.GetInt64("admin_user_id")
  372. drug_id, _ := c.GetInt64("id")
  373. start_time := c.GetString("start_time")
  374. end_time := c.GetString("end_time")
  375. adminUser := c.GetAdminUserInfo()
  376. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  377. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  378. drug, _ := service.GetDrugByID(drug_id)
  379. var struct3508 models.Struct3512
  380. struct3508.FixmedinsCode = miConfig.Code
  381. struct3508.OrgName = miConfig.OrgName
  382. struct3508.AccessKey = miConfig.AccessKey
  383. struct3508.Opter = curRoles.UserName
  384. struct3508.RequestUrl = miConfig.Url
  385. struct3508.Url = miConfig.Url
  386. struct3508.AppId = miConfig.Cainfo
  387. struct3508.AppSecret = miConfig.AppSecret
  388. struct3508.Enckey = miConfig.EncKey
  389. struct3508.SignKey = miConfig.SignKey
  390. struct3508.SecretKey = miConfig.SecretKey
  391. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  392. struct3508.Begndate = start_time
  393. struct3508.Enddate = end_time
  394. result1, result2, _ := service.FJyb3512(struct3508)
  395. saveLog(result1, result2, "3512", "3512")
  396. var res models.Result3512
  397. var respJSON2 map[string]interface{}
  398. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  401. return
  402. }
  403. userJSONBytes2, _ := json.Marshal(respJSON2)
  404. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  405. utils.ErrorLog("解析失败:%v", err)
  406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  407. return
  408. }
  409. if res.Infcode == -1 {
  410. c.ServeSuccessJSON(map[string]interface{}{
  411. "failed_code": -10,
  412. "msg": res.ErrMsg,
  413. })
  414. } else {
  415. c.ServeSuccessJSON(map[string]interface{}{
  416. "info": res.Output,
  417. })
  418. }
  419. }
  420. func (c *HisApiController) Get3513() {
  421. admin_user_id, _ := c.GetInt64("admin_user_id")
  422. drug_id, _ := c.GetInt64("id")
  423. start_time := c.GetString("start_time")
  424. end_time := c.GetString("end_time")
  425. adminUser := c.GetAdminUserInfo()
  426. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  427. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  428. drug, _ := service.GetDrugByID(drug_id)
  429. var struct3508 models.Struct3513
  430. struct3508.FixmedinsCode = miConfig.Code
  431. struct3508.OrgName = miConfig.OrgName
  432. struct3508.AccessKey = miConfig.AccessKey
  433. struct3508.Opter = curRoles.UserName
  434. struct3508.RequestUrl = miConfig.Url
  435. struct3508.Url = miConfig.Url
  436. struct3508.AppId = miConfig.Cainfo
  437. struct3508.AppSecret = miConfig.AppSecret
  438. struct3508.Enckey = miConfig.EncKey
  439. struct3508.SignKey = miConfig.SignKey
  440. struct3508.SecretKey = miConfig.SecretKey
  441. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  442. struct3508.Begndate = start_time
  443. struct3508.Enddate = end_time
  444. result1, result2, _ := service.FJyb3513(struct3508)
  445. saveLog(result1, result2, "3513", "3513")
  446. var res models.Result3513
  447. var respJSON2 map[string]interface{}
  448. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  449. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  451. return
  452. }
  453. userJSONBytes2, _ := json.Marshal(respJSON2)
  454. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  455. utils.ErrorLog("解析失败:%v", err)
  456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  457. return
  458. }
  459. if res.Infcode == -1 {
  460. c.ServeSuccessJSON(map[string]interface{}{
  461. "failed_code": -10,
  462. "msg": res.ErrMsg,
  463. })
  464. } else {
  465. c.ServeSuccessJSON(map[string]interface{}{
  466. "info": res.Output,
  467. })
  468. }
  469. }
  470. func (c *HisApiController) Get35081() {
  471. admin_user_id, _ := c.GetInt64("admin_user_id")
  472. drug_id, _ := c.GetInt64("id")
  473. //start_time := c.GetString("start_time")
  474. //end_time := c.GetString("end_time")
  475. page, _ := c.GetInt("page")
  476. adminUser := c.GetAdminUserInfo()
  477. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  478. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  479. drug, _ := service.GetDrugByID(drug_id)
  480. var struct3508 models.Struct35081
  481. struct3508.FixmedinsCode = miConfig.Code
  482. struct3508.OrgName = miConfig.OrgName
  483. struct3508.AccessKey = miConfig.AccessKey
  484. struct3508.Opter = curRoles.UserName
  485. struct3508.RequestUrl = miConfig.Url
  486. struct3508.Url = miConfig.Url
  487. struct3508.AppId = miConfig.Cainfo
  488. struct3508.AppSecret = miConfig.AppSecret
  489. struct3508.Enckey = miConfig.EncKey
  490. struct3508.SignKey = miConfig.SignKey
  491. struct3508.SecretKey = miConfig.SecretKey
  492. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  493. struct3508.PageNum = page
  494. struct3508.PageSize = 10
  495. result1, result2, _ := service.FJyb35081(struct3508)
  496. saveLog(result1, result2, "35081", "35081")
  497. var res models.Result35081
  498. var respJSON2 map[string]interface{}
  499. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  500. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  502. return
  503. }
  504. userJSONBytes2, _ := json.Marshal(respJSON2)
  505. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  506. utils.ErrorLog("解析失败:%v", err)
  507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  508. return
  509. }
  510. if res.Infcode == -1 {
  511. c.ServeSuccessJSON(map[string]interface{}{
  512. "failed_code": -10,
  513. "msg": res.ErrMsg,
  514. })
  515. } else {
  516. c.ServeSuccessJSON(map[string]interface{}{
  517. "info": res.Output,
  518. })
  519. }
  520. }
  521. func (c *HisApiController) Get35082() {
  522. admin_user_id, _ := c.GetInt64("admin_user_id")
  523. drug_id, _ := c.GetInt64("id")
  524. //start_time := c.GetString("start_time")
  525. //end_time := c.GetString("end_time")
  526. page, _ := c.GetInt("page")
  527. adminUser := c.GetAdminUserInfo()
  528. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  529. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  530. drug, _ := service.GetDrugByID(drug_id)
  531. var struct3508 models.Struct35082
  532. struct3508.FixmedinsCode = miConfig.Code
  533. struct3508.OrgName = miConfig.OrgName
  534. struct3508.AccessKey = miConfig.AccessKey
  535. struct3508.Opter = curRoles.UserName
  536. struct3508.RequestUrl = miConfig.Url
  537. struct3508.Url = miConfig.Url
  538. struct3508.AppId = miConfig.Cainfo
  539. struct3508.AppSecret = miConfig.AppSecret
  540. struct3508.Enckey = miConfig.EncKey
  541. struct3508.SignKey = miConfig.SignKey
  542. struct3508.SecretKey = miConfig.SecretKey
  543. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  544. struct3508.PageNum = page
  545. struct3508.PageSize = 10
  546. result1, result2, _ := service.FJyb35082(struct3508)
  547. saveLog(result1, result2, "35082", "35082")
  548. var res models.Result35082
  549. var respJSON2 map[string]interface{}
  550. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  551. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  553. return
  554. }
  555. userJSONBytes2, _ := json.Marshal(respJSON2)
  556. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  557. utils.ErrorLog("解析失败:%v", err)
  558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  559. return
  560. }
  561. if res.Infcode == -1 {
  562. c.ServeSuccessJSON(map[string]interface{}{
  563. "failed_code": -10,
  564. "msg": res.ErrMsg,
  565. })
  566. } else {
  567. c.ServeSuccessJSON(map[string]interface{}{
  568. "info": res.Output,
  569. })
  570. }
  571. }
  572. func (c *HisApiController) FJ3501AND3502() {
  573. ids := c.GetString("ids")
  574. admin_user_id, _ := c.GetInt64("admin_user_id")
  575. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  576. id_arr := strings.Split(ids, ",")
  577. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId,id_arr)
  578. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  579. //库盘
  580. var errs []string
  581. for _, drug := range drugs {
  582. if drug.IsPc == 0 && drug.IsBg == 0 {
  583. var res2 ResultSix
  584. var res3 ResultSix
  585. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  586. var struct3501 models.Struct3501
  587. struct3501.Code = miConfig.Code
  588. struct3501.OrgName = miConfig.OrgName
  589. struct3501.AccessKey = miConfig.AccessKey
  590. struct3501.Opter = roles.UserName
  591. struct3501.RequestUrl = miConfig.Url
  592. struct3501.Url = miConfig.Url
  593. struct3501.AppId = miConfig.Cainfo
  594. struct3501.AppSecret = miConfig.AppSecret
  595. struct3501.Enckey = miConfig.EncKey
  596. struct3501.SignKey = miConfig.SignKey
  597. struct3501.SecretKey = miConfig.SecretKey
  598. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  599. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  600. struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  601. struct3501.RxFlag = "0"
  602. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  603. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  604. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  605. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  606. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  607. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  608. struct3501.FixmedinsBchno = number
  609. struct3501.DrugTracCodg = drug.DrugCode
  610. memo := make(map[string]interface{})
  611. memo["pric"] = drug.Price
  612. bytesData, _ := json.Marshal(memo)
  613. struct3501.Memo = string(bytesData)
  614. if miConfig.MdtrtareaAdmvs == "350500"{
  615. result1, result2, _ := service.FJyb3501(struct3501)
  616. saveLog(result1, result2, "3501", "3501")
  617. //saveLog(result, requestLog, "2201", "挂号")
  618. var respJSON2 map[string]interface{}
  619. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  620. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  622. return
  623. }
  624. userJSONBytes2, _ := json.Marshal(respJSON2)
  625. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  626. utils.ErrorLog("解析失败:%v", err)
  627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  628. return
  629. }
  630. }else{
  631. data := make(map[string]interface{})
  632. data["struct_3501s"] = struct3501
  633. client := &http.Client{}
  634. bytesData, _ := json.Marshal(data)
  635. var req *http.Request
  636. if miConfig.MdtrtareaAdmvs == "320921" {
  637. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  638. } else {
  639. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  640. }
  641. resp, _ := client.Do(req)
  642. defer resp.Body.Close()
  643. body, ioErr := ioutil.ReadAll(resp.Body)
  644. if ioErr != nil {
  645. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  646. }
  647. var respJSON map[string]interface{}
  648. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  649. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  651. return
  652. }
  653. var resSix10265 ResultSix10265 //1101结果
  654. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  655. result, _ := json.Marshal(respJSON)
  656. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  657. utils.ErrorLog("解析失败:%v", err)
  658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  659. return
  660. }
  661. res2.InfRefmsgid = resSix10265.InfRefmsgid
  662. res2.Output = resSix10265.Output
  663. res2.ErrMsg = resSix10265.ErrMsg
  664. res2.Cainfo = resSix10265.Cainfo
  665. res2.WarnMsg = resSix10265.WarnMsg
  666. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  667. res2.Infcode = infocode
  668. }
  669. if res2.Infcode != -1 {
  670. drug.IsPc = 1
  671. drug.Bchno = number
  672. drug.PcDate = time.Now().Unix()
  673. err := service.SaveW(drug)
  674. if err == nil {
  675. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  676. var struct3502 models.Struct3502
  677. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  678. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  679. struct3502.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  680. struct3502.FixmedinsCode = miConfig.Code
  681. struct3502.Code = miConfig.Code
  682. struct3502.RxFlag = "0"
  683. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  684. struct3502.OrgName = miConfig.OrgName
  685. struct3502.Opter = roles.UserName
  686. struct3502.AccessKey = miConfig.AccessKey
  687. struct3502.RequestUrl = miConfig.Url
  688. struct3502.SecretKey = miConfig.SecretKey
  689. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  690. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  691. struct3502.Url = miConfig.Url
  692. struct3502.AppId = miConfig.Cainfo
  693. struct3502.AppSecret = miConfig.AppSecret
  694. struct3502.Enckey = miConfig.EncKey
  695. struct3502.SignKey = miConfig.SignKey
  696. struct3502.SecretKey = miConfig.SecretKey
  697. struct3502.DrugTracCodg = drug.DrugCode
  698. struct3502.Memo = ""
  699. struct3502.InvChgType = "108"
  700. struct3502.FixmedinsBchno = bg_number
  701. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  702. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  703. if miConfig.MdtrtareaAdmvs == "350500"{
  704. result11, result22, _ := service.FJyb3502(struct3502)
  705. saveLog(result11, result22, "3502", "3502")
  706. var respJSON3 map[string]interface{}
  707. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  708. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  710. return
  711. }
  712. userJSONBytes3, _ := json.Marshal(respJSON3)
  713. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  714. utils.ErrorLog("解析失败:%v", err)
  715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  716. return
  717. }
  718. }else {
  719. data := make(map[string]interface{})
  720. data["struct_3502s"] = struct3502
  721. client := &http.Client{}
  722. bytesData, _ := json.Marshal(data)
  723. var req *http.Request
  724. if miConfig.MdtrtareaAdmvs == "320921" {
  725. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  726. } else {
  727. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  728. }
  729. resp, _ := client.Do(req)
  730. defer resp.Body.Close()
  731. body, ioErr := ioutil.ReadAll(resp.Body)
  732. if ioErr != nil {
  733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  734. }
  735. var respJSON map[string]interface{}
  736. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  737. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  739. return
  740. }
  741. var resSix10265 ResultSix10265 //1101结果
  742. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  743. result, _ := json.Marshal(respJSON)
  744. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  745. utils.ErrorLog("解析失败:%v", err)
  746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  747. return
  748. }
  749. res3.InfRefmsgid = resSix10265.InfRefmsgid
  750. res3.Output = resSix10265.Output
  751. res3.ErrMsg = resSix10265.ErrMsg
  752. res3.Cainfo = resSix10265.Cainfo
  753. res3.WarnMsg = resSix10265.WarnMsg
  754. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  755. res3.Infcode = infocode
  756. }
  757. if res3.Infcode == -1 {
  758. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  759. c.ServeSuccessJSON(map[string]interface{}{
  760. "failed_code": -10,
  761. "msg": res3.ErrMsg,
  762. })
  763. } else {
  764. drug.IsBg = 1
  765. drug.BgBchno = bg_number
  766. service.SaveW(drug)
  767. }
  768. }
  769. } else {
  770. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  771. }
  772. }
  773. //变更
  774. if drug.IsPc == 1 && drug.IsBg == 0 {
  775. var res3 ResultSix
  776. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  777. var struct3502 models.Struct3502
  778. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  779. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  780. struct3502.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  781. struct3502.FixmedinsCode = miConfig.Code
  782. struct3502.Code = miConfig.Code
  783. struct3502.Opter = roles.UserName
  784. struct3502.RxFlag = "0"
  785. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  786. struct3502.OrgName = miConfig.OrgName
  787. struct3502.AccessKey = miConfig.AccessKey
  788. struct3502.RequestUrl = miConfig.Url
  789. struct3502.SecretKey = miConfig.SecretKey
  790. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  791. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  792. struct3502.InvChgType = "108"
  793. struct3502.DrugTracCodg = drug.DrugCode
  794. struct3502.Url = miConfig.Url
  795. struct3502.AppId = miConfig.Cainfo
  796. struct3502.AppSecret = miConfig.AppSecret
  797. struct3502.Enckey = miConfig.EncKey
  798. struct3502.SignKey = miConfig.SignKey
  799. struct3502.SecretKey = miConfig.SecretKey
  800. struct3502.FixmedinsBchno = bg_number
  801. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  802. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  803. if miConfig.MdtrtareaAdmvs == "350500"{
  804. result1, result2, _ := service.FJyb3502(struct3502)
  805. saveLog(result1, result2, "3502", "3502")
  806. var respJSON3 map[string]interface{}
  807. if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  810. return
  811. }
  812. userJSONBytes3, _ := json.Marshal(respJSON3)
  813. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  814. utils.ErrorLog("解析失败:%v", err)
  815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  816. return
  817. }
  818. } else {
  819. data := make(map[string]interface{})
  820. data["struct_3502s"] = struct3502
  821. client := &http.Client{}
  822. bytesData, _ := json.Marshal(data)
  823. var req *http.Request
  824. if miConfig.MdtrtareaAdmvs == "320921" {
  825. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  826. } else {
  827. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  828. }
  829. resp, _ := client.Do(req)
  830. defer resp.Body.Close()
  831. body, ioErr := ioutil.ReadAll(resp.Body)
  832. if ioErr != nil {
  833. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  834. }
  835. var respJSON map[string]interface{}
  836. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  837. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  839. return
  840. }
  841. var resSix10265 ResultSix10265 //1101结果
  842. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  843. result, _ := json.Marshal(respJSON)
  844. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  845. utils.ErrorLog("解析失败:%v", err)
  846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  847. return
  848. }
  849. res3.InfRefmsgid = resSix10265.InfRefmsgid
  850. res3.Output = resSix10265.Output
  851. res3.ErrMsg = resSix10265.ErrMsg
  852. res3.Cainfo = resSix10265.Cainfo
  853. res3.WarnMsg = resSix10265.WarnMsg
  854. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  855. res3.Infcode = infocode
  856. }
  857. if res3.Infcode == -1 {
  858. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  859. } else {
  860. drug.IsBg = 1
  861. drug.BgBchno = bg_number
  862. service.SaveW(drug)
  863. }
  864. }
  865. }
  866. if len(errs) == 0 {
  867. c.ServeSuccessJSON(map[string]interface{}{
  868. "msg": "盘存变更成功",
  869. })
  870. } else {
  871. c.ServeSuccessJSON(map[string]interface{}{
  872. "failed_code": -10,
  873. "msg": errs,
  874. })
  875. }
  876. }
  877. func (c *HisApiController) DeletePCandBG() {
  878. ids := c.GetString("ids")
  879. id_arr := strings.Split(ids, ",")
  880. admin_user_id, _ := c.GetInt64("admin_user_id")
  881. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  882. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId,id_arr)
  883. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  884. var err []string
  885. for _, item := range drugs {
  886. if item.IsPc == 1 && item.IsBg == 1 {
  887. var res FJ3507Result
  888. var res2 FJ3507Result
  889. var struct3507 models.Struct3507
  890. struct3507.FixmedinsBchno = item.Bchno
  891. struct3507.InvDataType = "1"
  892. struct3507.Opter = roles.UserName
  893. struct3507.OrgName = miConfig.OrgName
  894. struct3507.AccessKey = miConfig.AccessKey
  895. struct3507.RequestUrl = miConfig.Url
  896. struct3507.FixmedinsCode = miConfig.Code
  897. struct3507.Code = miConfig.Code
  898. struct3507.SecretKey = miConfig.SecretKey
  899. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  900. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  901. struct3507.Url = miConfig.Url
  902. struct3507.AppId = miConfig.Cainfo
  903. struct3507.AppSecret = miConfig.AppSecret
  904. struct3507.Enckey = miConfig.EncKey
  905. struct3507.SignKey = miConfig.SignKey
  906. struct3507.SecretKey = miConfig.SecretKey
  907. if miConfig.MdtrtareaAdmvs == "350500"{
  908. result, result1, _ := service.FJyb3507(struct3507)
  909. saveLog(result, result1, "3507", "3507")
  910. var respJSON2 map[string]interface{}
  911. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  912. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  914. return
  915. }
  916. userJSONBytes2, _ := json.Marshal(respJSON2)
  917. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  918. utils.ErrorLog("解析失败:%v", err)
  919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  920. return
  921. }
  922. }else {
  923. data := make(map[string]interface{})
  924. data["struct_3507s"] = struct3507
  925. client := &http.Client{}
  926. bytesData, _ := json.Marshal(data)
  927. var req *http.Request
  928. if miConfig.MdtrtareaAdmvs == "320921" {
  929. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  930. } else {
  931. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  932. }
  933. resp, _ := client.Do(req)
  934. defer resp.Body.Close()
  935. body, ioErr := ioutil.ReadAll(resp.Body)
  936. if ioErr != nil {
  937. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  938. }
  939. var respJSON map[string]interface{}
  940. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  941. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  943. return
  944. }
  945. var resSix10265 ResultSix10265 //1101结果
  946. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  947. result, _ := json.Marshal(respJSON)
  948. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  949. utils.ErrorLog("解析失败:%v", err)
  950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  951. return
  952. }
  953. res.InfRefmsgid = resSix10265.InfRefmsgid
  954. //res.Output = resSix10265.Output
  955. res.ErrMsg = resSix10265.ErrMsg
  956. res.Cainfo = resSix10265.Cainfo
  957. res.WarnMsg = resSix10265.WarnMsg
  958. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  959. res.Infcode = infocode
  960. }
  961. if res.Infcode == 0 {
  962. item.IsPc = 0
  963. err2 := service.SaveW(item)
  964. if err2 == nil {
  965. var struct3507_2 models.Struct3507
  966. struct3507_2.OrgName = miConfig.OrgName
  967. struct3507_2.AccessKey = miConfig.AccessKey
  968. struct3507_2.RequestUrl = miConfig.Url
  969. struct3507_2.Opter = roles.UserName
  970. struct3507_2.FixmedinsCode = miConfig.Code
  971. struct3507_2.Code = miConfig.Code
  972. struct3507_2.SecretKey = miConfig.SecretKey
  973. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  974. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  975. struct3507_2.Url = miConfig.Url
  976. struct3507_2.AppId = miConfig.Cainfo
  977. struct3507_2.AppSecret = miConfig.AppSecret
  978. struct3507_2.Enckey = miConfig.EncKey
  979. struct3507_2.SignKey = miConfig.SignKey
  980. struct3507_2.SecretKey = miConfig.SecretKey
  981. struct3507_2.FixmedinsBchno = item.BgBchno
  982. struct3507_2.InvDataType = "2"
  983. if miConfig.MdtrtareaAdmvs == "350500"{
  984. result11, result22, _ := service.FJyb3507(struct3507_2)
  985. saveLog(result11, result22, "3507", "3507")
  986. var respJSON3 map[string]interface{}
  987. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  990. return
  991. }
  992. userJSONBytes3, _ := json.Marshal(respJSON3)
  993. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  994. utils.ErrorLog("解析失败:%v", err)
  995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  996. return
  997. }
  998. }else{
  999. data := make(map[string]interface{})
  1000. data["struct_3507s"] = struct3507_2
  1001. client := &http.Client{}
  1002. bytesData, _ := json.Marshal(data)
  1003. var req *http.Request
  1004. if miConfig.MdtrtareaAdmvs == "320921" {
  1005. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1006. } else {
  1007. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1008. }
  1009. resp, _ := client.Do(req)
  1010. defer resp.Body.Close()
  1011. body, ioErr := ioutil.ReadAll(resp.Body)
  1012. if ioErr != nil {
  1013. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1014. }
  1015. var respJSON map[string]interface{}
  1016. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1017. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1019. return
  1020. }
  1021. var resSix10265 ResultSix10265 //1101结果
  1022. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1023. result, _ := json.Marshal(respJSON)
  1024. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1025. utils.ErrorLog("解析失败:%v", err)
  1026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1027. return
  1028. }
  1029. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1030. //res2.Output = resSix10265.Output
  1031. res2.ErrMsg = resSix10265.ErrMsg
  1032. res2.Cainfo = resSix10265.Cainfo
  1033. res2.WarnMsg = resSix10265.WarnMsg
  1034. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1035. res2.Infcode = infocode
  1036. }
  1037. if res2.Infcode != -1 {
  1038. item.IsBg = 0
  1039. item.Bchno = ""
  1040. item.BgBchno = ""
  1041. item.PcDate = 0
  1042. service.SaveW(item)
  1043. } else {
  1044. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1045. }
  1046. }
  1047. } else {
  1048. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1049. }
  1050. }
  1051. if item.IsPc == 1 && item.IsBg == 0 {
  1052. var res FJ3507Result
  1053. var struct3507 models.Struct3507
  1054. struct3507.FixmedinsBchno = item.Bchno
  1055. struct3507.InvDataType = "1"
  1056. struct3507.Opter = roles.UserName
  1057. struct3507.FixmedinsCode = miConfig.Code
  1058. struct3507.Code = miConfig.Code
  1059. struct3507.OrgName = miConfig.OrgName
  1060. struct3507.AccessKey = miConfig.AccessKey
  1061. struct3507.RequestUrl = miConfig.Url
  1062. struct3507.SecretKey = miConfig.SecretKey
  1063. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1064. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1065. struct3507.Url = miConfig.Url
  1066. struct3507.AppId = miConfig.Cainfo
  1067. struct3507.AppSecret = miConfig.AppSecret
  1068. struct3507.Enckey = miConfig.EncKey
  1069. struct3507.SignKey = miConfig.SignKey
  1070. struct3507.SecretKey = miConfig.SecretKey
  1071. //result, result1, _ := service.FJyb3507(struct3507)
  1072. //saveLog(result, result1, "3507", "3507")
  1073. if miConfig.MdtrtareaAdmvs == "350500"{
  1074. result, result1, _ := service.FJyb3507(struct3507)
  1075. saveLog(result, result1, "3507", "3507")
  1076. var respJSON2 map[string]interface{}
  1077. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1078. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1080. return
  1081. }
  1082. userJSONBytes2, _ := json.Marshal(respJSON2)
  1083. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1084. utils.ErrorLog("解析失败:%v", err)
  1085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1086. return
  1087. }
  1088. }else {
  1089. data := make(map[string]interface{})
  1090. data["struct_3507s"] = struct3507
  1091. client := &http.Client{}
  1092. bytesData, _ := json.Marshal(data)
  1093. var req *http.Request
  1094. if miConfig.MdtrtareaAdmvs == "320921" {
  1095. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1096. } else {
  1097. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1098. }
  1099. resp, _ := client.Do(req)
  1100. defer resp.Body.Close()
  1101. body, ioErr := ioutil.ReadAll(resp.Body)
  1102. if ioErr != nil {
  1103. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1104. }
  1105. var respJSON map[string]interface{}
  1106. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1107. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1109. return
  1110. }
  1111. var resSix10265 ResultSix10265 //1101结果
  1112. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1113. result, _ := json.Marshal(respJSON)
  1114. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1115. utils.ErrorLog("解析失败:%v", err)
  1116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1117. return
  1118. }
  1119. res.InfRefmsgid = resSix10265.InfRefmsgid
  1120. //res.Output = resSix10265.Output
  1121. res.ErrMsg = resSix10265.ErrMsg
  1122. res.Cainfo = resSix10265.Cainfo
  1123. res.WarnMsg = resSix10265.WarnMsg
  1124. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1125. res.Infcode = infocode
  1126. }
  1127. if res.Infcode == 0{
  1128. item.IsPc = 0
  1129. item.Bchno = ""
  1130. item.BgBchno = ""
  1131. item.PcDate = 0
  1132. service.SaveW(item)
  1133. } else {
  1134. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1135. }
  1136. }
  1137. if item.IsPc == 0 && item.IsBg == 1 {
  1138. var res FJ3507Result
  1139. var struct3507 models.Struct3507
  1140. struct3507.FixmedinsBchno = item.BgBchno
  1141. struct3507.InvDataType = "2"
  1142. struct3507.Opter = roles.UserName
  1143. struct3507.FixmedinsCode = miConfig.Code
  1144. struct3507.OrgName = miConfig.OrgName
  1145. struct3507.AccessKey = miConfig.AccessKey
  1146. struct3507.RequestUrl = miConfig.Url
  1147. struct3507.SecretKey = miConfig.SecretKey
  1148. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1149. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1150. struct3507.Url = miConfig.Url
  1151. struct3507.AppId = miConfig.Cainfo
  1152. struct3507.AppSecret = miConfig.AppSecret
  1153. struct3507.Enckey = miConfig.EncKey
  1154. struct3507.SignKey = miConfig.SignKey
  1155. struct3507.SecretKey = miConfig.SecretKey
  1156. //result, result1, _ := service.FJyb3507(struct3507)
  1157. //saveLog(result, result1, "3507", "3507")
  1158. if miConfig.MdtrtareaAdmvs == "350500"{
  1159. result, result1, _ := service.FJyb3507(struct3507)
  1160. saveLog(result, result1, "3507", "3507")
  1161. var respJSON2 map[string]interface{}
  1162. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1163. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1165. return
  1166. }
  1167. userJSONBytes2, _ := json.Marshal(respJSON2)
  1168. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1169. utils.ErrorLog("解析失败:%v", err)
  1170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1171. return
  1172. }
  1173. }else {
  1174. data := make(map[string]interface{})
  1175. data["struct_3507s"] = struct3507
  1176. client := &http.Client{}
  1177. bytesData, _ := json.Marshal(data)
  1178. var req *http.Request
  1179. if miConfig.MdtrtareaAdmvs == "320921" {
  1180. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1181. } else {
  1182. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1183. }
  1184. resp, _ := client.Do(req)
  1185. defer resp.Body.Close()
  1186. body, ioErr := ioutil.ReadAll(resp.Body)
  1187. if ioErr != nil {
  1188. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1189. }
  1190. var respJSON map[string]interface{}
  1191. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1194. return
  1195. }
  1196. var resSix10265 ResultSix10265 //1101结果
  1197. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1198. result, _ := json.Marshal(respJSON)
  1199. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1200. utils.ErrorLog("解析失败:%v", err)
  1201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1202. return
  1203. }
  1204. res.InfRefmsgid = resSix10265.InfRefmsgid
  1205. //res.Output = resSix10265.Output
  1206. res.ErrMsg = resSix10265.ErrMsg
  1207. res.Cainfo = resSix10265.Cainfo
  1208. res.WarnMsg = resSix10265.WarnMsg
  1209. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1210. res.Infcode = infocode
  1211. }
  1212. if res.Infcode == 0 {
  1213. item.IsBg = 0
  1214. item.Bchno = ""
  1215. item.BgBchno = ""
  1216. item.PcDate = 0
  1217. service.SaveW(item)
  1218. } else {
  1219. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1220. }
  1221. }
  1222. }
  1223. if len(err) == 0 {
  1224. c.ServeSuccessJSON(map[string]interface{}{
  1225. "msg": "删除盘存变更成功",
  1226. })
  1227. } else {
  1228. c.ServeSuccessJSON(map[string]interface{}{
  1229. "failed_code": -10,
  1230. "msg": err,
  1231. })
  1232. }
  1233. }
  1234. func (c *HisApiController) DeleteXSandBG() {
  1235. ids := c.GetString("ids")
  1236. id_arr := strings.Split(ids, ",")
  1237. admin_user_id, _ := c.GetInt64("admin_user_id")
  1238. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId,id_arr)
  1239. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1240. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1241. var err []string
  1242. for _, item := range flows {
  1243. if item.IsSale == 1 && item.IsChange == 1 {
  1244. var res FJ3507Result
  1245. var res2 FJ3507Result
  1246. var struct3507 models.Struct3507
  1247. struct3507.FixmedinsBchno = item.Bchno
  1248. struct3507.InvDataType = "4"
  1249. struct3507.Opter = roles.UserName
  1250. struct3507.OrgName = miConfig.OrgName
  1251. struct3507.AccessKey = miConfig.AccessKey
  1252. struct3507.RequestUrl = miConfig.Url
  1253. struct3507.FixmedinsCode = miConfig.Code
  1254. struct3507.SecretKey = miConfig.SecretKey
  1255. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1256. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1257. struct3507.Url = miConfig.Url
  1258. struct3507.AppId = miConfig.Cainfo
  1259. struct3507.AppSecret = miConfig.AppSecret
  1260. struct3507.Enckey = miConfig.EncKey
  1261. struct3507.SignKey = miConfig.SignKey
  1262. struct3507.SecretKey = miConfig.SecretKey
  1263. //result, result1, _ := service.FJyb3507(struct3507)
  1264. //saveLog(result, result1, "3507", "3507")
  1265. if miConfig.MdtrtareaAdmvs == "350500"{
  1266. result, result1, _ := service.FJyb3507(struct3507)
  1267. saveLog(result, result1, "3507", "3507")
  1268. var respJSON2 map[string]interface{}
  1269. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1270. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1272. return
  1273. }
  1274. userJSONBytes2, _ := json.Marshal(respJSON2)
  1275. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1276. utils.ErrorLog("解析失败:%v", err)
  1277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1278. return
  1279. }
  1280. }else {
  1281. data := make(map[string]interface{})
  1282. data["struct_3507s"] = struct3507
  1283. client := &http.Client{}
  1284. bytesData, _ := json.Marshal(data)
  1285. var req *http.Request
  1286. if miConfig.MdtrtareaAdmvs == "320921" {
  1287. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1288. } else {
  1289. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1290. }
  1291. resp, _ := client.Do(req)
  1292. defer resp.Body.Close()
  1293. body, ioErr := ioutil.ReadAll(resp.Body)
  1294. if ioErr != nil {
  1295. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1296. }
  1297. var respJSON map[string]interface{}
  1298. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1301. return
  1302. }
  1303. var resSix10265 ResultSix10265 //1101结果
  1304. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1305. result, _ := json.Marshal(respJSON)
  1306. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1307. utils.ErrorLog("解析失败:%v", err)
  1308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1309. return
  1310. }
  1311. res.InfRefmsgid = resSix10265.InfRefmsgid
  1312. //res.Output = resSix10265.Output
  1313. res.ErrMsg = resSix10265.ErrMsg
  1314. res.Cainfo = resSix10265.Cainfo
  1315. res.WarnMsg = resSix10265.WarnMsg
  1316. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1317. res.Infcode = infocode
  1318. }
  1319. if res.Infcode == 0 {
  1320. item.IsSale = 0
  1321. item.SaleDate = ""
  1322. item.Bchno = ""
  1323. err2 := service.SaveDF(item)
  1324. if err2 == nil {
  1325. var struct3507_2 models.Struct3507
  1326. struct3507_2.OrgName = miConfig.OrgName
  1327. struct3507_2.AccessKey = miConfig.AccessKey
  1328. struct3507_2.RequestUrl = miConfig.Url
  1329. struct3507_2.Opter = roles.UserName
  1330. struct3507_2.FixmedinsCode = miConfig.Code
  1331. struct3507_2.Code = miConfig.Code
  1332. struct3507_2.SecretKey = miConfig.SecretKey
  1333. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1334. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1335. struct3507_2.Url = miConfig.Url
  1336. struct3507_2.AppId = miConfig.Cainfo
  1337. struct3507_2.AppSecret = miConfig.AppSecret
  1338. struct3507_2.Enckey = miConfig.EncKey
  1339. struct3507_2.SignKey = miConfig.SignKey
  1340. struct3507_2.SecretKey = miConfig.SecretKey
  1341. struct3507_2.FixmedinsBchno = item.BgBchno
  1342. struct3507_2.InvDataType = "2"
  1343. if miConfig.MdtrtareaAdmvs == "350500"{
  1344. result11, result22, _ := service.FJyb3507(struct3507_2)
  1345. saveLog(result11, result22, "3507", "3507")
  1346. var respJSON3 map[string]interface{}
  1347. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1348. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1350. return
  1351. }
  1352. userJSONBytes3, _ := json.Marshal(respJSON3)
  1353. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1354. utils.ErrorLog("解析失败:%v", err)
  1355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1356. return
  1357. }
  1358. }else{
  1359. data := make(map[string]interface{})
  1360. data["struct_3507s"] = struct3507_2
  1361. client := &http.Client{}
  1362. bytesData, _ := json.Marshal(data)
  1363. var req *http.Request
  1364. if miConfig.MdtrtareaAdmvs == "320921" {
  1365. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1366. } else {
  1367. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1368. }
  1369. resp, _ := client.Do(req)
  1370. defer resp.Body.Close()
  1371. body, ioErr := ioutil.ReadAll(resp.Body)
  1372. if ioErr != nil {
  1373. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1374. }
  1375. var respJSON map[string]interface{}
  1376. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1377. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1379. return
  1380. }
  1381. var resSix10265 ResultSix10265 //1101结果
  1382. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1383. result, _ := json.Marshal(respJSON)
  1384. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1385. utils.ErrorLog("解析失败:%v", err)
  1386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1387. return
  1388. }
  1389. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1390. //res.Output = resSix10265.Output
  1391. res2.ErrMsg = resSix10265.ErrMsg
  1392. res2.Cainfo = resSix10265.Cainfo
  1393. res2.WarnMsg = resSix10265.WarnMsg
  1394. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1395. res2.Infcode = infocode
  1396. }
  1397. if res2.Infcode == 0 {
  1398. item.IsChange = 0
  1399. item.BgBchno = ""
  1400. service.SaveDF2(item)
  1401. } else {
  1402. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1403. }
  1404. }
  1405. } else {
  1406. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1407. }
  1408. }
  1409. if item.IsSale == 2 && item.IsChange == 1 {
  1410. var res FJ3507Result
  1411. var res2 FJ3507Result
  1412. var struct3507 models.Struct3507
  1413. struct3507.FixmedinsBchno = item.Bchno
  1414. struct3507.InvDataType = "4"
  1415. struct3507.Opter = roles.UserName
  1416. struct3507.OrgName = miConfig.OrgName
  1417. struct3507.AccessKey = miConfig.AccessKey
  1418. struct3507.RequestUrl = miConfig.Url
  1419. struct3507.FixmedinsCode = miConfig.Code
  1420. struct3507.Code = miConfig.Code
  1421. struct3507.SecretKey = miConfig.SecretKey
  1422. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1423. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1424. struct3507.Url = miConfig.Url
  1425. struct3507.AppId = miConfig.Cainfo
  1426. struct3507.AppSecret = miConfig.AppSecret
  1427. struct3507.Enckey = miConfig.EncKey
  1428. struct3507.SignKey = miConfig.SignKey
  1429. struct3507.SecretKey = miConfig.SecretKey
  1430. //result, result1, _ := service.FJyb3507(struct3507)
  1431. //saveLog(result, result1, "3507", "3507")
  1432. //
  1433. //var respJSON2 map[string]interface{}
  1434. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1435. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1436. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1437. // return
  1438. //}
  1439. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1440. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1441. // utils.ErrorLog("解析失败:%v", err)
  1442. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1443. // return
  1444. //}
  1445. if miConfig.MdtrtareaAdmvs == "350500"{
  1446. result, result1, _ := service.FJyb3507(struct3507)
  1447. saveLog(result, result1, "3507", "3507")
  1448. var respJSON2 map[string]interface{}
  1449. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1450. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1452. return
  1453. }
  1454. userJSONBytes2, _ := json.Marshal(respJSON2)
  1455. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1456. utils.ErrorLog("解析失败:%v", err)
  1457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1458. return
  1459. }
  1460. }else {
  1461. data := make(map[string]interface{})
  1462. data["struct_3507s"] = struct3507
  1463. client := &http.Client{}
  1464. bytesData, _ := json.Marshal(data)
  1465. var req *http.Request
  1466. if miConfig.MdtrtareaAdmvs == "320921" {
  1467. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1468. } else {
  1469. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1470. }
  1471. resp, _ := client.Do(req)
  1472. defer resp.Body.Close()
  1473. body, ioErr := ioutil.ReadAll(resp.Body)
  1474. if ioErr != nil {
  1475. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1476. }
  1477. var respJSON map[string]interface{}
  1478. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1479. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1481. return
  1482. }
  1483. var resSix10265 ResultSix10265 //1101结果
  1484. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1485. result, _ := json.Marshal(respJSON)
  1486. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1487. utils.ErrorLog("解析失败:%v", err)
  1488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1489. return
  1490. }
  1491. res.InfRefmsgid = resSix10265.InfRefmsgid
  1492. //res.Output = resSix10265.Output
  1493. res.ErrMsg = resSix10265.ErrMsg
  1494. res.Cainfo = resSix10265.Cainfo
  1495. res.WarnMsg = resSix10265.WarnMsg
  1496. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1497. res.Infcode = infocode
  1498. }
  1499. if res.Infcode == 0 {
  1500. item.IsSale = 0
  1501. item.SaleDate = ""
  1502. item.Bchno = ""
  1503. err2 := service.SaveDF(item)
  1504. if err2 == nil {
  1505. var struct3507_2 models.Struct3507
  1506. struct3507_2.OrgName = miConfig.OrgName
  1507. struct3507_2.AccessKey = miConfig.AccessKey
  1508. struct3507_2.RequestUrl = miConfig.Url
  1509. struct3507_2.Opter = roles.UserName
  1510. struct3507_2.FixmedinsCode = miConfig.Code
  1511. struct3507_2.Code = miConfig.Code
  1512. struct3507_2.SecretKey = miConfig.SecretKey
  1513. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1514. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1515. struct3507_2.Url = miConfig.Url
  1516. struct3507_2.AppId = miConfig.Cainfo
  1517. struct3507_2.AppSecret = miConfig.AppSecret
  1518. struct3507_2.Enckey = miConfig.EncKey
  1519. struct3507_2.SignKey = miConfig.SignKey
  1520. struct3507_2.SecretKey = miConfig.SecretKey
  1521. struct3507_2.FixmedinsBchno = item.BgBchno
  1522. struct3507_2.InvDataType = "2"
  1523. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1524. //saveLog(result11, result22, "3507", "3507")
  1525. //var respJSON3 map[string]interface{}
  1526. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1527. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1528. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1529. // return
  1530. //}
  1531. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1532. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1533. // utils.ErrorLog("解析失败:%v", err)
  1534. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1535. // return
  1536. //}
  1537. if miConfig.MdtrtareaAdmvs == "350500"{
  1538. result11, result22, _ := service.FJyb3507(struct3507_2)
  1539. saveLog(result11, result22, "3507", "3507")
  1540. var respJSON3 map[string]interface{}
  1541. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1542. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1544. return
  1545. }
  1546. userJSONBytes3, _ := json.Marshal(respJSON3)
  1547. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1548. utils.ErrorLog("解析失败:%v", err)
  1549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1550. return
  1551. }
  1552. }else{
  1553. data := make(map[string]interface{})
  1554. data["struct_3507s"] = struct3507_2
  1555. client := &http.Client{}
  1556. bytesData, _ := json.Marshal(data)
  1557. var req *http.Request
  1558. if miConfig.MdtrtareaAdmvs == "320921" {
  1559. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1560. } else {
  1561. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1562. }
  1563. resp, _ := client.Do(req)
  1564. defer resp.Body.Close()
  1565. body, ioErr := ioutil.ReadAll(resp.Body)
  1566. if ioErr != nil {
  1567. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1568. }
  1569. var respJSON map[string]interface{}
  1570. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1573. return
  1574. }
  1575. var resSix10265 ResultSix10265 //1101结果
  1576. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1577. result, _ := json.Marshal(respJSON)
  1578. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1579. utils.ErrorLog("解析失败:%v", err)
  1580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1581. return
  1582. }
  1583. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1584. //res.Output = resSix10265.Output
  1585. res2.ErrMsg = resSix10265.ErrMsg
  1586. res2.Cainfo = resSix10265.Cainfo
  1587. res2.WarnMsg = resSix10265.WarnMsg
  1588. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1589. res2.Infcode = infocode
  1590. }
  1591. if res2.Infcode == 0 {
  1592. item.IsChange = 0
  1593. item.BgBchno = ""
  1594. service.SaveDF2(item)
  1595. } else {
  1596. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1597. }
  1598. }
  1599. } else {
  1600. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1601. }
  1602. }
  1603. if item.IsSale == 1 && item.IsChange == 0 {
  1604. var res FJ3507Result
  1605. var struct3507 models.Struct3507
  1606. struct3507.FixmedinsBchno = item.Bchno
  1607. struct3507.InvDataType = "4"
  1608. struct3507.Opter = roles.UserName
  1609. struct3507.FixmedinsCode = miConfig.Code
  1610. struct3507.Code = miConfig.Code
  1611. struct3507.OrgName = miConfig.OrgName
  1612. struct3507.AccessKey = miConfig.AccessKey
  1613. struct3507.RequestUrl = miConfig.Url
  1614. struct3507.SecretKey = miConfig.SecretKey
  1615. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1616. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1617. struct3507.Url = miConfig.Url
  1618. struct3507.AppId = miConfig.Cainfo
  1619. struct3507.AppSecret = miConfig.AppSecret
  1620. struct3507.Enckey = miConfig.EncKey
  1621. struct3507.SignKey = miConfig.SignKey
  1622. struct3507.SecretKey = miConfig.SecretKey
  1623. //result, result1, _ := service.FJyb3507(struct3507)
  1624. //saveLog(result, result1, "3507", "3507")
  1625. //
  1626. //var respJSON3 map[string]interface{}
  1627. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1628. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1629. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1630. // return
  1631. //}
  1632. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1633. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1634. // utils.ErrorLog("解析失败:%v", err)
  1635. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1636. // return
  1637. //}
  1638. if miConfig.MdtrtareaAdmvs == "350500"{
  1639. result, result1, _ := service.FJyb3507(struct3507)
  1640. saveLog(result, result1, "3507", "3507")
  1641. var respJSON2 map[string]interface{}
  1642. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1643. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1645. return
  1646. }
  1647. userJSONBytes2, _ := json.Marshal(respJSON2)
  1648. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1649. utils.ErrorLog("解析失败:%v", err)
  1650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1651. return
  1652. }
  1653. }else {
  1654. data := make(map[string]interface{})
  1655. data["struct_3507s"] = struct3507
  1656. client := &http.Client{}
  1657. bytesData, _ := json.Marshal(data)
  1658. var req *http.Request
  1659. if miConfig.MdtrtareaAdmvs == "320921" {
  1660. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1661. } else {
  1662. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1663. }
  1664. resp, _ := client.Do(req)
  1665. defer resp.Body.Close()
  1666. body, ioErr := ioutil.ReadAll(resp.Body)
  1667. if ioErr != nil {
  1668. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1669. }
  1670. var respJSON map[string]interface{}
  1671. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1674. return
  1675. }
  1676. var resSix10265 ResultSix10265 //1101结果
  1677. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1678. result, _ := json.Marshal(respJSON)
  1679. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1680. utils.ErrorLog("解析失败:%v", err)
  1681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1682. return
  1683. }
  1684. res.InfRefmsgid = resSix10265.InfRefmsgid
  1685. //res.Output = resSix10265.Output
  1686. res.ErrMsg = resSix10265.ErrMsg
  1687. res.Cainfo = resSix10265.Cainfo
  1688. res.WarnMsg = resSix10265.WarnMsg
  1689. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1690. res.Infcode = infocode
  1691. }
  1692. if res.Infcode == 0 {
  1693. item.IsSale = 0
  1694. item.SaleDate = ""
  1695. service.SaveDF(item)
  1696. } else {
  1697. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1698. }
  1699. }
  1700. if item.IsSale == 2 && item.IsChange == 0 {
  1701. var res FJ3507Result
  1702. var struct3507 models.Struct3507
  1703. struct3507.FixmedinsBchno = item.Bchno
  1704. struct3507.InvDataType = "4"
  1705. struct3507.Opter = roles.UserName
  1706. struct3507.FixmedinsCode = miConfig.Code
  1707. struct3507.Code = miConfig.Code
  1708. struct3507.OrgName = miConfig.OrgName
  1709. struct3507.AccessKey = miConfig.AccessKey
  1710. struct3507.RequestUrl = miConfig.Url
  1711. struct3507.SecretKey = miConfig.SecretKey
  1712. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1713. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1714. struct3507.Url = miConfig.Url
  1715. struct3507.AppId = miConfig.Cainfo
  1716. struct3507.AppSecret = miConfig.AppSecret
  1717. struct3507.Enckey = miConfig.EncKey
  1718. struct3507.SignKey = miConfig.SignKey
  1719. struct3507.SecretKey = miConfig.SecretKey
  1720. //result, result1, _ := service.FJyb3507(struct3507)
  1721. //saveLog(result, result1, "3507", "3507")
  1722. //
  1723. //var respJSON3 map[string]interface{}
  1724. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1725. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1726. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1727. // return
  1728. //}
  1729. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1730. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1731. // utils.ErrorLog("解析失败:%v", err)
  1732. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1733. // return
  1734. //}
  1735. if miConfig.MdtrtareaAdmvs == "350500"{
  1736. result, result1, _ := service.FJyb3507(struct3507)
  1737. saveLog(result, result1, "3507", "3507")
  1738. var respJSON2 map[string]interface{}
  1739. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1740. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1742. return
  1743. }
  1744. userJSONBytes2, _ := json.Marshal(respJSON2)
  1745. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1746. utils.ErrorLog("解析失败:%v", err)
  1747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1748. return
  1749. }
  1750. }else {
  1751. data := make(map[string]interface{})
  1752. data["struct_3507s"] = struct3507
  1753. client := &http.Client{}
  1754. bytesData, _ := json.Marshal(data)
  1755. var req *http.Request
  1756. if miConfig.MdtrtareaAdmvs == "320921" {
  1757. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1758. } else {
  1759. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1760. }
  1761. resp, _ := client.Do(req)
  1762. defer resp.Body.Close()
  1763. body, ioErr := ioutil.ReadAll(resp.Body)
  1764. if ioErr != nil {
  1765. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1766. }
  1767. var respJSON map[string]interface{}
  1768. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1769. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1771. return
  1772. }
  1773. var resSix10265 ResultSix10265 //1101结果
  1774. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1775. result, _ := json.Marshal(respJSON)
  1776. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1777. utils.ErrorLog("解析失败:%v", err)
  1778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1779. return
  1780. }
  1781. res.InfRefmsgid = resSix10265.InfRefmsgid
  1782. //res.Output = resSix10265.Output
  1783. res.ErrMsg = resSix10265.ErrMsg
  1784. res.Cainfo = resSix10265.Cainfo
  1785. res.WarnMsg = resSix10265.WarnMsg
  1786. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1787. res.Infcode = infocode
  1788. }
  1789. if res.Infcode == 0 {
  1790. item.IsSale = 0
  1791. item.SaleDate = ""
  1792. item.Bchno = ""
  1793. service.SaveDF(item)
  1794. } else {
  1795. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1796. }
  1797. }
  1798. if item.IsSale == 0 && item.IsChange == 1 {
  1799. var res FJ3507Result
  1800. var struct3507 models.Struct3507
  1801. struct3507.FixmedinsBchno = item.BgBchno
  1802. struct3507.InvDataType = "2"
  1803. struct3507.Opter = roles.UserName
  1804. struct3507.FixmedinsCode = miConfig.Code
  1805. struct3507.Code = miConfig.Code
  1806. struct3507.OrgName = miConfig.OrgName
  1807. struct3507.AccessKey = miConfig.AccessKey
  1808. struct3507.RequestUrl = miConfig.Url
  1809. struct3507.SecretKey = miConfig.SecretKey
  1810. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1811. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1812. struct3507.Url = miConfig.Url
  1813. struct3507.AppId = miConfig.Cainfo
  1814. struct3507.AppSecret = miConfig.AppSecret
  1815. struct3507.Enckey = miConfig.EncKey
  1816. struct3507.SignKey = miConfig.SignKey
  1817. struct3507.SecretKey = miConfig.SecretKey
  1818. //result, result1, _ := service.FJyb3507(struct3507)
  1819. //saveLog(result, result1, "3507", "3507")
  1820. //
  1821. //var respJSON3 map[string]interface{}
  1822. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1823. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1824. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1825. // return
  1826. //}
  1827. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1828. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1829. // utils.ErrorLog("解析失败:%v", err)
  1830. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1831. // return
  1832. //}
  1833. if miConfig.MdtrtareaAdmvs == "350500"{
  1834. result, result1, _ := service.FJyb3507(struct3507)
  1835. saveLog(result, result1, "3507", "3507")
  1836. var respJSON2 map[string]interface{}
  1837. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1838. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1840. return
  1841. }
  1842. userJSONBytes2, _ := json.Marshal(respJSON2)
  1843. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1844. utils.ErrorLog("解析失败:%v", err)
  1845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1846. return
  1847. }
  1848. }else {
  1849. data := make(map[string]interface{})
  1850. data["struct_3507s"] = struct3507
  1851. client := &http.Client{}
  1852. bytesData, _ := json.Marshal(data)
  1853. var req *http.Request
  1854. if miConfig.MdtrtareaAdmvs == "320921" {
  1855. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1856. } else {
  1857. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1858. }
  1859. resp, _ := client.Do(req)
  1860. defer resp.Body.Close()
  1861. body, ioErr := ioutil.ReadAll(resp.Body)
  1862. if ioErr != nil {
  1863. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1864. }
  1865. var respJSON map[string]interface{}
  1866. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1867. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1869. return
  1870. }
  1871. var resSix10265 ResultSix10265 //1101结果
  1872. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1873. result, _ := json.Marshal(respJSON)
  1874. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1875. utils.ErrorLog("解析失败:%v", err)
  1876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1877. return
  1878. }
  1879. res.InfRefmsgid = resSix10265.InfRefmsgid
  1880. //res.Output = resSix10265.Output
  1881. res.ErrMsg = resSix10265.ErrMsg
  1882. res.Cainfo = resSix10265.Cainfo
  1883. res.WarnMsg = resSix10265.WarnMsg
  1884. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1885. res.Infcode = infocode
  1886. }
  1887. if res.Infcode == 0 {
  1888. item.IsChange = 0
  1889. item.BgBchno = ""
  1890. service.SaveDF2(item)
  1891. } else {
  1892. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1893. }
  1894. }
  1895. }
  1896. if len(err) == 0 {
  1897. c.ServeSuccessJSON(map[string]interface{}{
  1898. "msg": "删除销售变更成功",
  1899. })
  1900. } else {
  1901. c.ServeSuccessJSON(map[string]interface{}{
  1902. "failed_code": -10,
  1903. "msg": err,
  1904. })
  1905. }
  1906. }
  1907. func (c *HisApiController) ChangeDrugfour() {
  1908. ids := c.GetString("ids")
  1909. patient_id,_ := c.GetInt64("patient_id")
  1910. patient_id,_ := c.GetInt64("patient_id")
  1911. patient_id,_ := c.GetInt64("patient_id")
  1912. id_arr := strings.Split(ids, ",")
  1913. times := this.GetString("time", "")
  1914. orgid := this.GetAdminUserInfo().CurrentOrgId
  1915. creater := this.GetAdminUserInfo().AdminUser.Id
  1916. timeLayout := "2006-01-02"
  1917. loc, _ := time.LoadLocation("Local")
  1918. var stime, etime int64
  1919. if times == "" {
  1920. stime, etime = service.GetNowTime()
  1921. } else {
  1922. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  1923. stime = stmp.Unix()
  1924. etime = stime + 86399
  1925. }
  1926. advicelist, _ := service.FindeHisAdviceDocAdvice(orgid, patient_id, stime, etime)
  1927. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId,id_arr)
  1928. admin_user_id, _ := c.GetInt64("admin_user_id")
  1929. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1930. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1931. var err []string
  1932. for _, item := range flows {
  1933. var res3 ResultSix
  1934. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  1935. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  1936. if prescription.OrderStatus == 2 {
  1937. //已经结算
  1938. //判断是否已经销售
  1939. if item.IsSale == 1 { //是否已经销售,1是 0否
  1940. //是否已经变更 1是 0否
  1941. if item.IsChange == 0 { //没变更,进行变更操作
  1942. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  1943. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  1944. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  1945. var respJSON3 map[string]interface{}
  1946. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1947. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1949. return
  1950. }
  1951. userJSONBytes3, _ := json.Marshal(respJSON3)
  1952. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1953. utils.ErrorLog("解析失败:%v", err)
  1954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1955. return
  1956. }
  1957. if res3.Infcode == 0 {
  1958. item.IsChange = 1
  1959. item.BgBchno = bg_number
  1960. service.SaveDF2(item)
  1961. } else {
  1962. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  1963. }
  1964. }
  1965. } else { //没销售,
  1966. var res FJ3507Result
  1967. var res3507for10188 FJ3507ResultFor10188
  1968. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  1969. //进行商品销售接口
  1970. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  1971. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  1972. var respJSON3 map[string]interface{}
  1973. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  1974. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1976. return
  1977. }
  1978. userJSONBytes3, _ := json.Marshal(respJSON3)
  1979. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  1980. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  1981. utils.ErrorLog("解析失败:%v", err)
  1982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1983. return
  1984. }
  1985. //if res3507for10188.Infcode
  1986. res.InfRefmsgid = res3507for10188.InfRefmsgid
  1987. //res.Output = resSix10265.Output
  1988. res.ErrMsg = res3507for10188.ErrMsg
  1989. res.Cainfo = res3507for10188.Cainfo
  1990. res.WarnMsg = res3507for10188.WarnMsg
  1991. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  1992. res.Infcode = infocode
  1993. }else{
  1994. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1995. utils.ErrorLog("解析失败:%v", err)
  1996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1997. return
  1998. }
  1999. }
  2000. if res.Infcode == 0 {
  2001. item.IsSale = 1
  2002. item.Bchno = number
  2003. item.SaleDate = time.Now().Format("2006-01-02")
  2004. err5 := service.SaveDF(item)
  2005. if err5 == nil {
  2006. if item.IsChange == 0 { //没变更,进行变更操作
  2007. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2008. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  2009. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  2010. var respJSON3 map[string]interface{}
  2011. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2012. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2014. return
  2015. }
  2016. userJSONBytes3, _ := json.Marshal(respJSON3)
  2017. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2018. utils.ErrorLog("解析失败:%v", err)
  2019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2020. return
  2021. }
  2022. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2023. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2024. utils.ErrorLog("解析失败:%v", err)
  2025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2026. return
  2027. }
  2028. //if res3507for10188.Infcode
  2029. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  2030. //res.Output = resSix10265.Output
  2031. res3.ErrMsg = res3507for10188.ErrMsg
  2032. res3.Cainfo = res3507for10188.Cainfo
  2033. res3.WarnMsg = res3507for10188.WarnMsg
  2034. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2035. res3.Infcode = infocode
  2036. }else{
  2037. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2038. utils.ErrorLog("解析失败:%v", err)
  2039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2040. return
  2041. }
  2042. }
  2043. if res3.Infcode == 0 {
  2044. item.IsChange = 1
  2045. item.BgBchno = bg_number
  2046. service.SaveDF2(item)
  2047. } else {
  2048. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2049. }
  2050. }
  2051. }
  2052. } else {
  2053. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  2054. }
  2055. }
  2056. } else { //还没结算
  2057. var res3507for10188 FJ3507ResultFor10188
  2058. if item.IsChange == 0 { //没变更,进行变更操作
  2059. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2060. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  2061. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  2062. var respJSON3 map[string]interface{}
  2063. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2064. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2066. return
  2067. }
  2068. userJSONBytes3, _ := json.Marshal(respJSON3)
  2069. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2070. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2071. utils.ErrorLog("解析失败:%v", err)
  2072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2073. return
  2074. }
  2075. //if res3507for10188.Infcode
  2076. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  2077. //res.Output = resSix10265.Output
  2078. res3.ErrMsg = res3507for10188.ErrMsg
  2079. res3.Cainfo = res3507for10188.Cainfo
  2080. res3.WarnMsg = res3507for10188.WarnMsg
  2081. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2082. res3.Infcode = infocode
  2083. }else{
  2084. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2085. utils.ErrorLog("解析失败:%v", err)
  2086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2087. return
  2088. }
  2089. }
  2090. if res3.Infcode == 0 {
  2091. item.IsChange = 1
  2092. item.BgBchno = bg_number
  2093. service.SaveDF2(item)
  2094. } else {
  2095. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2096. }
  2097. }
  2098. }
  2099. } else if item.ConsumableType == 7 {
  2100. var res3507for10188 FJ3507ResultFor10188
  2101. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2102. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  2103. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  2104. //判断是否已经销售
  2105. if item.IsSale == 2 { //是否已经销售,1是 0否
  2106. //是否已经变更 1是 0否
  2107. if item.IsChange == 0 { //没变更,进行变更操作
  2108. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2109. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  2110. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  2111. var respJSON3 map[string]interface{}
  2112. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2115. return
  2116. }
  2117. userJSONBytes3, _ := json.Marshal(respJSON3)
  2118. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2119. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2120. utils.ErrorLog("解析失败:%v", err)
  2121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2122. return
  2123. }
  2124. //if res3507for10188.Infcode
  2125. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  2126. //res.Output = resSix10265.Output
  2127. res3.ErrMsg = res3507for10188.ErrMsg
  2128. res3.Cainfo = res3507for10188.Cainfo
  2129. res3.WarnMsg = res3507for10188.WarnMsg
  2130. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2131. res3.Infcode = infocode
  2132. }else{
  2133. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2134. utils.ErrorLog("解析失败:%v", err)
  2135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2136. return
  2137. }
  2138. }
  2139. if res3.Infcode == 0 {
  2140. item.IsChange = 1
  2141. item.BgBchno = bg_number
  2142. service.SaveDF2(item)
  2143. } else {
  2144. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2145. }
  2146. }
  2147. } else { //没销售,
  2148. //进行商品销售退货接口
  2149. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  2150. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2151. saveLog(result111, result222, "3506", "销售退货")
  2152. var res7 FJ3507Result
  2153. //进行商品销售接口
  2154. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  2155. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  2156. var respJSON3 map[string]interface{}
  2157. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  2158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2160. return
  2161. }
  2162. userJSONBytes3, _ := json.Marshal(respJSON3)
  2163. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2164. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2165. utils.ErrorLog("解析失败:%v", err)
  2166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2167. return
  2168. }
  2169. //if res3507for10188.Infcode
  2170. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  2171. //res.Output = resSix10265.Output
  2172. res7.ErrMsg = res3507for10188.ErrMsg
  2173. res7.Cainfo = res3507for10188.Cainfo
  2174. res7.WarnMsg = res3507for10188.WarnMsg
  2175. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2176. res7.Infcode = infocode
  2177. }else{
  2178. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  2179. utils.ErrorLog("解析失败:%v", err)
  2180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2181. return
  2182. }
  2183. }
  2184. if res7.Infcode == 0 {
  2185. item.IsSale = 2
  2186. item.SaleDate = item.SaleDate
  2187. item.Bchno = number
  2188. service.SaveDF(item)
  2189. if item.IsChange == 0 { //没变更,进行变更操作
  2190. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2191. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  2192. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  2193. var respJSON3 map[string]interface{}
  2194. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2195. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2197. return
  2198. }
  2199. userJSONBytes3, _ := json.Marshal(respJSON3)
  2200. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2201. // utils.ErrorLog("解析失败:%v", err)
  2202. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2203. // return
  2204. //}
  2205. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2206. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2207. utils.ErrorLog("解析失败:%v", err)
  2208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2209. return
  2210. }
  2211. //if res3507for10188.Infcode
  2212. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  2213. //res.Output = resSix10265.Output
  2214. res3.ErrMsg = res3507for10188.ErrMsg
  2215. res3.Cainfo = res3507for10188.Cainfo
  2216. res3.WarnMsg = res3507for10188.WarnMsg
  2217. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2218. res3.Infcode = infocode
  2219. }else{
  2220. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2221. utils.ErrorLog("解析失败:%v", err)
  2222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2223. return
  2224. }
  2225. }
  2226. if res3.Infcode == 0 {
  2227. item.IsChange = 1
  2228. item.BgBchno = bg_number
  2229. service.SaveDF2(item)
  2230. } else {
  2231. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2232. }
  2233. }
  2234. } else {
  2235. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  2236. }
  2237. }
  2238. } else { //还没结算
  2239. if item.IsChange == 0 { //没变更,进行变更操作
  2240. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2241. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  2242. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  2243. var respJSON3 map[string]interface{}
  2244. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2245. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2247. return
  2248. }
  2249. userJSONBytes3, _ := json.Marshal(respJSON3)
  2250. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2251. // utils.ErrorLog("解析失败:%v", err)
  2252. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2253. // return
  2254. //}
  2255. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2256. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2257. utils.ErrorLog("解析失败:%v", err)
  2258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2259. return
  2260. }
  2261. //if res3507for10188.Infcode
  2262. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  2263. //res.Output = resSix10265.Output
  2264. res3.ErrMsg = res3507for10188.ErrMsg
  2265. res3.Cainfo = res3507for10188.Cainfo
  2266. res3.WarnMsg = res3507for10188.WarnMsg
  2267. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2268. res3.Infcode = infocode
  2269. }else{
  2270. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2271. utils.ErrorLog("解析失败:%v", err)
  2272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2273. return
  2274. }
  2275. }
  2276. if res3.Infcode == 0 {
  2277. item.IsChange = 1
  2278. item.BgBchno = bg_number
  2279. service.SaveDF2(item)
  2280. } else {
  2281. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2282. }
  2283. }
  2284. }
  2285. }
  2286. }
  2287. if len(err) == 0 {
  2288. c.ServeSuccessJSON(map[string]interface{}{
  2289. "msg": "销售变更成功",
  2290. })
  2291. } else {
  2292. c.ServeSuccessJSON(map[string]interface{}{
  2293. "failed_code": -10,
  2294. "msg": err,
  2295. })
  2296. }
  2297. }
  2298. func (c *HisApiController) ChangeDrug() {
  2299. ids := c.GetString("ids")
  2300. id_arr := strings.Split(ids, ",")
  2301. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId,id_arr)
  2302. admin_user_id, _ := c.GetInt64("admin_user_id")
  2303. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2304. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2305. var err []string
  2306. for _, item := range flows {
  2307. var res3 ResultSix
  2308. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  2309. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2310. if prescription.OrderStatus == 2 {
  2311. //已经结算
  2312. //判断是否已经销售
  2313. if item.IsSale == 1 { //是否已经销售,1是 0否
  2314. //是否已经变更 1是 0否
  2315. if item.IsChange == 0 { //没变更,进行变更操作
  2316. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2317. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  2318. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  2319. var respJSON3 map[string]interface{}
  2320. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2323. return
  2324. }
  2325. userJSONBytes3, _ := json.Marshal(respJSON3)
  2326. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2327. utils.ErrorLog("解析失败:%v", err)
  2328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2329. return
  2330. }
  2331. if res3.Infcode == 0 {
  2332. item.IsChange = 1
  2333. item.BgBchno = bg_number
  2334. service.SaveDF2(item)
  2335. } else {
  2336. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2337. }
  2338. }
  2339. } else { //没销售,
  2340. var res FJ3507Result
  2341. var res3507for10188 FJ3507ResultFor10188
  2342. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  2343. //进行商品销售接口
  2344. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2345. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  2346. var respJSON3 map[string]interface{}
  2347. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  2348. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2350. return
  2351. }
  2352. userJSONBytes3, _ := json.Marshal(respJSON3)
  2353. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2354. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2355. utils.ErrorLog("解析失败:%v", err)
  2356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2357. return
  2358. }
  2359. //if res3507for10188.Infcode
  2360. res.InfRefmsgid = res3507for10188.InfRefmsgid
  2361. //res.Output = resSix10265.Output
  2362. res.ErrMsg = res3507for10188.ErrMsg
  2363. res.Cainfo = res3507for10188.Cainfo
  2364. res.WarnMsg = res3507for10188.WarnMsg
  2365. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2366. res.Infcode = infocode
  2367. }else{
  2368. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2369. utils.ErrorLog("解析失败:%v", err)
  2370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2371. return
  2372. }
  2373. }
  2374. if res.Infcode == 0 {
  2375. item.IsSale = 1
  2376. item.Bchno = number
  2377. item.SaleDate = time.Now().Format("2006-01-02")
  2378. err5 := service.SaveDF(item)
  2379. if err5 == nil {
  2380. if item.IsChange == 0 { //没变更,进行变更操作
  2381. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2382. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  2383. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  2384. var respJSON3 map[string]interface{}
  2385. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2388. return
  2389. }
  2390. userJSONBytes3, _ := json.Marshal(respJSON3)
  2391. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2392. utils.ErrorLog("解析失败:%v", err)
  2393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2394. return
  2395. }
  2396. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2397. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2398. utils.ErrorLog("解析失败:%v", err)
  2399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2400. return
  2401. }
  2402. //if res3507for10188.Infcode
  2403. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  2404. //res.Output = resSix10265.Output
  2405. res3.ErrMsg = res3507for10188.ErrMsg
  2406. res3.Cainfo = res3507for10188.Cainfo
  2407. res3.WarnMsg = res3507for10188.WarnMsg
  2408. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2409. res3.Infcode = infocode
  2410. }else{
  2411. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2412. utils.ErrorLog("解析失败:%v", err)
  2413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2414. return
  2415. }
  2416. }
  2417. if res3.Infcode == 0 {
  2418. item.IsChange = 1
  2419. item.BgBchno = bg_number
  2420. service.SaveDF2(item)
  2421. } else {
  2422. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2423. }
  2424. }
  2425. }
  2426. } else {
  2427. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  2428. }
  2429. }
  2430. } else { //还没结算
  2431. var res3507for10188 FJ3507ResultFor10188
  2432. if item.IsChange == 0 { //没变更,进行变更操作
  2433. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2434. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  2435. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  2436. var respJSON3 map[string]interface{}
  2437. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2438. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2440. return
  2441. }
  2442. userJSONBytes3, _ := json.Marshal(respJSON3)
  2443. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2444. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2445. utils.ErrorLog("解析失败:%v", err)
  2446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2447. return
  2448. }
  2449. //if res3507for10188.Infcode
  2450. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  2451. //res.Output = resSix10265.Output
  2452. res3.ErrMsg = res3507for10188.ErrMsg
  2453. res3.Cainfo = res3507for10188.Cainfo
  2454. res3.WarnMsg = res3507for10188.WarnMsg
  2455. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2456. res3.Infcode = infocode
  2457. }else{
  2458. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2459. utils.ErrorLog("解析失败:%v", err)
  2460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2461. return
  2462. }
  2463. }
  2464. if res3.Infcode == 0 {
  2465. item.IsChange = 1
  2466. item.BgBchno = bg_number
  2467. service.SaveDF2(item)
  2468. } else {
  2469. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2470. }
  2471. }
  2472. }
  2473. } else if item.ConsumableType == 7 {
  2474. var res3507for10188 FJ3507ResultFor10188
  2475. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2476. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  2477. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  2478. //判断是否已经销售
  2479. if item.IsSale == 2 { //是否已经销售,1是 0否
  2480. //是否已经变更 1是 0否
  2481. if item.IsChange == 0 { //没变更,进行变更操作
  2482. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2483. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  2484. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  2485. var respJSON3 map[string]interface{}
  2486. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2487. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2489. return
  2490. }
  2491. userJSONBytes3, _ := json.Marshal(respJSON3)
  2492. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2493. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2494. utils.ErrorLog("解析失败:%v", err)
  2495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2496. return
  2497. }
  2498. //if res3507for10188.Infcode
  2499. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  2500. //res.Output = resSix10265.Output
  2501. res3.ErrMsg = res3507for10188.ErrMsg
  2502. res3.Cainfo = res3507for10188.Cainfo
  2503. res3.WarnMsg = res3507for10188.WarnMsg
  2504. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2505. res3.Infcode = infocode
  2506. }else{
  2507. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2508. utils.ErrorLog("解析失败:%v", err)
  2509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2510. return
  2511. }
  2512. }
  2513. if res3.Infcode == 0 {
  2514. item.IsChange = 1
  2515. item.BgBchno = bg_number
  2516. service.SaveDF2(item)
  2517. } else {
  2518. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2519. }
  2520. }
  2521. } else { //没销售,
  2522. //进行商品销售退货接口
  2523. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  2524. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2525. saveLog(result111, result222, "3506", "销售退货")
  2526. var res7 FJ3507Result
  2527. //进行商品销售接口
  2528. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  2529. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  2530. var respJSON3 map[string]interface{}
  2531. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  2532. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2534. return
  2535. }
  2536. userJSONBytes3, _ := json.Marshal(respJSON3)
  2537. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2538. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2539. utils.ErrorLog("解析失败:%v", err)
  2540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2541. return
  2542. }
  2543. //if res3507for10188.Infcode
  2544. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  2545. //res.Output = resSix10265.Output
  2546. res7.ErrMsg = res3507for10188.ErrMsg
  2547. res7.Cainfo = res3507for10188.Cainfo
  2548. res7.WarnMsg = res3507for10188.WarnMsg
  2549. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2550. res7.Infcode = infocode
  2551. }else{
  2552. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  2553. utils.ErrorLog("解析失败:%v", err)
  2554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2555. return
  2556. }
  2557. }
  2558. if res7.Infcode == 0 {
  2559. item.IsSale = 2
  2560. item.SaleDate = item.SaleDate
  2561. item.Bchno = number
  2562. service.SaveDF(item)
  2563. if item.IsChange == 0 { //没变更,进行变更操作
  2564. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2565. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  2566. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  2567. var respJSON3 map[string]interface{}
  2568. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2569. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2571. return
  2572. }
  2573. userJSONBytes3, _ := json.Marshal(respJSON3)
  2574. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2575. // utils.ErrorLog("解析失败:%v", err)
  2576. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2577. // return
  2578. //}
  2579. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2580. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2581. utils.ErrorLog("解析失败:%v", err)
  2582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2583. return
  2584. }
  2585. //if res3507for10188.Infcode
  2586. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  2587. //res.Output = resSix10265.Output
  2588. res3.ErrMsg = res3507for10188.ErrMsg
  2589. res3.Cainfo = res3507for10188.Cainfo
  2590. res3.WarnMsg = res3507for10188.WarnMsg
  2591. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2592. res3.Infcode = infocode
  2593. }else{
  2594. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2595. utils.ErrorLog("解析失败:%v", err)
  2596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2597. return
  2598. }
  2599. }
  2600. if res3.Infcode == 0 {
  2601. item.IsChange = 1
  2602. item.BgBchno = bg_number
  2603. service.SaveDF2(item)
  2604. } else {
  2605. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2606. }
  2607. }
  2608. } else {
  2609. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  2610. }
  2611. }
  2612. } else { //还没结算
  2613. if item.IsChange == 0 { //没变更,进行变更操作
  2614. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2615. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  2616. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  2617. var respJSON3 map[string]interface{}
  2618. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2619. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2621. return
  2622. }
  2623. userJSONBytes3, _ := json.Marshal(respJSON3)
  2624. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2625. // utils.ErrorLog("解析失败:%v", err)
  2626. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2627. // return
  2628. //}
  2629. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2630. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2631. utils.ErrorLog("解析失败:%v", err)
  2632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2633. return
  2634. }
  2635. //if res3507for10188.Infcode
  2636. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  2637. //res.Output = resSix10265.Output
  2638. res3.ErrMsg = res3507for10188.ErrMsg
  2639. res3.Cainfo = res3507for10188.Cainfo
  2640. res3.WarnMsg = res3507for10188.WarnMsg
  2641. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2642. res3.Infcode = infocode
  2643. }else{
  2644. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2645. utils.ErrorLog("解析失败:%v", err)
  2646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2647. return
  2648. }
  2649. }
  2650. if res3.Infcode == 0 {
  2651. item.IsChange = 1
  2652. item.BgBchno = bg_number
  2653. service.SaveDF2(item)
  2654. } else {
  2655. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2656. }
  2657. }
  2658. }
  2659. }
  2660. }
  2661. if len(err) == 0 {
  2662. c.ServeSuccessJSON(map[string]interface{}{
  2663. "msg": "销售变更成功",
  2664. })
  2665. } else {
  2666. c.ServeSuccessJSON(map[string]interface{}{
  2667. "failed_code": -10,
  2668. "msg": err,
  2669. })
  2670. }
  2671. }
  2672. func (c *HisApiController) ChangeDrugtwo() {
  2673. //ids := c.GetString("ids")
  2674. //id_arr := strings.Split(ids, ",")
  2675. flows, _ := service.GetNewDrugFlowInfotwo()
  2676. admin_user_id, _ := c.GetInt64("admin_user_id")
  2677. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2678. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2679. var err []string
  2680. for _, item := range flows {
  2681. var res3 ResultSix
  2682. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  2683. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2684. if prescription.OrderStatus == 2 {
  2685. //已经结算
  2686. //判断是否已经销售
  2687. if item.IsSale == 1 { //是否已经销售,1是 0否
  2688. //是否已经变更 1是 0否
  2689. if item.IsChange == 0 { //没变更,进行变更操作
  2690. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2691. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  2692. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  2693. var respJSON3 map[string]interface{}
  2694. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2695. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2697. return
  2698. }
  2699. userJSONBytes3, _ := json.Marshal(respJSON3)
  2700. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2701. utils.ErrorLog("解析失败:%v", err)
  2702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2703. return
  2704. }
  2705. if res3.Infcode == 0 {
  2706. item.IsChange = 1
  2707. item.BgBchno = bg_number
  2708. service.SaveDF2(item)
  2709. } else {
  2710. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2711. }
  2712. }
  2713. } else { //没销售,
  2714. var res FJ3507Result
  2715. var res3507for10188 FJ3507ResultFor10188
  2716. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  2717. //进行商品销售接口
  2718. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2719. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  2720. var respJSON3 map[string]interface{}
  2721. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  2722. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2724. return
  2725. }
  2726. userJSONBytes3, _ := json.Marshal(respJSON3)
  2727. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2728. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2729. utils.ErrorLog("解析失败:%v", err)
  2730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2731. return
  2732. }
  2733. //if res3507for10188.Infcode
  2734. res.InfRefmsgid = res3507for10188.InfRefmsgid
  2735. //res.Output = resSix10265.Output
  2736. res.ErrMsg = res3507for10188.ErrMsg
  2737. res.Cainfo = res3507for10188.Cainfo
  2738. res.WarnMsg = res3507for10188.WarnMsg
  2739. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2740. res.Infcode = infocode
  2741. }else{
  2742. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2743. utils.ErrorLog("解析失败:%v", err)
  2744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2745. return
  2746. }
  2747. }
  2748. if res.Infcode == 0 {
  2749. item.IsSale = 1
  2750. item.Bchno = number
  2751. item.SaleDate = time.Now().Format("2006-01-02")
  2752. err5 := service.SaveDF(item)
  2753. if err5 == nil {
  2754. if item.IsChange == 0 { //没变更,进行变更操作
  2755. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2756. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  2757. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  2758. var respJSON3 map[string]interface{}
  2759. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2760. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2762. return
  2763. }
  2764. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2765. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2766. utils.ErrorLog("解析失败:%v", err)
  2767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2768. return
  2769. }
  2770. //if res3507for10188.Infcode
  2771. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  2772. //res.Output = resSix10265.Output
  2773. res3.ErrMsg = res3507for10188.ErrMsg
  2774. res3.Cainfo = res3507for10188.Cainfo
  2775. res3.WarnMsg = res3507for10188.WarnMsg
  2776. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2777. res3.Infcode = infocode
  2778. }else{
  2779. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2780. utils.ErrorLog("解析失败:%v", err)
  2781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2782. return
  2783. }
  2784. }
  2785. if res3.Infcode == 0 {
  2786. item.IsChange = 1
  2787. item.BgBchno = bg_number
  2788. service.SaveDF2(item)
  2789. } else {
  2790. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2791. }
  2792. }
  2793. }
  2794. } else {
  2795. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  2796. }
  2797. }
  2798. } else { //还没结算
  2799. var res3507for10188 FJ3507ResultFor10188
  2800. if item.IsChange == 0 { //没变更,进行变更操作
  2801. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2802. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  2803. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  2804. var respJSON3 map[string]interface{}
  2805. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2806. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2808. return
  2809. }
  2810. userJSONBytes3, _ := json.Marshal(respJSON3)
  2811. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2812. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2813. utils.ErrorLog("解析失败:%v", err)
  2814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2815. return
  2816. }
  2817. //if res3507for10188.Infcode
  2818. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  2819. //res.Output = resSix10265.Output
  2820. res3.ErrMsg = res3507for10188.ErrMsg
  2821. res3.Cainfo = res3507for10188.Cainfo
  2822. res3.WarnMsg = res3507for10188.WarnMsg
  2823. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2824. res3.Infcode = infocode
  2825. }else{
  2826. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2827. utils.ErrorLog("解析失败:%v", err)
  2828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2829. return
  2830. }
  2831. }
  2832. if res3.Infcode == 0 {
  2833. item.IsChange = 1
  2834. item.BgBchno = bg_number
  2835. service.SaveDF2(item)
  2836. } else {
  2837. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2838. }
  2839. }
  2840. }
  2841. } else if item.ConsumableType == 7 {
  2842. var res3507for10188 FJ3507ResultFor10188
  2843. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2844. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  2845. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  2846. //判断是否已经销售
  2847. if item.IsSale == 2 { //是否已经销售,1是 0否
  2848. //是否已经变更 1是 0否
  2849. if item.IsChange == 0 { //没变更,进行变更操作
  2850. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2851. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  2852. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  2853. var respJSON3 map[string]interface{}
  2854. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2855. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2857. return
  2858. }
  2859. userJSONBytes3, _ := json.Marshal(respJSON3)
  2860. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2861. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2862. utils.ErrorLog("解析失败:%v", err)
  2863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2864. return
  2865. }
  2866. //if res3507for10188.Infcode
  2867. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  2868. //res.Output = resSix10265.Output
  2869. res3.ErrMsg = res3507for10188.ErrMsg
  2870. res3.Cainfo = res3507for10188.Cainfo
  2871. res3.WarnMsg = res3507for10188.WarnMsg
  2872. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2873. res3.Infcode = infocode
  2874. }else{
  2875. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2876. utils.ErrorLog("解析失败:%v", err)
  2877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2878. return
  2879. }
  2880. }
  2881. if res3.Infcode == 0 {
  2882. item.IsChange = 1
  2883. item.BgBchno = bg_number
  2884. service.SaveDF2(item)
  2885. } else {
  2886. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2887. }
  2888. }
  2889. } else { //没销售,
  2890. //进行商品销售退货接口
  2891. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  2892. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2893. saveLog(result111, result222, "3506", "销售退货")
  2894. var res7 FJ3507Result
  2895. //进行商品销售接口
  2896. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  2897. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  2898. var respJSON3 map[string]interface{}
  2899. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  2900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2902. return
  2903. }
  2904. userJSONBytes3, _ := json.Marshal(respJSON3)
  2905. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2906. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2907. utils.ErrorLog("解析失败:%v", err)
  2908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2909. return
  2910. }
  2911. //if res3507for10188.Infcode
  2912. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  2913. //res.Output = resSix10265.Output
  2914. res7.ErrMsg = res3507for10188.ErrMsg
  2915. res7.Cainfo = res3507for10188.Cainfo
  2916. res7.WarnMsg = res3507for10188.WarnMsg
  2917. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2918. res7.Infcode = infocode
  2919. }else{
  2920. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  2921. utils.ErrorLog("解析失败:%v", err)
  2922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2923. return
  2924. }
  2925. }
  2926. if res7.Infcode == 0 {
  2927. item.IsSale = 2
  2928. item.SaleDate = item.SaleDate
  2929. item.Bchno = number
  2930. service.SaveDF(item)
  2931. if item.IsChange == 0 { //没变更,进行变更操作
  2932. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2933. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  2934. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  2935. var respJSON3 map[string]interface{}
  2936. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2937. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2939. return
  2940. }
  2941. userJSONBytes3, _ := json.Marshal(respJSON3)
  2942. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2943. // utils.ErrorLog("解析失败:%v", err)
  2944. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2945. // return
  2946. //}
  2947. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2948. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2949. utils.ErrorLog("解析失败:%v", err)
  2950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2951. return
  2952. }
  2953. //if res3507for10188.Infcode
  2954. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  2955. //res.Output = resSix10265.Output
  2956. res3.ErrMsg = res3507for10188.ErrMsg
  2957. res3.Cainfo = res3507for10188.Cainfo
  2958. res3.WarnMsg = res3507for10188.WarnMsg
  2959. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2960. res3.Infcode = infocode
  2961. }else{
  2962. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2963. utils.ErrorLog("解析失败:%v", err)
  2964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2965. return
  2966. }
  2967. }
  2968. if res3.Infcode == 0 {
  2969. item.IsChange = 1
  2970. item.BgBchno = bg_number
  2971. service.SaveDF2(item)
  2972. } else {
  2973. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2974. }
  2975. }
  2976. } else {
  2977. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  2978. }
  2979. }
  2980. } else { //还没结算
  2981. if item.IsChange == 0 { //没变更,进行变更操作
  2982. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2983. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  2984. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  2985. var respJSON3 map[string]interface{}
  2986. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2989. return
  2990. }
  2991. userJSONBytes3, _ := json.Marshal(respJSON3)
  2992. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2993. // utils.ErrorLog("解析失败:%v", err)
  2994. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2995. // return
  2996. //}
  2997. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2998. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2999. utils.ErrorLog("解析失败:%v", err)
  3000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3001. return
  3002. }
  3003. //if res3507for10188.Infcode
  3004. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3005. //res.Output = resSix10265.Output
  3006. res3.ErrMsg = res3507for10188.ErrMsg
  3007. res3.Cainfo = res3507for10188.Cainfo
  3008. res3.WarnMsg = res3507for10188.WarnMsg
  3009. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3010. res3.Infcode = infocode
  3011. }else{
  3012. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3013. utils.ErrorLog("解析失败:%v", err)
  3014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3015. return
  3016. }
  3017. }
  3018. if res3.Infcode == 0 {
  3019. item.IsChange = 1
  3020. item.BgBchno = bg_number
  3021. service.SaveDF2(item)
  3022. } else {
  3023. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3024. }
  3025. }
  3026. }
  3027. }
  3028. }
  3029. if len(err) == 0 {
  3030. c.ServeSuccessJSON(map[string]interface{}{
  3031. "msg": "销售变更成功",
  3032. })
  3033. } else {
  3034. c.ServeSuccessJSON(map[string]interface{}{
  3035. "failed_code": -10,
  3036. "msg": err,
  3037. })
  3038. }
  3039. }
  3040. func (c *HisApiController) ChangeDrugthree() {
  3041. //ids := c.GetString("ids")
  3042. //id_arr := strings.Split(ids, ",")
  3043. flows, _ := service.GetNewDrugFlowInfothree()
  3044. admin_user_id, _ := c.GetInt64("admin_user_id")
  3045. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3046. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3047. var err []string
  3048. for _, item := range flows {
  3049. var res3 ResultSix
  3050. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3051. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3052. if prescription.OrderStatus == 2 {
  3053. //已经结算
  3054. //判断是否已经销售
  3055. if item.IsSale == 1 { //是否已经销售,1是 0否
  3056. //是否已经变更 1是 0否
  3057. if item.IsChange == 0 { //没变更,进行变更操作
  3058. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3059. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3060. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3061. var respJSON3 map[string]interface{}
  3062. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3063. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3065. return
  3066. }
  3067. userJSONBytes3, _ := json.Marshal(respJSON3)
  3068. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3069. utils.ErrorLog("解析失败:%v", err)
  3070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3071. return
  3072. }
  3073. if res3.Infcode == 0 {
  3074. item.IsChange = 1
  3075. item.BgBchno = bg_number
  3076. service.SaveDF2(item)
  3077. } else {
  3078. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3079. }
  3080. }
  3081. } else { //没销售,
  3082. var res FJ3507Result
  3083. var res3507for10188 FJ3507ResultFor10188
  3084. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3085. //进行商品销售接口
  3086. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3087. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3088. var respJSON3 map[string]interface{}
  3089. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3090. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3092. return
  3093. }
  3094. userJSONBytes3, _ := json.Marshal(respJSON3)
  3095. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3096. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3097. utils.ErrorLog("解析失败:%v", err)
  3098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3099. return
  3100. }
  3101. //if res3507for10188.Infcode
  3102. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3103. //res.Output = resSix10265.Output
  3104. res.ErrMsg = res3507for10188.ErrMsg
  3105. res.Cainfo = res3507for10188.Cainfo
  3106. res.WarnMsg = res3507for10188.WarnMsg
  3107. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3108. res.Infcode = infocode
  3109. }else{
  3110. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3111. utils.ErrorLog("解析失败:%v", err)
  3112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3113. return
  3114. }
  3115. }
  3116. if res.Infcode == 0 {
  3117. item.IsSale = 1
  3118. item.Bchno = number
  3119. item.SaleDate = time.Now().Format("2006-01-02")
  3120. err5 := service.SaveDF(item)
  3121. if err5 == nil {
  3122. if item.IsChange == 0 { //没变更,进行变更操作
  3123. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3124. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3125. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3126. var respJSON3 map[string]interface{}
  3127. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3130. return
  3131. }
  3132. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  3133. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3134. utils.ErrorLog("解析失败:%v", err)
  3135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3136. return
  3137. }
  3138. //if res3507for10188.Infcode
  3139. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3140. //res.Output = resSix10265.Output
  3141. res3.ErrMsg = res3507for10188.ErrMsg
  3142. res3.Cainfo = res3507for10188.Cainfo
  3143. res3.WarnMsg = res3507for10188.WarnMsg
  3144. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3145. res3.Infcode = infocode
  3146. } else if c.GetAdminUserInfo().CurrentOrgId == 10217{
  3147. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3148. utils.ErrorLog("解析失败:%v", err)
  3149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3150. return
  3151. }
  3152. //if res3507for10188.Infcode
  3153. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3154. //res.Output = resSix10265.Output
  3155. res3.ErrMsg = res3507for10188.ErrMsg
  3156. res3.Cainfo = res3507for10188.Cainfo
  3157. res3.WarnMsg = res3507for10188.WarnMsg
  3158. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3159. res3.Infcode = infocode
  3160. }else{
  3161. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3162. utils.ErrorLog("解析失败:%v", err)
  3163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3164. return
  3165. }
  3166. }
  3167. if res3.Infcode == 0 {
  3168. item.IsChange = 1
  3169. item.BgBchno = bg_number
  3170. service.SaveDF2(item)
  3171. } else {
  3172. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3173. }
  3174. }
  3175. }
  3176. } else {
  3177. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3178. }
  3179. }
  3180. } else { //还没结算
  3181. var res3507for10188 FJ3507ResultFor10188
  3182. if item.IsChange == 0 { //没变更,进行变更操作
  3183. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3184. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3185. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3186. var respJSON3 map[string]interface{}
  3187. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3188. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3190. return
  3191. }
  3192. userJSONBytes3, _ := json.Marshal(respJSON3)
  3193. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  3194. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3195. utils.ErrorLog("解析失败:%v", err)
  3196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3197. return
  3198. }
  3199. //if res3507for10188.Infcode
  3200. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3201. //res.Output = resSix10265.Output
  3202. res3.ErrMsg = res3507for10188.ErrMsg
  3203. res3.Cainfo = res3507for10188.Cainfo
  3204. res3.WarnMsg = res3507for10188.WarnMsg
  3205. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3206. res3.Infcode = infocode
  3207. }else if c.GetAdminUserInfo().CurrentOrgId == 10217{
  3208. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3209. utils.ErrorLog("解析失败:%v", err)
  3210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3211. return
  3212. }
  3213. //if res3507for10188.Infcode
  3214. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3215. //res.Output = resSix10265.Output
  3216. res3.ErrMsg = res3507for10188.ErrMsg
  3217. res3.Cainfo = res3507for10188.Cainfo
  3218. res3.WarnMsg = res3507for10188.WarnMsg
  3219. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3220. res3.Infcode = infocode
  3221. }else{
  3222. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3223. utils.ErrorLog("解析失败:%v", err)
  3224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3225. return
  3226. }
  3227. }
  3228. if res3.Infcode == 0 {
  3229. item.IsChange = 1
  3230. item.BgBchno = bg_number
  3231. service.SaveDF2(item)
  3232. } else {
  3233. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3234. }
  3235. }
  3236. }
  3237. } else if item.ConsumableType == 7 {
  3238. var res3507for10188 FJ3507ResultFor10188
  3239. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3240. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3241. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3242. //判断是否已经销售
  3243. if item.IsSale == 2 { //是否已经销售,1是 0否
  3244. //是否已经变更 1是 0否
  3245. if item.IsChange == 0 { //没变更,进行变更操作
  3246. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3247. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3248. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3249. var respJSON3 map[string]interface{}
  3250. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3251. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3253. return
  3254. }
  3255. userJSONBytes3, _ := json.Marshal(respJSON3)
  3256. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3257. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3258. utils.ErrorLog("解析失败:%v", err)
  3259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3260. return
  3261. }
  3262. //if res3507for10188.Infcode
  3263. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3264. //res.Output = resSix10265.Output
  3265. res3.ErrMsg = res3507for10188.ErrMsg
  3266. res3.Cainfo = res3507for10188.Cainfo
  3267. res3.WarnMsg = res3507for10188.WarnMsg
  3268. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3269. res3.Infcode = infocode
  3270. }else{
  3271. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3272. utils.ErrorLog("解析失败:%v", err)
  3273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3274. return
  3275. }
  3276. }
  3277. if res3.Infcode == 0 {
  3278. item.IsChange = 1
  3279. item.BgBchno = bg_number
  3280. service.SaveDF2(item)
  3281. } else {
  3282. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3283. }
  3284. }
  3285. } else { //没销售,
  3286. //进行商品销售退货接口
  3287. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3288. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3289. saveLog(result111, result222, "3506", "销售退货")
  3290. var res7 FJ3507Result
  3291. //进行商品销售接口
  3292. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3293. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3294. var respJSON3 map[string]interface{}
  3295. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3296. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3298. return
  3299. }
  3300. userJSONBytes3, _ := json.Marshal(respJSON3)
  3301. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3302. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3303. utils.ErrorLog("解析失败:%v", err)
  3304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3305. return
  3306. }
  3307. //if res3507for10188.Infcode
  3308. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3309. //res.Output = resSix10265.Output
  3310. res7.ErrMsg = res3507for10188.ErrMsg
  3311. res7.Cainfo = res3507for10188.Cainfo
  3312. res7.WarnMsg = res3507for10188.WarnMsg
  3313. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3314. res7.Infcode = infocode
  3315. }else{
  3316. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3317. utils.ErrorLog("解析失败:%v", err)
  3318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3319. return
  3320. }
  3321. }
  3322. if res7.Infcode == 0 {
  3323. item.IsSale = 2
  3324. item.SaleDate = item.SaleDate
  3325. item.Bchno = number
  3326. service.SaveDF(item)
  3327. if item.IsChange == 0 { //没变更,进行变更操作
  3328. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3329. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3330. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3331. var respJSON3 map[string]interface{}
  3332. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3333. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3335. return
  3336. }
  3337. userJSONBytes3, _ := json.Marshal(respJSON3)
  3338. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3339. // utils.ErrorLog("解析失败:%v", err)
  3340. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3341. // return
  3342. //}
  3343. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3344. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3345. utils.ErrorLog("解析失败:%v", err)
  3346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3347. return
  3348. }
  3349. //if res3507for10188.Infcode
  3350. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3351. //res.Output = resSix10265.Output
  3352. res3.ErrMsg = res3507for10188.ErrMsg
  3353. res3.Cainfo = res3507for10188.Cainfo
  3354. res3.WarnMsg = res3507for10188.WarnMsg
  3355. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3356. res3.Infcode = infocode
  3357. }else{
  3358. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3359. utils.ErrorLog("解析失败:%v", err)
  3360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3361. return
  3362. }
  3363. }
  3364. if res3.Infcode == 0 {
  3365. item.IsChange = 1
  3366. item.BgBchno = bg_number
  3367. service.SaveDF2(item)
  3368. } else {
  3369. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3370. }
  3371. }
  3372. } else {
  3373. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3374. }
  3375. }
  3376. } else { //还没结算
  3377. if item.IsChange == 0 { //没变更,进行变更操作
  3378. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3379. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3380. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3381. var respJSON3 map[string]interface{}
  3382. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3383. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3385. return
  3386. }
  3387. userJSONBytes3, _ := json.Marshal(respJSON3)
  3388. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3389. // utils.ErrorLog("解析失败:%v", err)
  3390. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3391. // return
  3392. //}
  3393. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3394. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3395. utils.ErrorLog("解析失败:%v", err)
  3396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3397. return
  3398. }
  3399. //if res3507for10188.Infcode
  3400. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3401. //res.Output = resSix10265.Output
  3402. res3.ErrMsg = res3507for10188.ErrMsg
  3403. res3.Cainfo = res3507for10188.Cainfo
  3404. res3.WarnMsg = res3507for10188.WarnMsg
  3405. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3406. res3.Infcode = infocode
  3407. }else{
  3408. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3409. utils.ErrorLog("解析失败:%v", err)
  3410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3411. return
  3412. }
  3413. }
  3414. if res3.Infcode == 0 {
  3415. item.IsChange = 1
  3416. item.BgBchno = bg_number
  3417. service.SaveDF2(item)
  3418. } else {
  3419. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3420. }
  3421. }
  3422. }
  3423. }
  3424. }
  3425. if len(err) == 0 {
  3426. c.ServeSuccessJSON(map[string]interface{}{
  3427. "msg": "销售变更成功",
  3428. })
  3429. } else {
  3430. c.ServeSuccessJSON(map[string]interface{}{
  3431. "failed_code": -10,
  3432. "msg": err,
  3433. })
  3434. }
  3435. }
  3436. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  3437. var struct3502 models.Struct3502
  3438. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3439. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3440. struct3502.FixmedinsHilistName =drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3441. struct3502.FixmedinsCode = miConfig.Code
  3442. struct3502.Code = miConfig.Code
  3443. struct3502.Opter = role.UserName
  3444. struct3502.RxFlag = "0"
  3445. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  3446. struct3502.OrgName = miConfig.OrgName
  3447. struct3502.AccessKey = miConfig.AccessKey
  3448. struct3502.RequestUrl = miConfig.Url
  3449. struct3502.SecretKey = miConfig.SecretKey
  3450. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3451. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3452. struct3502.Url = miConfig.Url
  3453. struct3502.AppId = miConfig.Cainfo
  3454. struct3502.AppSecret = miConfig.AppSecret
  3455. struct3502.Enckey = miConfig.EncKey
  3456. struct3502.SignKey = miConfig.SignKey
  3457. struct3502.SecretKey = miConfig.SecretKey
  3458. struct3502.InvChgType = chgType
  3459. struct3502.FixmedinsBchno = number
  3460. struct3502.Cnt = strconv.FormatInt(count, 10)
  3461. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  3462. //result1, result2, _ := service.FJyb3502(struct3502)
  3463. if miConfig.MdtrtareaAdmvs == "350500"{
  3464. result1, result2, _ := service.FJyb3502(struct3502)
  3465. //saveLog(result1, result2, "3502", "3502")
  3466. return result1, result2
  3467. }else {
  3468. data := make(map[string]interface{})
  3469. data["struct_3502s"] = struct3502
  3470. client := &http.Client{}
  3471. bytesData, _ := json.Marshal(data)
  3472. var req *http.Request
  3473. if miConfig.MdtrtareaAdmvs == "320921" {
  3474. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  3475. } else {
  3476. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  3477. }
  3478. resp, _ := client.Do(req)
  3479. defer resp.Body.Close()
  3480. body, ioErr := ioutil.ReadAll(resp.Body)
  3481. if ioErr != nil {
  3482. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3483. }
  3484. var respJSON map[string]interface{}
  3485. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3486. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3487. }
  3488. //var resSix10265 ResultSix10265 //1101结果
  3489. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3490. result, _ := json.Marshal(respJSON)
  3491. return string(result), ""
  3492. }
  3493. }
  3494. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  3495. var struct3505 models.Struct3505
  3496. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3497. struct3505.FixmedinsHilistId =drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3498. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3499. struct3505.FixmedinsBchno = number
  3500. struct3505.Opter = role.UserName
  3501. struct3505.FixmedinsCode = miConfig.Code
  3502. struct3505.Code = miConfig.Code
  3503. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  3504. struct3505.PrscDrName = roles.UserName
  3505. if org_id == 10191{
  3506. struct3505.PharName = "刘水山"
  3507. struct3505.PharPracCertNo = "2015026350260000002611351127"
  3508. }
  3509. if org_id == 10188{
  3510. struct3505.PharName = "李汉清"
  3511. struct3505.PharPracCertNo = "30220200932022010034"
  3512. }
  3513. if org_id == 10217{
  3514. struct3505.PharName = "张敏"
  3515. struct3505.PharPracCertNo = "30220230432090100108"
  3516. }
  3517. order := service.GetHisOrderByNumber(pre.BatchNumber)
  3518. struct3505.SetlId = order.SetlId
  3519. struct3505.MdtrtSn = order.MdtrtId
  3520. struct3505.ManuLotnum = drug.Number
  3521. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  3522. struct3505.ExpyEnd = ""
  3523. struct3505.RxFlag = "0"
  3524. struct3505.TrdnFlag = "1"
  3525. struct3505.RtalDocno = order.Number
  3526. struct3505.Url = miConfig.Url
  3527. struct3505.AppId = miConfig.Cainfo
  3528. struct3505.AppSecret = miConfig.AppSecret
  3529. struct3505.Enckey = miConfig.EncKey
  3530. struct3505.SignKey = miConfig.SignKey
  3531. struct3505.SecretKey = miConfig.SecretKey
  3532. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  3533. struct3505.SelRetnCnt = strValue
  3534. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3535. struct3505.SelRetnOpterName = role.UserName
  3536. if order.IsMedicineInsurance == 1 {
  3537. struct3505.MdtrtSetlType = "1"
  3538. } else {
  3539. struct3505.MdtrtSetlType = "2"
  3540. }
  3541. struct3505.OrgName = miConfig.OrgName
  3542. struct3505.AccessKey = miConfig.AccessKey
  3543. struct3505.RequestUrl = miConfig.Url
  3544. struct3505.SecretKey = miConfig.SecretKey
  3545. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3546. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3547. struct3505.DrugTracCodg = drug.DrugCode
  3548. if miConfig.MdtrtareaAdmvs == "350500"{
  3549. result1, result2, _ := service.FJyb3505(struct3505)
  3550. return result1, result2
  3551. }else {
  3552. data := make(map[string]interface{})
  3553. data["struct_3505s"] = struct3505
  3554. client := &http.Client{}
  3555. bytesData, _ := json.Marshal(data)
  3556. var req *http.Request
  3557. if miConfig.MdtrtareaAdmvs == "320921" {
  3558. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  3559. } else {
  3560. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  3561. }
  3562. resp, _ := client.Do(req)
  3563. defer resp.Body.Close()
  3564. body, ioErr := ioutil.ReadAll(resp.Body)
  3565. if ioErr != nil {
  3566. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3567. }
  3568. var respJSON map[string]interface{}
  3569. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3571. }
  3572. //var resSix10265 ResultSix10265 //1101结果
  3573. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3574. result, _ := json.Marshal(respJSON)
  3575. return string(result), ""
  3576. }
  3577. }
  3578. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  3579. var struct3506 models.Struct3506
  3580. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3581. struct3506.FixmedinsHilistId =drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3582. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3583. struct3506.FixmedinsCode = miConfig.Code
  3584. struct3506.Code = miConfig.Code
  3585. struct3506.FixmedinsBchno = number
  3586. struct3506.Opter = role.UserName
  3587. order := service.GetHisOrderByNumber(pre.BatchNumber)
  3588. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  3589. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  3590. struct3506.MdtrtSn = order.MdtrtId
  3591. struct3506.ExpyEnd = ""
  3592. struct3506.RxFlag = "0"
  3593. struct3506.TrdnFlag = "1"
  3594. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  3595. struct3506.SelRetnCnt = strValue
  3596. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3597. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  3598. struct3506.SelRetnOpterName = role.UserName
  3599. struct3506.OrgName = miConfig.OrgName
  3600. struct3506.AccessKey = miConfig.AccessKey
  3601. struct3506.RequestUrl = miConfig.Url
  3602. struct3506.SecretKey = miConfig.SecretKey
  3603. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3604. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3605. struct3506.Url = miConfig.Url
  3606. struct3506.AppId = miConfig.Cainfo
  3607. struct3506.AppSecret = miConfig.AppSecret
  3608. struct3506.Enckey = miConfig.EncKey
  3609. struct3506.SignKey = miConfig.SignKey
  3610. struct3506.SecretKey = miConfig.SecretKey
  3611. struct3506.DrugTracCodg = drug.DrugCode
  3612. if miConfig.MdtrtareaAdmvs == "350500"{
  3613. result1, result2, _ := service.FJyb3506(struct3506)
  3614. return result1, result2
  3615. }else {
  3616. data := make(map[string]interface{})
  3617. data["struct_3506s"] = struct3506
  3618. client := &http.Client{}
  3619. bytesData, _ := json.Marshal(data)
  3620. var req *http.Request
  3621. if miConfig.MdtrtareaAdmvs == "320921" {
  3622. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  3623. } else {
  3624. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  3625. }
  3626. resp, _ := client.Do(req)
  3627. defer resp.Body.Close()
  3628. body, ioErr := ioutil.ReadAll(resp.Body)
  3629. if ioErr != nil {
  3630. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3631. }
  3632. var respJSON map[string]interface{}
  3633. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3634. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3635. }
  3636. //var resSix10265 ResultSix10265 //1101结果
  3637. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3638. result, _ := json.Marshal(respJSON)
  3639. return string(result), ""
  3640. }
  3641. }
  3642. func (c *HisApiController) Get1318() {
  3643. adminUser := c.GetAdminUserInfo()
  3644. admin_user_id, _ := c.GetInt64("admin_user_id")
  3645. code := c.GetString("code")
  3646. code = ""
  3647. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3648. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3649. api := ""
  3650. if miConfig.MdtrtareaAdmvs == "320921" {
  3651. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  3652. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  3653. } else {
  3654. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  3655. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  3656. }
  3657. resp, requestErr := http.Get(api)
  3658. if requestErr != nil {
  3659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3660. return
  3661. }
  3662. body, ioErr := ioutil.ReadAll(resp.Body)
  3663. if ioErr != nil {
  3664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3666. return
  3667. }
  3668. var respJSON map[string]interface{}
  3669. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3670. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3672. return
  3673. }
  3674. //var res Result2406
  3675. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3676. result, _ := json.Marshal(respJSON)
  3677. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3678. utils.ErrorLog("解析失败:%v", err)
  3679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3680. return
  3681. }
  3682. if res.Infcode == "0" {
  3683. c.ServeSuccessJSON(map[string]interface{}{
  3684. "result": "",
  3685. })
  3686. } else {
  3687. c.ServeSuccessJSON(map[string]interface{}{
  3688. "failed_code": -10,
  3689. "msg": res.ErrMsg,
  3690. })
  3691. */return
  3692. //}
  3693. }
  3694. func (c *HisApiController) Get2503() {
  3695. adminUser := c.GetAdminUserInfo()
  3696. admin_user_id, _ := c.GetInt64("admin_user_id")
  3697. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3698. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3699. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  3700. }
  3701. func (c *HisApiController) Get2406() {
  3702. id, _ := c.GetInt64("id")
  3703. record_time := c.GetString("record_time")
  3704. his_patient_id, _ := c.GetInt64("his_patient_id")
  3705. admin_user_id, _ := c.GetInt64("admin_user_id")
  3706. diagnosis_id := c.GetString("diagnosis")
  3707. timeLayout := "2006-01-02"
  3708. loc, _ := time.LoadLocation("Local")
  3709. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3710. if err != nil {
  3711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3712. return
  3713. }
  3714. recordDateTime := theTime.Unix()
  3715. adminUser := c.GetAdminUserInfo()
  3716. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3717. var config []*models.HisXtDiagnoseConfig
  3718. for _, item := range diagnosis_ids {
  3719. id, _ := strconv.ParseInt(item, 10, 64)
  3720. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3721. config = append(config, &diagnosisConfig)
  3722. }
  3723. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3724. fmt.Println(his_patient_id)
  3725. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3726. //timestamp := time.Now().Unix()
  3727. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3728. var patientPrescription models.HisPrescriptionInfo
  3729. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3730. if patientPrescription.ID == 0 {
  3731. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3732. }
  3733. var res2 Result2406
  3734. if miConfig.MdtrtareaAdmvs == "341203" {
  3735. data := make(map[string]interface{})
  3736. client := &http.Client{}
  3737. data["psn_no"] = his.PsnNo
  3738. data["mdtrt_id"] = his.Number
  3739. data["operator"] = roles.UserName
  3740. data["cert_no"] = his.IdCardNo
  3741. data["org_name"] = miConfig.OrgName
  3742. data["psn_name"] = his.Name
  3743. data["ipt_otp_no"] = his.IptOtpNo
  3744. data["ipt_psn_sp_flag_type"] = "0901"
  3745. data["ipt_psn_sp_flag"] = "1"
  3746. data["fixmedins_code"] = miConfig.Code
  3747. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3748. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3749. data["url"] = miConfig.Url
  3750. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  3751. bytesData, _ := json.Marshal(data)
  3752. var req *http.Request
  3753. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  3754. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  3755. resp, _ := client.Do(req)
  3756. defer resp.Body.Close()
  3757. body, ioErr := ioutil.ReadAll(resp.Body)
  3758. if ioErr != nil {
  3759. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3761. return
  3762. }
  3763. var respJSON map[string]interface{}
  3764. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3765. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3767. return
  3768. }
  3769. status := respJSON["data"].(map[string]interface{})["status"].(string)
  3770. if status == "0" {
  3771. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  3772. c.ServeSuccessJSON(map[string]interface{}{
  3773. "failed_code": -10,
  3774. "msg": err_msg,
  3775. })
  3776. return
  3777. }
  3778. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3779. userJSONBytes, _ := json.Marshal(respJSON)
  3780. fmt.Println("log")
  3781. fmt.Println(string(userJSONBytes))
  3782. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3783. utils.ErrorLog("解析失败:%v", err)
  3784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3785. return
  3786. }
  3787. }
  3788. if res2.Infcode != 0 {
  3789. adminUser := c.GetAdminUserInfo()
  3790. errlog := &models.HisOrderError{
  3791. UserOrgId: adminUser.CurrentOrgId,
  3792. Ctime: time.Now().Unix(),
  3793. Mtime: time.Now().Unix(),
  3794. ErrMsg: res2.ErrMsg,
  3795. Status: 1,
  3796. PatientId: id,
  3797. RecordTime: recordDateTime,
  3798. Stage: 3,
  3799. }
  3800. service.CreateErrMsgLog(errlog)
  3801. c.ServeSuccessJSON(map[string]interface{}{
  3802. "failed_code": -10,
  3803. "msg": res2.ErrMsg,
  3804. })
  3805. return
  3806. } else {
  3807. c.ServeSuccessJSON(map[string]interface{}{
  3808. "msg": "上传成功",
  3809. })
  3810. return
  3811. }
  3812. }
  3813. func (c *HisApiController) Get4105() {
  3814. }
  3815. func (c *HisApiController) Post5302() {
  3816. patient_id, _ := c.GetInt64("id")
  3817. admin_user_id, _ := c.GetInt64("admin_user_id")
  3818. p, _ := service.GetHisPatientById(patient_id)
  3819. adminUser := c.GetAdminUserInfo()
  3820. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3821. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3822. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  3823. }
  3824. func (c *HisApiController) Get4104() {
  3825. }
  3826. type Output struct {
  3827. CertNo string `json:"certno"`
  3828. PsnName string `json:"psn_name"`
  3829. CardNo string `json:"card_no"`
  3830. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3831. CardSN string `json:"card_sn"`
  3832. PsnCertType string `json:"psn_cert_type"`
  3833. MdtrtCertNo string `json:"mdtrt_cert_no"`
  3834. MdtrtCertType string `json:"mdtrt_cert_type"`
  3835. QRCode string `json:"qrCode"`
  3836. EcToken string `json:"ecToken"`
  3837. }
  3838. type AHResponse struct {
  3839. Body AHBody `json:"body"`
  3840. Code int `json:"code"`
  3841. CSBCode int `json:"csbCode"`
  3842. Message string `json:"message"`
  3843. RequestID string `json:"requestId"`
  3844. State struct{} `json:"state"`
  3845. }
  3846. type AHBody struct {
  3847. ErrMsg string `json:"err_msg"`
  3848. InfRefMsgID string `json:"inf_refmsgid"`
  3849. InfCode int `json:"infcode"`
  3850. Output struct {
  3851. Result []struct {
  3852. BasMednFlag string `json:"bas_medn_flag"`
  3853. ChldMedcFlag string `json:"chld_medc_flag"`
  3854. ChrgitmLv string `json:"chrgitm_lv"`
  3855. Cnt float64 `json:"cnt"`
  3856. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3857. DrtReimFlag string `json:"drt_reim_flag"`
  3858. FeedetlSn string `json:"feedetl_sn"`
  3859. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3860. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3861. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3862. ListSpItemFlag string `json:"list_sp_item_flag"`
  3863. LmtUsedFlag string `json:"lmt_used_flag"`
  3864. MedChrgitmType string `json:"med_chrgitm_type"`
  3865. Memo string `json:"memo"`
  3866. OverlmtAmt float64 `json:"overlmt_amt"`
  3867. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3868. Pric float64 `json:"pric"`
  3869. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3870. SelfpayProp float64 `json:"selfpay_prop"`
  3871. } `json:"result"`
  3872. } `json:"output"`
  3873. }
  3874. type Response struct {
  3875. Output Output `json:"output"`
  3876. Infcode int `json:"infcode"`
  3877. InfRefMsgID string `json:"inf_refmsgid"`
  3878. RefMsgTime string `json:"refmsg_time"`
  3879. RespondTime string `json:"respond_time"`
  3880. ErrMsg string `json:"err_msg"`
  3881. WarnMsg string `json:"warn_msg"`
  3882. SignType string `json:"signtype"`
  3883. CAInfo string `json:"cainfo"`
  3884. }
  3885. func (c *HisApiController) Getquerydata() {
  3886. query_type, _ := c.GetInt64("type")
  3887. refd_setl_flag := c.GetString("refd_setl_flag")
  3888. med_type := c.GetString("med_type")
  3889. //admin_user_id,_ := c.GetInt64("admin_user_id")
  3890. cert_no := c.GetString("cert_no")
  3891. psn_no := c.GetString("psn_no")
  3892. start_time := c.GetString("start_time")
  3893. end_time := c.GetString("end_time")
  3894. page, _ := c.GetInt64("page")
  3895. limit, _ := c.GetInt64("limit")
  3896. var bp models.BusinessParams5262
  3897. bp.RefdSetlFlag = refd_setl_flag
  3898. bp.MedType = med_type
  3899. bp.Certno = cert_no
  3900. bp.Psnno = psn_no
  3901. bp.QBegntime = start_time
  3902. bp.QEndtime = end_time
  3903. if query_type == 1 { //本地
  3904. Post5262(c, bp, page, limit)
  3905. } else { //异地
  3906. Post5267(c, bp, page, limit)
  3907. }
  3908. }
  3909. func (c *HisApiController) Drugscheck() {
  3910. admin_user_id, _ := c.GetInt64("admin_user_id")
  3911. adminUser := c.GetAdminUserInfo()
  3912. var queryResult []QueryResult
  3913. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  3914. for _, item := range drugs {
  3915. result := QueryResult{
  3916. ID: item.ID,
  3917. Name: item.DrugName,
  3918. Code: item.MedicalInsuranceNumber,
  3919. List_type_code: "101",
  3920. }
  3921. queryResult = append(queryResult, result)
  3922. }
  3923. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3924. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3925. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3926. for _, item := range queryResult {
  3927. 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)
  3928. }
  3929. }
  3930. func (c *HisApiController) Goodcheck() {
  3931. admin_user_id, _ := c.GetInt64("admin_user_id")
  3932. adminUser := c.GetAdminUserInfo()
  3933. var queryResult []QueryResult
  3934. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  3935. for _, item := range goods {
  3936. result := QueryResult{
  3937. ID: item.ID,
  3938. Name: item.GoodName,
  3939. Code: item.SocialSecurityDirectoryCode,
  3940. List_type_code: "301",
  3941. }
  3942. queryResult = append(queryResult, result)
  3943. }
  3944. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3945. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3946. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3947. for _, item := range queryResult {
  3948. 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)
  3949. //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)
  3950. }
  3951. }
  3952. func (c *HisApiController) Projectcheck() {
  3953. admin_user_id, _ := c.GetInt64("admin_user_id")
  3954. adminUser := c.GetAdminUserInfo()
  3955. var queryResult []QueryResult
  3956. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  3957. for _, item := range projects {
  3958. result := QueryResult{
  3959. ID: item.ID,
  3960. Name: item.ProjectName,
  3961. Code: item.MedicalCode,
  3962. List_type_code: "201",
  3963. }
  3964. queryResult = append(queryResult, result)
  3965. }
  3966. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3967. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3968. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3969. for _, item := range queryResult {
  3970. 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)
  3971. }
  3972. }
  3973. //func (c *HisApiController)CancleDia(){
  3974. //
  3975. // id, _ := c.GetInt64("id")
  3976. // record_time := c.GetString("record_time")
  3977. // his_patient_id, _ := c.GetInt64("his_patient_id")
  3978. //
  3979. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3980. //
  3981. // diagnosis_id := c.GetString("diagnosis")
  3982. // sick_type, _ := c.GetInt64("sick_type")
  3983. // reg_type, _ := c.GetInt64("p_type")
  3984. // begin_time := c.GetString("begin_time")
  3985. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  3986. //
  3987. //
  3988. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  3989. //
  3990. // fmt.Println(acct_used_flag)
  3991. //
  3992. //
  3993. // timeLayout := "2006-01-02"
  3994. // loc, _ := time.LoadLocation("Local")
  3995. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3996. // if err != nil {
  3997. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3998. // return
  3999. // }
  4000. // recordDateTime := theTime.Unix()
  4001. // adminUser := c.GetAdminUserInfo()
  4002. //
  4003. //
  4004. //
  4005. //
  4006. //
  4007. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4008. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4009. // var patientPrescription models.HisPrescriptionInfo
  4010. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4011. // if patientPrescription.ID == 0 {
  4012. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4013. // }
  4014. // //if patientPrescription.Do
  4015. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4016. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4017. //
  4018. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4019. //
  4020. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  4021. //
  4022. // var config []*models.HisXtDiagnoseConfig
  4023. // for _, item := range diagnosis_ids {
  4024. // id, _ := strconv.ParseInt(item, 10, 64)
  4025. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  4026. // config = append(config, &diagnosisConfig)
  4027. // }
  4028. //
  4029. // sickConfig, _ := service.FindSickById(sick_type)
  4030. //
  4031. //
  4032. // data := make(map[string]interface{})
  4033. // client := &http.Client{}
  4034. // data["psn_no"] = his.PsnNo
  4035. // data["mdtrt_id"] = his.Number
  4036. // data["doctor"] = roles.UserName
  4037. // data["department"] = department.Name
  4038. // data["org_name"] = miConfig.OrgName
  4039. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  4040. // data["doctor_id"] = doctor_info.DoctorNumber
  4041. // data["new_doctor_name"] = doctor_info.UserName
  4042. // data["fixmedins_code"] = miConfig.Code
  4043. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4044. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4045. // data["secret_key"] = miConfig.SecretKey
  4046. // data["sick_code"] = sickConfig.CountryCode
  4047. // data["sick_name"] = sickConfig.ClassName
  4048. // data["url"] = miConfig.Url
  4049. // data["ak"] = miConfig.AccessKey
  4050. // data["begin_time"] = begin_time
  4051. // data["cainfo"] = miConfig.Cainfo
  4052. // data["is_vaild"] = "0"
  4053. //
  4054. // data["dept"] = strconv.FormatInt(department.ID, 10)
  4055. // data["config"] = config
  4056. // bytesData, _ := json.Marshal(data)
  4057. //
  4058. // var req *http.Request
  4059. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  4060. // resp, _ := client.Do(req)
  4061. // defer resp.Body.Close()
  4062. // body, ioErr := ioutil.ReadAll(resp.Body)
  4063. // if ioErr != nil {
  4064. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4065. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4066. // return
  4067. // }
  4068. // var respJSON map[string]interface{}
  4069. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4070. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4071. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4072. // return
  4073. // }
  4074. //
  4075. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4076. // userJSONBytes, _ := json.Marshal(respJSON)
  4077. // fmt.Println("log")
  4078. // fmt.Println(string(userJSONBytes))
  4079. //
  4080. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  4081. // utils.ErrorLog("解析失败:%v", err)
  4082. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4083. // return
  4084. // }
  4085. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  4086. // res2.Output = ressix10265.Output
  4087. // res2.ErrMsg = ressix10265.ErrMsg
  4088. // res2.Cainfo = ressix10265.Cainfo
  4089. // res2.WarnMsg = ressix10265.WarnMsg
  4090. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4091. // res2.Infcode = infocode
  4092. //
  4093. //}
  4094. func (c *HisApiController) Get4102() {
  4095. order_id, _ := c.GetInt64("order_id")
  4096. admin_user_id, _ := c.GetInt64("admin_user_id")
  4097. stas_type := c.GetString("stas_type")
  4098. order, _ := service.GetHisOrderByIDTwo(order_id)
  4099. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4100. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4101. var pp models.PublicParams
  4102. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4103. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4104. pp.FixmedinsName = miConfig.OrgName
  4105. pp.FixmedinsCode = miConfig.Code
  4106. pp.RequestUrl = miConfig.Url
  4107. pp.Cainfo = miConfig.Cainfo
  4108. pp.SecretKey = miConfig.SecretKey
  4109. pp.AccessKey = miConfig.AccessKey
  4110. pp.OpterName = curRoles.UserName
  4111. if miConfig.MdtrtareaAdmvs == "350500" {
  4112. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  4113. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  4114. saveLog(result, request, "4102", "清单确认")
  4115. var dat map[string]interface{}
  4116. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4117. fmt.Println(dat)
  4118. } else {
  4119. fmt.Println(err)
  4120. }
  4121. var empty ResultFourteen
  4122. userJSONBytes, _ := json.Marshal(dat)
  4123. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  4124. utils.ErrorLog("解析失败:%v", err)
  4125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4126. return
  4127. }
  4128. if empty.Infcode == 0 {
  4129. c.ServeSuccessJSON(map[string]interface{}{
  4130. "msg": "确认成功",
  4131. })
  4132. return
  4133. }
  4134. } else {
  4135. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  4136. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  4137. result3, request3 := service.Jxyb4105(pp)
  4138. saveLog(result, request, "4102", "清单确认")
  4139. saveLog(result2, request2, "4103", "清单确认")
  4140. saveLog(result3, request3, "4105", "清单统计")
  4141. var dat map[string]interface{}
  4142. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4143. fmt.Println(dat)
  4144. } else {
  4145. fmt.Println(err)
  4146. }
  4147. var empty ResultFourteen
  4148. userJSONBytes, _ := json.Marshal(dat)
  4149. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  4150. utils.ErrorLog("解析失败:%v", err)
  4151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4152. return
  4153. }
  4154. if empty.Infcode == 0 {
  4155. c.ServeSuccessJSON(map[string]interface{}{
  4156. "msg": "确认成功",
  4157. })
  4158. return
  4159. }
  4160. }
  4161. }
  4162. // 对账权限查询
  4163. func (c *HisApiController) Get3260() {
  4164. admin_user_id, _ := c.GetInt64("admin_user_id")
  4165. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4166. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4167. var api string
  4168. var res models.JSResult3260
  4169. if miConfig.MdtrtareaAdmvs == "320921" {
  4170. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  4171. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  4172. } else {
  4173. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  4174. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  4175. }
  4176. resp, requestErr := http.Get(api)
  4177. if requestErr != nil {
  4178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4179. return
  4180. }
  4181. body, ioErr := ioutil.ReadAll(resp.Body)
  4182. if ioErr != nil {
  4183. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4185. return
  4186. }
  4187. var respJSON map[string]interface{}
  4188. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4189. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4191. return
  4192. }
  4193. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4194. result, _ := json.Marshal(respJSON)
  4195. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4196. utils.ErrorLog("解析失败:%v", err)
  4197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4198. return
  4199. }
  4200. if res.Infcode == "0" {
  4201. c.ServeSuccessJSON(map[string]interface{}{
  4202. "result": res.Output.Data,
  4203. })
  4204. } else {
  4205. c.ServeSuccessJSON(map[string]interface{}{
  4206. "failed_code": -10,
  4207. "msg": res.ErrMsg,
  4208. })
  4209. return
  4210. }
  4211. }
  4212. func (c *HisApiController) Get3261() {
  4213. admin_user_id, _ := c.GetInt64("admin_user_id")
  4214. //month := c.GetString("month")
  4215. startTime := c.GetString("start_time")
  4216. //endTime, _ := c.GetString("end_time")
  4217. times := strings.Split(startTime, "-")
  4218. stmt_mon := times[0] + times[1]
  4219. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4220. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4221. var api string
  4222. var res models.JSResult3261
  4223. //var res10265 Result5301For10265
  4224. if miConfig.MdtrtareaAdmvs == "320921" {
  4225. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  4226. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  4227. } else {
  4228. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  4229. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  4230. }
  4231. resp, requestErr := http.Get(api)
  4232. if requestErr != nil {
  4233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4234. return
  4235. }
  4236. body, ioErr := ioutil.ReadAll(resp.Body)
  4237. if ioErr != nil {
  4238. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4240. return
  4241. }
  4242. var respJSON map[string]interface{}
  4243. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4244. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4246. return
  4247. }
  4248. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4249. result, _ := json.Marshal(respJSON)
  4250. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4251. utils.ErrorLog("解析失败:%v", err)
  4252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4253. return
  4254. }
  4255. if res.Infcode == "0" {
  4256. c.ServeSuccessJSON(map[string]interface{}{
  4257. "result": res.Output,
  4258. })
  4259. } else {
  4260. c.ServeSuccessJSON(map[string]interface{}{
  4261. "failed_code": -10,
  4262. "msg": res.ErrMsg,
  4263. })
  4264. return
  4265. }
  4266. }
  4267. type TempFun struct {
  4268. FundKey string
  4269. FundCode string
  4270. }
  4271. func (c *HisApiController) Get3262() {
  4272. admin_user_id, _ := c.GetInt64("admin_user_id")
  4273. startTime := c.GetString("start_time")
  4274. endTime := c.GetString("end_time")
  4275. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4276. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4277. //timeLayout := "2006-01-02"
  4278. //loc, _ := time.LoadLocation("Local")
  4279. //var theStartTIme int64
  4280. //if len(startTime) > 0 {
  4281. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  4282. // if err != nil {
  4283. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4284. // return
  4285. // }
  4286. // theStartTIme = theTime.Unix()
  4287. //}
  4288. //var theEndtTIme int64
  4289. //if len(endTime) > 0 {
  4290. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  4291. // if err != nil {
  4292. // utils.ErrorLog(err.Error())
  4293. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4294. // return
  4295. // }
  4296. // theEndtTIme = theTime.Unix()
  4297. //}
  4298. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  4299. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  4300. for _, team := range datas {
  4301. fmt.Println(team.PsnTime)
  4302. for _, team_two := range datas_two {
  4303. fmt.Println(team_two.PsnTime)
  4304. if team.FundKey == team_two.FundKey {
  4305. fmt.Println(team_two.PsnTime)
  4306. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  4307. fmt.Println(team.PsnTime)
  4308. }
  4309. }
  4310. }
  4311. fmt.Println("1111")
  4312. fmt.Println(datas)
  4313. fmt.Println("1111")
  4314. var twos []models.FixMonRecDetailFileInTwo
  4315. for _, team := range datas {
  4316. var two models.FixMonRecDetailFileInTwo
  4317. two.MedType = team.MedType
  4318. two.Insutype = team.Insutype
  4319. two.PsnType = team.PsnType
  4320. two.MedType = team.MedType
  4321. two.FixBlngAdmdvs = "999999"
  4322. two.InsuAdmdvs = "555555"
  4323. two.PsnTime = team.PsnTime
  4324. two.PsnCnt = team.PsnCnt
  4325. two.FundKey = team.FundKey
  4326. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  4327. fps, _ := strconv.ParseFloat(team.Fund, 64)
  4328. ia, _ := strconv.ParseFloat(team.Amt, 64)
  4329. two.MedfeeSumAmt = ms
  4330. two.InscpAmt = ia
  4331. two.FundPaySumAmt = fps
  4332. twos = append(twos, two)
  4333. }
  4334. //startTime := c.GetString("start_time")
  4335. //endTime, _ := c.GetString("end_time")
  4336. times := strings.Split(startTime, "-")
  4337. stmt_mon := times[0] + times[1]
  4338. var funs []models.FundDetail
  4339. for _, item := range datas {
  4340. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  4341. funs = append(funs, fun...)
  4342. }
  4343. var funInfos []models.Fund
  4344. //for _, item := range funs {
  4345. // var rf []models.FundInfo
  4346. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  4347. // for _, subitem := range rf {
  4348. // var fund models.Fund
  4349. // fund.FundCode = subitem.FundPayType
  4350. // fund.FundName = subitem.FundPayTypeName
  4351. // fund.FundAmt = subitem.FundPayAmt
  4352. // fund.FundKey = item.FundKey
  4353. // fund.InsuAdmdvs = "555555"
  4354. // fund.FixBlngAdmdvs = "999999"
  4355. // funInfos = append(funInfos, fund)
  4356. // }
  4357. //}
  4358. var tempFuns []TempFun
  4359. for _, funInfo := range funInfos {
  4360. var tempFun TempFun
  4361. tempFun.FundKey = funInfo.FundKey
  4362. tempFun.FundCode = funInfo.FundCode
  4363. tempFuns = append(tempFuns, tempFun)
  4364. }
  4365. tempFuns = RemoveRepeatedFunElement(tempFuns)
  4366. fmt.Println(tempFuns)
  4367. var funInfosTwo []models.Fund
  4368. decimal.DivisionPrecision = 2
  4369. for _, item := range tempFuns {
  4370. var fund models.Fund
  4371. for _, subItem := range funInfos {
  4372. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  4373. fund.FundKey = subItem.FundKey
  4374. fund.InsuAdmdvs = subItem.InsuAdmdvs
  4375. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  4376. fund.FundName = subItem.FundName
  4377. fund.FundCode = subItem.FundCode
  4378. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  4379. }
  4380. }
  4381. funInfosTwo = append(funInfosTwo, fund)
  4382. }
  4383. fmt.Println("funInfosTwo")
  4384. fmt.Println(funInfosTwo)
  4385. var upld_btch string
  4386. var empty models.JSResultEmpty
  4387. data := make(map[string]interface{})
  4388. data["org_name"] = miConfig.OrgName
  4389. data["doctor"] = curRoles.UserName
  4390. data["doctor_name"] = curRoles.UserName
  4391. data["fixmedins_code"] = miConfig.Code
  4392. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4393. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4394. data["secret_key"] = miConfig.SecretKey
  4395. data["url"] = miConfig.Url
  4396. data["ak"] = miConfig.AccessKey
  4397. data["cainfo"] = miConfig.Cainfo
  4398. data["datas"] = twos
  4399. data["fund"] = funInfosTwo
  4400. fmt.Println(twos)
  4401. month := time.Unix(1557042972, 0).Format("1")
  4402. year := time.Now().Format("2006")
  4403. month = time.Now().Format("01")
  4404. day := time.Now().Format("02")
  4405. hour := time.Now().Format("15")
  4406. min := time.Now().Format("04")
  4407. sec := time.Now().Format("05")
  4408. fix_fill_date := year + month + day + hour + min + sec
  4409. data["fix_fill_dept"] = miConfig.OrgName
  4410. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  4411. data["fix_fill_psn"] = curRoles.UserName
  4412. data["fix_fill_date"] = fix_fill_date
  4413. data["stmt_loc"] = "2"
  4414. data["setl_mon"] = stmt_mon
  4415. upld_btch = "0"
  4416. data["upld_btch"] = upld_btch
  4417. //fmt.Println(data)
  4418. client := &http.Client{}
  4419. bytesData, _ := json.Marshal(data)
  4420. var req *http.Request
  4421. if miConfig.MdtrtareaAdmvs == "320921" {
  4422. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  4423. } else {
  4424. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  4425. }
  4426. resp, _ := client.Do(req)
  4427. defer resp.Body.Close()
  4428. body, ioErr := ioutil.ReadAll(resp.Body)
  4429. if ioErr != nil {
  4430. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4432. }
  4433. var respJSON map[string]interface{}
  4434. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4435. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4437. }
  4438. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4439. //fmt.Println(respJSON)
  4440. result, _ := json.Marshal(respJSON)
  4441. //fmt.Println(result)
  4442. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  4443. utils.ErrorLog("解析失败:%v", err)
  4444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4445. }
  4446. if empty.Infcode != "0" {
  4447. c.ServeSuccessJSON(map[string]interface{}{
  4448. "failed_code": -10,
  4449. "msg": empty.ErrMsg,
  4450. })
  4451. return
  4452. } else {
  4453. c.ServeSuccessJSON(map[string]interface{}{
  4454. "msg": "上传成功",
  4455. })
  4456. return
  4457. }
  4458. }
  4459. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  4460. newArr = make([]TempFun, 0)
  4461. for i := 0; i < len(arr); i++ {
  4462. repeat := false
  4463. for j := i + 1; j < len(arr); j++ {
  4464. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  4465. repeat = true
  4466. break
  4467. }
  4468. }
  4469. if !repeat {
  4470. newArr = append(newArr, arr[i])
  4471. }
  4472. }
  4473. return
  4474. }
  4475. func (c *HisApiController) Get3263() {
  4476. admin_user_id, _ := c.GetInt64("admin_user_id")
  4477. startTime := c.GetString("start_time")
  4478. //endTime, _ := c.GetString("end_time")
  4479. times := strings.Split(startTime, "-")
  4480. setl_mon := times[0] + times[1]
  4481. upld_btch := "0"
  4482. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4483. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4484. var result3263 models.JSResult3263
  4485. data := make(map[string]interface{})
  4486. data["org_name"] = miConfig.OrgName
  4487. data["doctor"] = curRoles.UserName
  4488. data["doctor_name"] = curRoles.UserName
  4489. data["fixmedins_code"] = miConfig.Code
  4490. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4491. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4492. data["secret_key"] = miConfig.SecretKey
  4493. data["url"] = miConfig.Url
  4494. data["ak"] = miConfig.AccessKey
  4495. data["cainfo"] = miConfig.Cainfo
  4496. data["setl_mon"] = setl_mon
  4497. data["stmt_loc"] = "2"
  4498. data["upld_btch"] = upld_btch
  4499. client := &http.Client{}
  4500. bytesData, _ := json.Marshal(data)
  4501. var req *http.Request
  4502. if miConfig.MdtrtareaAdmvs == "320921" {
  4503. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  4504. } else {
  4505. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  4506. }
  4507. resp, _ := client.Do(req)
  4508. defer resp.Body.Close()
  4509. body, ioErr := ioutil.ReadAll(resp.Body)
  4510. if ioErr != nil {
  4511. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4513. }
  4514. var respJSON map[string]interface{}
  4515. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4516. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4518. }
  4519. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4520. fmt.Println(respJSON)
  4521. result, _ := json.Marshal(respJSON)
  4522. fmt.Println(result)
  4523. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  4524. utils.ErrorLog("解析失败:%v", err)
  4525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4526. }
  4527. if result3263.Infcode != "0" {
  4528. c.ServeSuccessJSON(map[string]interface{}{
  4529. "failed_code": -10,
  4530. "msg": result3263.ErrMsg,
  4531. })
  4532. return
  4533. } else {
  4534. c.ServeSuccessJSON(map[string]interface{}{
  4535. "list": result3263.Output,
  4536. })
  4537. return
  4538. }
  4539. }
  4540. func (c *HisApiController) Get3264() {
  4541. admin_user_id, _ := c.GetInt64("admin_user_id")
  4542. startTime := c.GetString("start_time")
  4543. //endTime, _ := c.GetString("end_time")
  4544. times := strings.Split(startTime, "-")
  4545. setl_mon := times[0] + times[1]
  4546. upld_btch := "0"
  4547. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4548. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4549. //solidify_id := []
  4550. var result3263 models.JSResult3263
  4551. data := make(map[string]interface{})
  4552. data["org_name"] = miConfig.OrgName
  4553. data["doctor"] = curRoles.UserName
  4554. data["doctor_name"] = curRoles.UserName
  4555. data["fixmedins_code"] = miConfig.Code
  4556. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4557. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4558. data["secret_key"] = miConfig.SecretKey
  4559. data["url"] = miConfig.Url
  4560. data["ak"] = miConfig.AccessKey
  4561. data["cainfo"] = miConfig.Cainfo
  4562. data["setl_mon"] = setl_mon
  4563. data["stmt_loc"] = "2"
  4564. data["upld_btch"] = upld_btch
  4565. client := &http.Client{}
  4566. bytesData, _ := json.Marshal(data)
  4567. var req3263 *http.Request
  4568. if miConfig.MdtrtareaAdmvs == "320921" {
  4569. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  4570. } else {
  4571. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  4572. }
  4573. resp, _ := client.Do(req3263)
  4574. defer resp.Body.Close()
  4575. body, ioErr := ioutil.ReadAll(resp.Body)
  4576. if ioErr != nil {
  4577. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4579. }
  4580. var respJSON3263 map[string]interface{}
  4581. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  4582. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4584. }
  4585. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4586. fmt.Println(respJSON3263)
  4587. result, _ := json.Marshal(respJSON3263)
  4588. fmt.Println(result)
  4589. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  4590. utils.ErrorLog("解析失败:%v", err)
  4591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4592. }
  4593. var ids []string
  4594. for _, item := range result3263.Output {
  4595. ids = append(ids, item.SolidifyID)
  4596. }
  4597. var empty models.JSResultEmpty
  4598. data2 := make(map[string]interface{})
  4599. data2["org_name"] = miConfig.OrgName
  4600. data2["doctor"] = curRoles.UserName
  4601. data2["doctor_name"] = curRoles.UserName
  4602. data2["fixmedins_code"] = miConfig.Code
  4603. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4604. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4605. data2["secret_key"] = miConfig.SecretKey
  4606. data2["url"] = miConfig.Url
  4607. data2["ak"] = miConfig.AccessKey
  4608. data2["cainfo"] = miConfig.Cainfo
  4609. data2["setl_mon"] = setl_mon
  4610. data2["stmt_loc"] = "2"
  4611. data2["upld_btch"] = upld_btch
  4612. data2["solidify_id"] = ids
  4613. client2 := &http.Client{}
  4614. bytesData2, _ := json.Marshal(data2)
  4615. var req *http.Request
  4616. if miConfig.MdtrtareaAdmvs == "320921" {
  4617. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  4618. } else {
  4619. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  4620. }
  4621. resp2, _ := client2.Do(req)
  4622. defer resp.Body.Close()
  4623. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  4624. if ioErr2 != nil {
  4625. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  4626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4627. }
  4628. var respJSON map[string]interface{}
  4629. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  4630. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4632. }
  4633. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  4634. fmt.Println(respJSON)
  4635. result2, _ := json.Marshal(respJSON)
  4636. fmt.Println(result2)
  4637. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  4638. utils.ErrorLog("解析失败:%v", err)
  4639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4640. }
  4641. if empty.Infcode != "0" {
  4642. c.ServeSuccessJSON(map[string]interface{}{
  4643. "failed_code": -10,
  4644. "msg": empty.ErrMsg,
  4645. })
  4646. return
  4647. } else {
  4648. c.ServeSuccessJSON(map[string]interface{}{
  4649. "msg": "",
  4650. })
  4651. return
  4652. }
  4653. }
  4654. func (c *HisApiController) Get3265() {
  4655. admin_user_id, _ := c.GetInt64("admin_user_id")
  4656. startTime := c.GetString("start_time")
  4657. //endTime, _ := c.GetString("end_time")
  4658. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4659. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4660. times := strings.Split(startTime, "-")
  4661. setl_mon := times[0] + times[1]
  4662. var upld_btch string
  4663. upld_btch = "0"
  4664. //var empty models.JSResultEmpty
  4665. var result3265 models.JSResult3264
  4666. var result3263 models.JSResult3263
  4667. data2 := make(map[string]interface{})
  4668. data2["org_name"] = miConfig.OrgName
  4669. data2["doctor"] = curRoles.UserName
  4670. data2["doctor_name"] = curRoles.UserName
  4671. data2["fixmedins_code"] = miConfig.Code
  4672. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4673. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4674. data2["secret_key"] = miConfig.SecretKey
  4675. data2["url"] = miConfig.Url
  4676. data2["ak"] = miConfig.AccessKey
  4677. data2["cainfo"] = miConfig.Cainfo
  4678. data2["setl_mon"] = setl_mon
  4679. data2["stmt_loc"] = "2"
  4680. data2["upld_btch"] = upld_btch
  4681. client2 := &http.Client{}
  4682. bytesData2, _ := json.Marshal(data2)
  4683. var req3263 *http.Request
  4684. if miConfig.MdtrtareaAdmvs == "320921" {
  4685. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  4686. } else {
  4687. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  4688. }
  4689. resp2, _ := client2.Do(req3263)
  4690. defer resp2.Body.Close()
  4691. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  4692. if ioErr2 != nil {
  4693. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  4694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4695. }
  4696. var respJSON3263 map[string]interface{}
  4697. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  4698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4700. }
  4701. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4702. fmt.Println(respJSON3263)
  4703. result2, _ := json.Marshal(respJSON3263)
  4704. fmt.Println(result2)
  4705. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  4706. utils.ErrorLog("解析失败:%v", err)
  4707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4708. }
  4709. var ids []string
  4710. for _, item := range result3263.Output {
  4711. ids = append(ids, item.SolidifyID)
  4712. }
  4713. data := make(map[string]interface{})
  4714. data["org_name"] = miConfig.OrgName
  4715. data["doctor"] = curRoles.UserName
  4716. data["doctor_name"] = curRoles.UserName
  4717. data["fixmedins_code"] = miConfig.Code
  4718. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4719. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4720. data["secret_key"] = miConfig.SecretKey
  4721. data["url"] = miConfig.Url
  4722. data["ak"] = miConfig.AccessKey
  4723. data["cainfo"] = miConfig.Cainfo
  4724. data["setl_mon"] = setl_mon
  4725. data["solidify_id"] = ids
  4726. month := time.Unix(1557042972, 0).Format("1")
  4727. year := time.Now().Format("2006")
  4728. month = time.Now().Format("01")
  4729. day := time.Now().Format("02")
  4730. hour := time.Now().Format("15")
  4731. min := time.Now().Format("04")
  4732. sec := time.Now().Format("05")
  4733. fix_fill_date := year + month + day + hour + min + sec
  4734. data["fix_fill_dept"] = miConfig.OrgName
  4735. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  4736. data["fix_fill_psn"] = curRoles.UserName
  4737. data["fix_fill_date"] = fix_fill_date
  4738. data["stmt_loc"] = "2"
  4739. data["upld_btch"] = upld_btch
  4740. client := &http.Client{}
  4741. bytesData, _ := json.Marshal(data)
  4742. var req *http.Request
  4743. if miConfig.MdtrtareaAdmvs == "320921" {
  4744. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  4745. } else {
  4746. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  4747. }
  4748. resp, _ := client.Do(req)
  4749. defer resp.Body.Close()
  4750. body, ioErr := ioutil.ReadAll(resp.Body)
  4751. if ioErr != nil {
  4752. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4754. }
  4755. var respJSON map[string]interface{}
  4756. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4757. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4759. }
  4760. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4761. fmt.Println(respJSON)
  4762. result, _ := json.Marshal(respJSON)
  4763. fmt.Println(result)
  4764. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  4765. utils.ErrorLog("解析失败:%v", err)
  4766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4767. }
  4768. if result3265.Infcode != "0" {
  4769. c.ServeSuccessJSON(map[string]interface{}{
  4770. "failed_code": -10,
  4771. "msg": result3265.ErrMsg,
  4772. })
  4773. return
  4774. } else {
  4775. c.ServeSuccessJSON(map[string]interface{}{
  4776. "info": result3265.Output,
  4777. })
  4778. return
  4779. }
  4780. }
  4781. func (c *HisApiController) Get3266() {
  4782. admin_user_id, _ := c.GetInt64("admin_user_id")
  4783. startTime := c.GetString("start_time")
  4784. //endTime, _ := c.GetString("end_time")
  4785. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4786. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4787. times := strings.Split(startTime, "-")
  4788. stmt_mon := times[0] + times[1]
  4789. var upld_btch string
  4790. //var empty models.JSResultEmpty
  4791. var result3265 models.JSResult3264
  4792. data := make(map[string]interface{})
  4793. data["org_name"] = miConfig.OrgName
  4794. data["doctor"] = curRoles.UserName
  4795. data["doctor_name"] = curRoles.UserName
  4796. data["fixmedins_code"] = miConfig.Code
  4797. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4798. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4799. data["secret_key"] = miConfig.SecretKey
  4800. data["url"] = miConfig.Url
  4801. data["ak"] = miConfig.AccessKey
  4802. data["cainfo"] = miConfig.Cainfo
  4803. data["setl_mon"] = stmt_mon
  4804. month := time.Unix(1557042972, 0).Format("1")
  4805. year := time.Now().Format("2006")
  4806. month = time.Now().Format("01")
  4807. day := time.Now().Format("02")
  4808. hour := time.Now().Format("15")
  4809. min := time.Now().Format("04")
  4810. sec := time.Now().Format("05")
  4811. fix_fill_date := year + month + day + hour + min + sec
  4812. data["fix_fill_dept"] = miConfig.OrgName
  4813. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  4814. data["fix_fill_psn"] = curRoles.UserName
  4815. data["fix_fill_date"] = fix_fill_date
  4816. data["stmt_loc"] = "2"
  4817. upld_btch = "0"
  4818. data["upld_btch"] = upld_btch
  4819. client := &http.Client{}
  4820. bytesData, _ := json.Marshal(data)
  4821. var req *http.Request
  4822. if miConfig.MdtrtareaAdmvs == "320921" {
  4823. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  4824. } else {
  4825. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  4826. }
  4827. resp, _ := client.Do(req)
  4828. defer resp.Body.Close()
  4829. body, ioErr := ioutil.ReadAll(resp.Body)
  4830. if ioErr != nil {
  4831. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4833. }
  4834. var respJSON map[string]interface{}
  4835. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4838. }
  4839. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4840. fmt.Println(respJSON)
  4841. result, _ := json.Marshal(respJSON)
  4842. fmt.Println(result)
  4843. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  4844. utils.ErrorLog("解析失败:%v", err)
  4845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4846. }
  4847. if result3265.Infcode != "0" {
  4848. c.ServeSuccessJSON(map[string]interface{}{
  4849. "failed_code": -10,
  4850. "msg": result3265.ErrMsg,
  4851. })
  4852. return
  4853. } else {
  4854. c.ServeSuccessJSON(map[string]interface{}{
  4855. "info": result3265.Output,
  4856. })
  4857. return
  4858. }
  4859. }
  4860. func (c *HisApiController) Get3267() {
  4861. admin_user_id, _ := c.GetInt64("admin_user_id")
  4862. startTime := c.GetString("start_time")
  4863. //endTime, _ := c.GetString("end_time")
  4864. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4865. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4866. times := strings.Split(startTime, "-")
  4867. setl_mon := times[0] + times[1]
  4868. var upld_btch string
  4869. //var empty models.JSResultEmpty
  4870. var result3265 models.JSResult3264
  4871. upld_btch = "0"
  4872. data := make(map[string]interface{})
  4873. data["org_name"] = miConfig.OrgName
  4874. data["doctor"] = curRoles.UserName
  4875. data["doctor_name"] = curRoles.UserName
  4876. data["fixmedins_code"] = miConfig.Code
  4877. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4878. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4879. data["secret_key"] = miConfig.SecretKey
  4880. data["url"] = miConfig.Url
  4881. data["ak"] = miConfig.AccessKey
  4882. data["cainfo"] = miConfig.Cainfo
  4883. data["setl_mon"] = setl_mon
  4884. data["stmt_loc"] = "2"
  4885. data["upld_btch"] = upld_btch
  4886. client := &http.Client{}
  4887. bytesData, _ := json.Marshal(data)
  4888. var req *http.Request
  4889. if miConfig.MdtrtareaAdmvs == "320921" {
  4890. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  4891. } else {
  4892. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  4893. }
  4894. resp, _ := client.Do(req)
  4895. defer resp.Body.Close()
  4896. body, ioErr := ioutil.ReadAll(resp.Body)
  4897. if ioErr != nil {
  4898. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4900. }
  4901. var respJSON map[string]interface{}
  4902. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4903. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4905. }
  4906. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4907. fmt.Println(respJSON)
  4908. result, _ := json.Marshal(respJSON)
  4909. fmt.Println(result)
  4910. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  4911. utils.ErrorLog("解析失败:%v", err)
  4912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4913. }
  4914. if result3265.Infcode != "0" {
  4915. c.ServeSuccessJSON(map[string]interface{}{
  4916. "failed_code": -10,
  4917. "msg": result3265.ErrMsg,
  4918. })
  4919. return
  4920. } else {
  4921. c.ServeSuccessJSON(map[string]interface{}{
  4922. "info": result3265.Output.Data,
  4923. })
  4924. return
  4925. }
  4926. }
  4927. func (c *HisApiController) Get3268() {
  4928. admin_user_id, _ := c.GetInt64("admin_user_id")
  4929. startTime := c.GetString("start_time")
  4930. endTime := c.GetString("end_time")
  4931. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4932. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4933. times := strings.Split(startTime, "-")
  4934. setl_mon := times[0] + times[1]
  4935. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  4936. var twos []models.FixMonRecDetailFileInTwo
  4937. var funs []models.FundDetail
  4938. for _, item := range datas {
  4939. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  4940. funs = append(funs, fun...)
  4941. }
  4942. var funInfos []models.Fund
  4943. //for _, item := range funs {
  4944. // var rf []models.FundInfo
  4945. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  4946. // for _, subitem := range rf {
  4947. // var fund models.Fund
  4948. // fund.FundCode = subitem.FundPayType
  4949. // fund.FundName = subitem.FundPayTypeName
  4950. // fund.FundAmt = subitem.FundPayAmt
  4951. // fund.FundKey = item.FundKey
  4952. // fund.InsuAdmdvs = "555555"
  4953. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  4954. // funInfos = append(funInfos, fund)
  4955. // }
  4956. //}
  4957. for _, team := range datas {
  4958. var two models.FixMonRecDetailFileInTwo
  4959. two.SetlDate = time.Now().Format("2006-01-02")
  4960. two.MedType = team.MedType
  4961. two.Insutype = team.Insutype
  4962. two.PsnType = team.PsnType
  4963. two.MedType = team.MedType
  4964. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  4965. two.InsuAdmdvs = team.InsuAdmdvs
  4966. two.PsnTime = team.PsnTime
  4967. two.PsnCnt = team.PsnCnt
  4968. two.FundKey = team.FundKey
  4969. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  4970. fps, _ := strconv.ParseFloat(team.Fund, 64)
  4971. ia, _ := strconv.ParseFloat(team.Amt, 64)
  4972. two.MedfeeSumAmt = ms
  4973. two.InscpAmt = ia
  4974. two.FundPaySumAmt = fps
  4975. twos = append(twos, two)
  4976. }
  4977. var upld_btch string
  4978. upld_btch = "0"
  4979. var empty models.JSResultEmpty
  4980. data := make(map[string]interface{})
  4981. data["org_name"] = miConfig.OrgName
  4982. data["doctor"] = curRoles.UserName
  4983. data["doctor_name"] = curRoles.UserName
  4984. data["fixmedins_code"] = miConfig.Code
  4985. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4986. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4987. data["secret_key"] = miConfig.SecretKey
  4988. data["url"] = miConfig.Url
  4989. data["ak"] = miConfig.AccessKey
  4990. data["cainfo"] = miConfig.Cainfo
  4991. data["datas"] = twos
  4992. data["fund"] = funInfos
  4993. data["setl_mon"] = setl_mon
  4994. month := time.Unix(1557042972, 0).Format("1")
  4995. year := time.Now().Format("2006")
  4996. month = time.Now().Format("01")
  4997. day := time.Now().Format("02")
  4998. hour := time.Now().Format("15")
  4999. min := time.Now().Format("04")
  5000. sec := time.Now().Format("05")
  5001. fix_fill_date := year + month + day + hour + min + sec
  5002. data["fix_fill_dept"] = miConfig.OrgName
  5003. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  5004. data["fix_fill_psn"] = curRoles.UserName
  5005. data["fix_fill_date"] = fix_fill_date
  5006. data["stmt_loc"] = "2"
  5007. data["upld_btch"] = upld_btch
  5008. client := &http.Client{}
  5009. bytesData, _ := json.Marshal(data)
  5010. var req *http.Request
  5011. if miConfig.MdtrtareaAdmvs == "320921" {
  5012. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  5013. } else {
  5014. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  5015. }
  5016. resp, _ := client.Do(req)
  5017. defer resp.Body.Close()
  5018. body, ioErr := ioutil.ReadAll(resp.Body)
  5019. if ioErr != nil {
  5020. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5022. }
  5023. var respJSON map[string]interface{}
  5024. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5025. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5027. }
  5028. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5029. fmt.Println(respJSON)
  5030. result, _ := json.Marshal(respJSON)
  5031. fmt.Println(result)
  5032. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  5033. utils.ErrorLog("解析失败:%v", err)
  5034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5035. }
  5036. if empty.Infcode != "0" {
  5037. c.ServeSuccessJSON(map[string]interface{}{
  5038. "failed_code": -10,
  5039. "msg": empty.ErrMsg,
  5040. })
  5041. return
  5042. } else {
  5043. c.ServeSuccessJSON(map[string]interface{}{
  5044. "msg": "上传成功",
  5045. })
  5046. return
  5047. }
  5048. }
  5049. func (c *HisApiController) Get3269() {
  5050. admin_user_id, _ := c.GetInt64("admin_user_id")
  5051. startTime := c.GetString("start_time")
  5052. //endTime, _ := c.GetString("end_time")
  5053. times := strings.Split(startTime, "-")
  5054. setl_mon := times[0] + times[1]
  5055. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5056. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5057. var result3263 models.JSResult3263
  5058. data := make(map[string]interface{})
  5059. data["org_name"] = miConfig.OrgName
  5060. data["doctor"] = curRoles.UserName
  5061. data["doctor_name"] = curRoles.UserName
  5062. data["fixmedins_code"] = miConfig.Code
  5063. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5064. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5065. data["secret_key"] = miConfig.SecretKey
  5066. data["url"] = miConfig.Url
  5067. data["ak"] = miConfig.AccessKey
  5068. data["cainfo"] = miConfig.Cainfo
  5069. data["setl_mon"] = setl_mon
  5070. data["stmt_loc"] = "2"
  5071. client := &http.Client{}
  5072. bytesData, _ := json.Marshal(data)
  5073. var req *http.Request
  5074. if miConfig.MdtrtareaAdmvs == "320921" {
  5075. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  5076. } else {
  5077. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  5078. }
  5079. resp, _ := client.Do(req)
  5080. defer resp.Body.Close()
  5081. body, ioErr := ioutil.ReadAll(resp.Body)
  5082. if ioErr != nil {
  5083. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5085. }
  5086. var respJSON map[string]interface{}
  5087. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5088. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5090. }
  5091. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5092. fmt.Println(respJSON)
  5093. result, _ := json.Marshal(respJSON)
  5094. fmt.Println(result)
  5095. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  5096. utils.ErrorLog("解析失败:%v", err)
  5097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5098. }
  5099. if result3263.Infcode != "0" {
  5100. c.ServeSuccessJSON(map[string]interface{}{
  5101. "failed_code": -10,
  5102. "msg": result3263.ErrMsg,
  5103. })
  5104. return
  5105. } else {
  5106. c.ServeSuccessJSON(map[string]interface{}{
  5107. "msg": "上传成功",
  5108. })
  5109. return
  5110. }
  5111. }
  5112. func (c *HisApiController) Get3270() {
  5113. admin_user_id, _ := c.GetInt64("admin_user_id")
  5114. startTime := c.GetString("start_time")
  5115. //endTime, _ := c.GetString("end_time")
  5116. times := strings.Split(startTime, "-")
  5117. setl_mon := times[0] + times[1]
  5118. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5119. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5120. var result3263 models.JSResult3263
  5121. data2 := make(map[string]interface{})
  5122. data2["org_name"] = miConfig.OrgName
  5123. data2["doctor"] = curRoles.UserName
  5124. data2["doctor_name"] = curRoles.UserName
  5125. data2["fixmedins_code"] = miConfig.Code
  5126. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5127. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5128. data2["secret_key"] = miConfig.SecretKey
  5129. data2["url"] = miConfig.Url
  5130. data2["ak"] = miConfig.AccessKey
  5131. data2["cainfo"] = miConfig.Cainfo
  5132. data2["setl_mon"] = setl_mon
  5133. data2["stmt_loc"] = "2"
  5134. client2 := &http.Client{}
  5135. bytesData2, _ := json.Marshal(data2)
  5136. var req3263 *http.Request
  5137. if miConfig.MdtrtareaAdmvs == "320921" {
  5138. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  5139. } else {
  5140. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  5141. }
  5142. resp2, _ := client2.Do(req3263)
  5143. defer resp2.Body.Close()
  5144. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  5145. if ioErr2 != nil {
  5146. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  5147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5148. }
  5149. var respJSON3263 map[string]interface{}
  5150. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  5151. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5153. }
  5154. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5155. fmt.Println(respJSON3263)
  5156. result2, _ := json.Marshal(respJSON3263)
  5157. fmt.Println(result2)
  5158. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  5159. utils.ErrorLog("解析失败:%v", err)
  5160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5161. }
  5162. var ids []string
  5163. for _, item := range result3263.Output {
  5164. ids = append(ids, item.SolidifyID)
  5165. }
  5166. var result3264 models.JSResult3264
  5167. data := make(map[string]interface{})
  5168. data["org_name"] = miConfig.OrgName
  5169. data["doctor"] = curRoles.UserName
  5170. data["doctor_name"] = curRoles.UserName
  5171. data["fixmedins_code"] = miConfig.Code
  5172. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5173. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5174. data["secret_key"] = miConfig.SecretKey
  5175. data["url"] = miConfig.Url
  5176. data["ak"] = miConfig.AccessKey
  5177. data["cainfo"] = miConfig.Cainfo
  5178. data["setl_mon"] = setl_mon
  5179. data["stmt_loc"] = "2"
  5180. data["solidify_id"] = ids
  5181. client := &http.Client{}
  5182. bytesData, _ := json.Marshal(data)
  5183. var req *http.Request
  5184. if miConfig.MdtrtareaAdmvs == "320921" {
  5185. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  5186. } else {
  5187. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  5188. }
  5189. resp, _ := client.Do(req)
  5190. defer resp.Body.Close()
  5191. body, ioErr := ioutil.ReadAll(resp.Body)
  5192. if ioErr != nil {
  5193. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5195. }
  5196. var respJSON map[string]interface{}
  5197. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5198. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5200. }
  5201. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5202. fmt.Println(respJSON)
  5203. result, _ := json.Marshal(respJSON)
  5204. fmt.Println(result)
  5205. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  5206. utils.ErrorLog("解析失败:%v", err)
  5207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5208. }
  5209. if result3264.Infcode != "0" {
  5210. c.ServeSuccessJSON(map[string]interface{}{
  5211. "failed_code": -10,
  5212. "msg": result3264.ErrMsg,
  5213. })
  5214. return
  5215. } else {
  5216. c.ServeSuccessJSON(map[string]interface{}{
  5217. "info": result3264.Output,
  5218. })
  5219. return
  5220. }
  5221. }
  5222. func (c *HisApiController) Get3271() {
  5223. admin_user_id, _ := c.GetInt64("admin_user_id")
  5224. startTime := c.GetString("start_time")
  5225. //endTime, _ := c.GetString("end_time")
  5226. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5227. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5228. times := strings.Split(startTime, "-")
  5229. setl_mon := times[0] + times[1]
  5230. //var empty models.JSResultEmpty
  5231. var result3265 models.JSResult3264
  5232. var result3263 models.JSResult3263
  5233. data2 := make(map[string]interface{})
  5234. data2["org_name"] = miConfig.OrgName
  5235. data2["doctor"] = curRoles.UserName
  5236. data2["doctor_name"] = curRoles.UserName
  5237. data2["fixmedins_code"] = miConfig.Code
  5238. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5239. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5240. data2["secret_key"] = miConfig.SecretKey
  5241. data2["url"] = miConfig.Url
  5242. data2["ak"] = miConfig.AccessKey
  5243. data2["cainfo"] = miConfig.Cainfo
  5244. data2["setl_mon"] = setl_mon
  5245. data2["stmt_loc"] = "2"
  5246. client2 := &http.Client{}
  5247. bytesData2, _ := json.Marshal(data2)
  5248. var req3263 *http.Request
  5249. if miConfig.MdtrtareaAdmvs == "320921" {
  5250. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  5251. } else {
  5252. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  5253. }
  5254. resp2, _ := client2.Do(req3263)
  5255. defer resp2.Body.Close()
  5256. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  5257. if ioErr2 != nil {
  5258. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  5259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5260. }
  5261. var respJSON3263 map[string]interface{}
  5262. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  5263. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5265. }
  5266. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5267. fmt.Println(respJSON3263)
  5268. result2, _ := json.Marshal(respJSON3263)
  5269. fmt.Println(result2)
  5270. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  5271. utils.ErrorLog("解析失败:%v", err)
  5272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5273. }
  5274. var ids []string
  5275. for _, item := range result3263.Output {
  5276. ids = append(ids, item.SolidifyID)
  5277. }
  5278. data := make(map[string]interface{})
  5279. data["org_name"] = miConfig.OrgName
  5280. data["doctor"] = curRoles.UserName
  5281. data["doctor_name"] = curRoles.UserName
  5282. data["fixmedins_code"] = miConfig.Code
  5283. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5284. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5285. data["secret_key"] = miConfig.SecretKey
  5286. data["url"] = miConfig.Url
  5287. data["ak"] = miConfig.AccessKey
  5288. data["cainfo"] = miConfig.Cainfo
  5289. data["setl_mon"] = setl_mon
  5290. data["solidify_id"] = ids
  5291. month := time.Unix(1557042972, 0).Format("1")
  5292. year := time.Now().Format("2006")
  5293. month = time.Now().Format("01")
  5294. day := time.Now().Format("02")
  5295. hour := time.Now().Format("15")
  5296. min := time.Now().Format("04")
  5297. sec := time.Now().Format("05")
  5298. fix_fill_date := year + month + day + hour + min + sec
  5299. data["fix_fill_dept"] = miConfig.OrgName
  5300. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  5301. data["fix_fill_psn"] = curRoles.UserName
  5302. data["fix_fill_date"] = fix_fill_date
  5303. data["stmt_loc"] = "2"
  5304. client := &http.Client{}
  5305. bytesData, _ := json.Marshal(data)
  5306. var req *http.Request
  5307. if miConfig.MdtrtareaAdmvs == "320921" {
  5308. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  5309. } else {
  5310. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  5311. }
  5312. resp, _ := client.Do(req)
  5313. defer resp.Body.Close()
  5314. body, ioErr := ioutil.ReadAll(resp.Body)
  5315. if ioErr != nil {
  5316. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5318. }
  5319. var respJSON map[string]interface{}
  5320. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5323. }
  5324. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5325. fmt.Println(respJSON)
  5326. result, _ := json.Marshal(respJSON)
  5327. fmt.Println(result)
  5328. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  5329. utils.ErrorLog("解析失败:%v", err)
  5330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5331. }
  5332. if result3265.Infcode != "0" {
  5333. c.ServeSuccessJSON(map[string]interface{}{
  5334. "failed_code": -10,
  5335. "msg": result3265.ErrMsg,
  5336. })
  5337. return
  5338. } else {
  5339. c.ServeSuccessJSON(map[string]interface{}{
  5340. "info": result3265.Output.Data,
  5341. })
  5342. return
  5343. }
  5344. }
  5345. func (c *HisApiController) Get3272() {
  5346. admin_user_id, _ := c.GetInt64("admin_user_id")
  5347. startTime := c.GetString("start_time")
  5348. //endTime, _ := c.GetString("end_time")
  5349. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5350. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5351. times := strings.Split(startTime, "-")
  5352. setl_mon := times[0] + times[1]
  5353. var upld_btch string
  5354. //var empty models.JSResultEmpty
  5355. var result3265 models.JSResult3264
  5356. data := make(map[string]interface{})
  5357. data["org_name"] = miConfig.OrgName
  5358. data["doctor"] = curRoles.UserName
  5359. data["doctor_name"] = curRoles.UserName
  5360. data["fixmedins_code"] = miConfig.Code
  5361. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5362. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5363. data["secret_key"] = miConfig.SecretKey
  5364. data["url"] = miConfig.Url
  5365. data["ak"] = miConfig.AccessKey
  5366. data["cainfo"] = miConfig.Cainfo
  5367. data["setl_mon"] = setl_mon
  5368. month := time.Unix(1557042972, 0).Format("1")
  5369. year := time.Now().Format("2006")
  5370. month = time.Now().Format("01")
  5371. day := time.Now().Format("02")
  5372. hour := time.Now().Format("15")
  5373. min := time.Now().Format("04")
  5374. sec := time.Now().Format("05")
  5375. fix_fill_date := year + month + day + hour + min + sec
  5376. data["fix_fill_dept"] = miConfig.OrgName
  5377. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  5378. data["fix_fill_psn"] = curRoles.UserName
  5379. data["fix_fill_date"] = fix_fill_date
  5380. data["stmt_loc"] = "2"
  5381. data["upld_btch"] = upld_btch
  5382. client := &http.Client{}
  5383. bytesData, _ := json.Marshal(data)
  5384. var req *http.Request
  5385. if miConfig.MdtrtareaAdmvs == "320921" {
  5386. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  5387. } else {
  5388. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  5389. }
  5390. resp, _ := client.Do(req)
  5391. defer resp.Body.Close()
  5392. body, ioErr := ioutil.ReadAll(resp.Body)
  5393. if ioErr != nil {
  5394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5396. }
  5397. var respJSON map[string]interface{}
  5398. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5401. }
  5402. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5403. fmt.Println(respJSON)
  5404. result, _ := json.Marshal(respJSON)
  5405. fmt.Println(result)
  5406. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  5407. utils.ErrorLog("解析失败:%v", err)
  5408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5409. }
  5410. if result3265.Infcode != "0" {
  5411. c.ServeSuccessJSON(map[string]interface{}{
  5412. "failed_code": -10,
  5413. "msg": result3265.ErrMsg,
  5414. })
  5415. return
  5416. } else {
  5417. c.ServeSuccessJSON(map[string]interface{}{
  5418. "info": result3265.Output,
  5419. })
  5420. return
  5421. }
  5422. }
  5423. func (c *HisApiController) Get3273() {
  5424. admin_user_id, _ := c.GetInt64("admin_user_id")
  5425. startTime := c.GetString("start_time")
  5426. //endTime, _ := c.GetString("end_time")
  5427. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5428. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5429. times := strings.Split(startTime, "-")
  5430. setl_mon := times[0] + times[1]
  5431. var result3265 models.JSResult3264
  5432. data := make(map[string]interface{})
  5433. data["org_name"] = miConfig.OrgName
  5434. data["doctor"] = curRoles.UserName
  5435. data["doctor_name"] = curRoles.UserName
  5436. data["fixmedins_code"] = miConfig.Code
  5437. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5438. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5439. data["secret_key"] = miConfig.SecretKey
  5440. data["url"] = miConfig.Url
  5441. data["ak"] = miConfig.AccessKey
  5442. data["cainfo"] = miConfig.Cainfo
  5443. data["setl_mon"] = setl_mon
  5444. data["stmt_loc"] = "2"
  5445. client := &http.Client{}
  5446. bytesData, _ := json.Marshal(data)
  5447. var req *http.Request
  5448. if miConfig.MdtrtareaAdmvs == "320921" {
  5449. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  5450. } else {
  5451. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  5452. }
  5453. resp, _ := client.Do(req)
  5454. defer resp.Body.Close()
  5455. body, ioErr := ioutil.ReadAll(resp.Body)
  5456. if ioErr != nil {
  5457. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5459. }
  5460. var respJSON map[string]interface{}
  5461. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5462. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5464. }
  5465. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5466. fmt.Println(respJSON)
  5467. result, _ := json.Marshal(respJSON)
  5468. fmt.Println(result)
  5469. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  5470. utils.ErrorLog("解析失败:%v", err)
  5471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5472. }
  5473. if result3265.Infcode != "0" {
  5474. c.ServeSuccessJSON(map[string]interface{}{
  5475. "failed_code": -10,
  5476. "msg": result3265.ErrMsg,
  5477. })
  5478. return
  5479. } else {
  5480. c.ServeSuccessJSON(map[string]interface{}{
  5481. "info": result3265.Output.Data,
  5482. })
  5483. return
  5484. }
  5485. }
  5486. func (c *HisApiController) Get3274() {
  5487. //if miConfig.MdtrtareaAdmvs == "320921" {
  5488. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  5489. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5490. // "&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
  5491. //
  5492. //} else {
  5493. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  5494. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5495. // "&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
  5496. //
  5497. //}
  5498. }
  5499. func (c *HisApiController) Get3275() {
  5500. //if miConfig.MdtrtareaAdmvs == "320921" {
  5501. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  5502. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5503. // "&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
  5504. //
  5505. //} else {
  5506. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  5507. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5508. // "&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
  5509. //
  5510. //}
  5511. }
  5512. func (c *HisApiController) Get3276() {
  5513. //admin_user_id, _ := c.GetInt64("admin_user_id")
  5514. //month := c.GetString("month")
  5515. //
  5516. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5517. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5518. //var api string
  5519. //var res Result5301
  5520. //
  5521. //if miConfig.MdtrtareaAdmvs == "320921" {
  5522. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5523. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  5524. //} else {
  5525. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5526. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  5527. //}
  5528. //
  5529. //resp, requestErr := http.Get(api)
  5530. //if requestErr != nil {
  5531. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5532. // return
  5533. //}
  5534. //
  5535. //body, ioErr := ioutil.ReadAll(resp.Body)
  5536. //if ioErr != nil {
  5537. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5538. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5539. // return
  5540. //}
  5541. //var respJSON map[string]interface{}
  5542. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5543. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5544. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5545. // return
  5546. //}
  5547. //
  5548. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5549. //result, _ := json.Marshal(respJSON)
  5550. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5551. // utils.ErrorLog("解析失败:%v", err)
  5552. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5553. // return
  5554. //}
  5555. }
  5556. func (c *HisApiController) Get3277() {
  5557. //admin_user_id, _ := c.GetInt64("admin_user_id")
  5558. //month := c.GetString("month")
  5559. //
  5560. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5561. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5562. //var api string
  5563. //var res Result5301
  5564. //
  5565. //if miConfig.MdtrtareaAdmvs == "320921" {
  5566. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5567. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  5568. //} else {
  5569. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5570. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  5571. //}
  5572. //
  5573. //resp, requestErr := http.Get(api)
  5574. //if requestErr != nil {
  5575. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5576. // return
  5577. //}
  5578. //
  5579. //body, ioErr := ioutil.ReadAll(resp.Body)
  5580. //if ioErr != nil {
  5581. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5582. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5583. // return
  5584. //}
  5585. //var respJSON map[string]interface{}
  5586. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5587. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5588. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5589. // return
  5590. //}
  5591. //
  5592. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5593. //result, _ := json.Marshal(respJSON)
  5594. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5595. // utils.ErrorLog("解析失败:%v", err)
  5596. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5597. // return
  5598. //}
  5599. }
  5600. func (c *HisApiController) GetCFYLJG001() {
  5601. admin_user_id, _ := c.GetInt64("admin_user_id")
  5602. patient_id, _ := c.GetInt64("patient_id")
  5603. his_patient_id, _ := c.GetInt64("his_patient_id")
  5604. record_time := c.GetString("record_time")
  5605. admin_user_id = 3626
  5606. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5607. psn, _ := service.GetPsnByPatientId(patient_id)
  5608. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5609. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5610. var cFYLJG001 models.CFYLJG001
  5611. timeLayout := "2006-01-02"
  5612. loc, _ := time.LoadLocation("Local")
  5613. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5614. if err != nil {
  5615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5616. return
  5617. }
  5618. recordDateTime := theTime.Unix()
  5619. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  5620. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  5621. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  5622. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  5623. //dept, _ := service.GetDepartMentDetail(info.Departments)
  5624. for _, item := range prescriptions {
  5625. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  5626. if his.IdCardType == 1 {
  5627. bas := strings.Split(psn.CardInfo, "|")
  5628. basNumber := bas[1]
  5629. fmt.Println(basNumber)
  5630. card_sn := bas[3]
  5631. card_no := bas[2]
  5632. cFYLJG001.MdtrtCertType = "03"
  5633. cFYLJG001.CardSn = card_sn
  5634. cFYLJG001.MdtrtCertNo = card_no
  5635. cFYLJG001.EcToken = ""
  5636. cFYLJG001.AuthNo = ""
  5637. } else if his.IdCardType == 2 {
  5638. cFYLJG001.MdtrtCertType = "02"
  5639. cFYLJG001.CardSn = ""
  5640. cFYLJG001.MdtrtCertNo = his.IdCardNo
  5641. cFYLJG001.EcToken = ""
  5642. cFYLJG001.AuthNo = ""
  5643. } else if his.IdCardType == 4 {
  5644. cFYLJG001.MdtrtCertType = "01"
  5645. cFYLJG001.CardSn = ""
  5646. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  5647. cFYLJG001.EcToken = psn.VerifyNumber
  5648. cFYLJG001.AuthNo = ""
  5649. }
  5650. cFYLJG001.BizTypeCode = "01"
  5651. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  5652. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  5653. cFYLJG001.RxTypeCode = "1"
  5654. tempTime := time.Unix(item.PreTime, 0)
  5655. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  5656. cFYLJG001.PrscTime = timeFormatOne
  5657. var count float64
  5658. if item.Type == 1 {
  5659. for _, sumItem := range item.HisDoctorAdviceInfo {
  5660. count = count + sumItem.PrescribingNumber
  5661. }
  5662. }
  5663. cFYLJG001.RxDrugCnt = count
  5664. cFYLJG001.ValiDays = "5"
  5665. ts := time.Unix(item.PreTime, 0)
  5666. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  5667. tempTime3 := time.Unix(record_time2, 0)
  5668. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  5669. cFYLJG001.ValiEndTime = timeFormat3
  5670. cFYLJG001.RxCotnFlag = "0"
  5671. for _, subItem := range item.HisDoctorAdviceInfo {
  5672. var drug models.RxDrug
  5673. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  5674. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  5675. drug.RxItemTypeCode = "11"
  5676. drug.DrugDosform = "乳膏剂" //TODO
  5677. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  5678. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  5679. }
  5680. drug.MedcWayDscr = subItem.DeliveryWay
  5681. tempTime2 := time.Unix(subItem.StartTime, 0)
  5682. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  5683. drug.MedcBegntime = timeFormatTwo
  5684. if subItem.Day > 0 {
  5685. ts := time.Unix(subItem.StartTime, 0)
  5686. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  5687. tempTime4 := time.Unix(record_time, 0)
  5688. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  5689. drug.MedcEndtime = timeFormat5
  5690. } else {
  5691. tempTime2 := time.Unix(subItem.StartTime, 0)
  5692. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  5693. drug.MedcEndtime = timeFormatTwo
  5694. }
  5695. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  5696. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  5697. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  5698. drug.DrugCnt = subItem.PrescribingNumber
  5699. drug.DrugDosunt = subItem.PrescribingNumberUnit
  5700. drug.DrugGenname = subItem.AdviceName
  5701. drug.MedcWayCodg = subItem.DeliveryWay
  5702. //drug.DrugTotlcnt = subItem.PrescribingNumber
  5703. drug.SinDoscnt = subItem.SingleDose
  5704. drug.SinDosunt = subItem.SingleDoseUnit
  5705. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  5706. drug.UsedFrquName = subItem.ExecutionFrequency
  5707. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5708. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  5709. drug.HospApprFlag = "1"
  5710. cFYLJG001.List = append(cFYLJG001.List, drug)
  5711. }
  5712. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  5713. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  5714. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  5715. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  5716. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  5717. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  5718. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  5719. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  5720. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  5721. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  5722. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  5723. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  5724. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  5725. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  5726. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  5727. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  5728. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  5729. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  5730. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  5731. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  5732. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  5733. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  5734. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  5735. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  5736. tempTime2 := time.Now().Unix()
  5737. tempTime6 := time.Unix(tempTime2, 0)
  5738. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  5739. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  5740. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  5741. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  5742. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  5743. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  5744. //memo := make(map[string]interface{})
  5745. //inputData := make(map[string]interface{}, 0)
  5746. //type MyData struct {
  5747. // Insutype string `json:"insutype"`
  5748. //}
  5749. //
  5750. // data := MyData{
  5751. // Insutype: his.Insutype,
  5752. //}
  5753. //
  5754. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  5755. var config []*models.HisXtDiagnoseConfig
  5756. for _, item := range diagnosis_ids {
  5757. id, _ := strconv.ParseInt(item, 10, 64)
  5758. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5759. config = append(config, &diagnosisConfig)
  5760. }
  5761. for index, subitem := range config {
  5762. if index == 0 {
  5763. var dia models.DiseInfo
  5764. dia.DiagType = "1"
  5765. dia.MaindiagFlag = "1"
  5766. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  5767. dia.DiagCode = subitem.CountryCode
  5768. dia.DiagName = subitem.ClassName
  5769. dia.DiagDept = "肾内科"
  5770. dia.DiagDrNo = doctor.DoctorNumber
  5771. dia.DiagDrName = doctor.UserName
  5772. tempTime3 := time.Unix(item.PreTime, 0)
  5773. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  5774. dia.DiagTime = timeFormatTwo
  5775. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  5776. } else {
  5777. var dia models.DiseInfo
  5778. dia.DiagType = "1"
  5779. dia.MaindiagFlag = "0"
  5780. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  5781. dia.DiagCode = subitem.CountryCode
  5782. dia.DiagName = subitem.ClassName
  5783. dia.DiagDept = "肾内科"
  5784. dia.DiagDrNo = doctor.DoctorNumber
  5785. dia.DiagDrName = doctor.UserName
  5786. tempTime3 := time.Unix(item.PreTime, 0)
  5787. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  5788. dia.DiagTime = timeFormatTwo
  5789. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  5790. }
  5791. }
  5792. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  5793. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  5794. var res ResultCFYLJG001
  5795. var respJSON2 map[string]interface{}
  5796. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5797. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5799. return
  5800. }
  5801. userJSONBytes2, _ := json.Marshal(respJSON2)
  5802. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  5803. utils.ErrorLog("解析失败:%v", err)
  5804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5805. return
  5806. }
  5807. if res.Infcode == -1 {
  5808. c.ServeSuccessJSON(map[string]interface{}{
  5809. "failed_code": -10,
  5810. "msg": res.ErrMsg,
  5811. })
  5812. return
  5813. } else {
  5814. var flow models.HisPrescriptionFlow
  5815. flow.Ctime = time.Now().Unix()
  5816. flow.SignDigest = ""
  5817. flow.RxTraceCode = res.Output.RxTraceCode
  5818. flow.HiRxno = res.Output.HiRxno
  5819. flow.MID = his.Number
  5820. flow.Status = 1
  5821. flow.DCode = doctor_info.DoctorNumber
  5822. flow.OriginalRxFile = ""
  5823. flow.OriginalValue = ""
  5824. flow.SignCertDn = ""
  5825. flow.UserOrgId = 10454
  5826. flow.SignCertSn = ""
  5827. flow.Mtime = time.Now().Unix()
  5828. service.Createflow(&flow)
  5829. c.ServeSuccessJSON(map[string]interface{}{
  5830. "msg": "上传成功",
  5831. })
  5832. }
  5833. }
  5834. }
  5835. func (c *HisApiController) GetCFYLJG002() {
  5836. admin_user_id, _ := c.GetInt64("admin_user_id")
  5837. his_patient_id, _ := c.GetInt64("his_patient_id")
  5838. record_time := c.GetString("record_time")
  5839. admin_user_id = 3626
  5840. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5841. //id, _ := c.GetInt64("id")
  5842. admin_user_id = 3626
  5843. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5844. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5845. flow, _ := service.Getflowtwo(his.Number)
  5846. //his, _ := service.GetHisPatientByNumber(flow.MID)
  5847. //record_time := c.GetString("record_time")
  5848. patient_id, _ := c.GetInt64("patient_id")
  5849. //patient_id = 23834
  5850. //record_time = "2023-09-18"
  5851. timeLayout := "2006-01-02"
  5852. loc, _ := time.LoadLocation("Local")
  5853. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5854. if err != nil {
  5855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5856. return
  5857. }
  5858. recordDateTime := theTime.Unix()
  5859. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  5860. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  5861. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  5862. dept, _ := service.GetDepartMentDetail(info.Departments)
  5863. inputData := make(map[string]interface{})
  5864. inputData["rxTraceCode"] = flow.RxTraceCode
  5865. inputData["hiRxno"] = flow.HiRxno
  5866. inputData["mdtrtId"] = flow.MID
  5867. inputData["patnName"] = his.PsnName
  5868. inputData["psnCertType"] = his.PsnCertType
  5869. inputData["certno"] = his.Certno
  5870. inputData["fixmedinsName"] = miConfig.OrgName
  5871. inputData["fixmedinsCode"] = miConfig.Code
  5872. inputData["drCode"] = doctor_info.DoctorNumber
  5873. inputData["prscDrName"] = doctor_info.UserName
  5874. inputData["pharDeptName"] = dept.Name
  5875. inputData["pharDeptCode"] = dept.Number
  5876. inputData["pharProfttlCodg"] = dept.Name
  5877. inputData["pharProfttlName"] = ""
  5878. inputData["pharCode"] = "HY440309002107"
  5879. inputData["pharCertType"] = "01"
  5880. inputData["pharCertno"] = "430482199408260023"
  5881. inputData["pharName"] = "彭斯遥"
  5882. inputData["pharPracCertNo"] = ""
  5883. tempTime2 := time.Unix(info.Ctime, 0)
  5884. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  5885. inputData["pharChkTime"] = timeFormatTwo
  5886. bytesData, _ := json.Marshal(inputData)
  5887. fmt.Println(string(bytesData))
  5888. encoded := base64.StdEncoding.EncodeToString(bytesData)
  5889. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  5890. if err != nil {
  5891. fmt.Println("Error reading PDF file:", err)
  5892. return
  5893. }
  5894. // 将 PDF 文件内容进行 Base64 编码
  5895. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  5896. fmt.Println(err)
  5897. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  5898. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  5899. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  5900. var res2 Result002
  5901. var respJSON2 map[string]interface{}
  5902. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5903. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5905. return
  5906. }
  5907. userJSONBytes2, _ := json.Marshal(respJSON2)
  5908. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5909. utils.ErrorLog("解析失败:%v", err)
  5910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5911. return
  5912. }
  5913. if res2.Infcode == 0 {
  5914. flow.Ctime = time.Now().Unix()
  5915. flow.SignDigest = res2.Output.SignDigest
  5916. flow.RxFile = res2.Output.RxFile
  5917. flow.MID = his.Number
  5918. flow.Status = 1
  5919. flow.DCode = doctor_info.DoctorNumber
  5920. flow.OriginalRxFile = rx_encoded
  5921. flow.OriginalValue = encoded
  5922. flow.SignCertDn = res2.Output.SignCertDn
  5923. flow.SignCertSn = res2.Output.SignCertSn
  5924. flow.Mtime = time.Now().Unix()
  5925. service.Saveflow(flow)
  5926. c.ServeSuccessJSON(map[string]interface{}{
  5927. "msg": "预签名成功",
  5928. })
  5929. } else {
  5930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5931. return
  5932. }
  5933. }
  5934. func (c *HisApiController) GetCFYLJG003() {
  5935. admin_user_id, _ := c.GetInt64("admin_user_id")
  5936. his_patient_id, _ := c.GetInt64("his_patient_id")
  5937. record_time := c.GetString("record_time")
  5938. admin_user_id = 3626
  5939. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5940. //id, _ := c.GetInt64("id")
  5941. admin_user_id = 3626
  5942. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5943. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5944. flow, _ := service.Getflowtwo(his.Number)
  5945. //id = 3
  5946. patient_id, _ := c.GetInt64("patient_id")
  5947. //patient_id = 23834
  5948. //record_time = "2023-09-18"
  5949. timeLayout := "2006-01-02"
  5950. loc, _ := time.LoadLocation("Local")
  5951. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5952. if err != nil {
  5953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5954. return
  5955. }
  5956. recordDateTime := theTime.Unix()
  5957. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  5958. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  5959. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  5960. dept, _ := service.GetDepartMentDetail(info.Departments)
  5961. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  5962. var cFYLJG003 models.CFYLJG003
  5963. cFYLJG003.RxTraceCode = flow.RxTraceCode
  5964. cFYLJG003.HiRxno = flow.HiRxno
  5965. cFYLJG003.MdtrtID = flow.MID
  5966. cFYLJG003.PatnName = his.Name
  5967. cFYLJG003.Certno = his.Certno
  5968. cFYLJG003.FixmedinsName = miConfig.OrgName
  5969. cFYLJG003.FixmedinsCode = miConfig.Code
  5970. cFYLJG003.DrCode = doctor_info.DoctorNumber
  5971. cFYLJG003.PrscDrName = doctor_info.UserName
  5972. cFYLJG003.PharDeptName = dept.Name
  5973. cFYLJG003.PharDeptCode = dept.Number
  5974. cFYLJG003.PharCode = "HY440309002107"
  5975. cFYLJG003.PharCertType = "01"
  5976. cFYLJG003.PharCertno = "430482199408260023"
  5977. cFYLJG003.PharName = "彭斯遥"
  5978. cFYLJG003.PsnCertType = "01"
  5979. cFYLJG003.RxFile = flow.RxFile
  5980. cFYLJG003.SignDigest = flow.SignDigest
  5981. cFYLJG003.FixmedinsCode = miConfig.Code
  5982. cFYLJG003.PsnCertType = "01"
  5983. cFYLJG003.PharProfttlCodg = dept.Name
  5984. //inputData["pharProfttlCodg"] =dept.Name
  5985. tempTime2 := time.Unix(info.Ctime, 0)
  5986. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  5987. cFYLJG003.PharChkTime = timeFormatTwo
  5988. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  5989. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  5990. var res ResultCFYLJG003
  5991. var respJSON2 map[string]interface{}
  5992. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5995. return
  5996. }
  5997. userJSONBytes2, _ := json.Marshal(respJSON2)
  5998. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  5999. utils.ErrorLog("解析失败:%v", err)
  6000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6001. return
  6002. }
  6003. if res.Infcode == -1 {
  6004. c.ServeSuccessJSON(map[string]interface{}{
  6005. "failed_code": -10,
  6006. "msg": res.ErrMsg,
  6007. })
  6008. return
  6009. } else {
  6010. c.ServeSuccessJSON(map[string]interface{}{
  6011. "info": res.Output,
  6012. })
  6013. }
  6014. }
  6015. func (c *HisApiController) GetCFYLJG004() {
  6016. admin_user_id, _ := c.GetInt64("admin_user_id")
  6017. his_patient_id, _ := c.GetInt64("his_patient_id")
  6018. record_time := c.GetString("record_time")
  6019. admin_user_id = 3626
  6020. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6021. //id, _ := c.GetInt64("id")
  6022. admin_user_id = 3626
  6023. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6024. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6025. flow, _ := service.Getflowtwo(his.Number)
  6026. //id = 3
  6027. patient_id, _ := c.GetInt64("patient_id")
  6028. //patient_id = 23834
  6029. //record_time = "2023-09-18"
  6030. timeLayout := "2006-01-02"
  6031. loc, _ := time.LoadLocation("Local")
  6032. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6033. if err != nil {
  6034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6035. return
  6036. }
  6037. recordDateTime := theTime.Unix()
  6038. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  6039. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  6040. var cFYLJG004 models.CFYLJG004
  6041. cFYLJG004.HiRxno = flow.HiRxno
  6042. cFYLJG004.FixmedinsCode = miConfig.Code
  6043. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  6044. cFYLJG004.UndoDrCertType = "01"
  6045. cFYLJG004.UndoRea = "撤销处方"
  6046. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  6047. cFYLJG004.UndoDrName = doctor_info.UserName
  6048. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  6049. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  6050. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  6051. var res ResultCFYLJG004
  6052. var respJSON2 map[string]interface{}
  6053. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6056. return
  6057. }
  6058. userJSONBytes2, _ := json.Marshal(respJSON2)
  6059. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  6060. utils.ErrorLog("解析失败:%v", err)
  6061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6062. return
  6063. }
  6064. if res.Infcode == -1 {
  6065. c.ServeSuccessJSON(map[string]interface{}{
  6066. "failed_code": -10,
  6067. "msg": res.ErrMsg,
  6068. })
  6069. return
  6070. } else {
  6071. flow.Status = 0
  6072. service.Saveflow(flow)
  6073. c.ServeSuccessJSON(map[string]interface{}{
  6074. "msg": "撤销成功",
  6075. })
  6076. return
  6077. }
  6078. }
  6079. func (c *HisApiController) GetCFYLJG005() {
  6080. admin_user_id, _ := c.GetInt64("admin_user_id")
  6081. his_patient_id, _ := c.GetInt64("his_patient_id")
  6082. //record_time := c.GetString("record_time")
  6083. admin_user_id = 3626
  6084. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6085. //id, _ := c.GetInt64("id")
  6086. admin_user_id = 3626
  6087. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6088. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6089. flow, _ := service.Getflowtwo(his.Number)
  6090. //id = 3
  6091. var cFYLJG005 models.CFYLJG005
  6092. //patient_id, _ := c.GetInt64("patient_id")
  6093. cFYLJG005.HiRxno = flow.HiRxno
  6094. cFYLJG005.MdtrtID = flow.MID
  6095. cFYLJG005.EcToken = ""
  6096. cFYLJG005.PsnName = his.Name
  6097. cFYLJG005.PsnCertType = "01"
  6098. cFYLJG005.Certno = his.IdCardNo
  6099. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  6100. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  6101. var res ResultCFYLJG005
  6102. var respJSON2 map[string]interface{}
  6103. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6104. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6106. return
  6107. }
  6108. userJSONBytes2, _ := json.Marshal(respJSON2)
  6109. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  6110. utils.ErrorLog("解析失败:%v", err)
  6111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6112. return
  6113. }
  6114. if res.Infcode == -1 {
  6115. c.ServeSuccessJSON(map[string]interface{}{
  6116. "failed_code": -10,
  6117. "msg": res.ErrMsg,
  6118. })
  6119. return
  6120. } else {
  6121. c.ServeSuccessJSON(map[string]interface{}{
  6122. "info": res.Output,
  6123. })
  6124. return
  6125. }
  6126. }
  6127. func (c *HisApiController) GetCFYLJG006() {
  6128. admin_user_id, _ := c.GetInt64("admin_user_id")
  6129. his_patient_id, _ := c.GetInt64("his_patient_id")
  6130. admin_user_id = 3626
  6131. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6132. //id, _ := c.GetInt64("id")
  6133. admin_user_id = 3626
  6134. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6135. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6136. flow, _ := service.Getflowtwo(his.Number)
  6137. //id = 3
  6138. patient_id, _ := c.GetInt64("patient_id")
  6139. var cFYLJG006 models.CFYLJG006
  6140. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  6141. cFYLJG006.HiRxno = flow.HiRxno
  6142. cFYLJG006.MdtrtID = flow.MID
  6143. cFYLJG006.PsnName = patient.Name
  6144. cFYLJG006.PsnCertType = "01"
  6145. cFYLJG006.Certno = patient.IdCardNo
  6146. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  6147. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  6148. var res ResultCFYLJG006
  6149. var respJSON2 map[string]interface{}
  6150. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6151. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6153. return
  6154. }
  6155. userJSONBytes2, _ := json.Marshal(respJSON2)
  6156. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  6157. utils.ErrorLog("解析失败:%v", err)
  6158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6159. return
  6160. }
  6161. if res.Infcode == -1 {
  6162. c.ServeSuccessJSON(map[string]interface{}{
  6163. "failed_code": -10,
  6164. "msg": res.ErrMsg,
  6165. })
  6166. return
  6167. } else {
  6168. c.ServeSuccessJSON(map[string]interface{}{
  6169. "info": res.Output,
  6170. })
  6171. return
  6172. }
  6173. }
  6174. func (c *HisApiController) GetCFYLJG007() {
  6175. admin_user_id, _ := c.GetInt64("admin_user_id")
  6176. his_patient_id, _ := c.GetInt64("his_patient_id")
  6177. admin_user_id = 3626
  6178. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6179. //id, _ := c.GetInt64("id")
  6180. admin_user_id = 3626
  6181. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6182. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6183. flow, _ := service.Getflowtwo(his.Number)
  6184. //id = 3
  6185. patient_id, _ := c.GetInt64("patient_id")
  6186. var cFYLJG007 models.CFYLJG007
  6187. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  6188. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  6189. cFYLJG007.HiRxno = flow.HiRxno
  6190. cFYLJG007.MdtrtID = flow.MID
  6191. cFYLJG007.PsnNo = his.PsnNo
  6192. cFYLJG007.PsnCertType = "01"
  6193. cFYLJG007.Certno = patient.IdCardNo
  6194. cFYLJG007.PsnName = patient.Name
  6195. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  6196. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  6197. var res ResultCFYLJG007
  6198. var respJSON2 map[string]interface{}
  6199. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6202. return
  6203. }
  6204. userJSONBytes2, _ := json.Marshal(respJSON2)
  6205. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  6206. utils.ErrorLog("解析失败:%v", err)
  6207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6208. return
  6209. }
  6210. if res.Infcode == -1 {
  6211. c.ServeSuccessJSON(map[string]interface{}{
  6212. "failed_code": -10,
  6213. "msg": res.ErrMsg,
  6214. })
  6215. return
  6216. } else {
  6217. c.ServeSuccessJSON(map[string]interface{}{
  6218. "info": res,
  6219. })
  6220. return
  6221. }
  6222. }
  6223. func (c *HisApiController) GetCFYLJG008() {
  6224. admin_user_id, _ := c.GetInt64("admin_user_id")
  6225. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6226. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6227. var cFYLJG008 models.CFYLJG008
  6228. //id, _ := c.GetInt64("id")
  6229. patient_id, _ := c.GetInt64("patient_id")
  6230. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  6231. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  6232. //id = 3
  6233. //flow, _ := service.Getflow(id)
  6234. //his, _ := service.GetHisPatientByNumber(flow.MID)
  6235. //
  6236. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6237. //patient_id, _ := c.GetInt64("patient_id")
  6238. //his_patient_id, _ := c.GetInt64("his_patient_id")
  6239. record_time := c.GetString("record_time")
  6240. admin_user_id = 3626
  6241. patient_id = 19424
  6242. //his_patient_id = 263947
  6243. record_time = "2023-08-29"
  6244. timeLayout := "2006-01-02"
  6245. loc, _ := time.LoadLocation("Local")
  6246. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6247. if err != nil {
  6248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6249. return
  6250. }
  6251. recordDateTime := theTime.Unix()
  6252. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  6253. cFYLJG008.FixmedinsName = ""
  6254. cFYLJG008.Lat = ""
  6255. cFYLJG008.Lng = ""
  6256. cFYLJG008.OrderType = "1"
  6257. cFYLJG008.PoolareaNo = ""
  6258. cFYLJG008.Lng = ""
  6259. cFYLJG008.PageNum = 1
  6260. cFYLJG008.PageSize = 10
  6261. var MPI models.MedinsProdInvChgDDTO
  6262. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  6263. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  6264. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  6265. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  6266. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  6267. var res ResultCFYLJG008
  6268. var respJSON2 map[string]interface{}
  6269. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6270. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6272. return
  6273. }
  6274. userJSONBytes2, _ := json.Marshal(respJSON2)
  6275. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  6276. utils.ErrorLog("解析失败:%v", err)
  6277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6278. return
  6279. }
  6280. if res.Infcode == -1 {
  6281. c.ServeSuccessJSON(map[string]interface{}{
  6282. "failed_code": -10,
  6283. "msg": res.ErrMsg,
  6284. })
  6285. return
  6286. } else {
  6287. c.ServeSuccessJSON(map[string]interface{}{
  6288. "info": res.Output,
  6289. })
  6290. return
  6291. }
  6292. }
  6293. func (c *HisApiController) GetBL4201A() {
  6294. order_id, _ := c.GetInt64("order_id")
  6295. admin_user_id, _ := c.GetInt64("admin_user_id")
  6296. order, _ := service.GetHisOrderByIDTwo(order_id)
  6297. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  6298. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  6299. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  6300. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6301. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6302. department, _ := service.GetDepartMentDetail(his.Departments)
  6303. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  6304. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  6305. if order.ID == 0 {
  6306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  6307. return
  6308. }
  6309. var struct4201A models.Struct4201A
  6310. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  6311. for _, items := range order_info {
  6312. memo := make(map[string]interface{})
  6313. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  6314. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  6315. fsiOPFLD.MedType = "14"
  6316. fsiOPFLD.BkkpSn = items.FeedetlSn
  6317. fsiOPFLD.FixmedinsCode = miConfig.Code
  6318. fsiOPFLD.FixmedinsName = miConfig.OrgName
  6319. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  6320. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  6321. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  6322. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6323. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  6324. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  6325. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  6326. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  6327. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  6328. fsiOPFLD.BilgDeptName = department.Name
  6329. fsiOPFLD.BilgDeptCodg = department.Number
  6330. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  6331. fsiOPFLD.BilgDrName = doctor.UserName
  6332. fsiOPFLD.MedChrgitmType = "09"
  6333. memo["hosp_appr_flag"] = "1"
  6334. memo["invoice_no"] = order.MdtrtId
  6335. memo["memo"] = "自费"
  6336. bytesData, _ := json.Marshal(memo)
  6337. fsiOPFLD.Memo = string(bytesData)
  6338. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  6339. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  6340. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  6341. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  6342. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  6343. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  6344. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  6345. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  6346. fsiOPFLD.BilgDeptName = department.Name
  6347. fsiOPFLD.BilgDeptCodg = department.Number
  6348. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  6349. fsiOPFLD.BilgDrName = doctor.UserName
  6350. switch items.HisPrescriptionProject.HisProject.CostClassify {
  6351. case 0:
  6352. break
  6353. case 1:
  6354. fsiOPFLD.MedChrgitmType = "14"
  6355. break
  6356. case 2:
  6357. fsiOPFLD.MedChrgitmType = "05"
  6358. break
  6359. case 3:
  6360. fsiOPFLD.MedChrgitmType = "03"
  6361. break
  6362. case 4:
  6363. fsiOPFLD.MedChrgitmType = "03"
  6364. break
  6365. case 5:
  6366. fsiOPFLD.MedChrgitmType = "08"
  6367. break
  6368. case 6:
  6369. fsiOPFLD.MedChrgitmType = "14"
  6370. break
  6371. case 7:
  6372. fsiOPFLD.MedChrgitmType = "14"
  6373. break
  6374. case 8:
  6375. fsiOPFLD.MedChrgitmType = "03"
  6376. break
  6377. case 9:
  6378. fsiOPFLD.MedChrgitmType = "14"
  6379. break
  6380. case 10:
  6381. fsiOPFLD.MedChrgitmType = "14"
  6382. break
  6383. case 11:
  6384. fsiOPFLD.MedChrgitmType = "06"
  6385. break
  6386. case 12:
  6387. fsiOPFLD.MedChrgitmType = "12"
  6388. break
  6389. case 13:
  6390. fsiOPFLD.MedChrgitmType = "01"
  6391. break
  6392. case 14:
  6393. fsiOPFLD.MedChrgitmType = "04"
  6394. break
  6395. case 15:
  6396. fsiOPFLD.MedChrgitmType = "14"
  6397. break
  6398. }
  6399. memo["hosp_appr_flag"] = "1"
  6400. memo["invoice_no"] = order.MdtrtId
  6401. memo["memo"] = "自费"
  6402. bytesData, _ := json.Marshal(memo)
  6403. fsiOPFLD.Memo = string(bytesData)
  6404. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  6405. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  6406. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  6407. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  6408. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  6409. fsiOPFLD.BilgDeptName = department.Name
  6410. fsiOPFLD.BilgDeptCodg = department.Number
  6411. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  6412. fsiOPFLD.BilgDrName = doctor.UserName
  6413. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  6414. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  6415. fsiOPFLD.MedChrgitmType = "08"
  6416. memo["hosp_appr_flag"] = "1"
  6417. memo["invoice_no"] = order.MdtrtId
  6418. memo["memo"] = "自费"
  6419. bytesData, _ := json.Marshal(memo)
  6420. fsiOPFLD.Memo = string(bytesData)
  6421. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  6422. }
  6423. }
  6424. }
  6425. for _, items := range order_info_two {
  6426. memo := make(map[string]interface{})
  6427. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  6428. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  6429. fsiOPFLD.MedType = "14"
  6430. fsiOPFLD.BkkpSn = items.FeedetlSn
  6431. fsiOPFLD.FixmedinsCode = miConfig.Code
  6432. fsiOPFLD.FixmedinsName = miConfig.OrgName
  6433. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  6434. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  6435. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  6436. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6437. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  6438. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  6439. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  6440. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  6441. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  6442. fsiOPFLD.BilgDeptName = department.Name
  6443. fsiOPFLD.BilgDeptCodg = department.Number
  6444. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  6445. fsiOPFLD.BilgDrName = doctor.UserName
  6446. fsiOPFLD.MedChrgitmType = "09"
  6447. memo["hosp_appr_flag"] = "1"
  6448. memo["invoice_no"] = order.MdtrtId
  6449. memo["memo"] = "自费"
  6450. bytesData, _ := json.Marshal(memo)
  6451. fsiOPFLD.Memo = string(bytesData)
  6452. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  6453. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  6454. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  6455. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  6456. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  6457. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  6458. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  6459. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  6460. fsiOPFLD.BilgDeptName = department.Name
  6461. fsiOPFLD.BilgDeptCodg = department.Number
  6462. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  6463. fsiOPFLD.BilgDrName = doctor.UserName
  6464. switch items.HisPrescriptionProject.HisProject.CostClassify {
  6465. case 0:
  6466. break
  6467. case 1:
  6468. fsiOPFLD.MedChrgitmType = "14"
  6469. break
  6470. case 2:
  6471. fsiOPFLD.MedChrgitmType = "05"
  6472. break
  6473. case 3:
  6474. fsiOPFLD.MedChrgitmType = "03"
  6475. break
  6476. case 4:
  6477. fsiOPFLD.MedChrgitmType = "03"
  6478. break
  6479. case 5:
  6480. fsiOPFLD.MedChrgitmType = "08"
  6481. break
  6482. case 6:
  6483. fsiOPFLD.MedChrgitmType = "14"
  6484. break
  6485. case 7:
  6486. fsiOPFLD.MedChrgitmType = "14"
  6487. break
  6488. case 8:
  6489. fsiOPFLD.MedChrgitmType = "03"
  6490. break
  6491. case 9:
  6492. fsiOPFLD.MedChrgitmType = "14"
  6493. break
  6494. case 10:
  6495. fsiOPFLD.MedChrgitmType = "14"
  6496. break
  6497. case 11:
  6498. fsiOPFLD.MedChrgitmType = "06"
  6499. break
  6500. case 12:
  6501. fsiOPFLD.MedChrgitmType = "12"
  6502. break
  6503. case 13:
  6504. fsiOPFLD.MedChrgitmType = "01"
  6505. break
  6506. case 14:
  6507. fsiOPFLD.MedChrgitmType = "04"
  6508. break
  6509. case 15:
  6510. fsiOPFLD.MedChrgitmType = "14"
  6511. break
  6512. }
  6513. memo["hosp_appr_flag"] = "1"
  6514. memo["invoice_no"] = order.MdtrtId
  6515. memo["memo"] = "自费"
  6516. bytesData, _ := json.Marshal(memo)
  6517. fsiOPFLD.Memo = string(bytesData)
  6518. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  6519. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  6520. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  6521. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  6522. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  6523. fsiOPFLD.BilgDeptName = department.Name
  6524. fsiOPFLD.BilgDeptCodg = department.Number
  6525. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  6526. fsiOPFLD.BilgDrName = doctor.UserName
  6527. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  6528. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  6529. fsiOPFLD.MedChrgitmType = "08"
  6530. memo["hosp_appr_flag"] = "1"
  6531. memo["invoice_no"] = order.MdtrtId
  6532. memo["memo"] = "自费"
  6533. bytesData, _ := json.Marshal(memo)
  6534. fsiOPFLD.Memo = string(bytesData)
  6535. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  6536. }
  6537. }
  6538. }
  6539. fmt.Println(fsiOPFLDs)
  6540. struct4201A.Fopfd = fsiOPFLDs
  6541. fmt.Println(struct4201A.Fopfd)
  6542. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  6543. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  6544. var res2 ResultSix
  6545. var respJSON2 map[string]interface{}
  6546. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6547. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6549. return
  6550. }
  6551. userJSONBytes2, _ := json.Marshal(respJSON2)
  6552. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6553. utils.ErrorLog("解析失败:%v", err)
  6554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6555. return
  6556. }
  6557. if res2.Infcode != 0 {
  6558. c.ServeSuccessJSON(map[string]interface{}{
  6559. "failed_code": -10,
  6560. "msg": res2.ErrMsg,
  6561. })
  6562. return
  6563. } else {
  6564. order.IsUploadOrderInfo = 1
  6565. service.UpdateOrder(order)
  6566. c.ServeSuccessJSON(map[string]interface{}{
  6567. "msg": "上传成功",
  6568. })
  6569. }
  6570. }
  6571. func (c *HisApiController) Get2505() {
  6572. admin_user_id, _ := c.GetInt64("admin_user_id")
  6573. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  6574. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6575. service.Gdyb2505("45000000000008100145868008", curRoles.UserName, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "2024-01-12 09:00:00", "2026-12-31 23:00:00", admin_user_id)
  6576. }
  6577. func (c *HisApiController) Get4201A() {
  6578. order_id, _ := c.GetInt64("order_id")
  6579. admin_user_id, _ := c.GetInt64("admin_user_id")
  6580. order, _ := service.GetHisOrderByIDTwo(order_id)
  6581. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  6582. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  6583. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  6584. //order_info = append(order_info, order_info_two...)
  6585. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6586. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6587. department, _ := service.GetDepartMentDetail(his.Departments)
  6588. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  6589. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  6590. if order.ID == 0 {
  6591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  6592. return
  6593. }
  6594. var struct4201A models.Struct4201A
  6595. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  6596. for _, items := range order_info {
  6597. memo := make(map[string]interface{})
  6598. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  6599. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  6600. fsiOPFLD.MedType = "14"
  6601. fsiOPFLD.BkkpSn = items.FeedetlSn
  6602. fsiOPFLD.FixmedinsCode = miConfig.Code
  6603. fsiOPFLD.FixmedinsName = miConfig.OrgName
  6604. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  6605. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  6606. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  6607. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6608. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  6609. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  6610. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  6611. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  6612. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  6613. fsiOPFLD.BilgDeptName = department.Name
  6614. fsiOPFLD.BilgDeptCodg = department.Number
  6615. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  6616. fsiOPFLD.BilgDrName = doctor.UserName
  6617. fsiOPFLD.MedChrgitmType = "09"
  6618. memo["hosp_appr_flag"] = "1"
  6619. memo["invoice_no"] = order.MdtrtId
  6620. memo["memo"] = "自费"
  6621. bytesData, _ := json.Marshal(memo)
  6622. fsiOPFLD.Memo = string(bytesData)
  6623. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  6624. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  6625. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  6626. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  6627. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  6628. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  6629. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  6630. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  6631. fsiOPFLD.BilgDeptName = department.Name
  6632. fsiOPFLD.BilgDeptCodg = department.Number
  6633. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  6634. fsiOPFLD.BilgDrName = doctor.UserName
  6635. switch items.HisPrescriptionProject.HisProject.CostClassify {
  6636. case 0:
  6637. break
  6638. case 1:
  6639. fsiOPFLD.MedChrgitmType = "14"
  6640. break
  6641. case 2:
  6642. fsiOPFLD.MedChrgitmType = "05"
  6643. break
  6644. case 3:
  6645. fsiOPFLD.MedChrgitmType = "03"
  6646. break
  6647. case 4:
  6648. fsiOPFLD.MedChrgitmType = "03"
  6649. break
  6650. case 5:
  6651. fsiOPFLD.MedChrgitmType = "08"
  6652. break
  6653. case 6:
  6654. fsiOPFLD.MedChrgitmType = "14"
  6655. break
  6656. case 7:
  6657. fsiOPFLD.MedChrgitmType = "14"
  6658. break
  6659. case 8:
  6660. fsiOPFLD.MedChrgitmType = "03"
  6661. break
  6662. case 9:
  6663. fsiOPFLD.MedChrgitmType = "14"
  6664. break
  6665. case 10:
  6666. fsiOPFLD.MedChrgitmType = "14"
  6667. break
  6668. case 11:
  6669. fsiOPFLD.MedChrgitmType = "06"
  6670. break
  6671. case 12:
  6672. fsiOPFLD.MedChrgitmType = "12"
  6673. break
  6674. case 13:
  6675. fsiOPFLD.MedChrgitmType = "01"
  6676. break
  6677. case 14:
  6678. fsiOPFLD.MedChrgitmType = "04"
  6679. break
  6680. case 15:
  6681. fsiOPFLD.MedChrgitmType = "14"
  6682. break
  6683. }
  6684. memo["hosp_appr_flag"] = "1"
  6685. memo["invoice_no"] = order.MdtrtId
  6686. memo["memo"] = "自费"
  6687. bytesData, _ := json.Marshal(memo)
  6688. fsiOPFLD.Memo = string(bytesData)
  6689. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  6690. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  6691. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  6692. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  6693. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  6694. fsiOPFLD.BilgDeptName = department.Name
  6695. fsiOPFLD.BilgDeptCodg = department.Number
  6696. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  6697. fsiOPFLD.BilgDrName = doctor.UserName
  6698. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  6699. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  6700. fsiOPFLD.MedChrgitmType = "08"
  6701. memo["hosp_appr_flag"] = "1"
  6702. memo["invoice_no"] = order.MdtrtId
  6703. memo["memo"] = "自费"
  6704. bytesData, _ := json.Marshal(memo)
  6705. fsiOPFLD.Memo = string(bytesData)
  6706. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  6707. }
  6708. }
  6709. }
  6710. for _, items := range order_info_two {
  6711. memo := make(map[string]interface{})
  6712. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  6713. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  6714. fsiOPFLD.MedType = "14"
  6715. fsiOPFLD.BkkpSn = items.FeedetlSn
  6716. fsiOPFLD.FixmedinsCode = miConfig.Code
  6717. fsiOPFLD.FixmedinsName = miConfig.OrgName
  6718. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  6719. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  6720. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  6721. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6722. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  6723. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  6724. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  6725. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  6726. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  6727. fsiOPFLD.BilgDeptName = department.Name
  6728. fsiOPFLD.BilgDeptCodg = department.Number
  6729. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  6730. fsiOPFLD.BilgDrName = doctor.UserName
  6731. fsiOPFLD.MedChrgitmType = "09"
  6732. memo["hosp_appr_flag"] = "1"
  6733. memo["invoice_no"] = order.MdtrtId
  6734. memo["memo"] = "自费"
  6735. bytesData, _ := json.Marshal(memo)
  6736. fsiOPFLD.Memo = string(bytesData)
  6737. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  6738. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  6739. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  6740. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  6741. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  6742. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  6743. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  6744. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  6745. fsiOPFLD.BilgDeptName = department.Name
  6746. fsiOPFLD.BilgDeptCodg = department.Number
  6747. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  6748. fsiOPFLD.BilgDrName = doctor.UserName
  6749. switch items.HisPrescriptionProject.HisProject.CostClassify {
  6750. case 0:
  6751. break
  6752. case 1:
  6753. fsiOPFLD.MedChrgitmType = "14"
  6754. break
  6755. case 2:
  6756. fsiOPFLD.MedChrgitmType = "05"
  6757. break
  6758. case 3:
  6759. fsiOPFLD.MedChrgitmType = "03"
  6760. break
  6761. case 4:
  6762. fsiOPFLD.MedChrgitmType = "03"
  6763. break
  6764. case 5:
  6765. fsiOPFLD.MedChrgitmType = "08"
  6766. break
  6767. case 6:
  6768. fsiOPFLD.MedChrgitmType = "14"
  6769. break
  6770. case 7:
  6771. fsiOPFLD.MedChrgitmType = "14"
  6772. break
  6773. case 8:
  6774. fsiOPFLD.MedChrgitmType = "03"
  6775. break
  6776. case 9:
  6777. fsiOPFLD.MedChrgitmType = "14"
  6778. break
  6779. case 10:
  6780. fsiOPFLD.MedChrgitmType = "14"
  6781. break
  6782. case 11:
  6783. fsiOPFLD.MedChrgitmType = "06"
  6784. break
  6785. case 12:
  6786. fsiOPFLD.MedChrgitmType = "12"
  6787. break
  6788. case 13:
  6789. fsiOPFLD.MedChrgitmType = "01"
  6790. break
  6791. case 14:
  6792. fsiOPFLD.MedChrgitmType = "04"
  6793. break
  6794. case 15:
  6795. fsiOPFLD.MedChrgitmType = "14"
  6796. break
  6797. }
  6798. memo["hosp_appr_flag"] = "1"
  6799. memo["invoice_no"] = order.MdtrtId
  6800. memo["memo"] = "自费"
  6801. bytesData, _ := json.Marshal(memo)
  6802. fsiOPFLD.Memo = string(bytesData)
  6803. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  6804. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  6805. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  6806. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  6807. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  6808. fsiOPFLD.BilgDeptName = department.Name
  6809. fsiOPFLD.BilgDeptCodg = department.Number
  6810. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  6811. fsiOPFLD.BilgDrName = doctor.UserName
  6812. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  6813. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  6814. fsiOPFLD.MedChrgitmType = "08"
  6815. memo["hosp_appr_flag"] = "1"
  6816. memo["invoice_no"] = order.MdtrtId
  6817. memo["memo"] = "自费"
  6818. bytesData, _ := json.Marshal(memo)
  6819. fsiOPFLD.Memo = string(bytesData)
  6820. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  6821. }
  6822. }
  6823. }
  6824. fmt.Println(fsiOPFLDs)
  6825. struct4201A.Fopfd = fsiOPFLDs
  6826. fmt.Println(struct4201A.Fopfd)
  6827. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  6828. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  6829. var res2 ResultSix
  6830. var respJSON2 map[string]interface{}
  6831. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6832. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6834. return
  6835. }
  6836. userJSONBytes2, _ := json.Marshal(respJSON2)
  6837. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6838. utils.ErrorLog("解析失败:%v", err)
  6839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6840. return
  6841. }
  6842. if res2.Infcode != 0 {
  6843. c.ServeSuccessJSON(map[string]interface{}{
  6844. "failed_code": -10,
  6845. "msg": res2.ErrMsg,
  6846. })
  6847. return
  6848. } else {
  6849. order.IsUploadOrderInfo = 1
  6850. service.UpdateOrder(order)
  6851. c.ServeSuccessJSON(map[string]interface{}{
  6852. "msg": "上传成功",
  6853. })
  6854. }
  6855. }
  6856. func (c *HisApiController) Get4202() {
  6857. order_id, _ := c.GetInt64("order_id")
  6858. admin_user_id, _ := c.GetInt64("admin_user_id")
  6859. order, _ := service.GetHisOrderByIDTwo(order_id)
  6860. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  6861. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6862. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6863. if order.ID == 0 {
  6864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  6865. return
  6866. }
  6867. var struct4202 models.Struct4202
  6868. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  6869. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  6870. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  6871. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  6872. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  6873. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  6874. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  6875. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  6876. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  6877. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  6878. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6879. var config []*models.HisXtDiagnoseConfig
  6880. for _, item := range diagnosis_ids {
  6881. id, _ := strconv.ParseInt(item, 10, 64)
  6882. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6883. config = append(config, &diagnosisConfig)
  6884. }
  6885. var tempDiaginfos []models.OwnPayPatnDiagListD
  6886. for index, item := range config {
  6887. if index == 0 {
  6888. var tempDiaginfo models.OwnPayPatnDiagListD
  6889. tempDiaginfo.InoutDiagType = "1"
  6890. tempDiaginfo.DiagCode = item.CountryCode
  6891. tempDiaginfo.DiagName = item.CountryContentName
  6892. tempDiaginfo.DiagType = "1"
  6893. tempDiaginfo.DiagSrtNo = "1"
  6894. tempDiaginfo.MaindiagFlag = "1"
  6895. tempDiaginfo.ValiFlag = "1"
  6896. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  6897. } else {
  6898. var tempDiaginfo models.OwnPayPatnDiagListD
  6899. tempDiaginfo.DiagCode = item.CountryCode
  6900. tempDiaginfo.DiagName = item.CountryContentName
  6901. tempDiaginfo.DiagType = "2"
  6902. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  6903. tempDiaginfo.MaindiagFlag = "0"
  6904. tempDiaginfo.ValiFlag = "1"
  6905. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  6906. }
  6907. }
  6908. struct4202.ODiagListD = tempDiaginfos
  6909. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  6910. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  6911. var res2 ResultSix
  6912. var respJSON2 map[string]interface{}
  6913. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6914. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6916. return
  6917. }
  6918. userJSONBytes2, _ := json.Marshal(respJSON2)
  6919. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6920. utils.ErrorLog("解析失败:%v", err)
  6921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6922. return
  6923. }
  6924. if res2.Infcode != 0 {
  6925. c.ServeSuccessJSON(map[string]interface{}{
  6926. "failed_code": -10,
  6927. "msg": res2.ErrMsg,
  6928. })
  6929. return
  6930. } else {
  6931. order.IsUploadDiagnose = 1
  6932. service.UpdateOrder(order)
  6933. c.ServeSuccessJSON(map[string]interface{}{
  6934. "msg": "上传成功",
  6935. })
  6936. }
  6937. }
  6938. func (c *HisApiController) Get4203() {
  6939. admin_user_id, _ := c.GetInt64("admin_user_id")
  6940. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6941. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6942. order_id, _ := c.GetInt64("order_id")
  6943. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  6944. number := ""
  6945. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6946. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  6947. if his.ID == 0 {
  6948. number = hospital.Number
  6949. } else {
  6950. number = his.Number
  6951. }
  6952. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  6953. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  6954. var res2 ResultSix
  6955. var respJSON2 map[string]interface{}
  6956. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6957. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6959. return
  6960. }
  6961. userJSONBytes2, _ := json.Marshal(respJSON2)
  6962. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6963. utils.ErrorLog("解析失败:%v", err)
  6964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6965. return
  6966. }
  6967. if res2.Infcode != 0 {
  6968. c.ServeSuccessJSON(map[string]interface{}{
  6969. "failed_code": -10,
  6970. "msg": res2.ErrMsg,
  6971. })
  6972. return
  6973. } else {
  6974. order.IsUploadSuccess = 1
  6975. service.UpdateOrderTwo(order)
  6976. c.ServeSuccessJSON(map[string]interface{}{
  6977. "msg": "上传成功",
  6978. })
  6979. }
  6980. }
  6981. func (c *HisApiController) Get4205() {
  6982. order_id, _ := c.GetInt64("order_id")
  6983. admin_user_id, _ := c.GetInt64("admin_user_id")
  6984. fapiao_code := c.GetString("fapiao_code")
  6985. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  6986. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6987. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6988. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6989. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  6990. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  6991. //order_info = append(order_info, order_info_two...)
  6992. department, _ := service.GetDepartMentDetail(his.Departments)
  6993. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  6994. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  6995. if order.ID == 0 {
  6996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  6997. return
  6998. }
  6999. var struct4201A models.Struct4201A
  7000. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  7001. for _, items := range order_info {
  7002. memo := make(map[string]interface{})
  7003. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  7004. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  7005. fsiOPFLD.MedType = pre.MedType
  7006. fsiOPFLD.FixmedinsCode = miConfig.Code
  7007. fsiOPFLD.FixmedinsName = miConfig.OrgName
  7008. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  7009. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  7010. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  7011. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7012. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  7013. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7014. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  7015. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7016. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7017. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7018. fsiOPFLD.BilgDeptName = department.Name
  7019. fsiOPFLD.BilgDeptCodg = department.Number
  7020. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7021. fsiOPFLD.BilgDrName = doctor.UserName
  7022. fsiOPFLD.MedChrgitmType = "09"
  7023. memo["hosp_appr_flag"] = "1"
  7024. memo["invoice_no"] = fapiao_code
  7025. memo["memo"] = "自费"
  7026. bytesData, _ := json.Marshal(memo)
  7027. fsiOPFLD.Memo = string(bytesData)
  7028. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7029. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  7030. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  7031. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  7032. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7033. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7034. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7035. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  7036. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  7037. fsiOPFLD.BilgDeptName = department.Name
  7038. fsiOPFLD.BilgDeptCodg = department.Number
  7039. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7040. fsiOPFLD.BilgDrName = doctor.UserName
  7041. switch items.HisPrescriptionProject.HisProject.CostClassify {
  7042. case 0:
  7043. break
  7044. case 1:
  7045. fsiOPFLD.MedChrgitmType = "14"
  7046. break
  7047. case 2:
  7048. fsiOPFLD.MedChrgitmType = "05"
  7049. break
  7050. case 3:
  7051. fsiOPFLD.MedChrgitmType = "03"
  7052. break
  7053. case 4:
  7054. fsiOPFLD.MedChrgitmType = "03"
  7055. break
  7056. case 5:
  7057. fsiOPFLD.MedChrgitmType = "08"
  7058. break
  7059. case 6:
  7060. fsiOPFLD.MedChrgitmType = "14"
  7061. break
  7062. case 7:
  7063. fsiOPFLD.MedChrgitmType = "14"
  7064. break
  7065. case 8:
  7066. fsiOPFLD.MedChrgitmType = "03"
  7067. break
  7068. case 9:
  7069. fsiOPFLD.MedChrgitmType = "14"
  7070. break
  7071. case 10:
  7072. fsiOPFLD.MedChrgitmType = "14"
  7073. break
  7074. case 11:
  7075. fsiOPFLD.MedChrgitmType = "06"
  7076. break
  7077. case 12:
  7078. fsiOPFLD.MedChrgitmType = "12"
  7079. break
  7080. case 13:
  7081. fsiOPFLD.MedChrgitmType = "01"
  7082. break
  7083. case 14:
  7084. fsiOPFLD.MedChrgitmType = "04"
  7085. break
  7086. case 15:
  7087. fsiOPFLD.MedChrgitmType = "14"
  7088. break
  7089. }
  7090. memo["hosp_appr_flag"] = "1"
  7091. memo["invoice_no"] = fapiao_code
  7092. memo["memo"] = "自费"
  7093. bytesData, _ := json.Marshal(memo)
  7094. fsiOPFLD.Memo = string(bytesData)
  7095. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7096. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  7097. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7098. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7099. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7100. fsiOPFLD.BilgDeptName = department.Name
  7101. fsiOPFLD.BilgDeptCodg = department.Number
  7102. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7103. fsiOPFLD.BilgDrName = doctor.UserName
  7104. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  7105. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  7106. fsiOPFLD.MedChrgitmType = "08"
  7107. memo["hosp_appr_flag"] = "1"
  7108. memo["invoice_no"] = fapiao_code
  7109. memo["memo"] = "自费"
  7110. bytesData, _ := json.Marshal(memo)
  7111. fsiOPFLD.Memo = string(bytesData)
  7112. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7113. }
  7114. }
  7115. }
  7116. for _, items := range order_info_two {
  7117. memo := make(map[string]interface{})
  7118. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  7119. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  7120. fsiOPFLD.MedType = pre.MedType
  7121. fsiOPFLD.BkkpSn = items.FeedetlSn
  7122. fsiOPFLD.FixmedinsCode = miConfig.Code
  7123. fsiOPFLD.FixmedinsName = miConfig.OrgName
  7124. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  7125. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  7126. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  7127. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7128. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  7129. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7130. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7131. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7132. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7133. fsiOPFLD.BilgDeptName = department.Name
  7134. fsiOPFLD.BilgDeptCodg = department.Number
  7135. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7136. fsiOPFLD.BilgDrName = doctor.UserName
  7137. fsiOPFLD.MedChrgitmType = "09"
  7138. memo["hosp_appr_flag"] = "1"
  7139. memo["invoice_no"] = fapiao_code
  7140. memo["memo"] = "自费"
  7141. bytesData, _ := json.Marshal(memo)
  7142. fsiOPFLD.Memo = string(bytesData)
  7143. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7144. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  7145. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  7146. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  7147. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7148. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7149. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  7150. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  7151. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7152. fsiOPFLD.BilgDeptName = department.Name
  7153. fsiOPFLD.BilgDeptCodg = department.Number
  7154. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7155. fsiOPFLD.BilgDrName = doctor.UserName
  7156. switch items.HisPrescriptionProject.HisProject.CostClassify {
  7157. case 0:
  7158. break
  7159. case 1:
  7160. fsiOPFLD.MedChrgitmType = "14"
  7161. break
  7162. case 2:
  7163. fsiOPFLD.MedChrgitmType = "05"
  7164. break
  7165. case 3:
  7166. fsiOPFLD.MedChrgitmType = "03"
  7167. break
  7168. case 4:
  7169. fsiOPFLD.MedChrgitmType = "03"
  7170. break
  7171. case 5:
  7172. fsiOPFLD.MedChrgitmType = "08"
  7173. break
  7174. case 6:
  7175. fsiOPFLD.MedChrgitmType = "14"
  7176. break
  7177. case 7:
  7178. fsiOPFLD.MedChrgitmType = "14"
  7179. break
  7180. case 8:
  7181. fsiOPFLD.MedChrgitmType = "03"
  7182. break
  7183. case 9:
  7184. fsiOPFLD.MedChrgitmType = "14"
  7185. break
  7186. case 10:
  7187. fsiOPFLD.MedChrgitmType = "14"
  7188. break
  7189. case 11:
  7190. fsiOPFLD.MedChrgitmType = "06"
  7191. break
  7192. case 12:
  7193. fsiOPFLD.MedChrgitmType = "12"
  7194. break
  7195. case 13:
  7196. fsiOPFLD.MedChrgitmType = "01"
  7197. break
  7198. case 14:
  7199. fsiOPFLD.MedChrgitmType = "04"
  7200. break
  7201. case 15:
  7202. fsiOPFLD.MedChrgitmType = "14"
  7203. break
  7204. }
  7205. memo["hosp_appr_flag"] = "1"
  7206. memo["invoice_no"] = fapiao_code
  7207. memo["memo"] = "自费"
  7208. bytesData, _ := json.Marshal(memo)
  7209. fsiOPFLD.Memo = string(bytesData)
  7210. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7211. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  7212. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7213. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7214. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7215. fsiOPFLD.BilgDeptName = department.Name
  7216. fsiOPFLD.BilgDeptCodg = department.Number
  7217. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7218. fsiOPFLD.BilgDrName = doctor.UserName
  7219. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  7220. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  7221. fsiOPFLD.MedChrgitmType = "08"
  7222. memo["hosp_appr_flag"] = "1"
  7223. memo["invoice_no"] = fapiao_code
  7224. memo["memo"] = "自费"
  7225. bytesData, _ := json.Marshal(memo)
  7226. fsiOPFLD.Memo = string(bytesData)
  7227. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7228. }
  7229. }
  7230. }
  7231. fmt.Println(fsiOPFLDs)
  7232. struct4201A.Fopfd = fsiOPFLDs
  7233. fmt.Println(struct4201A.Fopfd)
  7234. var struct4202 models.Struct4202
  7235. timeLayout := "2006-01-02 15:04:05"
  7236. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  7237. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  7238. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  7239. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  7240. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  7241. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  7242. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  7243. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  7244. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  7245. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  7246. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  7247. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7248. var config []*models.HisXtDiagnoseConfig
  7249. for _, item := range diagnosis_ids {
  7250. id, _ := strconv.ParseInt(item, 10, 64)
  7251. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7252. config = append(config, &diagnosisConfig)
  7253. }
  7254. var tempDiaginfos []models.OwnPayPatnDiagListD
  7255. for index, item := range config {
  7256. if index == 0 {
  7257. var tempDiaginfo models.OwnPayPatnDiagListD
  7258. tempDiaginfo.InoutDiagType = "1"
  7259. tempDiaginfo.DiagCode = item.CountryCode
  7260. tempDiaginfo.DiagName = item.CountryContentName
  7261. tempDiaginfo.DiagType = "1"
  7262. tempDiaginfo.DiagSrtNo = "1"
  7263. tempDiaginfo.MaindiagFlag = "1"
  7264. tempDiaginfo.ValiFlag = "1"
  7265. tempDiaginfo.DiagDrName = doctor.UserName
  7266. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  7267. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  7268. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  7269. } else {
  7270. var tempDiaginfo models.OwnPayPatnDiagListD
  7271. tempDiaginfo.DiagCode = item.CountryCode
  7272. tempDiaginfo.DiagName = item.CountryContentName
  7273. tempDiaginfo.DiagType = "2"
  7274. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7275. tempDiaginfo.MaindiagFlag = "0"
  7276. tempDiaginfo.ValiFlag = "1"
  7277. tempDiaginfo.DiagDrName = doctor.UserName
  7278. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  7279. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  7280. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  7281. }
  7282. }
  7283. struct4202.ODiagListD = tempDiaginfos
  7284. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  7285. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  7286. var res2 ResultSix
  7287. var respJSON2 map[string]interface{}
  7288. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7289. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7291. return
  7292. }
  7293. userJSONBytes2, _ := json.Marshal(respJSON2)
  7294. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7295. utils.ErrorLog("解析失败:%v", err)
  7296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7297. return
  7298. }
  7299. if res2.Infcode != 0 {
  7300. c.ServeSuccessJSON(map[string]interface{}{
  7301. "failed_code": -10,
  7302. "msg": res2.ErrMsg,
  7303. })
  7304. return
  7305. } else {
  7306. order.IsUploadDiagnose = 1
  7307. order.IsUploadOrderInfo = 1
  7308. service.UpdateOrderTwo(order)
  7309. c.ServeSuccessJSON(map[string]interface{}{
  7310. "msg": "上传成功",
  7311. })
  7312. }
  7313. }
  7314. func (c *HisApiController) Get4207() {
  7315. admin_user_id, _ := c.GetInt64("admin_user_id")
  7316. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7317. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7318. order_id, _ := c.GetInt64("order_id")
  7319. order, _ := service.GetHisOrderByIDTwo(order_id)
  7320. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7321. var struct4207 models.Struct4207
  7322. struct4207.PageNum = "1"
  7323. struct4207.PageSize = "1000"
  7324. struct4207.FixmedinsCode = miConfig.Code
  7325. struct4207.FixmedinsMdtrtID = order.Number
  7326. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  7327. saveLog(result, requestLog, "4207", "查询")
  7328. var res2 ResultSix
  7329. var respJSON2 map[string]interface{}
  7330. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7331. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7333. return
  7334. }
  7335. userJSONBytes2, _ := json.Marshal(respJSON2)
  7336. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7337. utils.ErrorLog("解析失败:%v", err)
  7338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7339. return
  7340. }
  7341. if res2.Infcode != 0 {
  7342. c.ServeSuccessJSON(map[string]interface{}{
  7343. "failed_code": -10,
  7344. "msg": res2.ErrMsg,
  7345. })
  7346. return
  7347. } else {
  7348. c.ServeSuccessJSON(map[string]interface{}{
  7349. "msg": "查询成功",
  7350. })
  7351. }
  7352. }
  7353. func (c *HisApiController) Get4208() {
  7354. admin_user_id, _ := c.GetInt64("admin_user_id")
  7355. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7356. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7357. order_id, _ := c.GetInt64("order_id")
  7358. order, _ := service.GetHisOrderByIDTwo(order_id)
  7359. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7360. var struct4208 models.Struct4208
  7361. struct4208.PageNum = "1"
  7362. struct4208.PageSize = "1000"
  7363. struct4208.PsnCertType = "01"
  7364. struct4208.Certno = his.Certno
  7365. struct4208.MedType = order.MedType
  7366. struct4208.PsnName = his.Name
  7367. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  7368. saveLog(result, requestLog, "4208", "查询")
  7369. var res2 ResultSix
  7370. var respJSON2 map[string]interface{}
  7371. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7372. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7374. return
  7375. }
  7376. userJSONBytes2, _ := json.Marshal(respJSON2)
  7377. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7378. utils.ErrorLog("解析失败:%v", err)
  7379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7380. return
  7381. }
  7382. if res2.Infcode != 0 {
  7383. c.ServeSuccessJSON(map[string]interface{}{
  7384. "failed_code": -10,
  7385. "msg": res2.ErrMsg,
  7386. })
  7387. return
  7388. } else {
  7389. c.ServeSuccessJSON(map[string]interface{}{
  7390. "msg": "查询成功",
  7391. })
  7392. }
  7393. }
  7394. func (c *HisApiController) Get4209() {
  7395. admin_user_id, _ := c.GetInt64("admin_user_id")
  7396. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7397. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7398. order_id, _ := c.GetInt64("order_id")
  7399. order, _ := service.GetHisOrderByIDTwo(order_id)
  7400. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7401. var struct4209 models.Struct4209
  7402. struct4209.FixmedinsMdtrtID = order.Number
  7403. struct4209.FixmedinsCode = miConfig.Code
  7404. struct4209.PageSize = "1000"
  7405. struct4209.PageNum = "1"
  7406. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  7407. saveLog(result, requestLog, "4209", "查询")
  7408. var res2 ResultSix
  7409. var respJSON2 map[string]interface{}
  7410. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7411. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7413. return
  7414. }
  7415. userJSONBytes2, _ := json.Marshal(respJSON2)
  7416. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7417. utils.ErrorLog("解析失败:%v", err)
  7418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7419. return
  7420. }
  7421. if res2.Infcode != 0 {
  7422. c.ServeSuccessJSON(map[string]interface{}{
  7423. "failed_code": -10,
  7424. "msg": res2.ErrMsg,
  7425. })
  7426. return
  7427. } else {
  7428. c.ServeSuccessJSON(map[string]interface{}{
  7429. "msg": "查询成功",
  7430. })
  7431. }
  7432. }
  7433. type Result3101 struct {
  7434. Infcode string `json:"infcode"`
  7435. InfRefmsgid string `json:"inf_refmsgid"`
  7436. RefmsgTime string `json:"refmsg_time"`
  7437. RespondTime string `json:"respond_time"`
  7438. Enctype string `json:"enctype"`
  7439. Signtype string `json:"signtype"`
  7440. ErrMsg string `json:"err_msg"`
  7441. Output struct {
  7442. Result []struct {
  7443. JudgeResultDetailDtos []struct {
  7444. VolaItemType string `json:"vola_item_type"`
  7445. MdtrtID string `json:"mdtrt_id"`
  7446. JrdID string `json:"jrd_id"`
  7447. PatnID string `json:"patn_id"`
  7448. RxID string `json:"rx_id"`
  7449. VolaAmt interface{} `json:"vola_amt"`
  7450. } `json:"judge_result_detail_dtos"`
  7451. RuleID string `json:"rule_id"`
  7452. VolaEvid string `json:"vola_evid"`
  7453. MdtrtID string `json:"mdtrt_id"`
  7454. RuleName string `json:"rule_name"`
  7455. VolaAmtStas string `json:"vola_amt_stas"`
  7456. JrID string `json:"jr_id"`
  7457. PatnID string `json:"patn_id"`
  7458. SevDeg string `json:"sev_deg"`
  7459. VolaAmt float64 `json:"vola_amt"`
  7460. VolaBhvrType string `json:"vola_bhvr_type"`
  7461. VolaCont string `json:"vola_cont"`
  7462. } `json:"result"`
  7463. } `json:"output"`
  7464. }
  7465. type Resultgd3101 struct {
  7466. Infcode int64 `json:"infcode"`
  7467. InfRefmsgid string `json:"inf_refmsgid"`
  7468. RefmsgTime string `json:"refmsg_time"`
  7469. RespondTime string `json:"respond_time"`
  7470. Enctype string `json:"enctype"`
  7471. Signtype string `json:"signtype"`
  7472. ErrMsg string `json:"err_msg"`
  7473. Output struct {
  7474. Result []struct {
  7475. JudgeResultDetailDtos []struct {
  7476. VolaItemType string `json:"vola_item_type"`
  7477. MdtrtID string `json:"mdtrt_id"`
  7478. JrdID string `json:"jrd_id"`
  7479. PatnID string `json:"patn_id"`
  7480. RxID string `json:"rx_id"`
  7481. VolaAmt interface{} `json:"vola_amt"`
  7482. } `json:"judge_result_detail_dtos"`
  7483. RuleID string `json:"rule_id"`
  7484. VolaEvid string `json:"vola_evid"`
  7485. MdtrtID string `json:"mdtrt_id"`
  7486. RuleName string `json:"rule_name"`
  7487. VolaAmtStas string `json:"vola_amt_stas"`
  7488. JrID string `json:"jr_id"`
  7489. PatnID string `json:"patn_id"`
  7490. SevDeg string `json:"sev_deg"`
  7491. VolaAmt float64 `json:"vola_amt"`
  7492. VolaBhvrType string `json:"vola_bhvr_type"`
  7493. VolaCont string `json:"vola_cont"`
  7494. } `json:"result"`
  7495. } `json:"output"`
  7496. }
  7497. func (c *HisApiController) ReadEleToken() {
  7498. admin_user_id, _ := c.GetInt64("admin_user_id")
  7499. his_patient_id, _ := c.GetInt64("his_patient_id")
  7500. adminUser := c.GetAdminUserInfo()
  7501. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7502. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7503. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7504. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7505. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  7506. if len(tokens) > 0 {
  7507. c.ServeSuccessJSON(map[string]interface{}{
  7508. "msg": "读取成功",
  7509. })
  7510. } else {
  7511. c.ServeSuccessJSON(map[string]interface{}{
  7512. "failed_code": -10,
  7513. "msg": "读取失败",
  7514. })
  7515. }
  7516. } else if miConfig.MdtrtareaAdmvs == "341203" {
  7517. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  7518. if len(tokens) > 0 {
  7519. c.ServeSuccessJSON(map[string]interface{}{
  7520. "msg": "读取成功",
  7521. })
  7522. } else {
  7523. c.ServeSuccessJSON(map[string]interface{}{
  7524. "failed_code": -10,
  7525. "msg": "读取失败",
  7526. })
  7527. }
  7528. } else if miConfig.MdtrtareaAdmvs == "150499" {
  7529. var api string
  7530. 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 +
  7531. "&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"
  7532. resp, requestErr := http.Get(api)
  7533. if requestErr != nil {
  7534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7535. }
  7536. body, ioErr := ioutil.ReadAll(resp.Body)
  7537. if ioErr != nil {
  7538. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7540. }
  7541. var respJSON map[string]interface{}
  7542. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7543. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7545. return
  7546. }
  7547. var status string
  7548. status = respJSON["data"].(map[string]interface{})["status"].(string)
  7549. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  7550. var token string
  7551. var res ResultTwo //1101结果
  7552. var res10265 ResultTwo10265 //1101结果
  7553. if status == "0" { //读卡成功
  7554. var card_info string //卡信息
  7555. var busi_card_info string
  7556. token = respJSON["data"].(map[string]interface{})["token"].(string)
  7557. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  7558. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  7559. fmt.Println(card_info)
  7560. fmt.Println(busi_card_info)
  7561. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  7562. result, _ := json.Marshal(respJSON)
  7563. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7564. utils.ErrorLog("解析失败:%v", err)
  7565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7566. return
  7567. }
  7568. res.ErrMsg = res10265.ErrMsg
  7569. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7570. res.Infcode = infocode
  7571. res.Output = res10265.Output
  7572. res.InfRefmsgid = res10265.InfRefmsgid
  7573. if res.Infcode == 0 {
  7574. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7575. if err == gorm.ErrRecordNotFound {
  7576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7577. return
  7578. } else if err != nil {
  7579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7580. return
  7581. } else {
  7582. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7583. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7584. infoStr := string(Iinfos)
  7585. idetinfoStr := string(Idetinfos)
  7586. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  7587. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  7588. psn := &models.HisPsn{
  7589. PsnNo: res.Output.Baseinfo.PsnNo,
  7590. PatientId: patient.ID,
  7591. Certno: res.Output.Baseinfo.Certno,
  7592. Gend: res.Output.Baseinfo.Gend,
  7593. Naty: res.Output.Baseinfo.Naty,
  7594. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7595. PsnName: res.Output.Baseinfo.PsnName,
  7596. Age: float64(age),
  7597. Brdy: b,
  7598. Idetinfo: idetinfoStr,
  7599. Insuinfo: infoStr,
  7600. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7601. CardInfo: card_info,
  7602. VerifyNumber: token,
  7603. IdCardType: 4,
  7604. }
  7605. var rf []*ResultFive
  7606. json.Unmarshal([]byte(infoStr), &rf)
  7607. var insutypes []*ResultFive
  7608. var insutype string
  7609. var is390 int = 0
  7610. var is310 int = 0
  7611. for _, item := range rf {
  7612. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7613. insutypes = append(insutypes, item)
  7614. }
  7615. }
  7616. if len(insutypes) == 1 {
  7617. insutype = insutypes[0].Insutype
  7618. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7619. } else {
  7620. for _, i := range insutypes {
  7621. if i.Insutype == "390" {
  7622. is390 = 1
  7623. }
  7624. if i.Insutype == "310" {
  7625. is310 = 1
  7626. }
  7627. }
  7628. }
  7629. if is390 == 1 {
  7630. insutype = "390"
  7631. }
  7632. if is310 == 1 {
  7633. insutype = "310"
  7634. }
  7635. if len(insutypes) == 0 {
  7636. insutype = "310"
  7637. }
  7638. service.CreateHisPsn(psn)
  7639. c.ServeSuccessJSON(map[string]interface{}{
  7640. "patient": patient,
  7641. "number": token,
  7642. "insutype": insutype,
  7643. })
  7644. }
  7645. } else {
  7646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7647. return
  7648. }
  7649. } else { //读卡失败
  7650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7651. return
  7652. }
  7653. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7654. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  7655. if len(errMsg) == 0 {
  7656. type ELeData struct {
  7657. Data struct {
  7658. IdNo string `json:"idNo"`
  7659. IdType string `json:"idType"`
  7660. UserName string `json:"userName"`
  7661. EcToken string `json:"ecToken"`
  7662. InsuOrg string `json:"insuOrg"`
  7663. Gender string `json:"gender"`
  7664. Birthday string `json:"birthday"`
  7665. Nationality string `json:"nationality"`
  7666. Email string `json:"email"`
  7667. Extra string `json:"extra"`
  7668. } `json:"data"`
  7669. Code int `json:"code"`
  7670. Message string `json:"message"`
  7671. }
  7672. var ele ELeData
  7673. err := json.Unmarshal([]byte(outPutInfo), &ele)
  7674. if err != nil {
  7675. utils.ErrorLog("解析失败:%v", err)
  7676. }
  7677. token := ele.Data.EcToken
  7678. if len(token) > 0 {
  7679. psn := &models.HisPsn{
  7680. PsnNo: his.PsnNo,
  7681. Age: 0,
  7682. PatientId: his.PatientId,
  7683. Certno: his.Certno,
  7684. Brdy: his.Brdy,
  7685. Gend: his.Gend,
  7686. Naty: his.Naty,
  7687. PsnCertType: his.PsnCertType,
  7688. PsnName: his.PsnName,
  7689. Idetinfo: his.Idetinfo,
  7690. Insuinfo: his.Iinfo,
  7691. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7692. CardInfo: outPutInfo,
  7693. VerifyNumber: token,
  7694. }
  7695. service.CreateHisPsn(psn)
  7696. }
  7697. if len(token) > 0 {
  7698. c.ServeSuccessJSON(map[string]interface{}{
  7699. "msg": "读取成功",
  7700. })
  7701. } else {
  7702. c.ServeSuccessJSON(map[string]interface{}{
  7703. "failed_code": -10,
  7704. "msg": "读取失败",
  7705. })
  7706. }
  7707. }
  7708. } else if miConfig.MdtrtareaAdmvs == "360302" {
  7709. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  7710. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  7711. type ELeData struct {
  7712. Data struct {
  7713. IdNo string `json:"idNo"`
  7714. IdType string `json:"idType"`
  7715. UserName string `json:"userName"`
  7716. EcToken string `json:"ecToken"`
  7717. InsuOrg string `json:"insuOrg"`
  7718. Gender string `json:"gender"`
  7719. Birthday string `json:"birthday"`
  7720. Nationality string `json:"nationality"`
  7721. Email string `json:"email"`
  7722. Extra string `json:"extra"`
  7723. } `json:"data"`
  7724. Code int `json:"code"`
  7725. Message string `json:"message"`
  7726. }
  7727. var ele ELeData
  7728. err := json.Unmarshal([]byte(result), &ele)
  7729. if err != nil {
  7730. utils.ErrorLog("解析失败:%v", err)
  7731. }
  7732. token := ele.Data.EcToken
  7733. token = Remove0000(token)
  7734. fmt.Println(ele.Data.UserName)
  7735. 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)
  7736. saveLog(result2, requestLog2, "1101", "获取人员信息")
  7737. var res ResultTwo
  7738. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  7739. utils.ErrorLog("解析失败:%v", err)
  7740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7741. return
  7742. }
  7743. if res.Infcode == 0 {
  7744. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7745. if err == gorm.ErrRecordNotFound {
  7746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7747. return
  7748. } else if err != nil {
  7749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7750. return
  7751. } else {
  7752. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7753. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7754. infoStr := string(Iinfos)
  7755. idetinfoStr := string(Idetinfos)
  7756. psn := &models.HisPsn{
  7757. PsnNo: res.Output.Baseinfo.PsnNo,
  7758. PatientId: patient.ID,
  7759. Certno: res.Output.Baseinfo.Certno,
  7760. Gend: res.Output.Baseinfo.Gend,
  7761. Naty: res.Output.Baseinfo.Naty,
  7762. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7763. PsnName: res.Output.Baseinfo.PsnName,
  7764. Idetinfo: idetinfoStr,
  7765. Insuinfo: infoStr,
  7766. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7767. CardInfo: "",
  7768. VerifyNumber: token,
  7769. }
  7770. service.CreateHisPsn(psn)
  7771. c.ServeSuccessJSON(map[string]interface{}{
  7772. "patient": patient,
  7773. "number": token,
  7774. })
  7775. }
  7776. } else {
  7777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7778. return
  7779. }
  7780. } else if miConfig.MdtrtareaAdmvs == "430800" {
  7781. //if initFlag == 0 {
  7782. //c.TestGetJiangXiBasBaseInit()
  7783. //}
  7784. //if initEleFlag == 0 {
  7785. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  7786. //}
  7787. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  7788. utils.ErrorLog("解析失败:%v", json_result)
  7789. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  7790. type ELeData struct {
  7791. Data struct {
  7792. IdNo string `json:"idNo"`
  7793. IdType string `json:"idType"`
  7794. UserName string `json:"userName"`
  7795. EcToken string `json:"ecToken"`
  7796. InsuOrg string `json:"insuOrg"`
  7797. Gender string `json:"gender"`
  7798. Birthday string `json:"birthday"`
  7799. Nationality string `json:"nationality"`
  7800. Email string `json:"email"`
  7801. Extra string `json:"extra"`
  7802. } `json:"data"`
  7803. Code int `json:"code"`
  7804. Message string `json:"message"`
  7805. }
  7806. var ele ELeData
  7807. err := json.Unmarshal([]byte(json_result), &ele)
  7808. if err != nil {
  7809. utils.ErrorLog("解析失败:%v", err)
  7810. }
  7811. token := ele.Data.EcToken
  7812. token = Remove0000(token)
  7813. //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)
  7814. 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)
  7815. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  7816. saveLog(result2, requestLog2, "1101", "获取人员信息")
  7817. var res ResultTwo
  7818. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  7819. utils.ErrorLog("解析失败:%v", err)
  7820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7821. return
  7822. }
  7823. if res.Infcode == 0 {
  7824. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7825. if err == gorm.ErrRecordNotFound {
  7826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7827. return
  7828. } else if err != nil {
  7829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7830. return
  7831. } else {
  7832. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7833. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7834. infoStr := string(Iinfos)
  7835. idetinfoStr := string(Idetinfos)
  7836. psn := &models.HisPsn{
  7837. PsnNo: res.Output.Baseinfo.PsnNo,
  7838. PatientId: patient.ID,
  7839. Certno: res.Output.Baseinfo.Certno,
  7840. Gend: res.Output.Baseinfo.Gend,
  7841. Naty: res.Output.Baseinfo.Naty,
  7842. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7843. PsnName: res.Output.Baseinfo.PsnName,
  7844. Idetinfo: idetinfoStr,
  7845. Insuinfo: infoStr,
  7846. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7847. CardInfo: "",
  7848. VerifyNumber: token,
  7849. InsuplcAdmdvs: ele.Data.InsuOrg,
  7850. }
  7851. service.CreateHisPsn(psn)
  7852. c.ServeSuccessJSON(map[string]interface{}{
  7853. "patient": patient,
  7854. "number": token,
  7855. })
  7856. }
  7857. } else {
  7858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7859. return
  7860. }
  7861. } else if miConfig.MdtrtareaAdmvs == "450721" {
  7862. res := c.GetoleInfo()
  7863. if res.Infcode == 0 {
  7864. var result string
  7865. if res.Output.MdtrtCertType == "01" {
  7866. 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)
  7867. } else if res.Output.MdtrtCertType == "02" {
  7868. 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)
  7869. } else if res.Output.MdtrtCertType == "03" {
  7870. 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)
  7871. }
  7872. var dat map[string]interface{}
  7873. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7874. fmt.Println(dat)
  7875. } else {
  7876. fmt.Println(err)
  7877. }
  7878. userJSONBytes, _ := json.Marshal(dat)
  7879. var res2 ResultTwo
  7880. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7881. utils.ErrorLog("解析失败:%v", err)
  7882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7883. return
  7884. }
  7885. if res2.Infcode == 0 {
  7886. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  7887. if err == gorm.ErrRecordNotFound {
  7888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7889. return
  7890. } else if err != nil {
  7891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7892. return
  7893. } else {
  7894. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  7895. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  7896. infoStr := string(Iinfos)
  7897. idetinfoStr := string(Idetinfos)
  7898. var rf []*ResultFive
  7899. json.Unmarshal([]byte(infoStr), &rf)
  7900. var insutypes []*ResultFive
  7901. var insutype string
  7902. var is390 int = 0
  7903. var is310 int = 0
  7904. //var insuplc_admdvs string
  7905. for _, item := range rf {
  7906. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7907. insutypes = append(insutypes, item)
  7908. }
  7909. }
  7910. if len(insutypes) == 1 {
  7911. insutype = insutypes[0].Insutype
  7912. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7913. } else {
  7914. for _, i := range insutypes {
  7915. if i.Insutype == "390" {
  7916. is390 = 1
  7917. }
  7918. if i.Insutype == "310" {
  7919. is310 = 1
  7920. }
  7921. }
  7922. }
  7923. if is390 == 1 {
  7924. insutype = "390"
  7925. }
  7926. if is310 == 1 {
  7927. insutype = "310"
  7928. }
  7929. if len(insutypes) == 0 {
  7930. insutype = "310"
  7931. }
  7932. psn := &models.HisPsn{
  7933. PsnNo: res2.Output.Baseinfo.PsnNo,
  7934. PatientId: patient.ID,
  7935. Certno: res2.Output.Baseinfo.Certno,
  7936. Gend: res2.Output.Baseinfo.Gend,
  7937. Naty: res2.Output.Baseinfo.Naty,
  7938. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  7939. PsnName: res2.Output.Baseinfo.PsnName,
  7940. Idetinfo: idetinfoStr,
  7941. Insuinfo: infoStr,
  7942. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7943. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  7944. VerifyNumber: res.Output.EcToken,
  7945. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  7946. }
  7947. service.CreateHisPsn(psn)
  7948. c.ServeSuccessJSON(map[string]interface{}{
  7949. "patient": patient,
  7950. "number": res.Output.CardNo,
  7951. "insutype": insutype,
  7952. })
  7953. }
  7954. } else {
  7955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7956. return
  7957. }
  7958. } else {
  7959. c.ServeSuccessJSON(map[string]interface{}{
  7960. "failed_code": -10,
  7961. "msg": res.ErrMsg,
  7962. })
  7963. }
  7964. } else {
  7965. //if initFlag == 0 {
  7966. // c.TestGetBasBaseInit()
  7967. //}
  7968. //token := c.GetEleBaseInfo()
  7969. //token = Remove0000(token)
  7970. type ELeData struct {
  7971. Code string `json:"code"`
  7972. Data struct {
  7973. Aac002 string `json:"aac002"`
  7974. Aaz500 string `json:"aaz500"`
  7975. ActCardNo string `json:"actCardNo"`
  7976. Bab520 string `json:"bab520"`
  7977. Bkz543 string `json:"bkz543"`
  7978. BusinessType string `json:"businessType"`
  7979. CertfCodg string `json:"certfCodg"`
  7980. EcIndexNo string `json:"ecIndexNo"`
  7981. EcToken string `json:"ecToken"`
  7982. ID0000 string `json:"id0000"`
  7983. IDNo string `json:"idNo"`
  7984. IDType string `json:"idType"`
  7985. Idcode string `json:"idcode"`
  7986. IdentityToken string `json:"identity_token"`
  7987. InsuOrg string `json:"insuOrg"`
  7988. OfficeID string `json:"officeId"`
  7989. OfficeName string `json:"officeName"`
  7990. OperatorID string `json:"operatorId"`
  7991. OperatorName string `json:"operatorName"`
  7992. OrgID string `json:"orgId"`
  7993. UserName string `json:"userName"`
  7994. } `json:"data"`
  7995. Infno interface{} `json:"infno"`
  7996. Message string `json:"message"`
  7997. OrgID string `json:"orgId"`
  7998. TransType string `json:"transType"`
  7999. }
  8000. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  8001. fmt.Println(result)
  8002. outPutInfo := Remove0000(result)
  8003. fmt.Println(outPutInfo)
  8004. var ele ELeData
  8005. err := json.Unmarshal([]byte(outPutInfo), &ele)
  8006. if err != nil {
  8007. utils.ErrorLog("解析失败:%v", err)
  8008. }
  8009. token := ele.Data.EcToken
  8010. var result2 string
  8011. var requestLog2 string
  8012. if len(token) > 0 {
  8013. if strings.Contains(ele.Data.IDNo, "HKG") {
  8014. 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)
  8015. } else {
  8016. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  8017. }
  8018. saveLog(result2, requestLog2, "1101", "获取人员信息")
  8019. var res ResultTwo
  8020. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8021. utils.ErrorLog("解析失败:%v", err)
  8022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8023. return
  8024. }
  8025. if res.Infcode == 0 {
  8026. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8027. if err == gorm.ErrRecordNotFound {
  8028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8029. return
  8030. } else if err != nil {
  8031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8032. return
  8033. } else {
  8034. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8035. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8036. infoStr := string(Iinfos)
  8037. idetinfoStr := string(Idetinfos)
  8038. psn := &models.HisPsn{
  8039. PsnNo: res.Output.Baseinfo.PsnNo,
  8040. PatientId: patient.ID,
  8041. Certno: res.Output.Baseinfo.Certno,
  8042. Gend: res.Output.Baseinfo.Gend,
  8043. Naty: res.Output.Baseinfo.Naty,
  8044. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8045. PsnName: res.Output.Baseinfo.PsnName,
  8046. Idetinfo: idetinfoStr,
  8047. Insuinfo: infoStr,
  8048. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8049. CardInfo: "",
  8050. VerifyNumber: token,
  8051. }
  8052. service.CreateHisPsn(psn)
  8053. c.ServeSuccessJSON(map[string]interface{}{
  8054. "msg": "读取成功",
  8055. })
  8056. }
  8057. } else {
  8058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8059. return
  8060. }
  8061. } else {
  8062. c.ServeSuccessJSON(map[string]interface{}{
  8063. "failed_code": -10,
  8064. "msg": "读取失败",
  8065. })
  8066. }
  8067. }
  8068. }
  8069. func (c *HisApiController) ReadEleFace() {
  8070. admin_user_id, _ := c.GetInt64("admin_user_id")
  8071. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8072. adminUser := c.GetAdminUserInfo()
  8073. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8074. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8075. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8076. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8077. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  8078. if len(tokens) > 0 {
  8079. c.ServeSuccessJSON(map[string]interface{}{
  8080. "msg": "读取成功",
  8081. })
  8082. } else {
  8083. c.ServeSuccessJSON(map[string]interface{}{
  8084. "failed_code": -10,
  8085. "msg": "读取失败",
  8086. })
  8087. }
  8088. }
  8089. }
  8090. func (c *HisApiController) Get9001() {
  8091. adminUser := c.GetAdminUserInfo()
  8092. admin_user_id, _ := c.GetInt64("admin_user_id")
  8093. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8094. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8095. if miConfig.MdtrtareaAdmvs == "350500" {
  8096. service.GetFjAuthorizationInfo(miConfig.Code)
  8097. } else if miConfig.MdtrtareaAdmvs == "131023" {
  8098. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  8099. var dat map[string]interface{}
  8100. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8101. fmt.Println(dat)
  8102. } else {
  8103. fmt.Println(err)
  8104. }
  8105. userJSONBytes, _ := json.Marshal(dat)
  8106. var res models.Result9001
  8107. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8108. utils.ErrorLog("解析失败:%v", err)
  8109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8110. return
  8111. }
  8112. } else if miConfig.MdtrtareaAdmvs == "341203" {
  8113. fmt.Println(miConfig.SecretKey)
  8114. var res models.Result9001Two
  8115. 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 +
  8116. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  8117. resp, requestErr := http.Get(api)
  8118. if requestErr != nil {
  8119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8120. return
  8121. }
  8122. body, ioErr := ioutil.ReadAll(resp.Body)
  8123. if ioErr != nil {
  8124. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8126. return
  8127. }
  8128. var respJSON map[string]interface{}
  8129. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8130. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8132. return
  8133. }
  8134. status := respJSON["data"].(map[string]interface{})["status"].(string)
  8135. if status == "0" {
  8136. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  8137. c.ServeSuccessJSON(map[string]interface{}{
  8138. "failed_code": -10,
  8139. "msg": err_msg,
  8140. })
  8141. return
  8142. }
  8143. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8144. result, _ := json.Marshal(respJSON)
  8145. fmt.Println("log")
  8146. fmt.Println(string(result))
  8147. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8148. utils.ErrorLog("解析失败:%v", err)
  8149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8150. return
  8151. }
  8152. if res.Infcode == 0 {
  8153. sign := models.HisSignIn{
  8154. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8155. SignNo: res.Output.Signinoutb.SignNo,
  8156. SignTime: "",
  8157. Ctime: time.Now().Unix(),
  8158. Mtime: time.Now().Unix(),
  8159. Status: 1,
  8160. InputLog: "",
  8161. OutputLog: "",
  8162. FixmedinsCode: miConfig.Code,
  8163. }
  8164. err := service.CreateSignIn(&sign)
  8165. if err == nil {
  8166. c.ServeSuccessJSON(map[string]interface{}{
  8167. "msg": "签到成功",
  8168. })
  8169. }
  8170. } else {
  8171. c.ServeSuccessJSON(map[string]interface{}{
  8172. "failed_code": -10,
  8173. "msg": res.ErrMsg,
  8174. })
  8175. return
  8176. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8177. //return
  8178. }
  8179. } else {
  8180. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  8181. var dat map[string]interface{}
  8182. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8183. fmt.Println(dat)
  8184. } else {
  8185. fmt.Println(err)
  8186. }
  8187. userJSONBytes, _ := json.Marshal(dat)
  8188. var res models.Result9001
  8189. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8190. utils.ErrorLog("解析失败:%v", err)
  8191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8192. return
  8193. }
  8194. if res.Infcode == 0 {
  8195. sign := models.HisSignIn{
  8196. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8197. SignNo: res.Output.Signinoutb.SignNo,
  8198. SignTime: res.Output.Signinoutb.SignTime,
  8199. Ctime: time.Now().Unix(),
  8200. Mtime: time.Now().Unix(),
  8201. Status: 1,
  8202. InputLog: "",
  8203. OutputLog: "",
  8204. FixmedinsCode: miConfig.Code,
  8205. }
  8206. err := service.CreateSignIn(&sign)
  8207. if err == nil {
  8208. c.ServeSuccessJSON(map[string]interface{}{
  8209. "msg": "签到成功",
  8210. })
  8211. }
  8212. }
  8213. }
  8214. }
  8215. 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) {
  8216. var res Result3101
  8217. adminUser := c.GetAdminUserInfo()
  8218. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8219. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8220. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8221. //record_time := c.GetString("record_time")
  8222. //trig_scen := c.GetString("trig_scen")
  8223. timeLayout := "2006-01-02"
  8224. loc, _ := time.LoadLocation("Local")
  8225. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8226. if err != nil {
  8227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8228. return res
  8229. }
  8230. recordDateTime := theTime.Unix()
  8231. var patientPrescription models.HisPrescriptionInfo
  8232. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8233. //if patientPrescription.ID == 0 {
  8234. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8235. //}
  8236. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8237. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8238. //
  8239. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  8240. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8241. var pp models.PublicParams
  8242. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  8243. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  8244. pp.FixmedinsName = miConfig.OrgName
  8245. pp.FixmedinsCode = miConfig.Code
  8246. pp.RequestUrl = miConfig.Url
  8247. pp.Cainfo = miConfig.Cainfo
  8248. pp.SecretKey = miConfig.SecretKey
  8249. pp.AccessKey = miConfig.AccessKey
  8250. pp.OpterName = roles.UserName
  8251. var config []*models.HisXtDiagnoseConfig
  8252. for _, item := range diagnosis_ids {
  8253. id, _ := strconv.ParseInt(item, 10, 64)
  8254. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8255. config = append(config, &diagnosisConfig)
  8256. }
  8257. var pd models.PatientDtos
  8258. pd.PatnID = his.PsnNo
  8259. pd.PatnName = his.Name
  8260. pd.Gend = his.Gend
  8261. pd.Brdy = his.Brdy
  8262. pd.Poolarea = miConfig.MdtrtareaAdmvs
  8263. pd.CurrMdtrtID = his.Number
  8264. var fed models.FsiEncounterDtos
  8265. fed.MdtrtID = his.Number
  8266. fed.MedinsID = miConfig.Code
  8267. fed.MedinsName = miConfig.OrgName
  8268. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  8269. fed.MedMdtrtType = "1"
  8270. fed.MedinsType = "1"
  8271. fed.MedinsLv = "11"
  8272. tm := time.Unix(his.RecordDate, 0)
  8273. s_tm := tm.Format("2006-01-02 15:04:05")
  8274. fed.AdmDate = s_tm
  8275. fed.DscgDate = s_tm
  8276. fed.DscgMainDiseCodg = config[0].CountryCode
  8277. fed.DscgMainDiseName = config[0].CountryContentName
  8278. //诊断信息
  8279. var fdds []*models.FsiDiagnoseDtos
  8280. for index, item := range config {
  8281. if index == 0 {
  8282. var fdd models.FsiDiagnoseDtos
  8283. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  8284. fdd.InoutDiseType = "1"
  8285. fdd.MaindiseFlag = "1"
  8286. fdd.DiseDate = s_tm
  8287. fdd.DiasSrtNo = "1"
  8288. fdd.DiseName = item.CountryContentName
  8289. fdd.DiseCodg = item.CountryCode
  8290. fdds = append(fdds, &fdd)
  8291. } else {
  8292. var fdd models.FsiDiagnoseDtos
  8293. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  8294. fdd.InoutDiseType = "1"
  8295. fdd.MaindiseFlag = "1"
  8296. fdd.DiseDate = s_tm
  8297. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  8298. fdd.DiseName = item.CountryContentName
  8299. fdd.DiseCodg = item.CountryCode
  8300. fdds = append(fdds, &fdd)
  8301. }
  8302. }
  8303. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  8304. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  8305. fed.AdmDeptName = de.Name
  8306. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  8307. fed.DscgDeptName = de.Name
  8308. fed.MedMdtrtType = "1"
  8309. fed.MedType = "11"
  8310. //if his.Insutype == "390" {
  8311. // fed.MedType = "1402"
  8312. //} else {
  8313. // fed.MedType = "9933"
  8314. //}
  8315. var orders []*models.FsiOrderDtos
  8316. if trig_scen == "2" {
  8317. //处方医嘱信息
  8318. for _, item := range prescriptions {
  8319. for _, subItem := range item.HisDoctorAdviceInfo {
  8320. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8321. var order models.FsiOrderDtos
  8322. order.RxID = strconv.FormatInt(item.ID, 10)
  8323. order.Rxno = strconv.FormatInt(item.ID, 10)
  8324. order.LongDrordFlag = "0"
  8325. order.HilistType = "1"
  8326. order.ChrgType = "1"
  8327. order.DrordBhvr = "-"
  8328. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  8329. order.HosplistName = subItem.BaseDrugLib.DrugName
  8330. order.HilistLv = "1"
  8331. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  8332. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  8333. order.HosplistName = subItem.BaseDrugLib.DrugName
  8334. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  8335. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  8336. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  8337. order.OwnpayAmt = ""
  8338. order.SelfpayAmt = ""
  8339. order.Spec = ""
  8340. order.SpecUnt = ""
  8341. order.DrordBegnDate = s_tm
  8342. order.DrordStopDate = ""
  8343. order.DrordDrCodg = doctor_info.DoctorNumber
  8344. order.DrordDeptName = department.Name
  8345. order.DrordDeptCodg = department.Number
  8346. order.DrordDrName = doctor_info.UserName
  8347. order.DrordDrProfttl = "234"
  8348. order.CurrDrordFlag = "1"
  8349. orders = append(orders, &order)
  8350. }
  8351. }
  8352. for _, subItem := range item.HisPrescriptionProject {
  8353. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  8354. var order models.FsiOrderDtos
  8355. order.RxID = strconv.FormatInt(item.ID, 10)
  8356. order.Rxno = strconv.FormatInt(item.ID, 10)
  8357. order.LongDrordFlag = "0"
  8358. order.HilistType = "1"
  8359. order.ChrgType = "1"
  8360. order.DrordBhvr = "-"
  8361. order.HilistCode = subItem.HisProject.MedicalCode
  8362. order.HosplistName = subItem.HisProject.ProjectName
  8363. order.HilistLv = "1"
  8364. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  8365. order.HosplistCode = subItem.HisProject.MedicalCode
  8366. order.HosplistName = subItem.HisProject.ProjectName
  8367. order.Cnt = subItem.Count
  8368. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  8369. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  8370. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  8371. order.OwnpayAmt = ""
  8372. order.SelfpayAmt = ""
  8373. order.Spec = ""
  8374. order.SpecUnt = ""
  8375. order.DrordBegnDate = s_tm
  8376. order.DrordStopDate = ""
  8377. order.DrordDrCodg = doctor_info.DoctorNumber
  8378. order.DrordDeptName = department.Name
  8379. order.DrordDeptCodg = department.Number
  8380. order.DrordDrName = doctor_info.UserName
  8381. order.DrordDrProfttl = "234"
  8382. order.CurrDrordFlag = "1"
  8383. orders = append(orders, &order)
  8384. }
  8385. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  8386. var order models.FsiOrderDtos
  8387. order.RxID = strconv.FormatInt(item.ID, 10)
  8388. order.Rxno = strconv.FormatInt(item.ID, 10)
  8389. order.LongDrordFlag = "0"
  8390. order.HilistType = "1"
  8391. order.ChrgType = "1"
  8392. order.DrordBhvr = "-"
  8393. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  8394. order.HosplistName = subItem.GoodInfo.GoodName
  8395. order.HilistLv = "1"
  8396. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  8397. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  8398. order.HosplistName = subItem.GoodInfo.GoodName
  8399. order.Cnt = subItem.Count
  8400. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  8401. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  8402. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  8403. order.OwnpayAmt = ""
  8404. order.SelfpayAmt = ""
  8405. order.Spec = ""
  8406. order.SpecUnt = ""
  8407. order.DrordBegnDate = s_tm
  8408. order.DrordStopDate = ""
  8409. order.DrordDrCodg = doctor_info.DoctorNumber
  8410. order.DrordDeptName = department.Name
  8411. order.DrordDeptCodg = department.Number
  8412. order.DrordDrName = doctor_info.UserName
  8413. order.DrordDrProfttl = "234"
  8414. order.CurrDrordFlag = "1"
  8415. orders = append(orders, &order)
  8416. }
  8417. }
  8418. }
  8419. //处方医嘱信息
  8420. }
  8421. fed.MatnStas = "0"
  8422. fed.MedfeeSumamt = "0"
  8423. fed.OwnpayAmt = "0"
  8424. fed.SelfpayAmt = "0"
  8425. fed.AcctPayamt = "0"
  8426. fed.MaAmt = "0"
  8427. fed.HifpPayamt = "0"
  8428. fed.SetlTotlnum = "1"
  8429. fed.Insutype = his.Insutype
  8430. fed.ReimFlag = "0"
  8431. fed.OutSetlFlag = "0"
  8432. var fopd []*models.FsiOperationDtosData
  8433. data := make(map[string]interface{})
  8434. data["fed"] = fed
  8435. data["fdd"] = fdds
  8436. data["fod"] = orders
  8437. data["pd"] = pd
  8438. data["pp"] = pp
  8439. data["fopd"] = fopd
  8440. data["trig_scen"] = trig_scen
  8441. fmt.Println(data)
  8442. fmt.Println(fed)
  8443. fmt.Println(fdds)
  8444. fmt.Println(orders)
  8445. fmt.Println(pd)
  8446. fmt.Println(pp)
  8447. fmt.Println(fopd)
  8448. client := &http.Client{}
  8449. bytesData, _ := json.Marshal(data)
  8450. var req *http.Request
  8451. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8452. if miConfig.MdtrtareaAdmvs == "320921" {
  8453. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  8454. } else {
  8455. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  8456. }
  8457. resp, _ := client.Do(req)
  8458. defer resp.Body.Close()
  8459. body, ioErr := ioutil.ReadAll(resp.Body)
  8460. if ioErr != nil {
  8461. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8463. return res
  8464. }
  8465. var respJSON map[string]interface{}
  8466. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8469. return res
  8470. }
  8471. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  8472. fmt.Println(respJSON)
  8473. result, _ := json.Marshal(respJSON)
  8474. fmt.Println(result)
  8475. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8476. utils.ErrorLog("解析失败:%v", err)
  8477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8478. return res
  8479. }
  8480. return res
  8481. } else {
  8482. //if miConfig.MdtrtareaAdmvs == "441202" {
  8483. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  8484. saveLog(output, input, "3101", "事前")
  8485. if err := json.Unmarshal([]byte(output), &res); err != nil {
  8486. utils.ErrorLog("解析失败:%v", err)
  8487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8488. return
  8489. }
  8490. return res
  8491. //}
  8492. }
  8493. }
  8494. 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) {
  8495. adminUser := c.GetAdminUserInfo()
  8496. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8497. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8498. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8499. //record_time := c.GetString("record_time")
  8500. //trig_scen := c.GetString("trig_scen")
  8501. timeLayout := "2006-01-02"
  8502. loc, _ := time.LoadLocation("Local")
  8503. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8504. if err != nil {
  8505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8506. return res
  8507. }
  8508. recordDateTime := theTime.Unix()
  8509. var patientPrescription models.HisPrescriptionInfo
  8510. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8511. if patientPrescription.ID == 0 {
  8512. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8513. }
  8514. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8515. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8516. //
  8517. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  8518. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8519. var pp models.PublicParams
  8520. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  8521. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  8522. pp.FixmedinsName = miConfig.OrgName
  8523. pp.FixmedinsCode = miConfig.Code
  8524. pp.RequestUrl = miConfig.Url
  8525. pp.Cainfo = miConfig.Cainfo
  8526. pp.SecretKey = miConfig.SecretKey
  8527. pp.AccessKey = miConfig.AccessKey
  8528. pp.OpterName = roles.UserName
  8529. var config []*models.HisXtDiagnoseConfig
  8530. for _, item := range diagnosis_ids {
  8531. id, _ := strconv.ParseInt(item, 10, 64)
  8532. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8533. config = append(config, &diagnosisConfig)
  8534. }
  8535. var pd models.PatientDtos
  8536. pd.PatnID = his.PsnNo
  8537. pd.PatnName = his.Name
  8538. pd.Gend = his.Gend
  8539. pd.Brdy = his.Brdy
  8540. pd.Poolarea = his.InsuplcAdmdvs
  8541. pd.CurrMdtrtID = his.Number
  8542. var fed models.FsiEncounterDtos
  8543. fed.MdtrtID = his.Number
  8544. fed.MedinsID = miConfig.Code
  8545. fed.MedinsName = miConfig.OrgName
  8546. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  8547. fed.MedMdtrtType = "1"
  8548. fed.MedinsType = "1"
  8549. fed.MedinsLv = "11"
  8550. tm := time.Unix(his.RecordDate, 0)
  8551. s_tm := tm.Format("2006-01-02 15:04:05")
  8552. fed.AdmDate = s_tm
  8553. fed.DscgDate = s_tm
  8554. fed.DscgMainDiseCodg = config[0].CountryCode
  8555. fed.DscgMainDiseName = config[0].CountryContentName
  8556. //诊断信息
  8557. var fdds []*models.FsiDiagnoseDtos
  8558. for index, item := range config {
  8559. if index == 0 {
  8560. var fdd models.FsiDiagnoseDtos
  8561. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  8562. fdd.InoutDiseType = "1"
  8563. fdd.MaindiseFlag = "1"
  8564. fdd.DiseDate = s_tm
  8565. fdd.DiasSrtNo = "1"
  8566. fdd.DiseName = item.CountryContentName
  8567. fdd.DiseCodg = item.CountryCode
  8568. fdds = append(fdds, &fdd)
  8569. } else {
  8570. var fdd models.FsiDiagnoseDtos
  8571. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  8572. fdd.InoutDiseType = "1"
  8573. fdd.MaindiseFlag = "1"
  8574. fdd.DiseDate = s_tm
  8575. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  8576. fdd.DiseName = item.CountryContentName
  8577. fdd.DiseCodg = item.CountryCode
  8578. fdds = append(fdds, &fdd)
  8579. }
  8580. }
  8581. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  8582. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  8583. fed.AdmDeptName = department.Name
  8584. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  8585. fed.DscgDeptName = department.Name
  8586. fed.MedMdtrtType = "1"
  8587. fed.MedType = "11"
  8588. //if his.Insutype == "390" {
  8589. // fed.MedType = "1402"
  8590. //} else {
  8591. // fed.MedType = "9933"
  8592. //}
  8593. var orders []*models.FsiOrderDtos
  8594. if trig_scen == "2" {
  8595. //处方医嘱信息
  8596. for _, item := range prescriptions {
  8597. for _, subItem := range item.HisDoctorAdviceInfo {
  8598. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8599. var order models.FsiOrderDtos
  8600. order.RxID = strconv.FormatInt(item.ID, 10)
  8601. order.Rxno = strconv.FormatInt(item.ID, 10)
  8602. order.LongDrordFlag = "0"
  8603. order.HilistType = "1"
  8604. order.ChrgType = "1"
  8605. order.DrordBhvr = "-"
  8606. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  8607. order.HosplistName = subItem.BaseDrugLib.DrugName
  8608. order.HilistLv = "1"
  8609. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  8610. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  8611. order.HosplistName = subItem.BaseDrugLib.DrugName
  8612. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  8613. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  8614. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  8615. order.OwnpayAmt = ""
  8616. order.SelfpayAmt = ""
  8617. order.Spec = ""
  8618. order.SpecUnt = ""
  8619. order.DrordBegnDate = s_tm
  8620. order.DrordStopDate = ""
  8621. order.DrordDrCodg = doctor_info.DoctorNumber
  8622. order.DrordDeptName = department.Name
  8623. order.DrordDeptCodg = department.Number
  8624. order.DrordDrName = doctor_info.UserName
  8625. order.DrordDrProfttl = "234"
  8626. order.CurrDrordFlag = "1"
  8627. orders = append(orders, &order)
  8628. }
  8629. }
  8630. for _, subItem := range item.HisPrescriptionProject {
  8631. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  8632. var order models.FsiOrderDtos
  8633. order.RxID = strconv.FormatInt(item.ID, 10)
  8634. order.Rxno = strconv.FormatInt(item.ID, 10)
  8635. order.LongDrordFlag = "0"
  8636. order.HilistType = "1"
  8637. order.ChrgType = "1"
  8638. order.DrordBhvr = "-"
  8639. order.HilistCode = subItem.HisProject.MedicalCode
  8640. order.HosplistName = subItem.HisProject.ProjectName
  8641. order.HilistLv = "1"
  8642. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  8643. order.HosplistCode = subItem.HisProject.MedicalCode
  8644. order.HosplistName = subItem.HisProject.ProjectName
  8645. order.Cnt = subItem.Count
  8646. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  8647. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  8648. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  8649. order.OwnpayAmt = ""
  8650. order.SelfpayAmt = ""
  8651. order.Spec = ""
  8652. order.SpecUnt = ""
  8653. order.DrordBegnDate = s_tm
  8654. order.DrordStopDate = ""
  8655. order.DrordDrCodg = doctor_info.DoctorNumber
  8656. order.DrordDeptName = department.Name
  8657. order.DrordDeptCodg = department.Number
  8658. order.DrordDrName = doctor_info.UserName
  8659. order.DrordDrProfttl = "234"
  8660. order.CurrDrordFlag = "1"
  8661. orders = append(orders, &order)
  8662. }
  8663. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  8664. var order models.FsiOrderDtos
  8665. order.RxID = strconv.FormatInt(item.ID, 10)
  8666. order.Rxno = strconv.FormatInt(item.ID, 10)
  8667. order.LongDrordFlag = "0"
  8668. order.HilistType = "1"
  8669. order.ChrgType = "1"
  8670. order.DrordBhvr = "-"
  8671. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  8672. order.HosplistName = subItem.GoodInfo.GoodName
  8673. order.HilistLv = "1"
  8674. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  8675. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  8676. order.HosplistName = subItem.GoodInfo.GoodName
  8677. order.Cnt = subItem.Count
  8678. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  8679. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  8680. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  8681. order.OwnpayAmt = ""
  8682. order.SelfpayAmt = ""
  8683. order.Spec = ""
  8684. order.SpecUnt = ""
  8685. order.DrordBegnDate = s_tm
  8686. order.DrordStopDate = ""
  8687. order.DrordDrCodg = doctor_info.DoctorNumber
  8688. order.DrordDeptName = department.Name
  8689. order.DrordDeptCodg = department.Number
  8690. order.DrordDrName = doctor_info.UserName
  8691. order.DrordDrProfttl = "234"
  8692. order.CurrDrordFlag = "1"
  8693. orders = append(orders, &order)
  8694. }
  8695. }
  8696. }
  8697. //处方医嘱信息
  8698. }
  8699. fed.MatnStas = "0"
  8700. fed.MedfeeSumamt = "0"
  8701. fed.OwnpayAmt = "0"
  8702. fed.SelfpayAmt = "0"
  8703. fed.AcctPayamt = "0"
  8704. fed.MaAmt = "0"
  8705. fed.HifpPayamt = "0"
  8706. fed.SetlTotlnum = "1"
  8707. fed.Insutype = his.Insutype
  8708. fed.ReimFlag = "0"
  8709. fed.OutSetlFlag = "0"
  8710. var fopd []*models.FsiOperationDtosData
  8711. data := make(map[string]interface{})
  8712. data["fed"] = fed
  8713. data["fdd"] = fdds
  8714. data["fod"] = orders
  8715. data["pd"] = pd
  8716. data["pp"] = pp
  8717. data["fopd"] = fopd
  8718. data["trig_scen"] = trig_scen
  8719. fmt.Println(data)
  8720. fmt.Println(fed)
  8721. fmt.Println(fdds)
  8722. fmt.Println(orders)
  8723. fmt.Println(pd)
  8724. fmt.Println(pp)
  8725. fmt.Println(fopd)
  8726. client := &http.Client{}
  8727. bytesData, _ := json.Marshal(data)
  8728. var req *http.Request
  8729. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8730. if miConfig.MdtrtareaAdmvs == "320921" {
  8731. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  8732. } else {
  8733. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  8734. }
  8735. resp, _ := client.Do(req)
  8736. defer resp.Body.Close()
  8737. body, ioErr := ioutil.ReadAll(resp.Body)
  8738. if ioErr != nil {
  8739. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8741. return res
  8742. }
  8743. var respJSON map[string]interface{}
  8744. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8747. return res
  8748. }
  8749. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  8750. fmt.Println(respJSON)
  8751. result, _ := json.Marshal(respJSON)
  8752. fmt.Println(result)
  8753. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8754. utils.ErrorLog("解析失败:%v", err)
  8755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8756. return res
  8757. }
  8758. return res
  8759. } else {
  8760. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  8761. saveLog(output, input, "3101", "事前")
  8762. if err := json.Unmarshal([]byte(output), &res); err != nil {
  8763. utils.ErrorLog("解析失败:%v", err)
  8764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8765. return
  8766. }
  8767. return res
  8768. }
  8769. return res
  8770. }
  8771. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  8772. ////patient_id, _ := c.GetInt64("patient_id")
  8773. //order_id, _ := c.GetInt64("order_id")
  8774. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  8775. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  8776. //trig_scen := c.GetString("trig_scen")
  8777. adminUser := c.GetAdminUserInfo()
  8778. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8779. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8780. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8781. record_time := c.GetString("record_time")
  8782. order, _ := service.GetHisOrderByID(order_id)
  8783. psn_info, _ := service.GetPsnByPatientId(patient_id)
  8784. timeLayout := "2006-01-02"
  8785. loc, _ := time.LoadLocation("Local")
  8786. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8787. if err != nil {
  8788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8789. return
  8790. }
  8791. recordDateTime := theTime.Unix()
  8792. var patientPrescription models.HisPrescriptionInfo
  8793. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8794. if patientPrescription.ID == 0 {
  8795. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8796. }
  8797. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8798. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8799. //
  8800. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8801. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8802. var pp models.PublicParams
  8803. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  8804. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  8805. pp.FixmedinsName = miConfig.OrgName
  8806. pp.FixmedinsCode = miConfig.Code
  8807. pp.RequestUrl = miConfig.Url
  8808. pp.Cainfo = miConfig.Cainfo
  8809. pp.SecretKey = miConfig.SecretKey
  8810. pp.AccessKey = miConfig.AccessKey
  8811. pp.OpterName = roles.UserName
  8812. var config []*models.HisXtDiagnoseConfig
  8813. for _, item := range diagnosis_ids {
  8814. id, _ := strconv.ParseInt(item, 10, 64)
  8815. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8816. config = append(config, &diagnosisConfig)
  8817. }
  8818. var pd models.PatientDtos
  8819. pd.PatnID = his.PsnNo
  8820. pd.PatnName = his.Name
  8821. pd.Gend = his.Gend
  8822. pd.Brdy = psn_info.Brdy
  8823. pd.Poolarea = his.InsuplcAdmdvs
  8824. pd.CurrMdtrtID = his.Number
  8825. var fed models.FsiEncounterDtos
  8826. fed.MdtrtID = his.Number
  8827. fed.MedinsID = miConfig.Code
  8828. fed.MedinsName = miConfig.OrgName
  8829. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  8830. fed.MedMdtrtType = "1"
  8831. fed.MedinsType = "1"
  8832. fed.MedinsLv = "11"
  8833. tm := time.Unix(his.RecordDate, 0)
  8834. s_tm := tm.Format("2006-01-02 15:04:05")
  8835. fed.AdmDate = s_tm
  8836. fed.DscgDate = s_tm
  8837. fed.DscgMainDiseCodg = config[0].CountryCode
  8838. fed.DscgMainDiseName = config[0].CountryContentName
  8839. //诊断信息
  8840. var fdds []*models.FsiDiagnoseDtos
  8841. for index, item := range config {
  8842. if index == 0 {
  8843. var fdd models.FsiDiagnoseDtos
  8844. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  8845. fdd.InoutDiseType = "1"
  8846. fdd.MaindiseFlag = "1"
  8847. fdd.DiseDate = s_tm
  8848. fdd.DiasSrtNo = "1"
  8849. fdd.DiseName = item.CountryContentName
  8850. fdd.DiseCodg = item.CountryCode
  8851. fdds = append(fdds, &fdd)
  8852. } else {
  8853. var fdd models.FsiDiagnoseDtos
  8854. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  8855. fdd.InoutDiseType = "1"
  8856. fdd.MaindiseFlag = "1"
  8857. fdd.DiseDate = s_tm
  8858. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  8859. fdd.DiseName = item.CountryContentName
  8860. fdd.DiseCodg = item.CountryCode
  8861. fdds = append(fdds, &fdd)
  8862. }
  8863. }
  8864. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  8865. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  8866. fed.AdmDeptName = department.Name
  8867. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  8868. fed.DscgDeptName = department.Name
  8869. fed.MedType = order.MedType
  8870. //处方医嘱信息
  8871. var orders []*models.FsiOrderDtos
  8872. //for _, item := range prescriptions {
  8873. // for _, subItem := range item.HisDoctorAdviceInfo {
  8874. // var order models.FsiOrderDtos
  8875. // order.RxID = strconv.FormatInt(item.ID, 10)
  8876. // order.Rxno = strconv.FormatInt(item.ID, 10)
  8877. // order.LongDrordFlag = "0"
  8878. // order.HilistType = "1"
  8879. // order.ChrgType = "1"
  8880. // order.DrordBhvr = "-"
  8881. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  8882. // order.HosplistName = subItem.BaseDrugLib.DrugName
  8883. // order.HilistLv = "1"
  8884. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  8885. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  8886. // order.HosplistName = subItem.BaseDrugLib.DrugName
  8887. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  8888. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  8889. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  8890. // order.OwnpayAmt = ""
  8891. // order.SelfpayAmt = ""
  8892. // order.Spec = ""
  8893. // order.SpecUnt = ""
  8894. // order.DrordBegnDate = s_tm
  8895. // order.DrordStopDate = ""
  8896. // order.DrordDrCodg = "1"
  8897. // order.DrordDeptName = department.Name
  8898. // order.DrordDrCodg = "1"
  8899. // order.DrordDrName = doctor_info.UserName
  8900. // order.DrordDrProfttl = ""
  8901. // order.CurrDrordFlag = "1"
  8902. // orders = append(orders, &order)
  8903. // }
  8904. // for _, subItem := range item.HisPrescriptionProject {
  8905. // if subItem.Type == 2 {
  8906. // var order models.FsiOrderDtos
  8907. // order.RxID = strconv.FormatInt(item.ID, 10)
  8908. // order.Rxno = strconv.FormatInt(item.ID, 10)
  8909. // order.LongDrordFlag = "0"
  8910. // order.HilistType = "1"
  8911. // order.ChrgType = "1"
  8912. // order.DrordBhvr = "-"
  8913. // order.HilistCode = subItem.HisProject.MedicalCode
  8914. // order.HosplistName = subItem.HisProject.ProjectName
  8915. // order.HilistLv = "1"
  8916. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  8917. // order.HosplistCode = subItem.HisProject.MedicalCode
  8918. // order.HosplistName = subItem.HisProject.ProjectName
  8919. // order.Cnt = subItem.Count
  8920. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  8921. //
  8922. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  8923. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  8924. // order.OwnpayAmt = ""
  8925. // order.SelfpayAmt = ""
  8926. // order.Spec = ""
  8927. // order.SpecUnt = ""
  8928. // order.DrordBegnDate = s_tm
  8929. // order.DrordStopDate = ""
  8930. // order.DrordDrCodg = "1"
  8931. // order.DrordDeptName = department.Name
  8932. // order.DrordDrCodg = "1"
  8933. // order.DrordDrName = doctor_info.UserName
  8934. // order.DrordDrProfttl = ""
  8935. // order.CurrDrordFlag = "1"
  8936. // orders = append(orders, &order)
  8937. //
  8938. // }
  8939. // if subItem.Type == 3 {
  8940. //
  8941. // var order models.FsiOrderDtos
  8942. // order.RxID = strconv.FormatInt(item.ID, 10)
  8943. // order.Rxno = strconv.FormatInt(item.ID, 10)
  8944. // order.LongDrordFlag = "0"
  8945. // order.HilistType = "1"
  8946. // order.ChrgType = "1"
  8947. // order.DrordBhvr = "-"
  8948. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  8949. // order.HosplistName = subItem.GoodInfo.GoodName
  8950. // order.HilistLv = "1"
  8951. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  8952. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  8953. // order.HosplistName = subItem.GoodInfo.GoodName
  8954. // order.Cnt = subItem.Count
  8955. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  8956. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  8957. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  8958. // order.OwnpayAmt = ""
  8959. // order.SelfpayAmt = ""
  8960. // order.Spec = ""
  8961. // order.SpecUnt = ""
  8962. // order.DrordBegnDate = s_tm
  8963. // order.DrordStopDate = ""
  8964. // order.DrordDrCodg = "1"
  8965. // order.DrordDeptName = department.Name
  8966. // order.DrordDrCodg = "1"
  8967. // order.DrordDrName = doctor_info.UserName
  8968. // order.DrordDrProfttl = ""
  8969. // order.CurrDrordFlag = "1"
  8970. // orders = append(orders, &order)
  8971. //
  8972. // }
  8973. // }
  8974. //}
  8975. for _, item := range prescriptions {
  8976. for _, subItem := range item.HisDoctorAdviceInfo {
  8977. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8978. var order models.FsiOrderDtos
  8979. order.RxID = strconv.FormatInt(item.ID, 10)
  8980. order.Rxno = strconv.FormatInt(item.ID, 10)
  8981. order.LongDrordFlag = "0"
  8982. order.HilistType = "1"
  8983. order.ChrgType = "1"
  8984. order.DrordBhvr = "-"
  8985. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  8986. order.HosplistName = subItem.BaseDrugLib.DrugName
  8987. order.HilistLv = "1"
  8988. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  8989. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  8990. order.HosplistName = subItem.BaseDrugLib.DrugName
  8991. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  8992. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  8993. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  8994. order.OwnpayAmt = ""
  8995. order.SelfpayAmt = ""
  8996. order.Spec = ""
  8997. order.SpecUnt = ""
  8998. order.DrordBegnDate = s_tm
  8999. order.DrordStopDate = ""
  9000. order.DrordDrCodg = doctor_info.DoctorNumber
  9001. order.DrordDeptName = department.Name
  9002. order.DrordDeptCodg = department.Number
  9003. order.DrordDrName = doctor_info.UserName
  9004. order.DrordDrProfttl = "234"
  9005. order.CurrDrordFlag = "1"
  9006. orders = append(orders, &order)
  9007. }
  9008. }
  9009. for _, subItem := range item.HisPrescriptionProject {
  9010. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  9011. var order models.FsiOrderDtos
  9012. order.RxID = strconv.FormatInt(item.ID, 10)
  9013. order.Rxno = strconv.FormatInt(item.ID, 10)
  9014. order.LongDrordFlag = "0"
  9015. order.HilistType = "1"
  9016. order.ChrgType = "1"
  9017. order.DrordBhvr = "-"
  9018. order.HilistCode = subItem.HisProject.MedicalCode
  9019. order.HosplistName = subItem.HisProject.ProjectName
  9020. order.HilistLv = "1"
  9021. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9022. order.HosplistCode = subItem.HisProject.MedicalCode
  9023. order.HosplistName = subItem.HisProject.ProjectName
  9024. order.Cnt = subItem.Count
  9025. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9026. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9027. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9028. order.OwnpayAmt = ""
  9029. order.SelfpayAmt = ""
  9030. order.Spec = ""
  9031. order.SpecUnt = ""
  9032. order.DrordBegnDate = s_tm
  9033. order.DrordStopDate = ""
  9034. order.DrordDrCodg = doctor_info.DoctorNumber
  9035. order.DrordDeptName = department.Name
  9036. order.DrordDeptCodg = department.Number
  9037. order.DrordDrName = doctor_info.UserName
  9038. order.DrordDrProfttl = "234"
  9039. order.CurrDrordFlag = "1"
  9040. orders = append(orders, &order)
  9041. }
  9042. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  9043. var order models.FsiOrderDtos
  9044. order.RxID = strconv.FormatInt(item.ID, 10)
  9045. order.Rxno = strconv.FormatInt(item.ID, 10)
  9046. order.LongDrordFlag = "0"
  9047. order.HilistType = "1"
  9048. order.ChrgType = "1"
  9049. order.DrordBhvr = "0"
  9050. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9051. order.HosplistName = subItem.GoodInfo.GoodName
  9052. order.HilistLv = "1"
  9053. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9054. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9055. order.HosplistName = subItem.GoodInfo.GoodName
  9056. order.Cnt = subItem.Count
  9057. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9058. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9059. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9060. order.OwnpayAmt = ""
  9061. order.SelfpayAmt = ""
  9062. order.Spec = ""
  9063. order.SpecUnt = ""
  9064. order.DrordBegnDate = s_tm
  9065. order.DrordStopDate = ""
  9066. order.DrordDrCodg = doctor_info.DoctorNumber
  9067. order.DrordDeptName = department.Name
  9068. order.DrordDeptCodg = department.Number
  9069. order.DrordDrName = doctor_info.UserName
  9070. order.DrordDrProfttl = "234"
  9071. order.CurrDrordFlag = "1"
  9072. orders = append(orders, &order)
  9073. }
  9074. }
  9075. }
  9076. //处方医嘱信息
  9077. fed.MatnStas = "0"
  9078. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9079. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  9080. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  9081. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  9082. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  9083. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  9084. fed.SetlTotlnum = "1"
  9085. fed.Insutype = his.Insutype
  9086. fed.ReimFlag = "0"
  9087. fed.OutSetlFlag = "0"
  9088. var fopd []*models.FsiOperationDtosData
  9089. data := make(map[string]interface{})
  9090. data["fed"] = fed
  9091. data["fdd"] = fdds
  9092. data["fod"] = orders
  9093. data["pd"] = pd
  9094. data["pp"] = pp
  9095. data["fopd"] = fopd
  9096. data["trig_scen"] = trig_scen
  9097. client := &http.Client{}
  9098. bytesData, _ := json.Marshal(data)
  9099. var req *http.Request
  9100. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9101. if miConfig.MdtrtareaAdmvs == "320921" {
  9102. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  9103. } else {
  9104. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  9105. }
  9106. resp, _ := client.Do(req)
  9107. defer resp.Body.Close()
  9108. body, ioErr := ioutil.ReadAll(resp.Body)
  9109. if ioErr != nil {
  9110. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9112. return res
  9113. }
  9114. var respJSON map[string]interface{}
  9115. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9116. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9118. return res
  9119. }
  9120. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  9121. result, _ := json.Marshal(respJSON)
  9122. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9123. utils.ErrorLog("解析失败:%v", err)
  9124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9125. return res
  9126. }
  9127. return res
  9128. } else {
  9129. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  9130. saveLog(output, input, "3102", "事中")
  9131. if err := json.Unmarshal([]byte(output), &res); err != nil {
  9132. utils.ErrorLog("解析失败:%v", err)
  9133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9134. return
  9135. }
  9136. return res
  9137. }
  9138. return res
  9139. }
  9140. 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) {
  9141. var res Resultgd3101
  9142. adminUser := c.GetAdminUserInfo()
  9143. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9144. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9145. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9146. //record_time := c.GetString("record_time")
  9147. //trig_scen := c.GetString("trig_scen")
  9148. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  9149. //psn_info, _ := service.GetPatientId(patient_id)
  9150. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  9151. timeLayout := "2006-01-02"
  9152. loc, _ := time.LoadLocation("Local")
  9153. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9154. if err != nil {
  9155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9156. return res
  9157. }
  9158. recordDateTime := theTime.Unix()
  9159. var patientPrescription models.HisPrescriptionInfo
  9160. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9161. //if patientPrescription.ID == 0 {
  9162. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  9163. //}
  9164. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9165. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9166. //
  9167. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  9168. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9169. str,_ := getBirthDateFromIDCard(patient.IdCardNo)
  9170. var pp models.PublicParams
  9171. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9172. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9173. pp.FixmedinsName = miConfig.OrgName
  9174. pp.FixmedinsCode = miConfig.Code
  9175. pp.RequestUrl = miConfig.Url
  9176. pp.Cainfo = miConfig.Cainfo
  9177. pp.SecretKey = miConfig.SecretKey
  9178. pp.AccessKey = miConfig.AccessKey
  9179. pp.OpterName = roles.UserName
  9180. var config []*models.HisXtDiagnoseConfig
  9181. for _, item := range diagnosis_ids {
  9182. id, _ := strconv.ParseInt(item, 10, 64)
  9183. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9184. config = append(config, &diagnosisConfig)
  9185. }
  9186. var pd models.PatientDtos
  9187. pd.PatnID = his.PsnNo
  9188. pd.PatnName = his.Name
  9189. pd.Gend = his.Gend
  9190. pd.Brdy = str
  9191. pd.Poolarea = miConfig.MdtrtareaAdmvs
  9192. pd.CurrMdtrtID = his.Number
  9193. var fed models.FsiEncounterDtos
  9194. fed.MdtrtID = his.Number
  9195. fed.MedinsID = miConfig.Code
  9196. fed.MedinsName = miConfig.OrgName
  9197. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  9198. fed.MedMdtrtType = "1"
  9199. fed.MedinsType = "1"
  9200. fed.MedinsLv = "11"
  9201. tm := time.Unix(his.RecordDate, 0)
  9202. s_tm := tm.Format("2006-01-02 15:04:05")
  9203. fed.AdmDate = s_tm
  9204. fed.DscgDate = s_tm
  9205. fed.DscgMainDiseCodg = config[0].CountryCode
  9206. fed.DscgMainDiseName = config[0].CountryContentName
  9207. //诊断信息
  9208. var fdds []*models.FsiDiagnoseDtos
  9209. for index, item := range config {
  9210. if index == 0 {
  9211. var fdd models.FsiDiagnoseDtos
  9212. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9213. fdd.InoutDiseType = "1"
  9214. fdd.MaindiseFlag = "1"
  9215. fdd.DiseDate = s_tm
  9216. fdd.DiasSrtNo = "1"
  9217. fdd.DiseName = item.CountryContentName
  9218. fdd.DiseCodg = item.CountryCode
  9219. fdds = append(fdds, &fdd)
  9220. } else {
  9221. var fdd models.FsiDiagnoseDtos
  9222. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9223. fdd.InoutDiseType = "1"
  9224. fdd.MaindiseFlag = "1"
  9225. fdd.DiseDate = s_tm
  9226. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  9227. fdd.DiseName = item.CountryContentName
  9228. fdd.DiseCodg = item.CountryCode
  9229. fdds = append(fdds, &fdd)
  9230. }
  9231. }
  9232. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  9233. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  9234. fed.AdmDeptName = de.Name
  9235. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  9236. fed.DscgDeptName = de.Name
  9237. fed.MedMdtrtType = "1"
  9238. fed.MedType = "11"
  9239. //if his.Insutype == "390" {
  9240. // fed.MedType = "1402"
  9241. //} else {
  9242. // fed.MedType = "9933"
  9243. //}
  9244. var orders []*models.FsiOrderDtos
  9245. if trig_scen == "2" {
  9246. //处方医嘱信息
  9247. for _, item := range prescriptions {
  9248. for _, subItem := range item.HisDoctorAdviceInfo {
  9249. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9250. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  9251. var order models.FsiOrderDtos
  9252. order.RxID = strconv.FormatInt(item.ID, 10)
  9253. order.Rxno = strconv.FormatInt(item.ID, 10)
  9254. order.LongDrordFlag = "0"
  9255. order.HilistType = "1"
  9256. order.ChrgType = "1"
  9257. order.DrordBhvr = "0"
  9258. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9259. order.HosplistName = subItem.BaseDrugLib.DrugName
  9260. order.HilistLv = "1"
  9261. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9262. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9263. order.HosplistName = subItem.BaseDrugLib.DrugName
  9264. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  9265. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9266. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  9267. order.OwnpayAmt = ""
  9268. order.SelfpayAmt = ""
  9269. order.Spec = spec
  9270. order.SpecUnt = subItem.PrescribingNumberUnit
  9271. order.DrordBegnDate = s_tm
  9272. order.DrordStopDate = ""
  9273. order.DrordDrCodg = doctor_info.DoctorNumber
  9274. order.DrordDeptName = department.Name
  9275. order.DrordDeptCodg = department.Number
  9276. order.DrordDrName = doctor_info.UserName
  9277. order.DrordDrProfttl = "234"
  9278. order.CurrDrordFlag = "1"
  9279. orders = append(orders, &order)
  9280. }
  9281. }
  9282. for _, subItem := range item.HisPrescriptionProject {
  9283. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  9284. var order models.FsiOrderDtos
  9285. order.RxID = strconv.FormatInt(item.ID, 10)
  9286. order.Rxno = strconv.FormatInt(item.ID, 10)
  9287. order.LongDrordFlag = "0"
  9288. order.HilistType = "1"
  9289. order.ChrgType = "1"
  9290. order.DrordBhvr = "0"
  9291. order.HilistCode = subItem.HisProject.MedicalCode
  9292. order.HosplistName = subItem.HisProject.ProjectName
  9293. order.HilistLv = "1"
  9294. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9295. order.HosplistCode = subItem.HisProject.MedicalCode
  9296. order.HosplistName = subItem.HisProject.ProjectName
  9297. order.Cnt = subItem.Count
  9298. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9299. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9300. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9301. order.OwnpayAmt = ""
  9302. order.SelfpayAmt = ""
  9303. order.Spec = subItem.Unit
  9304. order.SpecUnt = subItem.Unit
  9305. order.DrordBegnDate = s_tm
  9306. order.DrordStopDate = ""
  9307. order.DrordDrCodg = doctor_info.DoctorNumber
  9308. order.DrordDeptName = department.Name
  9309. order.DrordDeptCodg = department.Number
  9310. order.DrordDrName = doctor_info.UserName
  9311. order.DrordDrProfttl = "234"
  9312. order.CurrDrordFlag = "1"
  9313. orders = append(orders, &order)
  9314. }
  9315. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  9316. var order models.FsiOrderDtos
  9317. order.RxID = strconv.FormatInt(item.ID, 10)
  9318. order.Rxno = strconv.FormatInt(item.ID, 10)
  9319. order.LongDrordFlag = "0"
  9320. order.HilistType = "1"
  9321. order.ChrgType = "1"
  9322. order.DrordBhvr = "0"
  9323. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9324. order.HosplistName = subItem.GoodInfo.GoodName
  9325. order.HilistLv = "1"
  9326. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9327. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9328. order.HosplistName = subItem.GoodInfo.GoodName
  9329. order.Cnt = subItem.Count
  9330. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9331. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9332. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9333. order.OwnpayAmt = ""
  9334. order.SelfpayAmt = ""
  9335. order.Spec = subItem.GoodInfo.SpecificationName
  9336. order.SpecUnt = subItem.Unit
  9337. order.DrordBegnDate = s_tm
  9338. order.DrordStopDate = ""
  9339. order.DrordDrCodg = doctor_info.DoctorNumber
  9340. order.DrordDeptName = department.Name
  9341. order.DrordDeptCodg = department.Number
  9342. order.DrordDrName = doctor_info.UserName
  9343. order.DrordDrProfttl = "234"
  9344. order.CurrDrordFlag = "1"
  9345. orders = append(orders, &order)
  9346. }
  9347. }
  9348. }
  9349. //处方医嘱信息
  9350. }
  9351. fed.MatnStas = "0"
  9352. fed.MedfeeSumamt = "0"
  9353. fed.OwnpayAmt = "0"
  9354. fed.SelfpayAmt = "0"
  9355. fed.AcctPayamt = "0"
  9356. fed.MaAmt = "0"
  9357. fed.HifpPayamt = "0"
  9358. fed.SetlTotlnum = "1"
  9359. fed.Insutype = his.Insutype
  9360. fed.ReimFlag = "0"
  9361. fed.OutSetlFlag = "0"
  9362. var fopd []*models.FsiOperationDtosData
  9363. data := make(map[string]interface{})
  9364. data["fed"] = fed
  9365. data["fdd"] = fdds
  9366. data["fod"] = orders
  9367. data["pd"] = pd
  9368. data["pp"] = pp
  9369. data["fopd"] = fopd
  9370. data["trig_scen"] = trig_scen
  9371. fmt.Println(data)
  9372. fmt.Println(fed)
  9373. fmt.Println(fdds)
  9374. fmt.Println(orders)
  9375. fmt.Println(pd)
  9376. fmt.Println(pp)
  9377. fmt.Println(fopd)
  9378. client := &http.Client{}
  9379. bytesData, _ := json.Marshal(data)
  9380. var req *http.Request
  9381. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9382. if miConfig.MdtrtareaAdmvs == "320921" {
  9383. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  9384. } else {
  9385. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  9386. }
  9387. resp, _ := client.Do(req)
  9388. defer resp.Body.Close()
  9389. body, ioErr := ioutil.ReadAll(resp.Body)
  9390. if ioErr != nil {
  9391. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9393. return res
  9394. }
  9395. var respJSON map[string]interface{}
  9396. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9397. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9399. return res
  9400. }
  9401. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  9402. fmt.Println(respJSON)
  9403. result, _ := json.Marshal(respJSON)
  9404. fmt.Println(result)
  9405. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9406. utils.ErrorLog("解析失败:%v", err)
  9407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9408. return res
  9409. }
  9410. return res
  9411. } else {
  9412. //if miConfig.MdtrtareaAdmvs == "441202" {
  9413. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  9414. saveLog(output, input, "3101", "事前")
  9415. if err := json.Unmarshal([]byte(output), &res); err != nil {
  9416. utils.ErrorLog("解析失败:%v", err)
  9417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9418. return
  9419. }
  9420. return res
  9421. //}
  9422. }
  9423. }
  9424. 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) {
  9425. adminUser := c.GetAdminUserInfo()
  9426. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9427. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9428. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9429. //record_time := c.GetString("record_time")
  9430. //trig_scen := c.GetString("trig_scen")
  9431. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  9432. timeLayout := "2006-01-02"
  9433. loc, _ := time.LoadLocation("Local")
  9434. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9435. if err != nil {
  9436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9437. return res
  9438. }
  9439. recordDateTime := theTime.Unix()
  9440. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  9441. var patientPrescription models.HisPrescriptionInfo
  9442. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9443. if patientPrescription.ID == 0 {
  9444. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  9445. }
  9446. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9447. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9448. //
  9449. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  9450. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9451. var pp models.PublicParams
  9452. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9453. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9454. pp.FixmedinsName = miConfig.OrgName
  9455. pp.FixmedinsCode = miConfig.Code
  9456. pp.RequestUrl = miConfig.Url
  9457. pp.Cainfo = miConfig.Cainfo
  9458. pp.SecretKey = miConfig.SecretKey
  9459. pp.AccessKey = miConfig.AccessKey
  9460. pp.OpterName = roles.UserName
  9461. var config []*models.HisXtDiagnoseConfig
  9462. for _, item := range diagnosis_ids {
  9463. id, _ := strconv.ParseInt(item, 10, 64)
  9464. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9465. config = append(config, &diagnosisConfig)
  9466. }
  9467. str,_ := getBirthDateFromIDCard(patient.IdCardNo)
  9468. var pd models.PatientDtos
  9469. pd.PatnID = his.PsnNo
  9470. pd.PatnName = his.Name
  9471. pd.Gend = his.Gend
  9472. pd.Brdy = str
  9473. pd.Poolarea = his.InsuplcAdmdvs
  9474. pd.CurrMdtrtID = his.Number
  9475. var fed models.FsiEncounterDtos
  9476. fed.MdtrtID = his.Number
  9477. fed.MedinsID = miConfig.Code
  9478. fed.MedinsName = miConfig.OrgName
  9479. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  9480. fed.MedMdtrtType = "1"
  9481. fed.MedinsType = "1"
  9482. fed.MedinsLv = "11"
  9483. tm := time.Unix(his.RecordDate, 0)
  9484. s_tm := tm.Format("2006-01-02 15:04:05")
  9485. fed.AdmDate = s_tm
  9486. fed.DscgDate = s_tm
  9487. fed.DscgMainDiseCodg = config[0].CountryCode
  9488. fed.DscgMainDiseName = config[0].CountryContentName
  9489. //诊断信息
  9490. var fdds []*models.FsiDiagnoseDtos
  9491. for index, item := range config {
  9492. if index == 0 {
  9493. var fdd models.FsiDiagnoseDtos
  9494. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9495. fdd.InoutDiseType = "1"
  9496. fdd.MaindiseFlag = "1"
  9497. fdd.DiseDate = s_tm
  9498. fdd.DiasSrtNo = "1"
  9499. fdd.DiseName = item.CountryContentName
  9500. fdd.DiseCodg = item.CountryCode
  9501. fdds = append(fdds, &fdd)
  9502. } else {
  9503. var fdd models.FsiDiagnoseDtos
  9504. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9505. fdd.InoutDiseType = "1"
  9506. fdd.MaindiseFlag = "1"
  9507. fdd.DiseDate = s_tm
  9508. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  9509. fdd.DiseName = item.CountryContentName
  9510. fdd.DiseCodg = item.CountryCode
  9511. fdds = append(fdds, &fdd)
  9512. }
  9513. }
  9514. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  9515. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  9516. fed.AdmDeptName = department.Name
  9517. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  9518. fed.DscgDeptName = department.Name
  9519. fed.MedMdtrtType = "1"
  9520. fed.MedType = "11"
  9521. //if his.Insutype == "390" {
  9522. // fed.MedType = "1402"
  9523. //} else {
  9524. // fed.MedType = "9933"
  9525. //}
  9526. var orders []*models.FsiOrderDtos
  9527. if trig_scen == "2" {
  9528. //处方医嘱信息
  9529. for _, item := range prescriptions {
  9530. for _, subItem := range item.HisDoctorAdviceInfo {
  9531. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9532. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  9533. var order models.FsiOrderDtos
  9534. order.RxID = strconv.FormatInt(item.ID, 10)
  9535. order.Rxno = strconv.FormatInt(item.ID, 10)
  9536. order.LongDrordFlag = "0"
  9537. order.HilistType = "1"
  9538. order.ChrgType = "1"
  9539. order.DrordBhvr = "0"
  9540. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9541. order.HosplistName = subItem.BaseDrugLib.DrugName
  9542. order.HilistLv = "1"
  9543. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9544. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9545. order.HosplistName = subItem.BaseDrugLib.DrugName
  9546. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  9547. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9548. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  9549. order.OwnpayAmt = ""
  9550. order.SelfpayAmt = ""
  9551. order.Spec = spec
  9552. order.SpecUnt = subItem.PrescribingNumberUnit
  9553. order.DrordBegnDate = s_tm
  9554. order.DrordStopDate = ""
  9555. order.DrordDrCodg = doctor_info.DoctorNumber
  9556. order.DrordDeptName = department.Name
  9557. order.DrordDeptCodg = department.Number
  9558. order.DrordDrName = doctor_info.UserName
  9559. order.DrordDrProfttl = "234"
  9560. order.CurrDrordFlag = "1"
  9561. orders = append(orders, &order)
  9562. }
  9563. }
  9564. for _, subItem := range item.HisPrescriptionProject {
  9565. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  9566. var order models.FsiOrderDtos
  9567. order.RxID = strconv.FormatInt(item.ID, 10)
  9568. order.Rxno = strconv.FormatInt(item.ID, 10)
  9569. order.LongDrordFlag = "0"
  9570. order.HilistType = "1"
  9571. order.ChrgType = "1"
  9572. order.DrordBhvr = "0"
  9573. order.HilistCode = subItem.HisProject.MedicalCode
  9574. order.HosplistName = subItem.HisProject.ProjectName
  9575. order.HilistLv = "1"
  9576. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9577. order.HosplistCode = subItem.HisProject.MedicalCode
  9578. order.HosplistName = subItem.HisProject.ProjectName
  9579. order.Cnt = subItem.Count
  9580. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9581. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9582. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9583. order.OwnpayAmt = ""
  9584. order.SelfpayAmt = ""
  9585. order.Spec = subItem.Unit
  9586. order.SpecUnt = subItem.Unit
  9587. order.DrordBegnDate = s_tm
  9588. order.DrordStopDate = ""
  9589. order.DrordDrCodg = doctor_info.DoctorNumber
  9590. order.DrordDeptName = department.Name
  9591. order.DrordDeptCodg = department.Number
  9592. order.DrordDrName = doctor_info.UserName
  9593. order.DrordDrProfttl = "234"
  9594. order.CurrDrordFlag = "1"
  9595. orders = append(orders, &order)
  9596. }
  9597. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  9598. var order models.FsiOrderDtos
  9599. order.RxID = strconv.FormatInt(item.ID, 10)
  9600. order.Rxno = strconv.FormatInt(item.ID, 10)
  9601. order.LongDrordFlag = "0"
  9602. order.HilistType = "1"
  9603. order.ChrgType = "1"
  9604. order.DrordBhvr = "0"
  9605. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9606. order.HosplistName = subItem.GoodInfo.GoodName
  9607. order.HilistLv = "1"
  9608. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9609. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9610. order.HosplistName = subItem.GoodInfo.GoodName
  9611. order.Cnt = subItem.Count
  9612. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9613. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9614. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9615. order.OwnpayAmt = ""
  9616. order.SelfpayAmt = ""
  9617. order.Spec = subItem.GoodInfo.SpecificationName
  9618. order.SpecUnt = subItem.Unit
  9619. order.DrordBegnDate = s_tm
  9620. order.DrordStopDate = ""
  9621. order.DrordDrCodg = doctor_info.DoctorNumber
  9622. order.DrordDeptName = department.Name
  9623. order.DrordDeptCodg = department.Number
  9624. order.DrordDrName = doctor_info.UserName
  9625. order.DrordDrProfttl = "234"
  9626. order.CurrDrordFlag = "1"
  9627. orders = append(orders, &order)
  9628. }
  9629. }
  9630. }
  9631. //处方医嘱信息
  9632. }
  9633. fed.MatnStas = "0"
  9634. fed.MedfeeSumamt = "0"
  9635. fed.OwnpayAmt = "0"
  9636. fed.SelfpayAmt = "0"
  9637. fed.AcctPayamt = "0"
  9638. fed.MaAmt = "0"
  9639. fed.HifpPayamt = "0"
  9640. fed.SetlTotlnum = "1"
  9641. fed.Insutype = his.Insutype
  9642. fed.ReimFlag = "0"
  9643. fed.OutSetlFlag = "0"
  9644. var fopd []*models.FsiOperationDtosData
  9645. data := make(map[string]interface{})
  9646. data["fed"] = fed
  9647. data["fdd"] = fdds
  9648. data["fod"] = orders
  9649. data["pd"] = pd
  9650. data["pp"] = pp
  9651. data["fopd"] = fopd
  9652. data["trig_scen"] = trig_scen
  9653. fmt.Println(data)
  9654. fmt.Println(fed)
  9655. fmt.Println(fdds)
  9656. fmt.Println(orders)
  9657. fmt.Println(pd)
  9658. fmt.Println(pp)
  9659. fmt.Println(fopd)
  9660. client := &http.Client{}
  9661. bytesData, _ := json.Marshal(data)
  9662. var req *http.Request
  9663. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9664. if miConfig.MdtrtareaAdmvs == "320921" {
  9665. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  9666. } else {
  9667. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  9668. }
  9669. resp, _ := client.Do(req)
  9670. defer resp.Body.Close()
  9671. body, ioErr := ioutil.ReadAll(resp.Body)
  9672. if ioErr != nil {
  9673. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9675. return res
  9676. }
  9677. var respJSON map[string]interface{}
  9678. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9679. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9681. return res
  9682. }
  9683. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  9684. fmt.Println(respJSON)
  9685. result, _ := json.Marshal(respJSON)
  9686. fmt.Println(result)
  9687. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9688. utils.ErrorLog("解析失败:%v", err)
  9689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9690. return res
  9691. }
  9692. return res
  9693. } else {
  9694. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  9695. saveLog(output, input, "3101", "事前")
  9696. if err := json.Unmarshal([]byte(output), &res); err != nil {
  9697. utils.ErrorLog("解析失败:%v", err)
  9698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9699. return
  9700. }
  9701. return res
  9702. }
  9703. return res
  9704. }
  9705. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  9706. ////patient_id, _ := c.GetInt64("patient_id")
  9707. //order_id, _ := c.GetInt64("order_id")
  9708. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  9709. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  9710. //trig_scen := c.GetString("trig_scen")
  9711. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  9712. //utils.ErrorLog("解析失败:%v", psn_info)
  9713. adminUser := c.GetAdminUserInfo()
  9714. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9715. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9716. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9717. record_time := c.GetString("record_time")
  9718. order, _ := service.GetHisOrderByID(order_id)
  9719. timeLayout := "2006-01-02"
  9720. loc, _ := time.LoadLocation("Local")
  9721. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9722. if err != nil {
  9723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9724. return
  9725. }
  9726. recordDateTime := theTime.Unix()
  9727. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  9728. var patientPrescription models.HisPrescriptionInfo
  9729. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9730. if patientPrescription.ID == 0 {
  9731. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  9732. }
  9733. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9734. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9735. //
  9736. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9737. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9738. var pp models.PublicParams
  9739. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9740. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9741. pp.FixmedinsName = miConfig.OrgName
  9742. pp.FixmedinsCode = miConfig.Code
  9743. pp.RequestUrl = miConfig.Url
  9744. pp.Cainfo = miConfig.Cainfo
  9745. pp.SecretKey = miConfig.SecretKey
  9746. pp.AccessKey = miConfig.AccessKey
  9747. pp.OpterName = roles.UserName
  9748. var config []*models.HisXtDiagnoseConfig
  9749. for _, item := range diagnosis_ids {
  9750. id, _ := strconv.ParseInt(item, 10, 64)
  9751. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9752. config = append(config, &diagnosisConfig)
  9753. }
  9754. str,_ := getBirthDateFromIDCard(patient.IdCardNo)
  9755. var pd models.PatientDtos
  9756. pd.PatnID = his.PsnNo
  9757. pd.PatnName = his.Name
  9758. pd.Gend = his.Gend
  9759. pd.Brdy = str
  9760. pd.Poolarea = his.InsuplcAdmdvs
  9761. pd.CurrMdtrtID = his.Number
  9762. var fed models.FsiEncounterDtos
  9763. fed.MdtrtID = his.Number
  9764. fed.MedinsID = miConfig.Code
  9765. fed.MedinsName = miConfig.OrgName
  9766. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  9767. fed.MedMdtrtType = "1"
  9768. fed.MedinsType = "1"
  9769. fed.MedinsLv = "11"
  9770. tm := time.Unix(his.RecordDate, 0)
  9771. s_tm := tm.Format("2006-01-02 15:04:05")
  9772. fed.AdmDate = s_tm
  9773. fed.DscgDate = s_tm
  9774. fed.DscgMainDiseCodg = config[0].CountryCode
  9775. fed.DscgMainDiseName = config[0].CountryContentName
  9776. //诊断信息
  9777. var fdds []*models.FsiDiagnoseDtos
  9778. for index, item := range config {
  9779. if index == 0 {
  9780. var fdd models.FsiDiagnoseDtos
  9781. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9782. fdd.InoutDiseType = "1"
  9783. fdd.MaindiseFlag = "1"
  9784. fdd.DiseDate = s_tm
  9785. fdd.DiasSrtNo = "1"
  9786. fdd.DiseName = item.CountryContentName
  9787. fdd.DiseCodg = item.CountryCode
  9788. fdds = append(fdds, &fdd)
  9789. } else {
  9790. var fdd models.FsiDiagnoseDtos
  9791. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9792. fdd.InoutDiseType = "1"
  9793. fdd.MaindiseFlag = "1"
  9794. fdd.DiseDate = s_tm
  9795. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  9796. fdd.DiseName = item.CountryContentName
  9797. fdd.DiseCodg = item.CountryCode
  9798. fdds = append(fdds, &fdd)
  9799. }
  9800. }
  9801. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  9802. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  9803. fed.AdmDeptName = department.Name
  9804. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  9805. fed.DscgDeptName = department.Name
  9806. fed.MedType = order.MedType
  9807. //处方医嘱信息
  9808. var orders []*models.FsiOrderDtos
  9809. //for _, item := range prescriptions {
  9810. // for _, subItem := range item.HisDoctorAdviceInfo {
  9811. // var order models.FsiOrderDtos
  9812. // order.RxID = strconv.FormatInt(item.ID, 10)
  9813. // order.Rxno = strconv.FormatInt(item.ID, 10)
  9814. // order.LongDrordFlag = "0"
  9815. // order.HilistType = "1"
  9816. // order.ChrgType = "1"
  9817. // order.DrordBhvr = "-"
  9818. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9819. // order.HosplistName = subItem.BaseDrugLib.DrugName
  9820. // order.HilistLv = "1"
  9821. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  9822. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9823. // order.HosplistName = subItem.BaseDrugLib.DrugName
  9824. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  9825. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  9826. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  9827. // order.OwnpayAmt = ""
  9828. // order.SelfpayAmt = ""
  9829. // order.Spec = ""
  9830. // order.SpecUnt = ""
  9831. // order.DrordBegnDate = s_tm
  9832. // order.DrordStopDate = ""
  9833. // order.DrordDrCodg = "1"
  9834. // order.DrordDeptName = department.Name
  9835. // order.DrordDrCodg = "1"
  9836. // order.DrordDrName = doctor_info.UserName
  9837. // order.DrordDrProfttl = ""
  9838. // order.CurrDrordFlag = "1"
  9839. // orders = append(orders, &order)
  9840. // }
  9841. // for _, subItem := range item.HisPrescriptionProject {
  9842. // if subItem.Type == 2 {
  9843. // var order models.FsiOrderDtos
  9844. // order.RxID = strconv.FormatInt(item.ID, 10)
  9845. // order.Rxno = strconv.FormatInt(item.ID, 10)
  9846. // order.LongDrordFlag = "0"
  9847. // order.HilistType = "1"
  9848. // order.ChrgType = "1"
  9849. // order.DrordBhvr = "-"
  9850. // order.HilistCode = subItem.HisProject.MedicalCode
  9851. // order.HosplistName = subItem.HisProject.ProjectName
  9852. // order.HilistLv = "1"
  9853. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  9854. // order.HosplistCode = subItem.HisProject.MedicalCode
  9855. // order.HosplistName = subItem.HisProject.ProjectName
  9856. // order.Cnt = subItem.Count
  9857. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9858. //
  9859. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  9860. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  9861. // order.OwnpayAmt = ""
  9862. // order.SelfpayAmt = ""
  9863. // order.Spec = ""
  9864. // order.SpecUnt = ""
  9865. // order.DrordBegnDate = s_tm
  9866. // order.DrordStopDate = ""
  9867. // order.DrordDrCodg = "1"
  9868. // order.DrordDeptName = department.Name
  9869. // order.DrordDrCodg = "1"
  9870. // order.DrordDrName = doctor_info.UserName
  9871. // order.DrordDrProfttl = ""
  9872. // order.CurrDrordFlag = "1"
  9873. // orders = append(orders, &order)
  9874. //
  9875. // }
  9876. // if subItem.Type == 3 {
  9877. //
  9878. // var order models.FsiOrderDtos
  9879. // order.RxID = strconv.FormatInt(item.ID, 10)
  9880. // order.Rxno = strconv.FormatInt(item.ID, 10)
  9881. // order.LongDrordFlag = "0"
  9882. // order.HilistType = "1"
  9883. // order.ChrgType = "1"
  9884. // order.DrordBhvr = "-"
  9885. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9886. // order.HosplistName = subItem.GoodInfo.GoodName
  9887. // order.HilistLv = "1"
  9888. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  9889. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9890. // order.HosplistName = subItem.GoodInfo.GoodName
  9891. // order.Cnt = subItem.Count
  9892. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9893. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  9894. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  9895. // order.OwnpayAmt = ""
  9896. // order.SelfpayAmt = ""
  9897. // order.Spec = ""
  9898. // order.SpecUnt = ""
  9899. // order.DrordBegnDate = s_tm
  9900. // order.DrordStopDate = ""
  9901. // order.DrordDrCodg = "1"
  9902. // order.DrordDeptName = department.Name
  9903. // order.DrordDrCodg = "1"
  9904. // order.DrordDrName = doctor_info.UserName
  9905. // order.DrordDrProfttl = ""
  9906. // order.CurrDrordFlag = "1"
  9907. // orders = append(orders, &order)
  9908. //
  9909. // }
  9910. // }
  9911. //}
  9912. for _, item := range prescriptions {
  9913. for _, subItem := range item.HisDoctorAdviceInfo {
  9914. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9915. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  9916. var order models.FsiOrderDtos
  9917. order.RxID = strconv.FormatInt(item.ID, 10)
  9918. order.Rxno = strconv.FormatInt(item.ID, 10)
  9919. order.LongDrordFlag = "0"
  9920. order.HilistType = "1"
  9921. order.ChrgType = "1"
  9922. order.DrordBhvr = "0"
  9923. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9924. order.HosplistName = subItem.BaseDrugLib.DrugName
  9925. order.HilistLv = "1"
  9926. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9927. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9928. order.HosplistName = subItem.BaseDrugLib.DrugName
  9929. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  9930. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9931. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  9932. order.OwnpayAmt = ""
  9933. order.SelfpayAmt = ""
  9934. order.Spec = spec
  9935. order.SpecUnt = subItem.PrescribingNumberUnit
  9936. order.DrordBegnDate = s_tm
  9937. order.DrordStopDate = ""
  9938. order.DrordDrCodg = doctor_info.DoctorNumber
  9939. order.DrordDeptName = department.Name
  9940. order.DrordDeptCodg = department.Number
  9941. order.DrordDrName = doctor_info.UserName
  9942. order.DrordDrProfttl = "234"
  9943. order.CurrDrordFlag = "1"
  9944. orders = append(orders, &order)
  9945. }
  9946. }
  9947. for _, subItem := range item.HisPrescriptionProject {
  9948. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  9949. var order models.FsiOrderDtos
  9950. order.RxID = strconv.FormatInt(item.ID, 10)
  9951. order.Rxno = strconv.FormatInt(item.ID, 10)
  9952. order.LongDrordFlag = "0"
  9953. order.HilistType = "1"
  9954. order.ChrgType = "1"
  9955. order.DrordBhvr = "0"
  9956. order.HilistCode = subItem.HisProject.MedicalCode
  9957. order.HosplistName = subItem.HisProject.ProjectName
  9958. order.HilistLv = "1"
  9959. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9960. order.HosplistCode = subItem.HisProject.MedicalCode
  9961. order.HosplistName = subItem.HisProject.ProjectName
  9962. order.Cnt = subItem.Count
  9963. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9964. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9965. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9966. order.OwnpayAmt = ""
  9967. order.SelfpayAmt = ""
  9968. order.Spec = subItem.Unit
  9969. order.SpecUnt = subItem.Unit
  9970. order.DrordBegnDate = s_tm
  9971. order.DrordStopDate = ""
  9972. order.DrordDrCodg = doctor_info.DoctorNumber
  9973. order.DrordDeptName = department.Name
  9974. order.DrordDeptCodg = department.Number
  9975. order.DrordDrName = doctor_info.UserName
  9976. order.DrordDrProfttl = "234"
  9977. order.CurrDrordFlag = "1"
  9978. orders = append(orders, &order)
  9979. }
  9980. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  9981. var order models.FsiOrderDtos
  9982. order.RxID = strconv.FormatInt(item.ID, 10)
  9983. order.Rxno = strconv.FormatInt(item.ID, 10)
  9984. order.LongDrordFlag = "0"
  9985. order.HilistType = "1"
  9986. order.ChrgType = "1"
  9987. order.DrordBhvr = "0"
  9988. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9989. order.HosplistName = subItem.GoodInfo.GoodName
  9990. order.HilistLv = "1"
  9991. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9992. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9993. order.HosplistName = subItem.GoodInfo.GoodName
  9994. order.Cnt = subItem.Count
  9995. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9996. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9997. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9998. order.OwnpayAmt = ""
  9999. order.SelfpayAmt = ""
  10000. order.Spec = subItem.GoodInfo.SpecificationName
  10001. order.SpecUnt = subItem.Unit
  10002. order.DrordBegnDate = s_tm
  10003. order.DrordStopDate = ""
  10004. order.DrordDrCodg = doctor_info.DoctorNumber
  10005. order.DrordDeptName = department.Name
  10006. order.DrordDeptCodg = department.Number
  10007. order.DrordDrName = doctor_info.UserName
  10008. order.DrordDrProfttl = "234"
  10009. order.CurrDrordFlag = "1"
  10010. orders = append(orders, &order)
  10011. }
  10012. }
  10013. }
  10014. //处方医嘱信息
  10015. fed.MatnStas = "0"
  10016. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  10017. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  10018. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  10019. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  10020. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  10021. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  10022. fed.SetlTotlnum = "1"
  10023. fed.Insutype = his.Insutype
  10024. fed.ReimFlag = "0"
  10025. fed.OutSetlFlag = "0"
  10026. var fopd []*models.FsiOperationDtosData
  10027. data := make(map[string]interface{})
  10028. data["fed"] = fed
  10029. data["fdd"] = fdds
  10030. data["fod"] = orders
  10031. data["pd"] = pd
  10032. data["pp"] = pp
  10033. data["fopd"] = fopd
  10034. data["trig_scen"] = trig_scen
  10035. client := &http.Client{}
  10036. bytesData, _ := json.Marshal(data)
  10037. var req *http.Request
  10038. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10039. if miConfig.MdtrtareaAdmvs == "320921" {
  10040. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  10041. } else {
  10042. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  10043. }
  10044. resp, _ := client.Do(req)
  10045. defer resp.Body.Close()
  10046. body, ioErr := ioutil.ReadAll(resp.Body)
  10047. if ioErr != nil {
  10048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10050. return res
  10051. }
  10052. var respJSON map[string]interface{}
  10053. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10056. return res
  10057. }
  10058. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10059. result, _ := json.Marshal(respJSON)
  10060. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10061. utils.ErrorLog("解析失败:%v", err)
  10062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10063. return res
  10064. }
  10065. return res
  10066. } else {
  10067. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10068. saveLog(output, input, "3102", "事中")
  10069. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10070. utils.ErrorLog("解析失败:%v", err)
  10071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10072. return
  10073. }
  10074. return res
  10075. }
  10076. return res
  10077. }
  10078. func (c *HisApiController) Check() {
  10079. psn_no := c.GetString("psn_no")
  10080. in := c.GetString("in")
  10081. mt := c.GetString("mt")
  10082. baseParams := models.BaseParams{
  10083. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  10084. FixmedinsCode: "H15049901371",
  10085. InsuplcAdmdvs: "150499",
  10086. MdtrtareaAdmvs: "150499",
  10087. OrgName: "赤峰费森血液透析中心",
  10088. Doctor: "1111",
  10089. }
  10090. service.Gdyb2001(baseParams, psn_no, in, mt)
  10091. }
  10092. func (c *HisApiController) GetPsnNcdsInfo() {
  10093. admin_user_id, _ := c.GetInt64("admin_user_id")
  10094. patient_id, _ := c.GetInt64("patient_id")
  10095. //id, _ := c.GetInt64("id")
  10096. adminUser := c.GetAdminUserInfo()
  10097. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10098. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10099. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10100. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10101. //psn_record, _ := service.GetP(id)
  10102. psn_info, _ := service.GetPsnByPatientId(patient_id)
  10103. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  10104. //
  10105. //if psn_record.ID == 0 {
  10106. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10107. // return
  10108. //}
  10109. var res Result5301
  10110. var res10265 Result5301For10265
  10111. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10112. psn_info, _ := service.GetPsnByPatientId(patient_id)
  10113. var api string
  10114. if miConfig.MdtrtareaAdmvs == "320921" {
  10115. 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 +
  10116. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  10117. } else {
  10118. 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 +
  10119. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  10120. }
  10121. resp, requestErr := http.Get(api)
  10122. if requestErr != nil {
  10123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10124. return
  10125. }
  10126. body, ioErr := ioutil.ReadAll(resp.Body)
  10127. if ioErr != nil {
  10128. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10130. return
  10131. }
  10132. var respJSON map[string]interface{}
  10133. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10134. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10136. return
  10137. }
  10138. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10139. result, _ := json.Marshal(respJSON)
  10140. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10141. utils.ErrorLog("解析失败:%v", err)
  10142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10143. return
  10144. }
  10145. res.ErrMsg = res10265.ErrMsg
  10146. res.Output = res10265.Output
  10147. res.InfRefmsgid = res10265.InfRefmsgid
  10148. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10149. res.Infcode = infocode
  10150. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10151. psn_info, _ := service.GetPsnByPatientId(patient_id)
  10152. var api string
  10153. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  10154. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  10155. resp, requestErr := http.Get(api)
  10156. if requestErr != nil {
  10157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10158. return
  10159. }
  10160. body, ioErr := ioutil.ReadAll(resp.Body)
  10161. if ioErr != nil {
  10162. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10164. return
  10165. }
  10166. var respJSON map[string]interface{}
  10167. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10168. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10170. return
  10171. }
  10172. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10173. if status == "0" {
  10174. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10175. c.ServeSuccessJSON(map[string]interface{}{
  10176. "failed_code": -10,
  10177. "msg": err_msg,
  10178. })
  10179. return
  10180. }
  10181. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10182. result, _ := json.Marshal(respJSON)
  10183. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10184. utils.ErrorLog("解析失败:%v", err)
  10185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10186. return
  10187. }
  10188. } else if miConfig.MdtrtareaAdmvs == "360302" {
  10189. p, _ := service.GetHisPatientById(patient_id)
  10190. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  10191. var dat map[string]interface{}
  10192. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10193. fmt.Println(dat)
  10194. } else {
  10195. fmt.Println(err)
  10196. }
  10197. userJSONBytes, _ := json.Marshal(dat)
  10198. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10199. utils.ErrorLog("解析失败:%v", err)
  10200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10201. return
  10202. }
  10203. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10204. p, _ := service.GetHisPatientById(patient_id)
  10205. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  10206. var dat map[string]interface{}
  10207. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10208. fmt.Println(dat)
  10209. } else {
  10210. fmt.Println(err)
  10211. }
  10212. userJSONBytes, _ := json.Marshal(dat)
  10213. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10214. utils.ErrorLog("解析失败:%v", err)
  10215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10216. return
  10217. }
  10218. } else if miConfig.MdtrtareaAdmvs == "420200" {
  10219. p, _ := service.GetHisPatientById(patient_id)
  10220. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  10221. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10222. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10223. resp, requestErr := http.Get(api)
  10224. if requestErr != nil {
  10225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10226. return
  10227. }
  10228. body, ioErr := ioutil.ReadAll(resp.Body)
  10229. if ioErr != nil {
  10230. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10232. return
  10233. }
  10234. var respJSON map[string]interface{}
  10235. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10236. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10238. return
  10239. }
  10240. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10241. result, _ := json.Marshal(respJSON)
  10242. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10243. utils.ErrorLog("解析失败:%v", err)
  10244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10245. return
  10246. }
  10247. } else if miConfig.MdtrtareaAdmvs == "420902" {
  10248. p, _ := service.GetHisPatientById(patient_id)
  10249. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  10250. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10251. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10252. resp, requestErr := http.Get(api)
  10253. if requestErr != nil {
  10254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10255. return
  10256. }
  10257. body, ioErr := ioutil.ReadAll(resp.Body)
  10258. if ioErr != nil {
  10259. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10261. return
  10262. }
  10263. var respJSON map[string]interface{}
  10264. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10265. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10267. return
  10268. }
  10269. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10270. result, _ := json.Marshal(respJSON)
  10271. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10272. utils.ErrorLog("解析失败:%v", err)
  10273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10274. return
  10275. }
  10276. } else if miConfig.MdtrtareaAdmvs == "421182" {
  10277. p, _ := service.GetHisPatientById(patient_id)
  10278. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  10279. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10280. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10281. resp, requestErr := http.Get(api)
  10282. if requestErr != nil {
  10283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10284. return
  10285. }
  10286. body, ioErr := ioutil.ReadAll(resp.Body)
  10287. if ioErr != nil {
  10288. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10290. return
  10291. }
  10292. var respJSON map[string]interface{}
  10293. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10294. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10296. return
  10297. }
  10298. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10299. result, _ := json.Marshal(respJSON)
  10300. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10301. utils.ErrorLog("解析失败:%v", err)
  10302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10303. return
  10304. }
  10305. } else if miConfig.MdtrtareaAdmvs == "420902" {
  10306. p, _ := service.GetHisPatientById(patient_id)
  10307. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  10308. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10309. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10310. resp, requestErr := http.Get(api)
  10311. if requestErr != nil {
  10312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10313. return
  10314. }
  10315. body, ioErr := ioutil.ReadAll(resp.Body)
  10316. if ioErr != nil {
  10317. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10319. return
  10320. }
  10321. var respJSON map[string]interface{}
  10322. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10323. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10325. return
  10326. }
  10327. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10328. result, _ := json.Marshal(respJSON)
  10329. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10330. utils.ErrorLog("解析失败:%v", err)
  10331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10332. return
  10333. }
  10334. } else if miConfig.MdtrtareaAdmvs == "421300" {
  10335. p, _ := service.GetHisPatientById(patient_id)
  10336. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  10337. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10338. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10339. resp, requestErr := http.Get(api)
  10340. if requestErr != nil {
  10341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10342. return
  10343. }
  10344. body, ioErr := ioutil.ReadAll(resp.Body)
  10345. if ioErr != nil {
  10346. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10348. return
  10349. }
  10350. var respJSON map[string]interface{}
  10351. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10352. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10354. return
  10355. }
  10356. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10357. result, _ := json.Marshal(respJSON)
  10358. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10359. utils.ErrorLog("解析失败:%v", err)
  10360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10361. return
  10362. }
  10363. } else if miConfig.MdtrtareaAdmvs == "441799" {
  10364. p, _ := service.GetHisPatientById(patient_id)
  10365. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  10366. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10367. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10368. resp, requestErr := http.Get(api)
  10369. if requestErr != nil {
  10370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10371. return
  10372. }
  10373. body, ioErr := ioutil.ReadAll(resp.Body)
  10374. if ioErr != nil {
  10375. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10377. return
  10378. }
  10379. var respJSON map[string]interface{}
  10380. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10381. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10383. return
  10384. }
  10385. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10386. result, _ := json.Marshal(respJSON)
  10387. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10388. utils.ErrorLog("解析失败:%v", err)
  10389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10390. return
  10391. }
  10392. } else {
  10393. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  10394. var dat map[string]interface{}
  10395. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10396. fmt.Println(dat)
  10397. } else {
  10398. fmt.Println(err)
  10399. }
  10400. userJSONBytes, _ := json.Marshal(dat)
  10401. if miConfig.Code == "H15049901371" {
  10402. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10403. utils.ErrorLog("解析失败:%v", err)
  10404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10405. return
  10406. }
  10407. res.InfRefmsgid = res10265.InfRefmsgid
  10408. res.Output = res10265.Output
  10409. res.ErrMsg = res10265.ErrMsg
  10410. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10411. res.Infcode = infocode
  10412. } else {
  10413. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10414. utils.ErrorLog("解析失败:%v", err)
  10415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10416. return
  10417. }
  10418. }
  10419. }
  10420. if res.Infcode == 0 {
  10421. c.ServeSuccessJSON(map[string]interface{}{
  10422. "result": res.Output.Result,
  10423. })
  10424. }
  10425. }
  10426. func (c *HisApiController) CheckInsutype() {
  10427. his_patient_id, _ := c.GetInt64("his_patient_id")
  10428. admin_user_id, _ := c.GetInt64("admin_user_id")
  10429. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10430. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10431. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10432. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10433. var dat map[string]interface{}
  10434. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10435. fmt.Println(dat)
  10436. } else {
  10437. fmt.Println(err)
  10438. }
  10439. userJSONBytes, _ := json.Marshal(dat)
  10440. var res Result90100
  10441. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10442. utils.ErrorLog("解析失败:%v", err)
  10443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10444. return
  10445. }
  10446. if res.Infcode != 0 {
  10447. c.ServeSuccessJSON(map[string]interface{}{
  10448. "failed_code": -10,
  10449. "msg": res.ErrMsg,
  10450. })
  10451. return
  10452. } else {
  10453. fmt.Println(res)
  10454. }
  10455. }
  10456. func (c *HisApiController) CheckCardPWD() {
  10457. card_pwd := c.GetString("card_pwd")
  10458. his_patient_id, _ := c.GetInt64("his_patient_id")
  10459. admin_user_id, _ := c.GetInt64("admin_user_id")
  10460. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10461. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10462. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10463. psn, _ := service.GetPsnByPatientId(his.PatientId)
  10464. bas := strings.Split(psn.CardInfo, "|")
  10465. basNumber := bas[2]
  10466. if psn.InsuplcAdmdvs[:4] == "4403" {
  10467. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  10468. var dat map[string]interface{}
  10469. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10470. fmt.Println(dat)
  10471. } else {
  10472. fmt.Println(err)
  10473. }
  10474. userJSONBytes, _ := json.Marshal(dat)
  10475. var res Result90991
  10476. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10477. utils.ErrorLog("解析失败:%v", err)
  10478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10479. return
  10480. }
  10481. if res.Infcode != 0 {
  10482. c.ServeSuccessJSON(map[string]interface{}{
  10483. "failed_code": -10,
  10484. "msg": res.ErrMsg,
  10485. })
  10486. return
  10487. } else {
  10488. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  10489. var msg string
  10490. switch res.Output.Result.CardStat {
  10491. case "00":
  10492. msg = "未激活"
  10493. break
  10494. case "10":
  10495. msg = "激活"
  10496. break
  10497. case "20":
  10498. msg = "窗口挂失"
  10499. break
  10500. case "21":
  10501. msg = "电话挂失"
  10502. break
  10503. case "22":
  10504. msg = "单位网上申报挂失"
  10505. break
  10506. case "23":
  10507. msg = "保健办挂失"
  10508. break
  10509. case "24":
  10510. msg = "个人网上挂失"
  10511. break
  10512. case "25":
  10513. msg = "网上服务大厅挂失"
  10514. break
  10515. case "30":
  10516. msg = "注销"
  10517. break
  10518. case "40":
  10519. msg = "回收"
  10520. break
  10521. case "99":
  10522. msg = "制卡中(无效卡)"
  10523. break
  10524. }
  10525. c.ServeSuccessJSON(map[string]interface{}{
  10526. "failed_code": -10,
  10527. "msg": msg,
  10528. })
  10529. return
  10530. } else {
  10531. c.ServeSuccessJSON(map[string]interface{}{
  10532. "msg": "校验成功",
  10533. })
  10534. return
  10535. }
  10536. }
  10537. } else {
  10538. c.ServeSuccessJSON(map[string]interface{}{
  10539. "msg": "校验成功",
  10540. })
  10541. return
  10542. }
  10543. }
  10544. func (c *HisApiController) CheckCardPWDTwo() {
  10545. //card_pwd := c.GetString("card_pwd")
  10546. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10547. admin_user_id, _ := c.GetInt64("admin_user_id")
  10548. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10549. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10550. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  10551. var dat map[string]interface{}
  10552. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10553. fmt.Println(dat)
  10554. } else {
  10555. fmt.Println(err)
  10556. }
  10557. userJSONBytes, _ := json.Marshal(dat)
  10558. var res Result90991
  10559. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10560. utils.ErrorLog("解析失败:%v", err)
  10561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10562. return
  10563. }
  10564. if res.Infcode != 0 {
  10565. c.ServeSuccessJSON(map[string]interface{}{
  10566. "failed_code": -10,
  10567. "msg": res.ErrMsg,
  10568. })
  10569. return
  10570. } else {
  10571. if res.Output.Result.SscnoCheckStat == "0" {
  10572. var msg string
  10573. switch res.Output.Result.CardStat {
  10574. case "00":
  10575. msg = "未激活"
  10576. break
  10577. case "10":
  10578. msg = "激活"
  10579. break
  10580. case "20":
  10581. msg = "窗口挂失"
  10582. break
  10583. case "21":
  10584. msg = "电话挂失"
  10585. break
  10586. case "22":
  10587. msg = "单位网上申报挂失"
  10588. break
  10589. case "23":
  10590. msg = "保健办挂失"
  10591. break
  10592. case "24":
  10593. msg = "个人网上挂失"
  10594. break
  10595. case "25":
  10596. msg = "网上服务大厅挂失"
  10597. break
  10598. case "30":
  10599. msg = "注销"
  10600. break
  10601. case "40":
  10602. msg = "回收"
  10603. break
  10604. case "99":
  10605. msg = "制卡中(无效卡)"
  10606. break
  10607. }
  10608. c.ServeSuccessJSON(map[string]interface{}{
  10609. "failed_code": -10,
  10610. "msg": msg,
  10611. })
  10612. return
  10613. } else {
  10614. c.ServeSuccessJSON(map[string]interface{}{
  10615. "msg": "校验成功",
  10616. })
  10617. return
  10618. }
  10619. }
  10620. }
  10621. type ELeCertData struct {
  10622. Data struct {
  10623. Extra string `json:"extra"`
  10624. IDNo string `json:"idNo"`
  10625. IDType string `json:"idType"`
  10626. EcToken string `json:"ecToken"`
  10627. InsuOrg string `json:"insuOrg"`
  10628. UserName string `json:"userName"`
  10629. EcIndexNo string `json:"ecIndexNo"`
  10630. Gender string `json:"gender"`
  10631. Birthday string `json:"birthday"`
  10632. Nationality string `json:"nationality"`
  10633. Email string `json:"email"`
  10634. } `json:"OutData"`
  10635. }
  10636. func (c *HisApiController) ReadCard() {
  10637. id_card_type, _ := c.GetInt64("id_card_type")
  10638. admin_user_id, _ := c.GetInt64("admin_user_id")
  10639. certificates, _ := c.GetInt64("certificates")
  10640. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  10641. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10642. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10643. switch id_card_type {
  10644. case 1:
  10645. if miConfig.MdtrtareaAdmvs == "421300" {
  10646. var res ResultTwo
  10647. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  10648. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10649. "&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)
  10650. resp, requestErr := http.Get(api)
  10651. if requestErr != nil {
  10652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10653. return
  10654. }
  10655. body, ioErr := ioutil.ReadAll(resp.Body)
  10656. if ioErr != nil {
  10657. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10659. return
  10660. }
  10661. var respJSON map[string]interface{}
  10662. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10665. return
  10666. }
  10667. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10668. result, _ := json.Marshal(respJSON)
  10669. fmt.Println("log")
  10670. fmt.Println(string(result))
  10671. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10672. utils.ErrorLog("解析失败:%v", err)
  10673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10674. return
  10675. }
  10676. if res.Infcode == 0 {
  10677. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10678. if err == gorm.ErrRecordNotFound {
  10679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10680. return
  10681. } else if err != nil {
  10682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10683. return
  10684. } else {
  10685. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10686. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10687. infoStr := string(Iinfos)
  10688. idetinfoStr := string(Idetinfos)
  10689. var rf []*ResultFive
  10690. json.Unmarshal([]byte(infoStr), &rf)
  10691. var insutypes []*ResultFive
  10692. var insutype string
  10693. var is390 int = 0
  10694. var is310 int = 0
  10695. for _, item := range rf {
  10696. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  10697. insutypes = append(insutypes, item)
  10698. }
  10699. }
  10700. if len(insutypes) == 1 {
  10701. insutype = insutypes[0].Insutype
  10702. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10703. } else {
  10704. for _, i := range insutypes {
  10705. if i.Insutype == "390" {
  10706. is390 = 1
  10707. }
  10708. if i.Insutype == "310" {
  10709. is310 = 1
  10710. }
  10711. }
  10712. }
  10713. if is390 == 1 {
  10714. insutype = "390"
  10715. }
  10716. if is310 == 1 {
  10717. insutype = "310"
  10718. }
  10719. if len(insutypes) == 0 {
  10720. insutype = "390"
  10721. }
  10722. var insuplc_admdvs string
  10723. for _, item := range rf {
  10724. if item.Insutype == insutype {
  10725. insuplc_admdvs = item.InsuplcAdmdvs
  10726. }
  10727. }
  10728. if strings.Contains(insuplc_admdvs, "4213") {
  10729. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  10730. }
  10731. psn := &models.HisPsn{
  10732. PsnNo: res.Output.Baseinfo.PsnNo,
  10733. PatientId: patient.ID,
  10734. Certno: res.Output.Baseinfo.Certno,
  10735. Gend: res.Output.Baseinfo.Gend,
  10736. Naty: res.Output.Baseinfo.Naty,
  10737. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10738. PsnName: res.Output.Baseinfo.PsnName,
  10739. Idetinfo: idetinfoStr,
  10740. Insuinfo: infoStr,
  10741. InsuplcAdmdvs: insuplc_admdvs,
  10742. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10743. }
  10744. service.CreateHisPsn(psn)
  10745. c.ServeSuccessJSON(map[string]interface{}{
  10746. "patient": patient,
  10747. "number": res.Output.Baseinfo.Certno,
  10748. })
  10749. }
  10750. } else {
  10751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10752. return
  10753. }
  10754. } else if miConfig.MdtrtareaAdmvs == "420200" {
  10755. var res ResultTwo
  10756. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  10757. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10758. "&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)
  10759. resp, requestErr := http.Get(api)
  10760. if requestErr != nil {
  10761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10762. return
  10763. }
  10764. body, ioErr := ioutil.ReadAll(resp.Body)
  10765. if ioErr != nil {
  10766. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10768. return
  10769. }
  10770. var respJSON map[string]interface{}
  10771. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10772. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10774. return
  10775. }
  10776. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10777. result, _ := json.Marshal(respJSON)
  10778. fmt.Println("log")
  10779. fmt.Println(string(result))
  10780. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10781. utils.ErrorLog("解析失败:%v", err)
  10782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10783. return
  10784. }
  10785. if res.Infcode == 0 {
  10786. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10787. if err == gorm.ErrRecordNotFound {
  10788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10789. return
  10790. } else if err != nil {
  10791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10792. return
  10793. } else {
  10794. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10795. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10796. infoStr := string(Iinfos)
  10797. idetinfoStr := string(Idetinfos)
  10798. psn := &models.HisPsn{
  10799. PsnNo: res.Output.Baseinfo.PsnNo,
  10800. PatientId: patient.ID,
  10801. Certno: res.Output.Baseinfo.Certno,
  10802. Gend: res.Output.Baseinfo.Gend,
  10803. Naty: res.Output.Baseinfo.Naty,
  10804. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10805. PsnName: res.Output.Baseinfo.PsnName,
  10806. Idetinfo: idetinfoStr,
  10807. Insuinfo: infoStr,
  10808. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10809. }
  10810. service.CreateHisPsn(psn)
  10811. var rf []*ResultFive
  10812. json.Unmarshal([]byte(infoStr), &rf)
  10813. var insutypes []*ResultFive
  10814. var insutype string
  10815. var is390 int = 0
  10816. var is310 int = 0
  10817. for _, item := range rf {
  10818. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10819. insutypes = append(insutypes, item)
  10820. }
  10821. }
  10822. if len(insutypes) == 1 {
  10823. insutype = insutypes[0].Insutype
  10824. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10825. } else {
  10826. for _, i := range insutypes {
  10827. if i.Insutype == "390" {
  10828. is390 = 1
  10829. }
  10830. if i.Insutype == "310" {
  10831. is310 = 1
  10832. }
  10833. }
  10834. }
  10835. if is390 == 1 {
  10836. insutype = "390"
  10837. }
  10838. if is310 == 1 {
  10839. insutype = "310"
  10840. }
  10841. if len(insutypes) == 0 {
  10842. insutype = "310"
  10843. }
  10844. c.ServeSuccessJSON(map[string]interface{}{
  10845. "patient": patient,
  10846. "number": res.Output.Baseinfo.Certno,
  10847. "insutype": insutype,
  10848. })
  10849. }
  10850. } else {
  10851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10852. return
  10853. }
  10854. } else if miConfig.MdtrtareaAdmvs == "420902" {
  10855. var res ResultTwo
  10856. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  10857. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10858. "&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)
  10859. resp, requestErr := http.Get(api)
  10860. if requestErr != nil {
  10861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10862. return
  10863. }
  10864. body, ioErr := ioutil.ReadAll(resp.Body)
  10865. if ioErr != nil {
  10866. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10868. return
  10869. }
  10870. var respJSON map[string]interface{}
  10871. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10874. return
  10875. }
  10876. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10877. result, _ := json.Marshal(respJSON)
  10878. fmt.Println("log")
  10879. fmt.Println(string(result))
  10880. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10881. utils.ErrorLog("解析失败:%v", err)
  10882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10883. return
  10884. }
  10885. if res.Infcode == 0 {
  10886. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10887. if err == gorm.ErrRecordNotFound {
  10888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10889. return
  10890. } else if err != nil {
  10891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10892. return
  10893. } else {
  10894. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10895. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10896. infoStr := string(Iinfos)
  10897. idetinfoStr := string(Idetinfos)
  10898. var rf []*ResultFive
  10899. json.Unmarshal([]byte(infoStr), &rf)
  10900. var insutypes []*ResultFive
  10901. var insutype string
  10902. var is390 int = 0
  10903. var is310 int = 0
  10904. for _, item := range rf {
  10905. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  10906. insutypes = append(insutypes, item)
  10907. }
  10908. }
  10909. if len(insutypes) == 1 {
  10910. insutype = insutypes[0].Insutype
  10911. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10912. } else {
  10913. for _, i := range insutypes {
  10914. if i.Insutype == "390" {
  10915. is390 = 1
  10916. }
  10917. if i.Insutype == "310" {
  10918. is310 = 1
  10919. }
  10920. }
  10921. }
  10922. if is390 == 1 {
  10923. insutype = "390"
  10924. }
  10925. if is310 == 1 {
  10926. insutype = "310"
  10927. }
  10928. if len(insutypes) == 0 {
  10929. insutype = "390"
  10930. }
  10931. var insuplc_admdvs string
  10932. for _, item := range rf {
  10933. if item.Insutype == insutype {
  10934. insuplc_admdvs = item.InsuplcAdmdvs
  10935. }
  10936. }
  10937. psn := &models.HisPsn{
  10938. PsnNo: res.Output.Baseinfo.PsnNo,
  10939. PatientId: patient.ID,
  10940. Certno: res.Output.Baseinfo.Certno,
  10941. Gend: res.Output.Baseinfo.Gend,
  10942. Naty: res.Output.Baseinfo.Naty,
  10943. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10944. PsnName: res.Output.Baseinfo.PsnName,
  10945. Idetinfo: idetinfoStr,
  10946. Insuinfo: infoStr,
  10947. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10948. InsuplcAdmdvs: insuplc_admdvs,
  10949. }
  10950. service.CreateHisPsn(psn)
  10951. for _, item := range rf {
  10952. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10953. insutypes = append(insutypes, item)
  10954. }
  10955. }
  10956. if len(insutypes) == 1 {
  10957. insutype = insutypes[0].Insutype
  10958. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10959. } else {
  10960. for _, i := range insutypes {
  10961. if i.Insutype == "390" {
  10962. is390 = 1
  10963. }
  10964. if i.Insutype == "310" {
  10965. is310 = 1
  10966. }
  10967. }
  10968. }
  10969. if is390 == 1 {
  10970. insutype = "390"
  10971. }
  10972. if is310 == 1 {
  10973. insutype = "310"
  10974. }
  10975. if len(insutypes) == 0 {
  10976. insutype = "310"
  10977. }
  10978. c.ServeSuccessJSON(map[string]interface{}{
  10979. "patient": patient,
  10980. "number": res.Output.Baseinfo.Certno,
  10981. "insutype": insutype,
  10982. })
  10983. }
  10984. } else {
  10985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10986. return
  10987. }
  10988. } else if miConfig.MdtrtareaAdmvs == "421182" {
  10989. var res ResultTwo
  10990. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  10991. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10992. "&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)
  10993. resp, requestErr := http.Get(api)
  10994. if requestErr != nil {
  10995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10996. return
  10997. }
  10998. body, ioErr := ioutil.ReadAll(resp.Body)
  10999. if ioErr != nil {
  11000. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11002. return
  11003. }
  11004. var respJSON map[string]interface{}
  11005. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11006. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11008. return
  11009. }
  11010. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11011. result, _ := json.Marshal(respJSON)
  11012. fmt.Println("log")
  11013. fmt.Println(string(result))
  11014. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11015. utils.ErrorLog("解析失败:%v", err)
  11016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11017. return
  11018. }
  11019. if res.Infcode == 0 {
  11020. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11021. if err == gorm.ErrRecordNotFound {
  11022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11023. return
  11024. } else if err != nil {
  11025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11026. return
  11027. } else {
  11028. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11029. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11030. infoStr := string(Iinfos)
  11031. idetinfoStr := string(Idetinfos)
  11032. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  11033. psn := &models.HisPsn{
  11034. PsnNo: res.Output.Baseinfo.PsnNo,
  11035. PatientId: patient.ID,
  11036. Certno: res.Output.Baseinfo.Certno,
  11037. Brdy: b,
  11038. Age: float64(age),
  11039. Gend: res.Output.Baseinfo.Gend,
  11040. Naty: res.Output.Baseinfo.Naty,
  11041. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11042. PsnName: res.Output.Baseinfo.PsnName,
  11043. Idetinfo: idetinfoStr,
  11044. Insuinfo: infoStr,
  11045. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11046. }
  11047. service.CreateHisPsn(psn)
  11048. var rf []*ResultFive
  11049. json.Unmarshal([]byte(infoStr), &rf)
  11050. var insutypes []*ResultFive
  11051. var insutype string
  11052. var is390 int = 0
  11053. var is310 int = 0
  11054. for _, item := range rf {
  11055. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11056. insutypes = append(insutypes, item)
  11057. }
  11058. }
  11059. if len(insutypes) == 1 {
  11060. insutype = insutypes[0].Insutype
  11061. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11062. } else {
  11063. for _, i := range insutypes {
  11064. if i.Insutype == "390" {
  11065. is390 = 1
  11066. }
  11067. if i.Insutype == "310" {
  11068. is310 = 1
  11069. }
  11070. }
  11071. }
  11072. if is390 == 1 {
  11073. insutype = "390"
  11074. }
  11075. if is310 == 1 {
  11076. insutype = "310"
  11077. }
  11078. if len(insutypes) == 0 {
  11079. insutype = "310"
  11080. }
  11081. c.ServeSuccessJSON(map[string]interface{}{
  11082. "patient": patient,
  11083. "number": res.Output.Baseinfo.Certno,
  11084. "insutype": insutype,
  11085. })
  11086. }
  11087. } else {
  11088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11089. return
  11090. }
  11091. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11092. var api string
  11093. if miConfig.MdtrtareaAdmvs == "320921" {
  11094. 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 +
  11095. "&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
  11096. fmt.Println(api)
  11097. } else {
  11098. 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 +
  11099. "&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)
  11100. }
  11101. resp, requestErr := http.Get(api)
  11102. if requestErr != nil {
  11103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11104. return
  11105. }
  11106. body, ioErr := ioutil.ReadAll(resp.Body)
  11107. if ioErr != nil {
  11108. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11110. return
  11111. }
  11112. var respJSON map[string]interface{}
  11113. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11114. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11116. return
  11117. }
  11118. var status string
  11119. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11120. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11121. //console.log()
  11122. fmt.Println("type===")
  11123. fmt.Println(card_type)
  11124. var token string
  11125. var res ResultTwo //1101结果
  11126. var res10265 ResultTwo10265 //1101结果
  11127. var card_info string //卡信息
  11128. var busi_card_info string
  11129. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11130. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11131. if status == "0" { //读卡成功
  11132. if card_type == "1" {
  11133. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11134. result, _ := json.Marshal(respJSON)
  11135. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11136. utils.ErrorLog("解析失败:%v", err)
  11137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11138. return
  11139. }
  11140. res.ErrMsg = res10265.ErrMsg
  11141. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11142. res.Infcode = infocode
  11143. res.Output = res10265.Output
  11144. res.InfRefmsgid = res10265.InfRefmsgid
  11145. } else {
  11146. //var card_info string //卡信息
  11147. //var busi_card_info string
  11148. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11149. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11150. //fmt.Println(card_info)
  11151. //fmt.Println(busi_card_info)
  11152. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11153. result, _ := json.Marshal(respJSON)
  11154. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11155. utils.ErrorLog("解析失败:%v", err)
  11156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11157. return
  11158. }
  11159. res.ErrMsg = res10265.ErrMsg
  11160. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11161. res.Infcode = infocode
  11162. res.Output = res10265.Output
  11163. res.InfRefmsgid = res10265.InfRefmsgid
  11164. }
  11165. if res.Infcode == 0 {
  11166. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11167. if err == gorm.ErrRecordNotFound {
  11168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11169. return
  11170. } else if err != nil {
  11171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11172. return
  11173. } else {
  11174. if card_type == "1" {
  11175. bas := strings.Split(card_info, "|")
  11176. basNumber := bas[2]
  11177. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11178. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11179. infoStr := string(Iinfos)
  11180. idetinfoStr := string(Idetinfos)
  11181. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  11182. psn := &models.HisPsn{
  11183. PsnNo: res.Output.Baseinfo.PsnNo,
  11184. PatientId: patient.ID,
  11185. Certno: res.Output.Baseinfo.Certno,
  11186. Brdy: b,
  11187. Age: float64(age),
  11188. Gend: res.Output.Baseinfo.Gend,
  11189. Naty: res.Output.Baseinfo.Naty,
  11190. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11191. PsnName: res.Output.Baseinfo.PsnName,
  11192. Idetinfo: idetinfoStr,
  11193. Insuinfo: infoStr,
  11194. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11195. CardInfo: card_info,
  11196. VerifyNumber: busi_card_info,
  11197. }
  11198. service.CreateHisPsn(psn)
  11199. var rf []*ResultFive
  11200. json.Unmarshal([]byte(infoStr), &rf)
  11201. var insutypes []*ResultFive
  11202. var insutype string
  11203. var is390 int = 0
  11204. var is310 int = 0
  11205. for _, item := range rf {
  11206. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11207. insutypes = append(insutypes, item)
  11208. }
  11209. }
  11210. if len(insutypes) == 1 {
  11211. insutype = insutypes[0].Insutype
  11212. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11213. } else {
  11214. for _, i := range insutypes {
  11215. if i.Insutype == "390" {
  11216. is390 = 1
  11217. }
  11218. if i.Insutype == "310" {
  11219. is310 = 1
  11220. }
  11221. }
  11222. }
  11223. if is390 == 1 {
  11224. insutype = "390"
  11225. }
  11226. if is310 == 1 {
  11227. insutype = "310"
  11228. }
  11229. if len(insutypes) == 0 {
  11230. insutype = "310"
  11231. }
  11232. c.ServeSuccessJSON(map[string]interface{}{
  11233. "patient": patient,
  11234. "number": basNumber,
  11235. "insutype": insutype,
  11236. })
  11237. } else {
  11238. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11239. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11240. infoStr := string(Iinfos)
  11241. idetinfoStr := string(Idetinfos)
  11242. psn := &models.HisPsn{
  11243. PsnNo: res.Output.Baseinfo.PsnNo,
  11244. PatientId: patient.ID,
  11245. Certno: res.Output.Baseinfo.Certno,
  11246. Gend: res.Output.Baseinfo.Gend,
  11247. Naty: res.Output.Baseinfo.Naty,
  11248. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11249. PsnName: res.Output.Baseinfo.PsnName,
  11250. Idetinfo: idetinfoStr,
  11251. Insuinfo: infoStr,
  11252. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11253. CardInfo: card_info,
  11254. VerifyNumber: token,
  11255. }
  11256. service.CreateHisPsn(psn)
  11257. c.ServeSuccessJSON(map[string]interface{}{
  11258. "patient": patient,
  11259. "number": token,
  11260. })
  11261. }
  11262. }
  11263. } else {
  11264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11265. return
  11266. }
  11267. } else { //读卡失败
  11268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11269. return
  11270. }
  11271. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11272. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  11273. cardnum = DeleteExtraSpaceTwo(cardnum)
  11274. cardCode = DeleteExtraSpaceTwo(cardCode)
  11275. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  11276. name = DeleteExtraSpaceTwo(name)
  11277. errmsg = DeleteExtraSpaceTwo(errmsg)
  11278. cardnum = Remove0000(cardnum)
  11279. cardCode = Remove0000(cardCode)
  11280. id_card_no = Remove0000(id_card_no)
  11281. name = Remove0000(name)
  11282. errmsg = Remove0000(errmsg)
  11283. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  11284. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  11285. //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)
  11286. //fmt.Println(result2)
  11287. //fmt.Println(requestLog2)
  11288. //fmt.Println(errMsgLog2)
  11289. 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)
  11290. saveLog(result, requestLog, "1101", "获取人员信息")
  11291. fmt.Println(errMsgLog)
  11292. if len(errMsgLog) > 0 {
  11293. } else {
  11294. var dat map[string]interface{}
  11295. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11296. fmt.Println(dat)
  11297. } else {
  11298. fmt.Println(err)
  11299. }
  11300. userJSONBytes, _ := json.Marshal(dat)
  11301. var res ResultTwo
  11302. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11303. utils.ErrorLog("解析失败:%v", err)
  11304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11305. return
  11306. }
  11307. res.ErrMsg = errMsgLog
  11308. if res.Infcode == 0 {
  11309. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  11310. if err == gorm.ErrRecordNotFound {
  11311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11312. return
  11313. } else if err != nil {
  11314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11315. return
  11316. } else {
  11317. fmt.Println(res)
  11318. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11319. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11320. infoStr := string(Iinfos)
  11321. idetinfoStr := string(Idetinfos)
  11322. var rf []*ResultFive
  11323. json.Unmarshal([]byte(infoStr), &rf)
  11324. var insutypes []*ResultFive
  11325. var insutype string
  11326. var is390 int = 0
  11327. var is310 int = 0
  11328. for _, item := range rf {
  11329. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  11330. insutypes = append(insutypes, item)
  11331. }
  11332. }
  11333. if len(insutypes) == 1 {
  11334. insutype = insutypes[0].Insutype
  11335. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11336. } else {
  11337. for _, i := range insutypes {
  11338. if i.Insutype == "390" {
  11339. is390 = 1
  11340. }
  11341. if i.Insutype == "310" {
  11342. is310 = 1
  11343. }
  11344. }
  11345. }
  11346. if is390 == 1 {
  11347. insutype = "390"
  11348. }
  11349. if is310 == 1 {
  11350. insutype = "310"
  11351. }
  11352. if len(insutypes) == 0 {
  11353. insutype = "390"
  11354. }
  11355. var insuplc_admdvs string
  11356. for _, item := range rf {
  11357. if item.Insutype == insutype {
  11358. insuplc_admdvs = item.InsuplcAdmdvs
  11359. }
  11360. }
  11361. psn := &models.HisPsn{
  11362. PsnNo: res.Output.Baseinfo.PsnNo,
  11363. PatientId: patient.ID,
  11364. Certno: res.Output.Baseinfo.Certno,
  11365. Gend: res.Output.Baseinfo.Gend,
  11366. Naty: res.Output.Baseinfo.Naty,
  11367. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11368. PsnName: res.Output.Baseinfo.PsnName,
  11369. Idetinfo: idetinfoStr,
  11370. Insuinfo: infoStr,
  11371. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11372. CardInfo: basStr,
  11373. VerifyNumber: "",
  11374. InsuplcAdmdvs: insuplc_admdvs,
  11375. }
  11376. service.CreateHisPsn(psn)
  11377. c.ServeSuccessJSON(map[string]interface{}{
  11378. "patient": patient,
  11379. "number": cardnum,
  11380. "insutype": insutype,
  11381. })
  11382. }
  11383. } else {
  11384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11385. return
  11386. }
  11387. }
  11388. } else if miConfig.MdtrtareaAdmvs == "360302" {
  11389. fmt.Println(initFlag)
  11390. fmt.Println("initFlag")
  11391. if initFlag == 0 {
  11392. c.TestGetJiangXiBasBaseInit()
  11393. }
  11394. basStr := c.GetBasBaseInfo()
  11395. if len(basStr) == 0 {
  11396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11397. return
  11398. }
  11399. fmt.Println(basStr)
  11400. bas := strings.Split(basStr, "|")
  11401. basNumber := bas[1]
  11402. fmt.Println(basNumber)
  11403. card_sn := bas[3]
  11404. fmt.Println(card_sn)
  11405. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  11406. 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)
  11407. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  11408. var dat map[string]interface{}
  11409. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11410. fmt.Println(dat)
  11411. } else {
  11412. fmt.Println(err)
  11413. }
  11414. userJSONBytes, _ := json.Marshal(dat)
  11415. var res ResultTwo
  11416. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11417. utils.ErrorLog("解析失败:%v", err)
  11418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11419. return
  11420. }
  11421. if res.Infcode == 0 {
  11422. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  11423. if err == gorm.ErrRecordNotFound {
  11424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11425. return
  11426. } else if err != nil {
  11427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11428. return
  11429. } else {
  11430. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11431. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11432. infoStr := string(Iinfos)
  11433. idetinfoStr := string(Idetinfos)
  11434. var rf []*ResultFive
  11435. json.Unmarshal([]byte(infoStr), &rf)
  11436. var insutypes []*ResultFive
  11437. var insutype string
  11438. var is390 int = 0
  11439. var is310 int = 0
  11440. var insuplc_admdvs string
  11441. for _, item := range rf {
  11442. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11443. insutypes = append(insutypes, item)
  11444. }
  11445. }
  11446. if len(insutypes) == 1 {
  11447. insutype = insutypes[0].Insutype
  11448. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11449. } else {
  11450. for _, i := range insutypes {
  11451. if i.Insutype == "390" {
  11452. is390 = 1
  11453. }
  11454. if i.Insutype == "310" {
  11455. is310 = 1
  11456. }
  11457. }
  11458. }
  11459. if is390 == 1 {
  11460. insutype = "390"
  11461. }
  11462. if is310 == 1 {
  11463. insutype = "310"
  11464. }
  11465. if len(insutypes) == 0 {
  11466. insutype = "310"
  11467. }
  11468. for _, item := range rf {
  11469. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  11470. insuplc_admdvs = item.InsuplcAdmdvs
  11471. }
  11472. }
  11473. psn := &models.HisPsn{
  11474. PsnNo: res.Output.Baseinfo.PsnNo,
  11475. PatientId: patient.ID,
  11476. Certno: res.Output.Baseinfo.Certno,
  11477. Gend: res.Output.Baseinfo.Gend,
  11478. Naty: res.Output.Baseinfo.Naty,
  11479. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11480. PsnName: res.Output.Baseinfo.PsnName,
  11481. Idetinfo: idetinfoStr,
  11482. Insuinfo: infoStr,
  11483. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11484. CardInfo: basStr,
  11485. InsuplcAdmdvs: insuplc_admdvs,
  11486. VerifyNumber: "",
  11487. }
  11488. service.CreateHisPsn(psn)
  11489. c.ServeSuccessJSON(map[string]interface{}{
  11490. "patient": patient,
  11491. "number": basNumber,
  11492. "insutype": insutype,
  11493. })
  11494. }
  11495. } else {
  11496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11497. return
  11498. }
  11499. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11500. fmt.Println(initFlag)
  11501. fmt.Println("initFlag")
  11502. if initFlag == 0 {
  11503. c.TestGetHnBasBaseInit()
  11504. }
  11505. basStr := c.GetBasBaseInfo()
  11506. if len(basStr) == 0 {
  11507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11508. return
  11509. }
  11510. fmt.Println(basStr)
  11511. bas := strings.Split(basStr, "|")
  11512. basNumber := bas[1]
  11513. fmt.Println(basNumber)
  11514. card_sn := bas[3]
  11515. card_no := bas[2]
  11516. fmt.Println(card_sn)
  11517. name := bas[4]
  11518. name = ConvertToString(name, "gbk", "utf-8")
  11519. 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)
  11520. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  11521. var dat map[string]interface{}
  11522. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11523. fmt.Println(dat)
  11524. } else {
  11525. fmt.Println(err)
  11526. }
  11527. userJSONBytes, _ := json.Marshal(dat)
  11528. var res ResultTwo
  11529. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11530. utils.ErrorLog("解析失败:%v", err)
  11531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11532. return
  11533. }
  11534. if res.Infcode == 0 {
  11535. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  11536. if err == gorm.ErrRecordNotFound {
  11537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11538. return
  11539. } else if err != nil {
  11540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11541. return
  11542. } else {
  11543. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11544. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11545. infoStr := string(Iinfos)
  11546. idetinfoStr := string(Idetinfos)
  11547. psn := &models.HisPsn{
  11548. PsnNo: res.Output.Baseinfo.PsnNo,
  11549. PatientId: patient.ID,
  11550. Certno: res.Output.Baseinfo.Certno,
  11551. Gend: res.Output.Baseinfo.Gend,
  11552. Naty: res.Output.Baseinfo.Naty,
  11553. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11554. PsnName: res.Output.Baseinfo.PsnName,
  11555. Idetinfo: idetinfoStr,
  11556. Insuinfo: infoStr,
  11557. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11558. CardInfo: basStr,
  11559. VerifyNumber: "",
  11560. }
  11561. service.CreateHisPsn(psn)
  11562. var rf []*ResultFive
  11563. json.Unmarshal([]byte(infoStr), &rf)
  11564. var insutypes []*ResultFive
  11565. var insutype string
  11566. var is390 int = 0
  11567. var is310 int = 0
  11568. for _, item := range rf {
  11569. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11570. insutypes = append(insutypes, item)
  11571. }
  11572. }
  11573. if len(insutypes) == 1 {
  11574. insutype = insutypes[0].Insutype
  11575. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11576. } else {
  11577. for _, i := range insutypes {
  11578. if i.Insutype == "390" {
  11579. is390 = 1
  11580. }
  11581. if i.Insutype == "310" {
  11582. is310 = 1
  11583. }
  11584. }
  11585. }
  11586. if is390 == 1 {
  11587. insutype = "390"
  11588. }
  11589. if is310 == 1 {
  11590. insutype = "310"
  11591. }
  11592. if len(insutypes) == 0 {
  11593. insutype = "310"
  11594. }
  11595. c.ServeSuccessJSON(map[string]interface{}{
  11596. "patient": patient,
  11597. "number": basNumber,
  11598. "insutype": insutype,
  11599. })
  11600. }
  11601. } else {
  11602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11603. return
  11604. }
  11605. } else if miConfig.MdtrtareaAdmvs == "150499" {
  11606. var api string
  11607. 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 +
  11608. "&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
  11609. fmt.Println(api)
  11610. resp, requestErr := http.Get(api)
  11611. if requestErr != nil {
  11612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11613. return
  11614. }
  11615. body, ioErr := ioutil.ReadAll(resp.Body)
  11616. if ioErr != nil {
  11617. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11619. return
  11620. }
  11621. var respJSON map[string]interface{}
  11622. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11623. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11625. return
  11626. }
  11627. var res ResultTwo //1101结果
  11628. var res10265 ResultTwo10265 //1101结果
  11629. var card_info string //卡信息
  11630. token := respJSON["data"].(map[string]interface{})["token"].(string)
  11631. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11632. result, _ := json.Marshal(respJSON)
  11633. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11634. utils.ErrorLog("解析失败:%v", err)
  11635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11636. return
  11637. }
  11638. res.ErrMsg = res10265.ErrMsg
  11639. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11640. res.Infcode = infocode
  11641. res.Output = res10265.Output
  11642. res.InfRefmsgid = res10265.InfRefmsgid
  11643. if res.Infcode == 0 {
  11644. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11645. if err == gorm.ErrRecordNotFound {
  11646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11647. return
  11648. } else if err != nil {
  11649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11650. return
  11651. } else {
  11652. bas := strings.Split(card_info, "|")
  11653. basNumber := bas[2]
  11654. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11655. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11656. infoStr := string(Iinfos)
  11657. idetinfoStr := string(Idetinfos)
  11658. psn := &models.HisPsn{
  11659. PsnNo: res.Output.Baseinfo.PsnNo,
  11660. PatientId: patient.ID,
  11661. Certno: res.Output.Baseinfo.Certno,
  11662. Gend: res.Output.Baseinfo.Gend,
  11663. Naty: res.Output.Baseinfo.Naty,
  11664. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11665. PsnName: res.Output.Baseinfo.PsnName,
  11666. Idetinfo: idetinfoStr,
  11667. Insuinfo: infoStr,
  11668. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11669. CardInfo: card_info,
  11670. VerifyNumber: token,
  11671. }
  11672. service.CreateHisPsn(psn)
  11673. var rf []*ResultFive
  11674. json.Unmarshal([]byte(infoStr), &rf)
  11675. var insutypes []*ResultFive
  11676. var insutype string
  11677. var is390 int = 0
  11678. var is310 int = 0
  11679. for _, item := range rf {
  11680. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11681. insutypes = append(insutypes, item)
  11682. }
  11683. }
  11684. if len(insutypes) == 1 {
  11685. insutype = insutypes[0].Insutype
  11686. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11687. } else {
  11688. for _, i := range insutypes {
  11689. if i.Insutype == "390" {
  11690. is390 = 1
  11691. }
  11692. if i.Insutype == "310" {
  11693. is310 = 1
  11694. }
  11695. }
  11696. }
  11697. if is390 == 1 {
  11698. insutype = "390"
  11699. }
  11700. if is310 == 1 {
  11701. insutype = "310"
  11702. }
  11703. if len(insutypes) == 0 {
  11704. insutype = "310"
  11705. }
  11706. c.ServeSuccessJSON(map[string]interface{}{
  11707. "patient": patient,
  11708. "number": basNumber,
  11709. "insutype": insutype,
  11710. })
  11711. }
  11712. } else {
  11713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11714. return
  11715. }
  11716. } else if miConfig.MdtrtareaAdmvs == "450721" {
  11717. res := c.GetoleInfo()
  11718. if res.Infcode == 0 {
  11719. var result string
  11720. if res.Output.MdtrtCertType == "01" {
  11721. 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)
  11722. } else if res.Output.MdtrtCertType == "02" {
  11723. 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)
  11724. } else if res.Output.MdtrtCertType == "03" {
  11725. 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)
  11726. }
  11727. var dat map[string]interface{}
  11728. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11729. fmt.Println(dat)
  11730. } else {
  11731. fmt.Println(err)
  11732. }
  11733. userJSONBytes, _ := json.Marshal(dat)
  11734. var res2 ResultTwo
  11735. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11736. utils.ErrorLog("解析失败:%v", err)
  11737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11738. return
  11739. }
  11740. if res2.Infcode == 0 {
  11741. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  11742. if err == gorm.ErrRecordNotFound {
  11743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11744. return
  11745. } else if err != nil {
  11746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11747. return
  11748. } else {
  11749. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  11750. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  11751. infoStr := string(Iinfos)
  11752. idetinfoStr := string(Idetinfos)
  11753. var rf []*ResultFive
  11754. json.Unmarshal([]byte(infoStr), &rf)
  11755. var insutypes []*ResultFive
  11756. var insutype string
  11757. var is390 int = 0
  11758. var is310 int = 0
  11759. //var insuplc_admdvs string
  11760. for _, item := range rf {
  11761. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11762. insutypes = append(insutypes, item)
  11763. }
  11764. }
  11765. if len(insutypes) == 1 {
  11766. insutype = insutypes[0].Insutype
  11767. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11768. } else {
  11769. for _, i := range insutypes {
  11770. if i.Insutype == "390" {
  11771. is390 = 1
  11772. }
  11773. if i.Insutype == "310" {
  11774. is310 = 1
  11775. }
  11776. }
  11777. }
  11778. if is390 == 1 {
  11779. insutype = "390"
  11780. }
  11781. if is310 == 1 {
  11782. insutype = "310"
  11783. }
  11784. if len(insutypes) == 0 {
  11785. insutype = "310"
  11786. }
  11787. psn := &models.HisPsn{
  11788. PsnNo: res2.Output.Baseinfo.PsnNo,
  11789. PatientId: patient.ID,
  11790. Certno: res2.Output.Baseinfo.Certno,
  11791. Gend: res2.Output.Baseinfo.Gend,
  11792. Naty: res2.Output.Baseinfo.Naty,
  11793. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  11794. PsnName: res2.Output.Baseinfo.PsnName,
  11795. Idetinfo: idetinfoStr,
  11796. Insuinfo: infoStr,
  11797. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11798. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  11799. VerifyNumber: res.Output.EcToken,
  11800. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  11801. }
  11802. if res.Output.MdtrtCertType == "01" {
  11803. psn.VerifyNumber = res.Output.EcToken
  11804. //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)
  11805. } else if res.Output.MdtrtCertType == "02" {
  11806. psn.VerifyNumber = res.Output.MdtrtCertNo
  11807. //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)
  11808. } else if res.Output.MdtrtCertType == "03" {
  11809. psn.VerifyNumber = res.Output.MdtrtCertNo
  11810. //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)
  11811. }
  11812. var balc float64
  11813. for _, item := range rf {
  11814. if item.Insutype == insutype {
  11815. balc = item.Balc
  11816. }
  11817. }
  11818. service.CreateHisPsn(psn)
  11819. c.ServeSuccessJSON(map[string]interface{}{
  11820. "patient": patient,
  11821. "number": res.Output.CardNo,
  11822. "insutype": insutype,
  11823. "blac": balc,
  11824. "desc": idetinfoStr,
  11825. })
  11826. }
  11827. } else {
  11828. c.ServeSuccessJSON(map[string]interface{}{
  11829. "failed_code": -10,
  11830. "msg": res2.ErrMsg,
  11831. })
  11832. }
  11833. } else {
  11834. c.ServeSuccessJSON(map[string]interface{}{
  11835. "failed_code": -10,
  11836. "msg": res.ErrMsg,
  11837. })
  11838. }
  11839. } else if miConfig.MdtrtareaAdmvs == "341203" {
  11840. var api string
  11841. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  11842. "&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
  11843. fmt.Println(api)
  11844. resp, requestErr := http.Get(api)
  11845. if requestErr != nil {
  11846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11847. return
  11848. }
  11849. body, ioErr := ioutil.ReadAll(resp.Body)
  11850. if ioErr != nil {
  11851. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11853. return
  11854. }
  11855. var respJSON map[string]interface{}
  11856. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11857. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11859. return
  11860. }
  11861. var status string
  11862. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11863. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11864. //console.log()
  11865. fmt.Println("type===")
  11866. fmt.Println(card_type)
  11867. var token string
  11868. var res ResultTwo //1101结果
  11869. //var res10265 ResultTwoesultTwo10265 //1101结果
  11870. var card_info string //卡信息
  11871. var busi_card_info string
  11872. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11873. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11874. if status == "0" { //读卡成功
  11875. if card_type == "1" {
  11876. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11877. result, _ := json.Marshal(respJSON)
  11878. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11879. utils.ErrorLog("解析失败:%v", err)
  11880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11881. return
  11882. }
  11883. } else {
  11884. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11885. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11886. result, _ := json.Marshal(respJSON)
  11887. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11888. utils.ErrorLog("解析失败:%v", err)
  11889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11890. return
  11891. }
  11892. }
  11893. if res.Infcode == 0 {
  11894. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11895. if err == gorm.ErrRecordNotFound {
  11896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11897. return
  11898. } else if err != nil {
  11899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11900. return
  11901. } else {
  11902. if card_type == "1" {
  11903. bas := strings.Split(card_info, "|")
  11904. basNumber := bas[2]
  11905. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11906. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11907. infoStr := string(Iinfos)
  11908. idetinfoStr := string(Idetinfos)
  11909. psn := &models.HisPsn{
  11910. PsnNo: res.Output.Baseinfo.PsnNo,
  11911. PatientId: patient.ID,
  11912. Certno: res.Output.Baseinfo.Certno,
  11913. Gend: res.Output.Baseinfo.Gend,
  11914. Naty: res.Output.Baseinfo.Naty,
  11915. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11916. PsnName: res.Output.Baseinfo.PsnName,
  11917. Idetinfo: idetinfoStr,
  11918. Insuinfo: infoStr,
  11919. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11920. CardInfo: card_info,
  11921. VerifyNumber: busi_card_info,
  11922. }
  11923. service.CreateHisPsn(psn)
  11924. var rf []*ResultFive
  11925. json.Unmarshal([]byte(infoStr), &rf)
  11926. var insutypes []*ResultFive
  11927. var insutype string
  11928. var is390 int = 0
  11929. var is310 int = 0
  11930. for _, item := range rf {
  11931. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11932. insutypes = append(insutypes, item)
  11933. }
  11934. }
  11935. if len(insutypes) == 1 {
  11936. insutype = insutypes[0].Insutype
  11937. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11938. } else {
  11939. for _, i := range insutypes {
  11940. if i.Insutype == "390" {
  11941. is390 = 1
  11942. }
  11943. if i.Insutype == "310" {
  11944. is310 = 1
  11945. }
  11946. }
  11947. }
  11948. if is390 == 1 {
  11949. insutype = "390"
  11950. }
  11951. if is310 == 1 {
  11952. insutype = "310"
  11953. }
  11954. if len(insutypes) == 0 {
  11955. insutype = "310"
  11956. }
  11957. c.ServeSuccessJSON(map[string]interface{}{
  11958. "patient": patient,
  11959. "number": basNumber,
  11960. "insutype": insutype,
  11961. })
  11962. } else {
  11963. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11964. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11965. infoStr := string(Iinfos)
  11966. idetinfoStr := string(Idetinfos)
  11967. psn := &models.HisPsn{
  11968. PsnNo: res.Output.Baseinfo.PsnNo,
  11969. PatientId: patient.ID,
  11970. Certno: res.Output.Baseinfo.Certno,
  11971. Gend: res.Output.Baseinfo.Gend,
  11972. Naty: res.Output.Baseinfo.Naty,
  11973. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11974. PsnName: res.Output.Baseinfo.PsnName,
  11975. Idetinfo: idetinfoStr,
  11976. Insuinfo: infoStr,
  11977. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11978. CardInfo: card_info,
  11979. VerifyNumber: token,
  11980. }
  11981. service.CreateHisPsn(psn)
  11982. c.ServeSuccessJSON(map[string]interface{}{
  11983. "patient": patient,
  11984. "number": token,
  11985. })
  11986. }
  11987. }
  11988. } else {
  11989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11990. return
  11991. }
  11992. } else { //读卡失败
  11993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11994. return
  11995. }
  11996. } else {
  11997. if initFlag == 0 {
  11998. c.TestGetBasBaseInit()
  11999. }
  12000. basStr := c.GetBasBaseInfo()
  12001. if len(basStr) == 0 {
  12002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  12003. return
  12004. }
  12005. fmt.Println(basStr)
  12006. bas := strings.Split(basStr, "|")
  12007. basNumber := bas[1]
  12008. fmt.Println(basNumber)
  12009. card_sn := bas[3]
  12010. fmt.Println(card_sn)
  12011. cardNumber := bas[2]
  12012. fmt.Println(cardNumber)
  12013. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  12014. var result string
  12015. if bas[0][:2] == "44" {
  12016. 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)
  12017. } else {
  12018. 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)
  12019. }
  12020. var dat map[string]interface{}
  12021. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12022. fmt.Println(dat)
  12023. } else {
  12024. fmt.Println(err)
  12025. }
  12026. userJSONBytes, _ := json.Marshal(dat)
  12027. var res ResultTwo
  12028. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12029. utils.ErrorLog("解析失败:%v", err)
  12030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12031. return
  12032. }
  12033. if res.Infcode == 0 {
  12034. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  12035. if err == gorm.ErrRecordNotFound {
  12036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12037. return
  12038. } else if err != nil {
  12039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12040. return
  12041. } else {
  12042. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12043. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12044. infoStr := string(Iinfos)
  12045. idetinfoStr := string(Idetinfos)
  12046. var rf []*ResultFive
  12047. json.Unmarshal([]byte(infoStr), &rf)
  12048. var insutypes []*ResultFive
  12049. var insutype string
  12050. var is390 int = 0
  12051. var is310 int = 0
  12052. var insuplc_admdvs string
  12053. for _, item := range rf {
  12054. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12055. insutypes = append(insutypes, item)
  12056. }
  12057. }
  12058. if len(insutypes) == 1 {
  12059. insutype = insutypes[0].Insutype
  12060. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12061. } else {
  12062. for _, i := range insutypes {
  12063. if i.Insutype == "390" {
  12064. is390 = 1
  12065. }
  12066. if i.Insutype == "310" {
  12067. is310 = 1
  12068. }
  12069. }
  12070. }
  12071. if is390 == 1 {
  12072. insutype = "390"
  12073. }
  12074. if is310 == 1 {
  12075. insutype = "310"
  12076. }
  12077. if len(insutypes) == 0 {
  12078. insutype = "310"
  12079. }
  12080. for _, item := range rf {
  12081. if item.Insutype == insutype {
  12082. insuplc_admdvs = item.InsuplcAdmdvs
  12083. }
  12084. }
  12085. psn := &models.HisPsn{
  12086. PsnNo: res.Output.Baseinfo.PsnNo,
  12087. PatientId: patient.ID,
  12088. Certno: res.Output.Baseinfo.Certno,
  12089. Gend: res.Output.Baseinfo.Gend,
  12090. Naty: res.Output.Baseinfo.Naty,
  12091. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12092. PsnName: res.Output.Baseinfo.PsnName,
  12093. Idetinfo: idetinfoStr,
  12094. Insuinfo: infoStr,
  12095. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12096. CardInfo: basStr,
  12097. VerifyNumber: "",
  12098. InsuplcAdmdvs: insuplc_admdvs,
  12099. }
  12100. service.CreateHisPsn(psn)
  12101. c.ServeSuccessJSON(map[string]interface{}{
  12102. "patient": patient,
  12103. "number": basNumber,
  12104. })
  12105. }
  12106. } else {
  12107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12108. return
  12109. }
  12110. break
  12111. }
  12112. case 2:
  12113. if miConfig.MdtrtareaAdmvs == "430800" {
  12114. if initFlag == 0 {
  12115. c.TestGetHnBasBaseInit()
  12116. }
  12117. SFZStr := c.GetSFZBaseInfo()
  12118. if len(SFZStr) == 0 {
  12119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  12120. return
  12121. }
  12122. fmt.Println(SFZStr)
  12123. id_card_str := strings.Split(SFZStr, "^")
  12124. card_no := id_card_str[0]
  12125. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  12126. //name := id_card_str[1]
  12127. //name = ConvertToString(name, "gbk", "utf-8")
  12128. 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)
  12129. var dat map[string]interface{}
  12130. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12131. fmt.Println(dat)
  12132. } else {
  12133. fmt.Println(err)
  12134. }
  12135. userJSONBytes, _ := json.Marshal(dat)
  12136. var res ResultTwo
  12137. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12138. utils.ErrorLog("解析失败:%v", err)
  12139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12140. return
  12141. }
  12142. if res.Infcode == 0 {
  12143. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  12144. if err == gorm.ErrRecordNotFound {
  12145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12146. return
  12147. } else if err != nil {
  12148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12149. return
  12150. } else {
  12151. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12152. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12153. infoStr := string(Iinfos)
  12154. idetinfoStr := string(Idetinfos)
  12155. var rf []*ResultFive
  12156. json.Unmarshal([]byte(infoStr), &rf)
  12157. var insutypes []*ResultFive
  12158. var insutype string
  12159. var is390 int = 0
  12160. var is310 int = 0
  12161. for _, item := range rf {
  12162. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12163. insutypes = append(insutypes, item)
  12164. }
  12165. }
  12166. if len(insutypes) == 1 {
  12167. insutype = insutypes[0].Insutype
  12168. } else {
  12169. for _, i := range insutypes {
  12170. if i.Insutype == "390" {
  12171. is390 = 1
  12172. }
  12173. if i.Insutype == "310" {
  12174. is310 = 1
  12175. }
  12176. }
  12177. }
  12178. if is390 == 1 {
  12179. insutype = "390"
  12180. }
  12181. if is310 == 1 {
  12182. insutype = "310"
  12183. }
  12184. if len(insutypes) == 0 {
  12185. insutype = "310"
  12186. }
  12187. var InsuplcAdmdvs string
  12188. for _, item := range rf {
  12189. if item.Insutype == insutype {
  12190. InsuplcAdmdvs = item.InsuplcAdmdvs
  12191. }
  12192. }
  12193. psn := &models.HisPsn{
  12194. PsnNo: res.Output.Baseinfo.PsnNo,
  12195. PatientId: patient.ID,
  12196. Certno: res.Output.Baseinfo.Certno,
  12197. Gend: res.Output.Baseinfo.Gend,
  12198. Naty: res.Output.Baseinfo.Naty,
  12199. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12200. PsnName: res.Output.Baseinfo.PsnName,
  12201. Idetinfo: idetinfoStr,
  12202. Insuinfo: infoStr,
  12203. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12204. CardInfo: SFZStr,
  12205. VerifyNumber: "",
  12206. InsuplcAdmdvs: InsuplcAdmdvs,
  12207. }
  12208. service.CreateHisPsn(psn)
  12209. c.ServeSuccessJSON(map[string]interface{}{
  12210. "patient": patient,
  12211. "number": card_no,
  12212. "insutype": insutype,
  12213. })
  12214. }
  12215. } else {
  12216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12217. return
  12218. }
  12219. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12220. var res ResultTwo
  12221. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  12222. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12223. "&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)
  12224. resp, requestErr := http.Get(api)
  12225. if requestErr != nil {
  12226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12227. return
  12228. }
  12229. body, ioErr := ioutil.ReadAll(resp.Body)
  12230. if ioErr != nil {
  12231. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12233. return
  12234. }
  12235. var respJSON map[string]interface{}
  12236. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12237. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12239. return
  12240. }
  12241. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12242. result, _ := json.Marshal(respJSON)
  12243. fmt.Println("log")
  12244. fmt.Println(string(result))
  12245. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12246. utils.ErrorLog("解析失败:%v", err)
  12247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12248. return
  12249. }
  12250. if res.Infcode == 0 {
  12251. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12252. if err == gorm.ErrRecordNotFound {
  12253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12254. return
  12255. } else if err != nil {
  12256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12257. return
  12258. } else {
  12259. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12260. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12261. infoStr := string(Iinfos)
  12262. idetinfoStr := string(Idetinfos)
  12263. psn := &models.HisPsn{
  12264. PsnNo: res.Output.Baseinfo.PsnNo,
  12265. PatientId: patient.ID,
  12266. Certno: res.Output.Baseinfo.Certno,
  12267. Gend: res.Output.Baseinfo.Gend,
  12268. Naty: res.Output.Baseinfo.Naty,
  12269. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12270. PsnName: res.Output.Baseinfo.PsnName,
  12271. Idetinfo: idetinfoStr,
  12272. Insuinfo: infoStr,
  12273. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12274. }
  12275. service.CreateHisPsn(psn)
  12276. c.ServeSuccessJSON(map[string]interface{}{
  12277. "patient": patient,
  12278. "number": res.Output.Baseinfo.Certno,
  12279. })
  12280. }
  12281. } else {
  12282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12283. return
  12284. }
  12285. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12286. var res ResultTwo
  12287. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  12288. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12289. "&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)
  12290. resp, requestErr := http.Get(api)
  12291. if requestErr != nil {
  12292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12293. return
  12294. }
  12295. body, ioErr := ioutil.ReadAll(resp.Body)
  12296. if ioErr != nil {
  12297. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12299. return
  12300. }
  12301. var respJSON map[string]interface{}
  12302. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12305. return
  12306. }
  12307. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12308. result, _ := json.Marshal(respJSON)
  12309. fmt.Println("log")
  12310. fmt.Println(string(result))
  12311. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12312. utils.ErrorLog("解析失败:%v", err)
  12313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12314. return
  12315. }
  12316. if res.Infcode == 0 {
  12317. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12318. if err == gorm.ErrRecordNotFound {
  12319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12320. return
  12321. } else if err != nil {
  12322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12323. return
  12324. } else {
  12325. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12326. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12327. infoStr := string(Iinfos)
  12328. idetinfoStr := string(Idetinfos)
  12329. psn := &models.HisPsn{
  12330. PsnNo: res.Output.Baseinfo.PsnNo,
  12331. PatientId: patient.ID,
  12332. Certno: res.Output.Baseinfo.Certno,
  12333. Gend: res.Output.Baseinfo.Gend,
  12334. Naty: res.Output.Baseinfo.Naty,
  12335. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12336. PsnName: res.Output.Baseinfo.PsnName,
  12337. Idetinfo: idetinfoStr,
  12338. Insuinfo: infoStr,
  12339. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12340. }
  12341. service.CreateHisPsn(psn)
  12342. c.ServeSuccessJSON(map[string]interface{}{
  12343. "patient": patient,
  12344. "number": res.Output.Baseinfo.Certno,
  12345. })
  12346. }
  12347. } else {
  12348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12349. return
  12350. }
  12351. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12352. var res ResultTwo
  12353. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  12354. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12355. "&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)
  12356. resp, requestErr := http.Get(api)
  12357. if requestErr != nil {
  12358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12359. return
  12360. }
  12361. body, ioErr := ioutil.ReadAll(resp.Body)
  12362. if ioErr != nil {
  12363. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12365. return
  12366. }
  12367. var respJSON map[string]interface{}
  12368. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12371. return
  12372. }
  12373. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12374. result, _ := json.Marshal(respJSON)
  12375. fmt.Println("log")
  12376. fmt.Println(string(result))
  12377. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12378. utils.ErrorLog("解析失败:%v", err)
  12379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12380. return
  12381. }
  12382. if res.Infcode == 0 {
  12383. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12384. if err == gorm.ErrRecordNotFound {
  12385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12386. return
  12387. } else if err != nil {
  12388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12389. return
  12390. } else {
  12391. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12392. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12393. infoStr := string(Iinfos)
  12394. idetinfoStr := string(Idetinfos)
  12395. var rf []*ResultFive
  12396. json.Unmarshal([]byte(infoStr), &rf)
  12397. var insutypes []*ResultFive
  12398. var insutype string
  12399. var is390 int = 0
  12400. var is310 int = 0
  12401. for _, item := range rf {
  12402. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12403. insutypes = append(insutypes, item)
  12404. }
  12405. }
  12406. if len(insutypes) == 1 {
  12407. insutype = insutypes[0].Insutype
  12408. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12409. } else {
  12410. for _, i := range insutypes {
  12411. if i.Insutype == "390" {
  12412. is390 = 1
  12413. }
  12414. if i.Insutype == "310" {
  12415. is310 = 1
  12416. }
  12417. }
  12418. }
  12419. if is390 == 1 {
  12420. insutype = "390"
  12421. }
  12422. if is310 == 1 {
  12423. insutype = "310"
  12424. }
  12425. if len(insutypes) == 0 {
  12426. insutype = "390"
  12427. }
  12428. var insuplc_admdvs string
  12429. for _, item := range rf {
  12430. if item.Insutype == insutype {
  12431. insuplc_admdvs = item.InsuplcAdmdvs
  12432. }
  12433. }
  12434. psn := &models.HisPsn{
  12435. PsnNo: res.Output.Baseinfo.PsnNo,
  12436. PatientId: patient.ID,
  12437. Certno: res.Output.Baseinfo.Certno,
  12438. Gend: res.Output.Baseinfo.Gend,
  12439. Naty: res.Output.Baseinfo.Naty,
  12440. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12441. PsnName: res.Output.Baseinfo.PsnName,
  12442. Idetinfo: idetinfoStr,
  12443. Insuinfo: infoStr,
  12444. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12445. InsuplcAdmdvs: insuplc_admdvs,
  12446. }
  12447. service.CreateHisPsn(psn)
  12448. c.ServeSuccessJSON(map[string]interface{}{
  12449. "patient": patient,
  12450. "number": res.Output.Baseinfo.Certno,
  12451. })
  12452. }
  12453. } else {
  12454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12455. return
  12456. }
  12457. } else if miConfig.MdtrtareaAdmvs == "450721" {
  12458. res := c.GetoleInfo()
  12459. if res.Infcode == 0 {
  12460. var result string
  12461. if res.Output.MdtrtCertType == "01" {
  12462. 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)
  12463. } else if res.Output.MdtrtCertType == "02" {
  12464. 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)
  12465. } else if res.Output.MdtrtCertType == "03" {
  12466. 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)
  12467. }
  12468. var dat map[string]interface{}
  12469. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12470. fmt.Println(dat)
  12471. } else {
  12472. fmt.Println(err)
  12473. }
  12474. userJSONBytes, _ := json.Marshal(dat)
  12475. var res2 ResultTwo
  12476. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12477. utils.ErrorLog("解析失败:%v", err)
  12478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12479. return
  12480. }
  12481. if res2.Infcode == 0 {
  12482. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  12483. if err == gorm.ErrRecordNotFound {
  12484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12485. return
  12486. } else if err != nil {
  12487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12488. return
  12489. } else {
  12490. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  12491. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  12492. infoStr := string(Iinfos)
  12493. idetinfoStr := string(Idetinfos)
  12494. var rf []*ResultFive
  12495. json.Unmarshal([]byte(infoStr), &rf)
  12496. var insutypes []*ResultFive
  12497. var insutype string
  12498. var is390 int = 0
  12499. var is310 int = 0
  12500. //var insuplc_admdvs string
  12501. for _, item := range rf {
  12502. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12503. insutypes = append(insutypes, item)
  12504. }
  12505. }
  12506. if len(insutypes) == 1 {
  12507. insutype = insutypes[0].Insutype
  12508. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12509. } else {
  12510. for _, i := range insutypes {
  12511. if i.Insutype == "390" {
  12512. is390 = 1
  12513. }
  12514. if i.Insutype == "310" {
  12515. is310 = 1
  12516. }
  12517. }
  12518. }
  12519. if is390 == 1 {
  12520. insutype = "390"
  12521. }
  12522. if is310 == 1 {
  12523. insutype = "310"
  12524. }
  12525. if len(insutypes) == 0 {
  12526. insutype = "310"
  12527. }
  12528. psn := &models.HisPsn{
  12529. PsnNo: res2.Output.Baseinfo.PsnNo,
  12530. PatientId: patient.ID,
  12531. //Brdy: res2.Output.Baseinfo.Brdy,
  12532. Certno: res2.Output.Baseinfo.Certno,
  12533. Gend: res2.Output.Baseinfo.Gend,
  12534. Naty: res2.Output.Baseinfo.Naty,
  12535. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  12536. PsnName: res2.Output.Baseinfo.PsnName,
  12537. Idetinfo: idetinfoStr,
  12538. Insuinfo: infoStr,
  12539. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12540. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  12541. VerifyNumber: res.Output.EcToken,
  12542. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  12543. }
  12544. service.CreateHisPsn(psn)
  12545. var balc float64
  12546. for _, item := range rf {
  12547. if item.Insutype == insutype {
  12548. balc = item.Balc
  12549. }
  12550. }
  12551. c.ServeSuccessJSON(map[string]interface{}{
  12552. "patient": patient,
  12553. "number": res.Output.CardNo,
  12554. "insutype": insutype,
  12555. "blac": balc,
  12556. "desc": idetinfoStr,
  12557. })
  12558. }
  12559. } else {
  12560. c.ServeSuccessJSON(map[string]interface{}{
  12561. "failed_code": -10,
  12562. "msg": res2.ErrMsg,
  12563. })
  12564. }
  12565. } else {
  12566. c.ServeSuccessJSON(map[string]interface{}{
  12567. "failed_code": -10,
  12568. "msg": res.ErrMsg,
  12569. })
  12570. }
  12571. } else {
  12572. SFZStr := c.GetSFZBaseInfo()
  12573. id_card_str := strings.Split(SFZStr, "^")
  12574. id_card_number := id_card_str[0]
  12575. card_sn := ""
  12576. 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)
  12577. var dat map[string]interface{}
  12578. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12579. fmt.Println(dat)
  12580. } else {
  12581. fmt.Println(err)
  12582. }
  12583. userJSONBytes, _ := json.Marshal(dat)
  12584. var res ResultTwo
  12585. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12586. utils.ErrorLog("解析失败:%v", err)
  12587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12588. return
  12589. }
  12590. if res.Infcode == 0 {
  12591. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  12592. if err == gorm.ErrRecordNotFound {
  12593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12594. return
  12595. } else if err != nil {
  12596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12597. return
  12598. } else {
  12599. c.ServeSuccessJSON(map[string]interface{}{
  12600. "patient": patient,
  12601. "number": id_card_number,
  12602. })
  12603. }
  12604. } else {
  12605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12606. return
  12607. }
  12608. }
  12609. break
  12610. case 3:
  12611. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12612. var api string
  12613. if miConfig.MdtrtareaAdmvs == "320921" {
  12614. 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 +
  12615. "&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
  12616. fmt.Println(api)
  12617. } else {
  12618. 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 +
  12619. "&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)
  12620. }
  12621. resp, requestErr := http.Get(api)
  12622. if requestErr != nil {
  12623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12624. return
  12625. }
  12626. body, ioErr := ioutil.ReadAll(resp.Body)
  12627. if ioErr != nil {
  12628. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12630. return
  12631. }
  12632. var respJSON map[string]interface{}
  12633. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12634. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12636. return
  12637. }
  12638. var status string
  12639. status = respJSON["data"].(map[string]interface{})["status"].(string)
  12640. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  12641. var token string
  12642. var res ResultTwo //1101结果
  12643. var res10265 ResultTwo10265 //1101结果
  12644. var card_info string //卡信息
  12645. var busi_card_info string
  12646. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  12647. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12648. if status == "0" { //读卡成功
  12649. if card_type == "1" {
  12650. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12651. result, _ := json.Marshal(respJSON)
  12652. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12653. utils.ErrorLog("解析失败:%v", err)
  12654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12655. return
  12656. }
  12657. res.ErrMsg = res10265.ErrMsg
  12658. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12659. res.Infcode = infocode
  12660. res.Output = res10265.Output
  12661. res.InfRefmsgid = res10265.InfRefmsgid
  12662. } else {
  12663. //var card_info string //卡信息
  12664. //var busi_card_info string
  12665. token = respJSON["data"].(map[string]interface{})["token"].(string)
  12666. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12667. //fmt.Println(card_info)
  12668. //fmt.Println(busi_card_info)
  12669. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12670. result, _ := json.Marshal(respJSON)
  12671. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12672. utils.ErrorLog("解析失败:%v", err)
  12673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12674. return
  12675. }
  12676. res.ErrMsg = res10265.ErrMsg
  12677. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12678. res.Infcode = infocode
  12679. res.Output = res10265.Output
  12680. res.InfRefmsgid = res10265.InfRefmsgid
  12681. }
  12682. if res.Infcode == 0 {
  12683. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12684. if err == gorm.ErrRecordNotFound {
  12685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12686. return
  12687. } else if err != nil {
  12688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12689. return
  12690. } else {
  12691. if card_type == "1" {
  12692. bas := strings.Split(card_info, "|")
  12693. basNumber := bas[2]
  12694. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12695. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12696. infoStr := string(Iinfos)
  12697. idetinfoStr := string(Idetinfos)
  12698. psn := &models.HisPsn{
  12699. PsnNo: res.Output.Baseinfo.PsnNo,
  12700. PatientId: patient.ID,
  12701. Certno: res.Output.Baseinfo.Certno,
  12702. //Brdy: res.Output.Baseinfo.Brdy,
  12703. Gend: res.Output.Baseinfo.Gend,
  12704. Naty: res.Output.Baseinfo.Naty,
  12705. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12706. PsnName: res.Output.Baseinfo.PsnName,
  12707. Idetinfo: idetinfoStr,
  12708. Insuinfo: infoStr,
  12709. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12710. CardInfo: card_info,
  12711. VerifyNumber: busi_card_info,
  12712. }
  12713. service.CreateHisPsn(psn)
  12714. c.ServeSuccessJSON(map[string]interface{}{
  12715. "patient": patient,
  12716. "number": basNumber,
  12717. })
  12718. } else {
  12719. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12720. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12721. infoStr := string(Iinfos)
  12722. idetinfoStr := string(Idetinfos)
  12723. psn := &models.HisPsn{
  12724. PsnNo: res.Output.Baseinfo.PsnNo,
  12725. PatientId: patient.ID,
  12726. Certno: res.Output.Baseinfo.Certno,
  12727. Gend: res.Output.Baseinfo.Gend,
  12728. Naty: res.Output.Baseinfo.Naty,
  12729. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12730. PsnName: res.Output.Baseinfo.PsnName,
  12731. Idetinfo: idetinfoStr,
  12732. Insuinfo: infoStr,
  12733. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12734. CardInfo: card_info,
  12735. VerifyNumber: token,
  12736. }
  12737. service.CreateHisPsn(psn)
  12738. var rf []*ResultFive
  12739. json.Unmarshal([]byte(infoStr), &rf)
  12740. var insutypes []*ResultFive
  12741. var insutype string
  12742. var is390 int = 0
  12743. var is310 int = 0
  12744. for _, item := range rf {
  12745. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12746. insutypes = append(insutypes, item)
  12747. }
  12748. }
  12749. if len(insutypes) == 1 {
  12750. insutype = insutypes[0].Insutype
  12751. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12752. } else {
  12753. for _, i := range insutypes {
  12754. if i.Insutype == "390" {
  12755. is390 = 1
  12756. }
  12757. if i.Insutype == "310" {
  12758. is310 = 1
  12759. }
  12760. }
  12761. }
  12762. if is390 == 1 {
  12763. insutype = "390"
  12764. }
  12765. if is310 == 1 {
  12766. insutype = "310"
  12767. }
  12768. if len(insutypes) == 0 {
  12769. insutype = "310"
  12770. }
  12771. c.ServeSuccessJSON(map[string]interface{}{
  12772. "patient": patient,
  12773. "number": token,
  12774. "insutype": insutype,
  12775. })
  12776. }
  12777. }
  12778. } else {
  12779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12780. return
  12781. }
  12782. } else { //读卡失败
  12783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12784. return
  12785. }
  12786. }
  12787. break
  12788. case 4:
  12789. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12790. var api string
  12791. if miConfig.MdtrtareaAdmvs == "320921" {
  12792. 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 +
  12793. "&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
  12794. fmt.Println(api)
  12795. } else {
  12796. 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 +
  12797. "&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)
  12798. }
  12799. resp, requestErr := http.Get(api)
  12800. if requestErr != nil {
  12801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12802. return
  12803. }
  12804. body, ioErr := ioutil.ReadAll(resp.Body)
  12805. if ioErr != nil {
  12806. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12808. return
  12809. }
  12810. var respJSON map[string]interface{}
  12811. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12814. return
  12815. }
  12816. var status string
  12817. status = respJSON["data"].(map[string]interface{})["status"].(string)
  12818. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  12819. var token string
  12820. var res ResultTwo //1101结果
  12821. var res10265 ResultTwo10265 //1101结果
  12822. if status == "0" { //读卡成功
  12823. var card_info string //卡信息
  12824. var busi_card_info string
  12825. token = respJSON["data"].(map[string]interface{})["token"].(string)
  12826. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12827. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  12828. fmt.Println(card_info)
  12829. fmt.Println(busi_card_info)
  12830. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12831. result, _ := json.Marshal(respJSON)
  12832. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12833. utils.ErrorLog("解析失败:%v", err)
  12834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12835. return
  12836. }
  12837. res.ErrMsg = res10265.ErrMsg
  12838. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12839. res.Infcode = infocode
  12840. res.Output = res10265.Output
  12841. res.InfRefmsgid = res10265.InfRefmsgid
  12842. if res.Infcode == 0 {
  12843. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12844. if err == gorm.ErrRecordNotFound {
  12845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12846. return
  12847. } else if err != nil {
  12848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12849. return
  12850. } else {
  12851. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12852. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12853. infoStr := string(Iinfos)
  12854. idetinfoStr := string(Idetinfos)
  12855. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  12856. psn := &models.HisPsn{
  12857. PsnNo: res.Output.Baseinfo.PsnNo,
  12858. PatientId: patient.ID,
  12859. Certno: res.Output.Baseinfo.Certno,
  12860. Brdy: b,
  12861. Age: float64(age),
  12862. //Brdy: res.Output.Baseinfo.Brdy,
  12863. Gend: res.Output.Baseinfo.Gend,
  12864. Naty: res.Output.Baseinfo.Naty,
  12865. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12866. PsnName: res.Output.Baseinfo.PsnName,
  12867. Idetinfo: idetinfoStr,
  12868. Insuinfo: infoStr,
  12869. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12870. CardInfo: card_info,
  12871. VerifyNumber: token,
  12872. }
  12873. var rf []*ResultFive
  12874. json.Unmarshal([]byte(infoStr), &rf)
  12875. var insutypes []*ResultFive
  12876. var insutype string
  12877. var is390 int = 0
  12878. var is310 int = 0
  12879. for _, item := range rf {
  12880. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12881. insutypes = append(insutypes, item)
  12882. }
  12883. }
  12884. if len(insutypes) == 1 {
  12885. insutype = insutypes[0].Insutype
  12886. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12887. } else {
  12888. for _, i := range insutypes {
  12889. if i.Insutype == "390" {
  12890. is390 = 1
  12891. }
  12892. if i.Insutype == "310" {
  12893. is310 = 1
  12894. }
  12895. }
  12896. }
  12897. if is390 == 1 {
  12898. insutype = "390"
  12899. }
  12900. if is310 == 1 {
  12901. insutype = "310"
  12902. }
  12903. if len(insutypes) == 0 {
  12904. insutype = "310"
  12905. }
  12906. service.CreateHisPsn(psn)
  12907. c.ServeSuccessJSON(map[string]interface{}{
  12908. "patient": patient,
  12909. "number": token,
  12910. "insutype": insutype,
  12911. })
  12912. }
  12913. } else {
  12914. c.ServeSuccessJSON(map[string]interface{}{
  12915. "failed_code": -10,
  12916. "msg": res.ErrMsg,
  12917. })
  12918. }
  12919. } else { //读卡失败
  12920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12921. return
  12922. }
  12923. } else if miConfig.MdtrtareaAdmvs == "341203" {
  12924. var api string
  12925. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  12926. "&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
  12927. resp, requestErr := http.Get(api)
  12928. if requestErr != nil {
  12929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12930. return
  12931. }
  12932. body, ioErr := ioutil.ReadAll(resp.Body)
  12933. if ioErr != nil {
  12934. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12936. return
  12937. }
  12938. var respJSON map[string]interface{}
  12939. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12940. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12942. return
  12943. }
  12944. var status string
  12945. status = respJSON["data"].(map[string]interface{})["status"].(string)
  12946. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  12947. var token string
  12948. var res ResultTwo //1101结果
  12949. if status == "1" { //读卡成功
  12950. var card_info string //卡信息
  12951. var busi_card_info string
  12952. token = respJSON["data"].(map[string]interface{})["token"].(string)
  12953. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12954. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  12955. fmt.Println(card_info)
  12956. fmt.Println(busi_card_info)
  12957. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12958. result, _ := json.Marshal(respJSON)
  12959. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12960. utils.ErrorLog("解析失败:%v", err)
  12961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12962. return
  12963. }
  12964. if res.Infcode == 0 {
  12965. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12966. if err == gorm.ErrRecordNotFound {
  12967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12968. return
  12969. } else if err != nil {
  12970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12971. return
  12972. } else {
  12973. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12974. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12975. infoStr := string(Iinfos)
  12976. idetinfoStr := string(Idetinfos)
  12977. psn := &models.HisPsn{
  12978. PsnNo: res.Output.Baseinfo.PsnNo,
  12979. PatientId: patient.ID,
  12980. Certno: res.Output.Baseinfo.Certno,
  12981. Gend: res.Output.Baseinfo.Gend,
  12982. Naty: res.Output.Baseinfo.Naty,
  12983. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12984. PsnName: res.Output.Baseinfo.PsnName,
  12985. Idetinfo: idetinfoStr,
  12986. Insuinfo: infoStr,
  12987. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12988. CardInfo: card_info,
  12989. VerifyNumber: token,
  12990. }
  12991. var rf []*ResultFive
  12992. json.Unmarshal([]byte(infoStr), &rf)
  12993. var insutypes []*ResultFive
  12994. var insutype string
  12995. var is390 int = 0
  12996. var is310 int = 0
  12997. for _, item := range rf {
  12998. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12999. insutypes = append(insutypes, item)
  13000. }
  13001. }
  13002. if len(insutypes) == 1 {
  13003. insutype = insutypes[0].Insutype
  13004. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13005. } else {
  13006. for _, i := range insutypes {
  13007. if i.Insutype == "390" {
  13008. is390 = 1
  13009. }
  13010. if i.Insutype == "310" {
  13011. is310 = 1
  13012. }
  13013. }
  13014. }
  13015. if is390 == 1 {
  13016. insutype = "390"
  13017. }
  13018. if is310 == 1 {
  13019. insutype = "310"
  13020. }
  13021. if len(insutypes) == 0 {
  13022. insutype = "310"
  13023. }
  13024. service.CreateHisPsn(psn)
  13025. c.ServeSuccessJSON(map[string]interface{}{
  13026. "patient": patient,
  13027. "number": token,
  13028. "insutype": insutype,
  13029. })
  13030. }
  13031. } else {
  13032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13033. return
  13034. }
  13035. } else { //读卡失败
  13036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13037. return
  13038. }
  13039. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13040. //idNo := c.GetString("idNo")
  13041. //userName := c.GetString("userName")
  13042. //ecToken := c.GetString("ecToken")
  13043. //insuOrg := c.GetString("insuOrg")
  13044. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  13045. utils.ErrorLog("解析失败:%v", json_result)
  13046. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  13047. type ELeData struct {
  13048. Data struct {
  13049. IdNo string `json:"idNo"`
  13050. IdType string `json:"idType"`
  13051. UserName string `json:"userName"`
  13052. EcToken string `json:"ecToken"`
  13053. InsuOrg string `json:"insuOrg"`
  13054. Gender string `json:"gender"`
  13055. Birthday string `json:"birthday"`
  13056. Nationality string `json:"nationality"`
  13057. Email string `json:"email"`
  13058. Extra string `json:"extra"`
  13059. } `json:"data"`
  13060. Code int `json:"code"`
  13061. Message string `json:"message"`
  13062. }
  13063. var ele ELeData
  13064. err := json.Unmarshal([]byte(json_result), &ele)
  13065. if err != nil {
  13066. utils.ErrorLog("解析失败:%v", err)
  13067. }
  13068. token := ele.Data.EcToken
  13069. token = Remove0000(token)
  13070. 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)
  13071. saveLog(result2, requestLog2, "1101", "获取人员信息")
  13072. var res ResultTwo
  13073. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  13074. utils.ErrorLog("解析失败:%v", err)
  13075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13076. return
  13077. }
  13078. if res.Infcode == 0 {
  13079. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13080. if err == gorm.ErrRecordNotFound {
  13081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13082. return
  13083. } else if err != nil {
  13084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13085. return
  13086. } else {
  13087. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13088. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13089. infoStr := string(Iinfos)
  13090. idetinfoStr := string(Idetinfos)
  13091. psn := &models.HisPsn{
  13092. PsnNo: res.Output.Baseinfo.PsnNo,
  13093. PatientId: patient.ID,
  13094. Certno: res.Output.Baseinfo.Certno,
  13095. Gend: res.Output.Baseinfo.Gend,
  13096. Naty: res.Output.Baseinfo.Naty,
  13097. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13098. PsnName: res.Output.Baseinfo.PsnName,
  13099. Idetinfo: idetinfoStr,
  13100. Insuinfo: infoStr,
  13101. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13102. CardInfo: "",
  13103. Stage: "1",
  13104. VerifyNumber: token,
  13105. InsuplcAdmdvs: ele.Data.InsuOrg,
  13106. }
  13107. service.CreateHisPsn(psn)
  13108. var rf []*ResultFive
  13109. json.Unmarshal([]byte(infoStr), &rf)
  13110. var insutypes []*ResultFive
  13111. var insutype string
  13112. var is390 int = 0
  13113. var is310 int = 0
  13114. for _, item := range rf {
  13115. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13116. insutypes = append(insutypes, item)
  13117. }
  13118. }
  13119. if len(insutypes) == 1 {
  13120. insutype = insutypes[0].Insutype
  13121. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13122. } else {
  13123. for _, i := range insutypes {
  13124. if i.Insutype == "390" {
  13125. is390 = 1
  13126. }
  13127. if i.Insutype == "310" {
  13128. is310 = 1
  13129. }
  13130. }
  13131. }
  13132. if is390 == 1 {
  13133. insutype = "390"
  13134. }
  13135. if is310 == 1 {
  13136. insutype = "310"
  13137. }
  13138. if len(insutypes) == 0 {
  13139. insutype = "310"
  13140. }
  13141. c.ServeSuccessJSON(map[string]interface{}{
  13142. "patient": patient,
  13143. "number": token,
  13144. "insutype": insutype,
  13145. })
  13146. }
  13147. } else {
  13148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13149. return
  13150. }
  13151. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13152. //if initFlag == 0 {
  13153. //c.TestGetJiangXiBasBaseInit()
  13154. //}
  13155. //if initEleFlag == 0 {
  13156. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  13157. //}
  13158. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  13159. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  13160. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  13161. type ELeData struct {
  13162. Data struct {
  13163. IdNo string `json:"idNo"`
  13164. IdType string `json:"idType"`
  13165. UserName string `json:"userName"`
  13166. EcToken string `json:"ecToken"`
  13167. InsuOrg string `json:"insuOrg"`
  13168. Gender string `json:"gender"`
  13169. Birthday string `json:"birthday"`
  13170. Nationality string `json:"nationality"`
  13171. Email string `json:"email"`
  13172. Extra string `json:"extra"`
  13173. } `json:"data"`
  13174. Code int `json:"code"`
  13175. Message string `json:"message"`
  13176. }
  13177. var ele ELeData
  13178. err := json.Unmarshal([]byte(result), &ele)
  13179. if err != nil {
  13180. utils.ErrorLog("解析失败:%v", err)
  13181. }
  13182. token := ele.Data.EcToken
  13183. token = Remove0000(token)
  13184. 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)
  13185. saveLog(result2, requestLog2, "1101", "获取人员信息")
  13186. var res ResultTwo
  13187. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  13188. utils.ErrorLog("解析失败:%v", err)
  13189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13190. return
  13191. }
  13192. if res.Infcode == 0 {
  13193. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13194. if err == gorm.ErrRecordNotFound {
  13195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13196. return
  13197. } else if err != nil {
  13198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13199. return
  13200. } else {
  13201. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13202. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13203. infoStr := string(Iinfos)
  13204. idetinfoStr := string(Idetinfos)
  13205. psn := &models.HisPsn{
  13206. PsnNo: res.Output.Baseinfo.PsnNo,
  13207. PatientId: patient.ID,
  13208. Certno: res.Output.Baseinfo.Certno,
  13209. Gend: res.Output.Baseinfo.Gend,
  13210. Naty: res.Output.Baseinfo.Naty,
  13211. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13212. PsnName: res.Output.Baseinfo.PsnName,
  13213. Idetinfo: idetinfoStr,
  13214. Insuinfo: infoStr,
  13215. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13216. CardInfo: "",
  13217. VerifyNumber: token,
  13218. InsuplcAdmdvs: ele.Data.InsuOrg,
  13219. }
  13220. service.CreateHisPsn(psn)
  13221. var rf []*ResultFive
  13222. json.Unmarshal([]byte(infoStr), &rf)
  13223. var insutypes []*ResultFive
  13224. var insutype string
  13225. var is390 int = 0
  13226. var is310 int = 0
  13227. for _, item := range rf {
  13228. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13229. insutypes = append(insutypes, item)
  13230. }
  13231. }
  13232. if len(insutypes) == 1 {
  13233. insutype = insutypes[0].Insutype
  13234. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13235. } else {
  13236. for _, i := range insutypes {
  13237. if i.Insutype == "390" {
  13238. is390 = 1
  13239. }
  13240. if i.Insutype == "310" {
  13241. is310 = 1
  13242. }
  13243. }
  13244. }
  13245. if is390 == 1 {
  13246. insutype = "390"
  13247. }
  13248. if is310 == 1 {
  13249. insutype = "310"
  13250. }
  13251. if len(insutypes) == 0 {
  13252. insutype = "310"
  13253. }
  13254. c.ServeSuccessJSON(map[string]interface{}{
  13255. "patient": patient,
  13256. "number": token,
  13257. "insutype": insutype,
  13258. })
  13259. }
  13260. } else {
  13261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13262. return
  13263. }
  13264. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13265. //if initFlag == 0 {
  13266. c.TestGetJiangXiBasBaseInit()
  13267. //}
  13268. //if initEleFlag == 0 {
  13269. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  13270. //}
  13271. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  13272. type ELeData struct {
  13273. Data struct {
  13274. IdNo string `json:"idNo"`
  13275. IdType string `json:"idType"`
  13276. UserName string `json:"userName"`
  13277. EcToken string `json:"ecToken"`
  13278. InsuOrg string `json:"insuOrg"`
  13279. Gender string `json:"gender"`
  13280. Birthday string `json:"birthday"`
  13281. Nationality string `json:"nationality"`
  13282. Email string `json:"email"`
  13283. Extra string `json:"extra"`
  13284. } `json:"data"`
  13285. Code int `json:"code"`
  13286. Message string `json:"message"`
  13287. }
  13288. var ele ELeData
  13289. err := json.Unmarshal([]byte(json_result), &ele)
  13290. if err != nil {
  13291. utils.ErrorLog("解析失败:%v", err)
  13292. }
  13293. token := ele.Data.EcToken
  13294. token = Remove0000(token)
  13295. 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)
  13296. saveLog(result2, requestLog2, "1101", "获取人员信息")
  13297. var res ResultTwo
  13298. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  13299. utils.ErrorLog("解析失败:%v", err)
  13300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13301. return
  13302. }
  13303. if res.Infcode == 0 {
  13304. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13305. if err == gorm.ErrRecordNotFound {
  13306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13307. return
  13308. } else if err != nil {
  13309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13310. return
  13311. } else {
  13312. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13313. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13314. infoStr := string(Iinfos)
  13315. idetinfoStr := string(Idetinfos)
  13316. psn := &models.HisPsn{
  13317. PsnNo: res.Output.Baseinfo.PsnNo,
  13318. PatientId: patient.ID,
  13319. Certno: res.Output.Baseinfo.Certno,
  13320. Gend: res.Output.Baseinfo.Gend,
  13321. Naty: res.Output.Baseinfo.Naty,
  13322. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13323. PsnName: res.Output.Baseinfo.PsnName,
  13324. Idetinfo: idetinfoStr,
  13325. Insuinfo: infoStr,
  13326. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13327. CardInfo: "",
  13328. VerifyNumber: token,
  13329. }
  13330. service.CreateHisPsn(psn)
  13331. var rf []*ResultFive
  13332. json.Unmarshal([]byte(infoStr), &rf)
  13333. var insutypes []*ResultFive
  13334. var insutype string
  13335. var is390 int = 0
  13336. var is310 int = 0
  13337. for _, item := range rf {
  13338. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13339. insutypes = append(insutypes, item)
  13340. }
  13341. }
  13342. if len(insutypes) == 1 {
  13343. insutype = insutypes[0].Insutype
  13344. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13345. } else {
  13346. for _, i := range insutypes {
  13347. if i.Insutype == "390" {
  13348. is390 = 1
  13349. }
  13350. if i.Insutype == "310" {
  13351. is310 = 1
  13352. }
  13353. }
  13354. }
  13355. if is390 == 1 {
  13356. insutype = "390"
  13357. }
  13358. if is310 == 1 {
  13359. insutype = "310"
  13360. }
  13361. if len(insutypes) == 0 {
  13362. insutype = "310"
  13363. }
  13364. c.ServeSuccessJSON(map[string]interface{}{
  13365. "patient": patient,
  13366. "number": token,
  13367. "insutype": insutype,
  13368. })
  13369. }
  13370. } else {
  13371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13372. return
  13373. }
  13374. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13375. type ELeData struct {
  13376. Code string `json:"code"`
  13377. Data struct {
  13378. Aac002 string `json:"aac002"`
  13379. Aaz500 string `json:"aaz500"`
  13380. ActCardNo string `json:"actCardNo"`
  13381. Bab520 string `json:"bab520"`
  13382. Bkz543 string `json:"bkz543"`
  13383. BusinessType string `json:"businessType"`
  13384. CertfCodg string `json:"certfCodg"`
  13385. EcIndexNo string `json:"ecIndexNo"`
  13386. EcToken string `json:"ecToken"`
  13387. ID0000 string `json:"id0000"`
  13388. IDNo string `json:"idNo"`
  13389. IDType string `json:"idType"`
  13390. Idcode string `json:"idcode"`
  13391. IdentityToken string `json:"identity_token"`
  13392. InsuOrg string `json:"insuOrg"`
  13393. OfficeID string `json:"officeId"`
  13394. OfficeName string `json:"officeName"`
  13395. OperatorID string `json:"operatorId"`
  13396. OperatorName string `json:"operatorName"`
  13397. OrgID string `json:"orgId"`
  13398. UserName string `json:"userName"`
  13399. } `json:"data"`
  13400. Infno interface{} `json:"infno"`
  13401. Message string `json:"message"`
  13402. OrgID string `json:"orgId"`
  13403. TransType string `json:"transType"`
  13404. }
  13405. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  13406. outPutInfo = Remove0000(outPutInfo)
  13407. if len(outPutInfo) > 0 {
  13408. var ele ELeData
  13409. err := json.Unmarshal([]byte(outPutInfo), &ele)
  13410. if err != nil {
  13411. utils.ErrorLog("解析失败:%v", err)
  13412. }
  13413. token := ele.Data.EcToken
  13414. fmt.Println(inputInfo)
  13415. fmt.Println(outPutInfo)
  13416. 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)
  13417. saveLog(result, requestLog, "1101", "获取人员信息")
  13418. var dat map[string]interface{}
  13419. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13420. fmt.Println(dat)
  13421. } else {
  13422. fmt.Println(err)
  13423. }
  13424. userJSONBytes, _ := json.Marshal(dat)
  13425. var res ResultTwo
  13426. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13427. utils.ErrorLog("解析失败:%v", err)
  13428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13429. return
  13430. }
  13431. res.ErrMsg = errMsgLog
  13432. if res.Infcode == 0 {
  13433. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  13434. if err == gorm.ErrRecordNotFound {
  13435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13436. return
  13437. } else if err != nil {
  13438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13439. return
  13440. } else {
  13441. fmt.Println(res)
  13442. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13443. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13444. infoStr := string(Iinfos)
  13445. idetinfoStr := string(Idetinfos)
  13446. psn := &models.HisPsn{
  13447. PsnNo: res.Output.Baseinfo.PsnNo,
  13448. PatientId: patient.ID,
  13449. Certno: res.Output.Baseinfo.Certno,
  13450. Gend: res.Output.Baseinfo.Gend,
  13451. Naty: res.Output.Baseinfo.Naty,
  13452. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13453. PsnName: res.Output.Baseinfo.PsnName,
  13454. Idetinfo: idetinfoStr,
  13455. Insuinfo: infoStr,
  13456. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13457. CardInfo: outPutInfo,
  13458. VerifyNumber: token,
  13459. InsuplcAdmdvs: ele.Data.InsuOrg,
  13460. }
  13461. service.CreateHisPsn(psn)
  13462. var rf []*ResultFive
  13463. json.Unmarshal([]byte(infoStr), &rf)
  13464. var insutypes []*ResultFive
  13465. var insutype string
  13466. var is390 int = 0
  13467. var is310 int = 0
  13468. for _, item := range rf {
  13469. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13470. insutypes = append(insutypes, item)
  13471. }
  13472. }
  13473. if len(insutypes) == 1 {
  13474. insutype = insutypes[0].Insutype
  13475. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13476. } else {
  13477. for _, i := range insutypes {
  13478. if i.Insutype == "390" {
  13479. is390 = 1
  13480. }
  13481. if i.Insutype == "310" {
  13482. is310 = 1
  13483. }
  13484. }
  13485. }
  13486. if is390 == 1 {
  13487. insutype = "390"
  13488. }
  13489. if is310 == 1 {
  13490. insutype = "310"
  13491. }
  13492. if len(insutypes) == 0 {
  13493. insutype = "310"
  13494. }
  13495. c.ServeSuccessJSON(map[string]interface{}{
  13496. "patient": patient,
  13497. "number": token,
  13498. "insutype": insutype,
  13499. })
  13500. }
  13501. } else {
  13502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13503. return
  13504. }
  13505. }
  13506. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13507. var api string
  13508. 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 +
  13509. "&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
  13510. resp, requestErr := http.Get(api)
  13511. if requestErr != nil {
  13512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13513. return
  13514. }
  13515. body, ioErr := ioutil.ReadAll(resp.Body)
  13516. if ioErr != nil {
  13517. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13519. return
  13520. }
  13521. var respJSON map[string]interface{}
  13522. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13523. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13525. return
  13526. }
  13527. var status string
  13528. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13529. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13530. var token string
  13531. var res ResultTwo //1101结果
  13532. var res10265 ResultTwo10265 //1101结果
  13533. if status == "0" { //读卡成功
  13534. var card_info string //卡信息
  13535. var busi_card_info string
  13536. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13537. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13538. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13539. fmt.Println(card_info)
  13540. fmt.Println(busi_card_info)
  13541. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13542. result, _ := json.Marshal(respJSON)
  13543. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13544. utils.ErrorLog("解析失败:%v", err)
  13545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13546. return
  13547. }
  13548. res.ErrMsg = res10265.ErrMsg
  13549. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13550. res.Infcode = infocode
  13551. res.Output = res10265.Output
  13552. res.InfRefmsgid = res10265.InfRefmsgid
  13553. if res.Infcode == 0 {
  13554. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13555. if err == gorm.ErrRecordNotFound {
  13556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13557. return
  13558. } else if err != nil {
  13559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13560. return
  13561. } else {
  13562. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13563. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13564. infoStr := string(Iinfos)
  13565. idetinfoStr := string(Idetinfos)
  13566. psn := &models.HisPsn{
  13567. PsnNo: res.Output.Baseinfo.PsnNo,
  13568. PatientId: patient.ID,
  13569. Certno: res.Output.Baseinfo.Certno,
  13570. Gend: res.Output.Baseinfo.Gend,
  13571. Naty: res.Output.Baseinfo.Naty,
  13572. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13573. PsnName: res.Output.Baseinfo.PsnName,
  13574. Idetinfo: idetinfoStr,
  13575. Insuinfo: infoStr,
  13576. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13577. CardInfo: card_info,
  13578. VerifyNumber: token,
  13579. }
  13580. var rf []*ResultFive
  13581. json.Unmarshal([]byte(infoStr), &rf)
  13582. var insutypes []*ResultFive
  13583. var insutype string
  13584. var is390 int = 0
  13585. var is310 int = 0
  13586. for _, item := range rf {
  13587. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13588. insutypes = append(insutypes, item)
  13589. }
  13590. }
  13591. if len(insutypes) == 1 {
  13592. insutype = insutypes[0].Insutype
  13593. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13594. } else {
  13595. for _, i := range insutypes {
  13596. if i.Insutype == "390" {
  13597. is390 = 1
  13598. }
  13599. if i.Insutype == "310" {
  13600. is310 = 1
  13601. }
  13602. }
  13603. }
  13604. if is390 == 1 {
  13605. insutype = "390"
  13606. }
  13607. if is310 == 1 {
  13608. insutype = "310"
  13609. }
  13610. if len(insutypes) == 0 {
  13611. insutype = "310"
  13612. }
  13613. service.CreateHisPsn(psn)
  13614. c.ServeSuccessJSON(map[string]interface{}{
  13615. "patient": patient,
  13616. "number": token,
  13617. "insutype": insutype,
  13618. })
  13619. }
  13620. } else {
  13621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13622. return
  13623. }
  13624. } else { //读卡失败
  13625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13626. return
  13627. }
  13628. } else if miConfig.MdtrtareaAdmvs == "450721" {
  13629. res := c.GetoleInfo()
  13630. if res.Infcode == 0 {
  13631. var result string
  13632. if res.Output.MdtrtCertType == "01" {
  13633. 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)
  13634. } else if res.Output.MdtrtCertType == "02" {
  13635. 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)
  13636. } else if res.Output.MdtrtCertType == "03" {
  13637. 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)
  13638. }
  13639. var dat map[string]interface{}
  13640. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13641. fmt.Println(dat)
  13642. } else {
  13643. fmt.Println(err)
  13644. }
  13645. userJSONBytes, _ := json.Marshal(dat)
  13646. var res2 ResultTwo
  13647. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13648. utils.ErrorLog("解析失败:%v", err)
  13649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13650. return
  13651. }
  13652. if res2.Infcode == 0 {
  13653. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  13654. if err == gorm.ErrRecordNotFound {
  13655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13656. return
  13657. } else if err != nil {
  13658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13659. return
  13660. } else {
  13661. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  13662. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  13663. infoStr := string(Iinfos)
  13664. idetinfoStr := string(Idetinfos)
  13665. var rf []*ResultFive
  13666. json.Unmarshal([]byte(infoStr), &rf)
  13667. var insutypes []*ResultFive
  13668. var insutype string
  13669. var is390 int = 0
  13670. var is310 int = 0
  13671. //var insuplc_admdvs string
  13672. for _, item := range rf {
  13673. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13674. insutypes = append(insutypes, item)
  13675. }
  13676. }
  13677. if len(insutypes) == 1 {
  13678. insutype = insutypes[0].Insutype
  13679. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13680. } else {
  13681. for _, i := range insutypes {
  13682. if i.Insutype == "390" {
  13683. is390 = 1
  13684. }
  13685. if i.Insutype == "310" {
  13686. is310 = 1
  13687. }
  13688. }
  13689. }
  13690. if is390 == 1 {
  13691. insutype = "390"
  13692. }
  13693. if is310 == 1 {
  13694. insutype = "310"
  13695. }
  13696. if len(insutypes) == 0 {
  13697. insutype = "310"
  13698. }
  13699. psn := &models.HisPsn{
  13700. PsnNo: res2.Output.Baseinfo.PsnNo,
  13701. PatientId: patient.ID,
  13702. Certno: res2.Output.Baseinfo.Certno,
  13703. Gend: res2.Output.Baseinfo.Gend,
  13704. Naty: res2.Output.Baseinfo.Naty,
  13705. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  13706. PsnName: res2.Output.Baseinfo.PsnName,
  13707. Idetinfo: idetinfoStr,
  13708. Insuinfo: infoStr,
  13709. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13710. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  13711. VerifyNumber: res.Output.EcToken,
  13712. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  13713. }
  13714. if res.Output.MdtrtCertType == "01" {
  13715. psn.VerifyNumber = res.Output.EcToken
  13716. //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)
  13717. } else if res.Output.MdtrtCertType == "02" {
  13718. psn.VerifyNumber = res.Output.CardNo
  13719. //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)
  13720. } else if res.Output.MdtrtCertType == "03" {
  13721. psn.VerifyNumber = res.Output.MdtrtCertNo
  13722. //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)
  13723. }
  13724. service.CreateHisPsn(psn)
  13725. var balc float64
  13726. for _, item := range rf {
  13727. if item.Insutype == insutype {
  13728. balc = item.Balc
  13729. }
  13730. }
  13731. c.ServeSuccessJSON(map[string]interface{}{
  13732. "patient": patient,
  13733. "number": res.Output.CardNo,
  13734. "insutype": insutype,
  13735. "blac": balc,
  13736. "desc": idetinfoStr,
  13737. })
  13738. }
  13739. } else {
  13740. c.ServeSuccessJSON(map[string]interface{}{
  13741. "failed_code": -10,
  13742. "msg": res2.ErrMsg,
  13743. })
  13744. }
  13745. } else {
  13746. c.ServeSuccessJSON(map[string]interface{}{
  13747. "failed_code": -10,
  13748. "msg": res.ErrMsg,
  13749. })
  13750. }
  13751. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13752. var res ResultTwo
  13753. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13754. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13755. "&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)
  13756. resp, requestErr := http.Get(api)
  13757. if requestErr != nil {
  13758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13759. return
  13760. }
  13761. body, ioErr := ioutil.ReadAll(resp.Body)
  13762. if ioErr != nil {
  13763. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13765. return
  13766. }
  13767. var respJSON map[string]interface{}
  13768. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13769. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13771. return
  13772. }
  13773. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13774. result, _ := json.Marshal(respJSON)
  13775. fmt.Println("log")
  13776. fmt.Println(string(result))
  13777. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13778. utils.ErrorLog("解析失败:%v", err)
  13779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13780. return
  13781. }
  13782. if res.Infcode == 0 {
  13783. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13784. if err == gorm.ErrRecordNotFound {
  13785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13786. return
  13787. } else if err != nil {
  13788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13789. return
  13790. } else {
  13791. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13792. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13793. infoStr := string(Iinfos)
  13794. idetinfoStr := string(Idetinfos)
  13795. var rf []*ResultFive
  13796. json.Unmarshal([]byte(infoStr), &rf)
  13797. var insutypes []*ResultFive
  13798. var insutype string
  13799. var is390 int = 0
  13800. var is310 int = 0
  13801. for _, item := range rf {
  13802. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13803. insutypes = append(insutypes, item)
  13804. }
  13805. }
  13806. if len(insutypes) == 1 {
  13807. insutype = insutypes[0].Insutype
  13808. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13809. } else {
  13810. for _, i := range insutypes {
  13811. if i.Insutype == "390" {
  13812. is390 = 1
  13813. }
  13814. if i.Insutype == "310" {
  13815. is310 = 1
  13816. }
  13817. }
  13818. }
  13819. if is390 == 1 {
  13820. insutype = "390"
  13821. }
  13822. if is310 == 1 {
  13823. insutype = "310"
  13824. }
  13825. if len(insutypes) == 0 {
  13826. insutype = "390"
  13827. }
  13828. var insuplc_admdvs string
  13829. for _, item := range rf {
  13830. if item.Insutype == insutype {
  13831. insuplc_admdvs = item.InsuplcAdmdvs
  13832. }
  13833. }
  13834. psn := &models.HisPsn{
  13835. PsnNo: res.Output.Baseinfo.PsnNo,
  13836. PatientId: patient.ID,
  13837. Certno: res.Output.Baseinfo.Certno,
  13838. Gend: res.Output.Baseinfo.Gend,
  13839. Naty: res.Output.Baseinfo.Naty,
  13840. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13841. PsnName: res.Output.Baseinfo.PsnName,
  13842. Idetinfo: idetinfoStr,
  13843. Insuinfo: infoStr,
  13844. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13845. InsuplcAdmdvs: insuplc_admdvs,
  13846. }
  13847. service.CreateHisPsn(psn)
  13848. c.ServeSuccessJSON(map[string]interface{}{
  13849. "patient": patient,
  13850. "number": res.Output.Baseinfo.Certno,
  13851. })
  13852. }
  13853. } else {
  13854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13855. return
  13856. }
  13857. } else {
  13858. type ELeData struct {
  13859. Code string `json:"code"`
  13860. Data struct {
  13861. Aac002 string `json:"aac002"`
  13862. Aaz500 string `json:"aaz500"`
  13863. ActCardNo string `json:"actCardNo"`
  13864. Bab520 string `json:"bab520"`
  13865. Bkz543 string `json:"bkz543"`
  13866. BusinessType string `json:"businessType"`
  13867. CertfCodg string `json:"certfCodg"`
  13868. EcIndexNo string `json:"ecIndexNo"`
  13869. EcToken string `json:"ecToken"`
  13870. ID0000 string `json:"id0000"`
  13871. IDNo string `json:"idNo"`
  13872. IDType string `json:"idType"`
  13873. Idcode string `json:"idcode"`
  13874. IdentityToken string `json:"identity_token"`
  13875. InsuOrg string `json:"insuOrg"`
  13876. OfficeID string `json:"officeId"`
  13877. OfficeName string `json:"officeName"`
  13878. OperatorID string `json:"operatorId"`
  13879. OperatorName string `json:"operatorName"`
  13880. OrgID string `json:"orgId"`
  13881. UserName string `json:"userName"`
  13882. } `json:"data"`
  13883. Infno interface{} `json:"infno"`
  13884. Message string `json:"message"`
  13885. OrgID string `json:"orgId"`
  13886. TransType string `json:"transType"`
  13887. }
  13888. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  13889. fmt.Println(result)
  13890. outPutInfo := Remove0000(result)
  13891. fmt.Println(outPutInfo)
  13892. if len(outPutInfo) > 0 {
  13893. var ele ELeData
  13894. err := json.Unmarshal([]byte(outPutInfo), &ele)
  13895. if err != nil {
  13896. utils.ErrorLog("解析失败:%v", err)
  13897. }
  13898. token := ele.Data.EcToken
  13899. fmt.Println(outPutInfo)
  13900. 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)
  13901. saveLog(result, requestLog, "1101", "获取人员信息")
  13902. var dat map[string]interface{}
  13903. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13904. fmt.Println(dat)
  13905. } else {
  13906. fmt.Println(err)
  13907. }
  13908. userJSONBytes, _ := json.Marshal(dat)
  13909. var res ResultTwo
  13910. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13911. utils.ErrorLog("解析失败:%v", err)
  13912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13913. return
  13914. }
  13915. if res.Infcode == 0 {
  13916. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  13917. if err == gorm.ErrRecordNotFound {
  13918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13919. return
  13920. } else if err != nil {
  13921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13922. return
  13923. } else {
  13924. fmt.Println(res)
  13925. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13926. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13927. infoStr := string(Iinfos)
  13928. idetinfoStr := string(Idetinfos)
  13929. psn := &models.HisPsn{
  13930. PsnNo: res.Output.Baseinfo.PsnNo,
  13931. PatientId: patient.ID,
  13932. Certno: res.Output.Baseinfo.Certno,
  13933. Gend: res.Output.Baseinfo.Gend,
  13934. Naty: res.Output.Baseinfo.Naty,
  13935. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13936. PsnName: res.Output.Baseinfo.PsnName,
  13937. Idetinfo: idetinfoStr,
  13938. Insuinfo: infoStr,
  13939. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13940. CardInfo: outPutInfo,
  13941. VerifyNumber: token,
  13942. InsuplcAdmdvs: ele.Data.InsuOrg,
  13943. }
  13944. service.CreateHisPsn(psn)
  13945. var rf []*ResultFive
  13946. json.Unmarshal([]byte(infoStr), &rf)
  13947. var insutypes []*ResultFive
  13948. var insutype string
  13949. var is390 int = 0
  13950. var is310 int = 0
  13951. for _, item := range rf {
  13952. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13953. insutypes = append(insutypes, item)
  13954. }
  13955. }
  13956. if len(insutypes) == 1 {
  13957. insutype = insutypes[0].Insutype
  13958. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13959. } else {
  13960. for _, i := range insutypes {
  13961. if i.Insutype == "390" {
  13962. is390 = 1
  13963. }
  13964. if i.Insutype == "310" {
  13965. is310 = 1
  13966. }
  13967. }
  13968. }
  13969. if is390 == 1 {
  13970. insutype = "390"
  13971. }
  13972. if is310 == 1 {
  13973. insutype = "310"
  13974. }
  13975. if len(insutypes) == 0 {
  13976. insutype = "310"
  13977. }
  13978. c.ServeSuccessJSON(map[string]interface{}{
  13979. "patient": patient,
  13980. "number": token,
  13981. "insutype": insutype,
  13982. })
  13983. }
  13984. } else {
  13985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13986. return
  13987. }
  13988. }
  13989. //fmt.Println(result)
  13990. //
  13991. //if initFlag == 0 {
  13992. // c.TestGetBasBaseInit()
  13993. //}
  13994. //token := c.GetEleBaseInfo()
  13995. //
  13996. //token = Remove0000(token)
  13997. //
  13998. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  13999. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  14000. ////
  14001. //var res ResultTwo
  14002. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  14003. // utils.ErrorLog("解析失败:%v", err)
  14004. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14005. // return
  14006. //}
  14007. //
  14008. //if res.Infcode == 0 {
  14009. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14010. // if err == gorm.ErrRecordNotFound {
  14011. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14012. // return
  14013. // } else if err != nil {
  14014. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14015. // return
  14016. //
  14017. // } else {
  14018. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14019. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14020. // infoStr := string(Iinfos)
  14021. // idetinfoStr := string(Idetinfos)
  14022. //
  14023. //
  14024. //
  14025. //
  14026. // var rf []*ResultFive
  14027. // json.Unmarshal([]byte(infoStr), &rf)
  14028. //
  14029. // var insutypes []*ResultFive
  14030. // var insutype string
  14031. // var is390 int = 0
  14032. // var is310 int = 0
  14033. // var insuplc_admdvs string
  14034. //
  14035. // for _, item := range rf {
  14036. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14037. // insutypes = append(insutypes, item)
  14038. // }
  14039. // }
  14040. //
  14041. // if len(insutypes) == 1 {
  14042. // insutype = insutypes[0].Insutype
  14043. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14044. // } else {
  14045. // for _, i := range insutypes {
  14046. // if i.Insutype == "390" {
  14047. // is390 = 1
  14048. // }
  14049. //
  14050. // if i.Insutype == "310" {
  14051. // is310 = 1
  14052. // }
  14053. // }
  14054. // }
  14055. // if is390 == 1 {
  14056. // insutype = "390"
  14057. // }
  14058. //
  14059. // if is310 == 1 {
  14060. // insutype = "310"
  14061. // }
  14062. // if len(insutypes) == 0 {
  14063. // insutype = "310"
  14064. // }
  14065. // for _, item := range rf {
  14066. // if item.Insutype == insutype {
  14067. // insuplc_admdvs = item.InsuplcAdmdvs
  14068. // }
  14069. // }
  14070. // psn := &models.HisPsn{
  14071. // PsnNo: res.Output.Baseinfo.PsnNo,
  14072. // Age: res.Output.Baseinfo.Age,
  14073. // PatientId: patient.ID,
  14074. // Certno: res.Output.Baseinfo.Certno,
  14075. // Brdy: res.Output.Baseinfo.Brdy,
  14076. // Gend: res.Output.Baseinfo.Gend,
  14077. // Naty: res.Output.Baseinfo.Naty,
  14078. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  14079. // PsnName: res.Output.Baseinfo.PsnName,
  14080. // Idetinfo: idetinfoStr,
  14081. // Insuinfo: infoStr,
  14082. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14083. // CardInfo: "",
  14084. // VerifyNumber: token,
  14085. // InsuplcAdmdvs: insuplc_admdvs,
  14086. // }
  14087. // service.CreateHisPsn(psn)
  14088. //
  14089. // c.ServeSuccessJSON(map[string]interface{}{
  14090. // "patient": patient,
  14091. // "number": token,
  14092. // })
  14093. // }
  14094. //} else {
  14095. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14096. // return
  14097. //}
  14098. }
  14099. break
  14100. case 5:
  14101. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14102. var api string
  14103. if miConfig.MdtrtareaAdmvs == "320921" {
  14104. 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 +
  14105. "&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
  14106. fmt.Println(api)
  14107. } else {
  14108. 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 +
  14109. "&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)
  14110. }
  14111. resp, requestErr := http.Get(api)
  14112. if requestErr != nil {
  14113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14114. return
  14115. }
  14116. body, ioErr := ioutil.ReadAll(resp.Body)
  14117. if ioErr != nil {
  14118. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14120. return
  14121. }
  14122. var respJSON map[string]interface{}
  14123. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14124. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14126. return
  14127. }
  14128. var status string
  14129. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14130. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14131. var token string
  14132. var res ResultTwo //1101结果
  14133. var res10265 ResultTwo10265 //1101结果
  14134. if status == "0" { //读卡成功
  14135. var card_info string //卡信息
  14136. //var busi_card_info string
  14137. var auth_info string
  14138. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14139. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14140. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14141. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  14142. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14143. result, _ := json.Marshal(respJSON)
  14144. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14145. utils.ErrorLog("解析失败:%v", err)
  14146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14147. return
  14148. }
  14149. res.ErrMsg = res10265.ErrMsg
  14150. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14151. res.Infcode = infocode
  14152. res.Output = res10265.Output
  14153. res.InfRefmsgid = res10265.InfRefmsgid
  14154. if res.Infcode == 0 {
  14155. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14156. if err == gorm.ErrRecordNotFound {
  14157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14158. return
  14159. } else if err != nil {
  14160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14161. return
  14162. } else {
  14163. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14164. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14165. infoStr := string(Iinfos)
  14166. idetinfoStr := string(Idetinfos)
  14167. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  14168. psn := &models.HisPsn{
  14169. PsnNo: res.Output.Baseinfo.PsnNo,
  14170. PatientId: patient.ID,
  14171. Certno: res.Output.Baseinfo.Certno,
  14172. Gend: res.Output.Baseinfo.Gend,
  14173. Brdy: b,
  14174. Age: float64(age),
  14175. Naty: res.Output.Baseinfo.Naty,
  14176. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14177. PsnName: res.Output.Baseinfo.PsnName,
  14178. Idetinfo: idetinfoStr,
  14179. Insuinfo: infoStr,
  14180. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14181. CardInfo: card_info,
  14182. VerifyNumber: token,
  14183. AuthInfo: auth_info,
  14184. }
  14185. var rf []*ResultFive
  14186. json.Unmarshal([]byte(infoStr), &rf)
  14187. var insutypes []*ResultFive
  14188. var insutype string
  14189. var is390 int = 0
  14190. var is310 int = 0
  14191. for _, item := range rf {
  14192. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14193. insutypes = append(insutypes, item)
  14194. }
  14195. }
  14196. if len(insutypes) == 1 {
  14197. insutype = insutypes[0].Insutype
  14198. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14199. } else {
  14200. for _, i := range insutypes {
  14201. if i.Insutype == "390" {
  14202. is390 = 1
  14203. }
  14204. if i.Insutype == "310" {
  14205. is310 = 1
  14206. }
  14207. }
  14208. }
  14209. if is390 == 1 {
  14210. insutype = "390"
  14211. }
  14212. if is310 == 1 {
  14213. insutype = "310"
  14214. }
  14215. if len(insutypes) == 0 {
  14216. insutype = "310"
  14217. }
  14218. service.CreateHisPsn(psn)
  14219. c.ServeSuccessJSON(map[string]interface{}{
  14220. "patient": patient,
  14221. "number": token,
  14222. "insutype": insutype,
  14223. })
  14224. }
  14225. } else {
  14226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14227. return
  14228. }
  14229. } else { //读卡失败
  14230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14231. return
  14232. }
  14233. }
  14234. break
  14235. }
  14236. }
  14237. var initFlag int64 = 0
  14238. var initEleFlag int64 = 0
  14239. func (c *HisApiController) TestGetBasBaseInit() {
  14240. DllDef := syscall.MustLoadDLL("SSCard.dll")
  14241. Iinit := DllDef.MustFindProc("Init")
  14242. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14243. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  14244. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  14245. if ret != 0 {
  14246. fmt.Println("SSCard的报错原因:", err)
  14247. fmt.Println("SSCard的运算结果为:", ret)
  14248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14249. return
  14250. }
  14251. result := int(ret)
  14252. fmt.Println("SSCard的运算结果为1:", result)
  14253. initFlag = 1
  14254. return
  14255. }
  14256. func (c *HisApiController) HandleJiangXiReadCard() {
  14257. fmt.Println("~~~~~~")
  14258. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14259. admin_user_id, _ := c.GetInt64("admin_user_id")
  14260. id_card_type, _ := c.GetInt64("id_card_type")
  14261. //certificates, _ := c.GetInt64("certificates")
  14262. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  14263. if initFlag == 0 {
  14264. c.TestGetJiangXiBasBaseInit()
  14265. }
  14266. basStr := c.GetBasBaseInfo()
  14267. if len(basStr) == 0 {
  14268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14269. return
  14270. }
  14271. fmt.Println(basStr)
  14272. bas := strings.Split(basStr, "|")
  14273. basNumber := bas[1]
  14274. fmt.Println(basNumber)
  14275. card_sn := bas[3]
  14276. fmt.Println(card_sn)
  14277. 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, "")
  14278. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14279. var dat map[string]interface{}
  14280. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14281. fmt.Println(dat)
  14282. } else {
  14283. fmt.Println(err)
  14284. }
  14285. userJSONBytes, _ := json.Marshal(dat)
  14286. var res ResultTwo
  14287. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14288. utils.ErrorLog("解析失败:%v", err)
  14289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14290. return
  14291. }
  14292. if res.Infcode == 0 {
  14293. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14294. if err == gorm.ErrRecordNotFound {
  14295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14296. return
  14297. } else if err != nil {
  14298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14299. return
  14300. } else {
  14301. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14302. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14303. infoStr := string(Iinfos)
  14304. idetinfoStr := string(Idetinfos)
  14305. psn := &models.HisPsn{
  14306. PsnNo: res.Output.Baseinfo.PsnNo,
  14307. PatientId: patient.ID,
  14308. Certno: res.Output.Baseinfo.Certno,
  14309. Gend: res.Output.Baseinfo.Gend,
  14310. Naty: res.Output.Baseinfo.Naty,
  14311. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14312. PsnName: res.Output.Baseinfo.PsnName,
  14313. Idetinfo: idetinfoStr,
  14314. Insuinfo: infoStr,
  14315. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14316. CardInfo: basStr,
  14317. VerifyNumber: "",
  14318. }
  14319. service.CreateHisPsn(psn)
  14320. c.ServeSuccessJSON(map[string]interface{}{
  14321. "patient": patient,
  14322. "number": basNumber,
  14323. })
  14324. }
  14325. } else {
  14326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14327. return
  14328. }
  14329. }
  14330. func (c *HisApiController) TestGetHnBasBaseInit(){
  14331. DllDef := syscall.MustLoadDLL("SSCard.dll")
  14332. Iinit := DllDef.MustFindProc("Init")
  14333. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14334. //http://10.77.211.236/CSB/hsa-fsi-1303
  14335. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  14336. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  14337. // 调用 Init 函数
  14338. 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"))))
  14339. //if ret != 0 {
  14340. fmt.Println("SSCard的报错原因:", err)
  14341. fmt.Println("SSCard的运算结果为:", ret)
  14342. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14343. // return
  14344. //}
  14345. result := int(ret)
  14346. fmt.Println("SSCard的运算结果为1:", result)
  14347. initFlag = 1
  14348. return
  14349. }
  14350. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  14351. DllDef := syscall.MustLoadDLL("SSCard.dll")
  14352. Iinit := DllDef.MustFindProc("Init")
  14353. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14354. //http://10.77.211.236/CSB/hsa-fsi-1303
  14355. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  14356. if ret != 0 {
  14357. fmt.Println("SSCard的报错原因:", err)
  14358. fmt.Println("SSCard的运算结果为:", ret)
  14359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14360. return
  14361. }
  14362. result := int(ret)
  14363. fmt.Println("SSCard的运算结果为1:", result)
  14364. initFlag = 1
  14365. return
  14366. }
  14367. func (c *HisApiController) GetSFZBaseInfo() string {
  14368. DllDef := syscall.MustLoadDLL("SSCard.dll")
  14369. readCard := DllDef.MustFindProc("ReadSFZ")
  14370. if readCard == nil {
  14371. fmt.Println("readcard is nil")
  14372. readCard = DllDef.MustFindProc("ReadSFZ")
  14373. }
  14374. str := make([]byte, 8096)
  14375. str1 := make([]byte, 8096)
  14376. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  14377. fmt.Println(r)
  14378. return Remove0000(string(str))
  14379. }
  14380. func (c *HisApiController) GetEleBaseInfo() string {
  14381. DllDef := syscall.MustLoadDLL("SSCard.dll")
  14382. readCard := DllDef.MustFindProc("GetQRBase")
  14383. fmt.Println(readCard)
  14384. if readCard == nil {
  14385. fmt.Println("readcard is nil")
  14386. readCard = DllDef.MustFindProc("GetQRBase")
  14387. }
  14388. str := make([]byte, 1024)
  14389. str1 := make([]byte, 1024)
  14390. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  14391. fmt.Println(ret2)
  14392. fmt.Println(string(str1))
  14393. fmt.Println(string(str))
  14394. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  14395. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  14396. if ret2 != 0 {
  14397. return ""
  14398. }
  14399. return string(str)
  14400. }
  14401. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  14402. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  14403. readCard := DllDef.MustFindProc("NationEcTrans")
  14404. fmt.Println(readCard)
  14405. fmt.Println("!!!!!")
  14406. pBusiCardInfo := make([]byte, 2048)
  14407. input := make(map[string]interface{})
  14408. inputData := make(map[string]interface{})
  14409. inputData["orgId"] = code
  14410. inputData["businessType"] = "01101"
  14411. inputData["operatorId"] = "1"
  14412. inputData["operatorName"] = "admin"
  14413. inputData["officeId"] = "001"
  14414. inputData["officeName"] = "血透室"
  14415. inputData["deviceType"] = ""
  14416. input["data"] = inputData
  14417. input["orgId"] = code
  14418. input["transType"] = "ec.query"
  14419. bytesData, _ := json.Marshal(input)
  14420. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  14421. fmt.Println(ret2)
  14422. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  14423. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  14424. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  14425. }
  14426. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  14427. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  14428. readCard := DllDef.MustFindProc("NationEcTrans")
  14429. fmt.Println(readCard)
  14430. fmt.Println("!!!!!")
  14431. pBusiCardInfo := make([]byte, 2048)
  14432. input := make(map[string]interface{})
  14433. inputData := make(map[string]interface{})
  14434. inputData["orgId"] = code
  14435. inputData["businessType"] = "01101"
  14436. inputData["operatorId"] = "9"
  14437. inputData["operatorName"] = "admin"
  14438. inputData["officeId"] = "001"
  14439. inputData["officeName"] = "血透室"
  14440. inputData["deviceType"] = ""
  14441. input["data"] = inputData
  14442. input["orgId"] = code
  14443. input["transType"] = "ec.query"
  14444. bytesData, _ := json.Marshal(input)
  14445. 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])))
  14446. fmt.Println(ret2)
  14447. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  14448. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  14449. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  14450. }
  14451. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  14452. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  14453. readCard := DllDef.MustFindProc("NationEcTrans")
  14454. fmt.Println(readCard)
  14455. fmt.Println("!!!!!")
  14456. pBusiCardInfo := make([]byte, 2048)
  14457. input := make(map[string]interface{})
  14458. inputData := make(map[string]interface{})
  14459. inputData["orgId"] = code
  14460. inputData["businessType"] = "01301"
  14461. inputData["operatorId"] = "9"
  14462. inputData["operatorName"] = "admin"
  14463. inputData["officeId"] = "001"
  14464. inputData["officeName"] = "血透室"
  14465. inputData["deviceType"] = ""
  14466. input["data"] = inputData
  14467. input["orgId"] = code
  14468. input["transType"] = "ec.query"
  14469. bytesData, _ := json.Marshal(input)
  14470. 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])))
  14471. fmt.Println(ret2)
  14472. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  14473. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  14474. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  14475. }
  14476. func GetJxEleBaseInfo(org_id int64) string {
  14477. DllDef := syscall.MustLoadDLL("SSCard.dll")
  14478. readCard := DllDef.MustFindProc("NationEcTrans")
  14479. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  14480. if readCard == nil {
  14481. fmt.Println("readcard is nil")
  14482. readCard = DllDef.MustFindProc("NationEcTrans")
  14483. }
  14484. str1 := make([]byte, 1024)
  14485. data := make(map[string]interface{})
  14486. inputData := make(map[string]interface{})
  14487. inputData["orgId"] = miConfig.Code
  14488. inputData["businessType"] = "01101"
  14489. inputData["operatorId"] = "test001"
  14490. inputData["operatorName"] = "cn"
  14491. inputData["officeId"] = "32760"
  14492. inputData["officeName"] = "waike"
  14493. inputData["deviceType"] = ""
  14494. data["data"] = inputData
  14495. data["transType"] = "ec.query"
  14496. data["extra "] = ""
  14497. data["orgId"] = miConfig.Code
  14498. bytesData, _ := json.Marshal(data)
  14499. //bytesData, _ := json.Marshal(data)
  14500. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  14501. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  14502. fmt.Println(ret2)
  14503. fmt.Println(string(str1))
  14504. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  14505. if ret2 != 0 {
  14506. return ""
  14507. }
  14508. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  14509. }
  14510. //func GetJxEleBaseInfoTWO(org_id int64) string {
  14511. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  14512. // readCard := DllDef.MustFindProc("NationEcTrans")
  14513. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  14514. //
  14515. // if readCard == nil {
  14516. // fmt.Println("readcard is nil")
  14517. // readCard = DllDef.MustFindProc("NationEcTrans")
  14518. // }
  14519. // str1 := make([]byte, 1024)
  14520. //
  14521. // data := make(map[string]interface{})
  14522. //
  14523. // inputData := make(map[string]interface{})
  14524. // inputData["orgId"] = miConfig.Code
  14525. // inputData["businessType"] = "01101"
  14526. // inputData["operatorId"] = "test001"
  14527. // inputData["operatorName"] = "cn"
  14528. // inputData["officeId"] = "32760"
  14529. // inputData["officeName"] = "waike"
  14530. // inputData["deviceType"] = ""
  14531. //
  14532. // data["data"] = inputData
  14533. // data["transType"] = "ec.query"
  14534. // data["extra "] = ""
  14535. // data["orgId"] = miConfig.Code
  14536. // bytesData, _ := json.Marshal(data)
  14537. // //bytesData, _ := json.Marshal(data)
  14538. //
  14539. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  14540. //
  14541. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  14542. // fmt.Println(ret2)
  14543. // fmt.Println(string(str1))
  14544. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  14545. //
  14546. // if ret2 != 0 {
  14547. // return ""
  14548. // }
  14549. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  14550. //}
  14551. func GetJxEleBaseInitInfo(org_id int64) string {
  14552. DllDef := syscall.MustLoadDLL("SSCard.dll")
  14553. readCard := DllDef.MustFindProc("NationEcTrans")
  14554. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  14555. if readCard == nil {
  14556. fmt.Println("readcard is nil")
  14557. readCard = DllDef.MustFindProc("NationEcTrans")
  14558. }
  14559. str1 := make([]byte, 2048)
  14560. data := make(map[string]interface{})
  14561. inputData := make(map[string]interface{})
  14562. inputData["orgId"] = miConfig.Code
  14563. inputData["businessType"] = "01101"
  14564. inputData["operatorId"] = "1"
  14565. inputData["operatorName"] = "huangchuang"
  14566. inputData["officeId"] = "101"
  14567. inputData["officeName"] = "xuetou"
  14568. inputData["deviceType"] = ""
  14569. data["data"] = inputData
  14570. data["transType"] = "ec.query"
  14571. data["orgId"] = miConfig.Code
  14572. bytesData, _ := json.Marshal(data)
  14573. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  14574. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  14575. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  14576. fmt.Println(ret2)
  14577. fmt.Println(string(str1))
  14578. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  14579. if ret2 != 0 {
  14580. return ""
  14581. }
  14582. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  14583. initEleFlag = 1
  14584. }
  14585. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  14586. }
  14587. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  14588. // // 构建命令
  14589. // cmd := exec.Command("python", "b.py")
  14590. //
  14591. // // 执行命令并等待完成
  14592. // output, err := cmd.CombinedOutput()
  14593. // if err != nil {
  14594. // fmt.Println("Error executing Python script:", err)
  14595. // return
  14596. // }
  14597. //
  14598. // // 打印Python脚本的输出
  14599. // fmt.Println(string(output))
  14600. //}
  14601. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  14602. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  14603. readCard := DllDef.MustFindProc("gxyb_call")
  14604. if readCard == nil {
  14605. fmt.Println("readcard is nil")
  14606. readCard = DllDef.MustFindProc("gxyb_call")
  14607. }
  14608. str := make([]byte, 1024)
  14609. str1 := make([]byte, 1024)
  14610. //data := make(map[string]interface{})
  14611. currentTime := time.Now()
  14612. // 格式化时间为 "YYYYMMDDHH24MISS"
  14613. formattedTime := currentTime.Format("20060102150405")
  14614. inputData := make(map[string]interface{})
  14615. inputData2 := make(map[string]interface{})
  14616. inputData["transNo"] = "1401"
  14617. inputData["transType"] = "passwordCheck"
  14618. inputData["timestamp"] = formattedTime
  14619. inputData2["fixmedinsCode"] = code
  14620. inputData2["psnNo"] = ""
  14621. inputData["data"] = inputData2
  14622. jsonBytes, err := json.Marshal(inputData)
  14623. if err != nil {
  14624. fmt.Println("Error encoding map to JSON:", err)
  14625. }
  14626. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  14627. fmt.Println(string(str1))
  14628. fmt.Println(string(str))
  14629. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  14630. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  14631. if ret2 != 0 {
  14632. return ""
  14633. }
  14634. return string(str)
  14635. }
  14636. func (c *HisApiController) GetoleInfo() Response {
  14637. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  14638. defer ole.CoUninitialize()
  14639. // Replace with the ProgID or CLSID of your COM object
  14640. progID := "YinHai.XJ.Actual.Interface.New"
  14641. // Create COM object
  14642. unknown, err := oleutil.CreateObject(progID)
  14643. if err != nil {
  14644. fmt.Println("Unable to create COM object:", err)
  14645. }
  14646. defer unknown.Release()
  14647. // Query for the IDispatch interface
  14648. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  14649. if err != nil {
  14650. fmt.Println("Unable to get IDispatch interface:", err)
  14651. }
  14652. defer dispatch.Release()
  14653. // Prepare parameters
  14654. transNo := "1401"
  14655. transType := "passwordCheck"
  14656. timestamp := time.Now().Unix()
  14657. fixmedinsCode := "H45072101171"
  14658. psnNo := ""
  14659. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  14660. result2 := ""
  14661. // Call COM object's method using the IDispatch interface
  14662. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  14663. fmt.Println(resulr)
  14664. fmt.Println(result2)
  14665. if err != nil {
  14666. fmt.Println("调用COM对象方法失败:", err)
  14667. }
  14668. var response Response
  14669. err2 := json.Unmarshal([]byte(result2), &response)
  14670. if err2 != nil {
  14671. fmt.Println("解析JSON失败:", err)
  14672. }
  14673. return response
  14674. }
  14675. func (c *HisApiController) GetBasBaseInfo() string {
  14676. DllDef := syscall.MustLoadDLL("SSCard.dll")
  14677. readCard := DllDef.MustFindProc("ReadCardBas")
  14678. if readCard == nil {
  14679. fmt.Println("readcard is nil")
  14680. readCard = DllDef.MustFindProc("ReadCardBas")
  14681. }
  14682. str := make([]byte, 1024)
  14683. str1 := make([]byte, 1024)
  14684. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  14685. fmt.Println(string(str1))
  14686. fmt.Println(string(str))
  14687. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  14688. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  14689. if ret2 != 0 {
  14690. return ""
  14691. }
  14692. return string(str)
  14693. }
  14694. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  14695. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  14696. readCard := DllDef.MustFindProc("read_cardinfo")
  14697. if readCard == nil {
  14698. fmt.Println("readcard is nil")
  14699. readCard = DllDef.MustFindProc("read_cardinfo")
  14700. }
  14701. str := make([]byte, 1024) //卡号
  14702. str1 := make([]byte, 1024) //卡识别码
  14703. str2 := make([]byte, 1024) //身份证号
  14704. str3 := make([]byte, 1024) //姓名
  14705. str4 := make([]byte, 1024) //错误信息
  14706. 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])))
  14707. fmt.Println(string(str1))
  14708. fmt.Println(string(str))
  14709. fmt.Println(string(str2))
  14710. fmt.Println(string(str3))
  14711. fmt.Println(string(str4))
  14712. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  14713. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  14714. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  14715. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  14716. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  14717. if ret2 != 0 {
  14718. return "", "", "", "", ""
  14719. }
  14720. return string(str), string(str1), string(str2), string(str3), string(str4)
  14721. }
  14722. type CustomFundPay struct {
  14723. FundPayType string `json:"fund_pay_type"`
  14724. FundPayamt float64 `json:"fund_payamt"`
  14725. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14726. }
  14727. //func (c *HisApiController) GetBatchSettleList() {
  14728. // start_time_str := c.GetString("start_time")
  14729. // //end_time_str := c.GetString("end_time")
  14730. // admin_user_id, _ := c.GetInt64("admin_user_id")
  14731. //
  14732. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  14733. //
  14734. // for _, item := range orders {
  14735. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  14736. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  14737. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  14738. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  14739. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  14740. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  14741. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14742. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  14743. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  14744. //
  14745. // if order.ID == 0 {
  14746. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  14747. // return
  14748. // }
  14749. //
  14750. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  14751. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  14752. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  14753. // //fmt.Println(count)
  14754. // //var zero string
  14755. // //number := count + 1
  14756. // //if number >= 1000 {
  14757. // // zero = "0000" + strconv.FormatInt(number, 10)
  14758. // //} else if number >= 10000 {
  14759. // // zero = "000" + strconv.FormatInt(number, 10)
  14760. // //} else if number >= 100000 {
  14761. // // zero = "00" + strconv.FormatInt(number, 10)
  14762. // //} else if number >= 1000000 {
  14763. // // zero = "0" + strconv.FormatInt(number, 10)
  14764. // //} else {
  14765. // // zero = strconv.FormatInt(number, 10)
  14766. // //}
  14767. // //fmt.Println(zero)
  14768. //
  14769. // struct4101 := service.Struct4101{
  14770. // PsnNo: order.PsnNo,
  14771. // MdtrtId: order.MdtrtId,
  14772. // SetlId: order.SetlId,
  14773. // PsnName: order.PsnName,
  14774. // Gend: order.Gend,
  14775. // Brdy: his.Brdy,
  14776. // Age: his.Age,
  14777. // Naty: order.Naty,
  14778. // PatnCertType: "01",
  14779. // Certno: order.Certno,
  14780. // Prfs: "90",
  14781. // ConerName: roles[0].UserName,
  14782. // PatnRlts: "99",
  14783. // ConerAddr: miConfig.OrgName,
  14784. // ConerTel: admin.Mobile,
  14785. // HiType: order.Insutype,
  14786. // Insuplc: miConfig.InsuplcAdmdvs,
  14787. // MaindiagFlag: "1",
  14788. // BillCode: order.SetlId,
  14789. // BillNo: order.SetlId,
  14790. // BizSn: order.Number,
  14791. // PsnSelfPay: order.PsnPartAmt,
  14792. // PsnOwnPay: order.PsnPartAmt,
  14793. // AcctPay: order.AcctPay,
  14794. // PsnCashpay: order.PsnCashPay,
  14795. // HiPaymtd: "1",
  14796. // Hsorg: miConfig.InsuplcAdmdvs,
  14797. // HsorgOpter: miConfig.InsuplcAdmdvs,
  14798. // MedinsFillPsn: curRoles.UserName,
  14799. // MedinsFillDept: miConfig.OrgName,
  14800. // IptMedType: "2",
  14801. // }
  14802. // struct4101.SetlBegnDate = order.SetlTime
  14803. // struct4101.SetlEndDate = order.SetlTime
  14804. // time_arr := strings.Split(order.SetlTime, " ")
  14805. // struct4101.AdmTime = time_arr[0]
  14806. // struct4101.AdmEndTime = time_arr[0]
  14807. //
  14808. // var rf []CustomFundPay
  14809. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  14810. //
  14811. // var tempFunPays []service.CustomStruct
  14812. // for _, item := range rf {
  14813. // var tempFunPay service.CustomStruct
  14814. // tempFunPay.FundPayamt = item.FundPayamt
  14815. // tempFunPay.FundPayType = item.FundPayType
  14816. // tempFunPays = append(tempFunPays, tempFunPay)
  14817. // }
  14818. // struct4101.CustomStruct = tempFunPays
  14819. //
  14820. // var tempDiaginfos []service.DiaginfoStructTwo
  14821. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  14822. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  14823. //
  14824. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  14825. // var config []*models.HisXtDiagnoseConfig
  14826. // for _, item := range diagnosis_ids {
  14827. // id, _ := strconv.ParseInt(item, 10, 64)
  14828. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  14829. // config = append(config, &diagnosisConfig)
  14830. // }
  14831. //
  14832. // for index, item := range config {
  14833. // if index == 0 {
  14834. // var tempDiaginfo service.DiaginfoStructTwo
  14835. // tempDiaginfo.DiagCode = item.CountryCode
  14836. // tempDiaginfo.DiagName = item.CountryContentName
  14837. // tempDiaginfo.DiagType = "1"
  14838. // tempDiaginfo.MaindiagFlag = "1"
  14839. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14840. // } else {
  14841. // var tempDiaginfo service.DiaginfoStructTwo
  14842. // tempDiaginfo.DiagCode = item.CountryCode
  14843. // tempDiaginfo.DiagName = item.CountryContentName
  14844. // tempDiaginfo.DiagType = "1"
  14845. // tempDiaginfo.MaindiagFlag = "0"
  14846. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14847. // }
  14848. // }
  14849. // struct4101.Diseinfo = tempDiaginfos
  14850. //
  14851. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  14852. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  14853. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  14854. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  14855. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  14856. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  14857. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  14858. //
  14859. // var iteminfo service.IteminfoStruct
  14860. //
  14861. // var bedCostTotal float64 = 0 //床位总费
  14862. // var bedCostSelfTotal float64 = 0 //床位自费
  14863. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  14864. //
  14865. // var operationCostTotal float64 = 0 //手术费
  14866. // var operationCostSelfTotal float64 = 0 //手术费
  14867. // var operationCostPartSelfTotal float64 = 0 //手术费
  14868. //
  14869. // var otherCostTotal float64 = 0 //其他费用
  14870. // var otherCostSelfTotal float64 = 0 //其他费用
  14871. // var otherCostPartSelfTotal float64 = 0 //其他费用
  14872. //
  14873. // var materialCostTotal float64 = 0 //材料费
  14874. // var materialCostSelfTotal float64 = 0 //材料费
  14875. // var materialCostPartSelfTotal float64 = 0 //材料费
  14876. //
  14877. // var westernMedicineCostTotal float64 = 0 //西药费
  14878. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  14879. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  14880. //
  14881. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  14882. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  14883. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  14884. //
  14885. // var checkCostTotal float64 = 0 //检查费
  14886. // var checkCostSelfTotal float64 = 0 //检查费
  14887. // var checkCostPartSelfTotal float64 = 0 //检查费
  14888. //
  14889. // var laboratoryCostTotal float64 = 0 //化验费
  14890. // var laboratoryCostSelfTotal float64 = 0 //化验费
  14891. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  14892. //
  14893. // var treatCostTotal float64 = 0 //治疗费用
  14894. // var treatCostSelfTotal float64 = 0 //治疗费用
  14895. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  14896. //
  14897. // decimal.DivisionPrecision = 2
  14898. //
  14899. // var bed_fulamt_ownpay_amt float64 = 0
  14900. // var operation_fulamt_ownpay_amt float64 = 0
  14901. // var other_fulamt_ownpay_amt float64 = 0
  14902. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  14903. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  14904. // var check_fulamt_ownpay_amt float64 = 0
  14905. // var material_fulamt_ownpay_amt float64 = 0
  14906. // var laboratory_fulamt_ownpay_amt float64 = 0
  14907. // var treat_fulamt_ownpay_amt float64 = 0
  14908. //
  14909. // var bed_claa_sunmfee float64 = 0
  14910. // var bed_clab_amt float64 = 0
  14911. // var bed_other_amt float64 = 0
  14912. //
  14913. // var operation_claa_sunmfee float64 = 0
  14914. // var operation_clab_amt float64 = 0
  14915. // var operation_other_amt float64 = 0
  14916. //
  14917. // var other_claa_sunmfee float64 = 0
  14918. // var other_clab_amt float64 = 0
  14919. // var other_other_amt float64 = 0
  14920. //
  14921. // var westernMedicine_claa_sunmfee float64 = 0
  14922. // var westernMedicine_clab_amt float64 = 0
  14923. // var westernMedicine_other_amt float64 = 0
  14924. //
  14925. // var chineseTraditional_claa_sunmfee float64 = 0
  14926. // var chineseTraditional_clab_amt float64 = 0
  14927. // var chineseTraditional_other_amt float64 = 0
  14928. //
  14929. // var check_claa_sunmfee float64 = 0
  14930. // var check_clab_amt float64 = 0
  14931. // var check_other_amt float64 = 0
  14932. //
  14933. // var material_claa_sunmfee float64 = 0
  14934. // var material_clab_amt float64 = 0
  14935. // var material_other_amt float64 = 0
  14936. //
  14937. // var laboratory_claa_sunmfee float64 = 0
  14938. // var laboratory_clab_amt float64 = 0
  14939. // var laboratory_other_amt float64 = 0
  14940. //
  14941. // var treat_claa_sunmfee float64 = 0
  14942. // var treat_clab_amt float64 = 0
  14943. // var treat_other_amt float64 = 0
  14944. //
  14945. // for _, item := range order.HisOrderInfo {
  14946. // if item.MedChrgitmType == "01" { //床位费
  14947. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14948. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14949. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14950. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14951. // if item.ChrgitmLv == "1" {
  14952. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14953. // }
  14954. // if item.ChrgitmLv == "2" {
  14955. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14956. //
  14957. // }
  14958. // if item.ChrgitmLv == "3" {
  14959. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14960. // }
  14961. //
  14962. // }
  14963. //
  14964. // if item.MedChrgitmType == "03" { //检查费
  14965. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14966. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14967. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14968. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14969. // if item.ChrgitmLv == "1" {
  14970. //
  14971. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14972. //
  14973. // }
  14974. // if item.ChrgitmLv == "2" {
  14975. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14976. //
  14977. // }
  14978. // if item.ChrgitmLv == "3" {
  14979. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14980. // }
  14981. // }
  14982. //
  14983. // if item.MedChrgitmType == "04" { //化验费
  14984. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14985. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14986. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14987. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14988. // if item.ChrgitmLv == "1" {
  14989. //
  14990. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14991. //
  14992. // }
  14993. // if item.ChrgitmLv == "2" {
  14994. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14995. //
  14996. // }
  14997. // if item.ChrgitmLv == "3" {
  14998. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14999. // }
  15000. // }
  15001. //
  15002. // if item.MedChrgitmType == "05" { //治疗费
  15003. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15004. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15005. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15006. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15007. // if item.ChrgitmLv == "1" {
  15008. //
  15009. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15010. //
  15011. // }
  15012. // if item.ChrgitmLv == "2" {
  15013. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15014. //
  15015. // }
  15016. // if item.ChrgitmLv == "3" {
  15017. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15018. // }
  15019. // }
  15020. //
  15021. // if item.MedChrgitmType == "06" { //手术费
  15022. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15023. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15024. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15025. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15026. //
  15027. // if item.ChrgitmLv == "1" {
  15028. //
  15029. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15030. //
  15031. // }
  15032. // if item.ChrgitmLv == "2" {
  15033. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15034. //
  15035. // }
  15036. // if item.ChrgitmLv == "3" {
  15037. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15038. // }
  15039. // }
  15040. //
  15041. // if item.MedChrgitmType == "08" { //材料费
  15042. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15043. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15044. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15045. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15046. // if item.ChrgitmLv == "1" {
  15047. //
  15048. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15049. //
  15050. // }
  15051. // if item.ChrgitmLv == "2" {
  15052. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15053. //
  15054. // }
  15055. // if item.ChrgitmLv == "3" {
  15056. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15057. // }
  15058. // }
  15059. //
  15060. // if item.MedChrgitmType == "09" { //西药费
  15061. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15062. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15063. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15064. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15065. // if item.ChrgitmLv == "1" {
  15066. //
  15067. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15068. //
  15069. // }
  15070. // if item.ChrgitmLv == "2" {
  15071. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15072. //
  15073. // }
  15074. // if item.ChrgitmLv == "3" {
  15075. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15076. // }
  15077. // }
  15078. //
  15079. // if item.MedChrgitmType == "11" { //中成费
  15080. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15081. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15082. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15083. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15084. // if item.ChrgitmLv == "1" {
  15085. //
  15086. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15087. //
  15088. // }
  15089. // if item.ChrgitmLv == "2" {
  15090. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15091. //
  15092. // }
  15093. // if item.ChrgitmLv == "3" {
  15094. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15095. // }
  15096. // }
  15097. //
  15098. // if item.MedChrgitmType == "14" { //其他费
  15099. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15100. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15101. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15102. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15103. // if item.ChrgitmLv == "1" {
  15104. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15105. //
  15106. // }
  15107. // if item.ChrgitmLv == "2" {
  15108. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15109. //
  15110. // }
  15111. // if item.ChrgitmLv == "3" {
  15112. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15113. // }
  15114. // }
  15115. //
  15116. // }
  15117. //
  15118. // var iteminfoStructs []service.IteminfoStruct
  15119. //
  15120. // if bedCostTotal != 0 {
  15121. // iteminfo.MedChrgitm = "01"
  15122. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  15123. // iteminfo.Amt = bedCostTotal
  15124. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  15125. // iteminfo.ClabAmt = bed_clab_amt
  15126. // iteminfo.OthAmt = bed_other_amt
  15127. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15128. // }
  15129. //
  15130. // if checkCostTotal != 0 {
  15131. // iteminfo.MedChrgitm = "03"
  15132. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  15133. // iteminfo.Amt = checkCostTotal
  15134. // iteminfo.ClaaSumfee = check_claa_sunmfee
  15135. // iteminfo.ClabAmt = check_clab_amt
  15136. // iteminfo.OthAmt = check_other_amt
  15137. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15138. //
  15139. // }
  15140. //
  15141. // if laboratoryCostTotal != 0 {
  15142. // iteminfo.MedChrgitm = "04"
  15143. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  15144. // iteminfo.Amt = laboratoryCostTotal
  15145. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  15146. // iteminfo.ClabAmt = laboratory_clab_amt
  15147. // iteminfo.OthAmt = laboratory_other_amt
  15148. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15149. //
  15150. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15151. //
  15152. // }
  15153. //
  15154. // if treatCostTotal != 0 {
  15155. // iteminfo.MedChrgitm = "05"
  15156. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  15157. // iteminfo.Amt = treatCostTotal
  15158. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  15159. // iteminfo.ClabAmt = treat_clab_amt
  15160. // iteminfo.OthAmt = treat_other_amt
  15161. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15162. // //(struct4101.IteminfoStruct, iteminfo)
  15163. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15164. // }
  15165. //
  15166. // if operationCostTotal != 0 {
  15167. // iteminfo.MedChrgitm = "06"
  15168. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  15169. // iteminfo.Amt = operationCostTotal
  15170. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  15171. // iteminfo.ClabAmt = operation_clab_amt
  15172. // iteminfo.OthAmt = operation_other_amt
  15173. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15174. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15175. // }
  15176. //
  15177. // if materialCostTotal != 0 {
  15178. // iteminfo.MedChrgitm = "08"
  15179. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  15180. // iteminfo.Amt = materialCostTotal
  15181. // iteminfo.ClaaSumfee = material_claa_sunmfee
  15182. // iteminfo.ClabAmt = material_clab_amt
  15183. // iteminfo.OthAmt = material_other_amt
  15184. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15185. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15186. // }
  15187. //
  15188. // if westernMedicineCostTotal != 0 {
  15189. // iteminfo.MedChrgitm = "09"
  15190. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  15191. // iteminfo.Amt = westernMedicineCostTotal
  15192. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  15193. // iteminfo.ClabAmt = westernMedicine_clab_amt
  15194. // iteminfo.OthAmt = westernMedicine_other_amt
  15195. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15196. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15197. //
  15198. // }
  15199. // if chineseTraditionalMedicineCostTotal != 0 {
  15200. // iteminfo.MedChrgitm = "11"
  15201. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  15202. // iteminfo.Amt = westernMedicineCostTotal
  15203. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  15204. // iteminfo.ClabAmt = westernMedicine_clab_amt
  15205. // iteminfo.OthAmt = westernMedicine_other_amt
  15206. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15207. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15208. //
  15209. // }
  15210. // if otherCostTotal != 0 {
  15211. // iteminfo.MedChrgitm = "14"
  15212. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  15213. // iteminfo.Amt = otherCostTotal
  15214. // iteminfo.ClaaSumfee = other_claa_sunmfee
  15215. // iteminfo.ClabAmt = other_clab_amt
  15216. // iteminfo.OthAmt = other_other_amt
  15217. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15218. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15219. //
  15220. // }
  15221. // struct4101.IteminfoStruct = iteminfoStructs
  15222. // struct4101.Ntly = "中国"
  15223. // struct4101.AdmCaty = "A03.06"
  15224. //
  15225. // struct4101.DoctorName = doctor.UserName
  15226. // struct4101.DoctorCode = doctor.DoctorNumber
  15227. //
  15228. // var res ResultSeventeen
  15229. //
  15230. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15231. // struct4101.BillCode = order.Number
  15232. // struct4101.BillNo = order.SetlId
  15233. // var resOther ResultSeventeenOther
  15234. // var pp models.PublicParams
  15235. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  15236. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  15237. // pp.FixmedinsName = miConfig.OrgName
  15238. // pp.FixmedinsCode = miConfig.Code
  15239. // pp.RequestUrl = miConfig.Url
  15240. // pp.Cainfo = miConfig.Cainfo
  15241. // pp.SecretKey = miConfig.SecretKey
  15242. // pp.AccessKey = miConfig.AccessKey
  15243. // pp.OpterName = curRoles.UserName
  15244. //
  15245. // client := &http.Client{}
  15246. // var req *http.Request
  15247. // data := make(map[string]interface{})
  15248. // data["struct4101"] = struct4101
  15249. // data["pp"] = pp
  15250. // bytesData, _ := json.Marshal(data)
  15251. // if miConfig.MdtrtareaAdmvs == "320921" {
  15252. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  15253. // } else {
  15254. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  15255. // }
  15256. // resp, _ := client.Do(req)
  15257. // defer resp.Body.Close()
  15258. // body, ioErr := ioutil.ReadAll(resp.Body)
  15259. // if ioErr != nil {
  15260. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15261. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15262. // return
  15263. // }
  15264. // var respJSON map[string]interface{}
  15265. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15266. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15267. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15268. // return
  15269. // }
  15270. //
  15271. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15272. // userJSONBytes, _ := json.Marshal(respJSON)
  15273. // fmt.Println("log")
  15274. // fmt.Println(string(userJSONBytes))
  15275. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  15276. // utils.ErrorLog("解析失败:%v", err)
  15277. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15278. // return
  15279. // }
  15280. // res.InfRefmsgid = resOther.InfRefmsgid
  15281. // res.Output = resOther.Output
  15282. // res.ErrMsg = resOther.ErrMsg
  15283. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  15284. // res.Infcode = infocode
  15285. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  15286. //
  15287. // var pp models.PublicParams
  15288. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  15289. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  15290. // pp.FixmedinsName = miConfig.OrgName
  15291. // pp.FixmedinsCode = miConfig.Code
  15292. // pp.RequestUrl = miConfig.Url
  15293. // pp.Cainfo = miConfig.Cainfo
  15294. // pp.SecretKey = miConfig.SecretKey
  15295. // pp.AccessKey = miConfig.AccessKey
  15296. // pp.OpterName = curRoles.UserName
  15297. // result, _ := service.Jxyb4101(struct4101, pp)
  15298. // var dat map[string]interface{}
  15299. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15300. // fmt.Println(dat)
  15301. // } else {
  15302. // fmt.Println(err)
  15303. // }
  15304. // userJSONBytes, _ := json.Marshal(dat)
  15305. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15306. // utils.ErrorLog("解析失败:%v", err)
  15307. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15308. // return
  15309. // }
  15310. //
  15311. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  15312. // var pp models.PublicParams
  15313. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  15314. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  15315. // pp.FixmedinsName = miConfig.OrgName
  15316. // pp.FixmedinsCode = miConfig.Code
  15317. // pp.RequestUrl = miConfig.Url
  15318. // pp.Cainfo = miConfig.Cainfo
  15319. // pp.SecretKey = miConfig.SecretKey
  15320. // pp.AccessKey = miConfig.AccessKey
  15321. // pp.OpterName = curRoles.UserName
  15322. // result, _ := service.Hnyb4101(struct4101, pp)
  15323. // var dat map[string]interface{}
  15324. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15325. // fmt.Println(dat)
  15326. // } else {
  15327. // fmt.Println(err)
  15328. // }
  15329. // userJSONBytes, _ := json.Marshal(dat)
  15330. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15331. // utils.ErrorLog("解析失败:%v", err)
  15332. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15333. // return
  15334. // }
  15335. //
  15336. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  15337. // var resOther ResultSeventeenOther
  15338. //
  15339. // var pp models.PublicParams
  15340. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  15341. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  15342. // pp.FixmedinsName = miConfig.OrgName
  15343. // pp.FixmedinsCode = miConfig.Code
  15344. // pp.RequestUrl = miConfig.Url
  15345. // pp.Cainfo = miConfig.Cainfo
  15346. // pp.SecretKey = miConfig.SecretKey
  15347. // pp.AccessKey = miConfig.AccessKey
  15348. // pp.OpterName = curRoles.UserName
  15349. // client := &http.Client{}
  15350. // var req *http.Request
  15351. // data := make(map[string]interface{})
  15352. // data["struct4101"] = struct4101
  15353. // data["pp"] = pp
  15354. // bytesData, _ := json.Marshal(data)
  15355. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  15356. // resp, _ := client.Do(req)
  15357. // defer resp.Body.Close()
  15358. // body, ioErr := ioutil.ReadAll(resp.Body)
  15359. // if ioErr != nil {
  15360. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15361. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15362. // return
  15363. // }
  15364. // var respJSON map[string]interface{}
  15365. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15366. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15367. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15368. // return
  15369. // }
  15370. //
  15371. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15372. // userJSONBytes, _ := json.Marshal(respJSON)
  15373. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  15374. // utils.ErrorLog("解析失败:%v", err)
  15375. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15376. // return
  15377. // }
  15378. // res.InfRefmsgid = resOther.InfRefmsgid
  15379. // res.Output = resOther.Output
  15380. // res.ErrMsg = resOther.ErrMsg
  15381. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  15382. // res.Infcode = infocode
  15383. //
  15384. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  15385. // var pp models.PublicParams
  15386. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  15387. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  15388. // pp.FixmedinsName = miConfig.OrgName
  15389. // pp.FixmedinsCode = miConfig.Code
  15390. // pp.RequestUrl = miConfig.Url
  15391. // pp.Cainfo = miConfig.Cainfo
  15392. // pp.SecretKey = miConfig.SecretKey
  15393. // pp.AccessKey = miConfig.AccessKey
  15394. // pp.OpterName = curRoles.UserName
  15395. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  15396. // fmt.Println(requestLog)
  15397. // fmt.Println(errMsgLog)
  15398. //
  15399. // saveLog(result, requestLog, "4101a", "上传清单")
  15400. //
  15401. // var dat map[string]interface{}
  15402. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15403. // fmt.Println(dat)
  15404. // } else {
  15405. // fmt.Println(err)
  15406. // }
  15407. // userJSONBytes, _ := json.Marshal(dat)
  15408. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15409. // utils.ErrorLog("解析失败:%v", err)
  15410. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15411. // return
  15412. // }
  15413. //
  15414. // } else {
  15415. //
  15416. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  15417. // var dat map[string]interface{}
  15418. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15419. // fmt.Println(dat)
  15420. // } else {
  15421. // fmt.Println(err)
  15422. // }
  15423. // userJSONBytes, _ := json.Marshal(dat)
  15424. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15425. // utils.ErrorLog("解析失败:%v", err)
  15426. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15427. // return
  15428. // }
  15429. // }
  15430. //
  15431. // if res.Infcode != 0 {
  15432. // adminUser := c.GetAdminUserInfo()
  15433. // errlog := &models.HisOrderError{
  15434. // UserOrgId: adminUser.CurrentOrgId,
  15435. // Ctime: time.Now().Unix(),
  15436. // Mtime: time.Now().Unix(),
  15437. // ErrMsg: res.ErrMsg,
  15438. // Status: 1,
  15439. // PatientId: order.ID,
  15440. // Stage: 10265,
  15441. // }
  15442. // service.CreateErrMsgLog(errlog)
  15443. // continue
  15444. // } else {
  15445. // //order.FaPiaoNumber = zero
  15446. // //order.FaPiaoCode = last_order.FaPiaoCode
  15447. // //service.UpdateOrder(order)
  15448. // hisFundSettleListResult := &models.HisFundSettleListResult{
  15449. // Number: res.Output.SetlListId,
  15450. // Status: 1,
  15451. // Ctime: time.Now().Unix(),
  15452. // Mtime: time.Now().Unix(),
  15453. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15454. // IsUpload: 1,
  15455. // OrderId: order.ID,
  15456. // }
  15457. // service.CreateUploadRecord(hisFundSettleListResult)
  15458. // c.ServeSuccessJSON(map[string]interface{}{
  15459. // "msg": "上传成功",
  15460. // "result": hisFundSettleListResult,
  15461. // })
  15462. // continue
  15463. // }
  15464. // }
  15465. //}
  15466. func (c *HisApiController) GetbatchSettleList() {
  15467. //order_id, _ := c.GetInt64("order_id")
  15468. admin_user_id, _ := c.GetInt64("admin_user_id")
  15469. orders, _ := service.GetAllHisOrderTwo10485()
  15470. for _, item := range orders {
  15471. order, _ := service.GetHisOrderByIDTwo(item.ID)
  15472. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  15473. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  15474. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  15475. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  15476. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  15477. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15478. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  15479. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  15480. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  15481. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  15482. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  15483. //fmt.Println(count)
  15484. //var zero string
  15485. //number := count + 1
  15486. //if number >= 1000 {
  15487. // zero = "0000" + strconv.FormatInt(number, 10)
  15488. //} else if number >= 10000 {
  15489. // zero = "000" + strconv.FormatInt(number, 10)
  15490. //} else if number >= 100000 {
  15491. // zero = "00" + strconv.FormatInt(number, 10)
  15492. //} else if number >= 1000000 {
  15493. // zero = "0" + strconv.FormatInt(number, 10)
  15494. //} else {
  15495. // zero = strconv.FormatInt(number, 10)
  15496. //}
  15497. //fmt.Println(zero)
  15498. struct4101 := service.Struct4101{
  15499. PsnNo: order.PsnNo,
  15500. MdtrtId: order.MdtrtId,
  15501. SetlId: order.SetlId,
  15502. PsnName: order.PsnName,
  15503. Gend: order.Gend,
  15504. Brdy: his.Brdy,
  15505. Age: his.Age,
  15506. Naty: order.Naty,
  15507. PatnCertType: "01",
  15508. Certno: order.Certno,
  15509. Prfs: "90",
  15510. ConerName: roles[0].UserName,
  15511. PatnRlts: "99",
  15512. ConerAddr: miConfig.OrgName,
  15513. ConerTel: admin.Mobile,
  15514. HiType: order.Insutype,
  15515. Insuplc: miConfig.InsuplcAdmdvs,
  15516. MaindiagFlag: "1",
  15517. BillCode: order.SetlId,
  15518. BillNo: order.SetlId,
  15519. BizSn: order.Number,
  15520. PsnSelfPay: order.PsnPartAmt,
  15521. PsnOwnPay: order.PsnPartAmt,
  15522. AcctPay: order.AcctPay,
  15523. PsnCashpay: order.PsnCashPay,
  15524. HiPaymtd: "1",
  15525. Hsorg: miConfig.InsuplcAdmdvs,
  15526. HsorgOpter: miConfig.InsuplcAdmdvs,
  15527. MedinsFillPsn: curRoles.UserName,
  15528. MedinsFillDept: miConfig.OrgName,
  15529. IptMedType: "2",
  15530. }
  15531. struct4101.SetlBegnDate = order.SetlTime
  15532. struct4101.SetlEndDate = order.SetlTime
  15533. time_arr := strings.Split(order.SetlTime, " ")
  15534. struct4101.AdmTime = time_arr[0]
  15535. struct4101.AdmEndTime = time_arr[0]
  15536. //var rf []CustomFundPay
  15537. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  15538. //
  15539. //var tempFunPays []service.CustomStruct
  15540. //for _, item := range rf {
  15541. // var tempFunPay service.CustomStruct
  15542. // tempFunPay.FundPayamt = item.FundPayamt
  15543. // tempFunPay.FundPayType = item.FundPayType
  15544. // tempFunPays = append(tempFunPays, tempFunPay)
  15545. //}
  15546. //struct4101.CustomStruct = tempFunPays
  15547. var tempDiaginfos []service.DiaginfoStructTwo
  15548. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  15549. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  15550. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  15551. var config []*models.HisXtDiagnoseConfig
  15552. for _, item := range diagnosis_ids {
  15553. id, _ := strconv.ParseInt(item, 10, 64)
  15554. diagnosisConfig, _ := service.FindDiagnoseById(id)
  15555. config = append(config, &diagnosisConfig)
  15556. }
  15557. for index, item := range config {
  15558. if index == 0 {
  15559. var tempDiaginfo service.DiaginfoStructTwo
  15560. tempDiaginfo.DiagCode = item.CountryCode
  15561. tempDiaginfo.DiagName = item.CountryContentName
  15562. tempDiaginfo.DiagType = "1"
  15563. tempDiaginfo.MaindiagFlag = "1"
  15564. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  15565. } else {
  15566. var tempDiaginfo service.DiaginfoStructTwo
  15567. tempDiaginfo.DiagCode = item.CountryCode
  15568. tempDiaginfo.DiagName = item.CountryContentName
  15569. tempDiaginfo.DiagType = "1"
  15570. tempDiaginfo.MaindiagFlag = "0"
  15571. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  15572. }
  15573. }
  15574. struct4101.Diseinfo = tempDiaginfos
  15575. sickConfigTwo, _ := service.FindSickById(his.SickType)
  15576. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  15577. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  15578. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  15579. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  15580. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  15581. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  15582. var iteminfo service.IteminfoStruct
  15583. var bedCostTotal float64 = 0 //床位总费
  15584. var bedCostSelfTotal float64 = 0 //床位自费
  15585. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  15586. var operationCostTotal float64 = 0 //手术费
  15587. var operationCostSelfTotal float64 = 0 //手术费
  15588. var operationCostPartSelfTotal float64 = 0 //手术费
  15589. var otherCostTotal float64 = 0 //其他费用
  15590. var otherCostSelfTotal float64 = 0 //其他费用
  15591. var otherCostPartSelfTotal float64 = 0 //其他费用
  15592. var materialCostTotal float64 = 0 //材料费
  15593. var materialCostSelfTotal float64 = 0 //材料费
  15594. var materialCostPartSelfTotal float64 = 0 //材料费
  15595. var westernMedicineCostTotal float64 = 0 //西药费
  15596. var westernMedicineCostSelfTotal float64 = 0 //西药费
  15597. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  15598. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  15599. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  15600. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  15601. var checkCostTotal float64 = 0 //检查费
  15602. var checkCostSelfTotal float64 = 0 //检查费
  15603. var checkCostPartSelfTotal float64 = 0 //检查费
  15604. var laboratoryCostTotal float64 = 0 //化验费
  15605. var laboratoryCostSelfTotal float64 = 0 //化验费
  15606. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  15607. var treatCostTotal float64 = 0 //治疗费用
  15608. var treatCostSelfTotal float64 = 0 //治疗费用
  15609. var treatCostPartSelfTotal float64 = 0 //治疗费用
  15610. decimal.DivisionPrecision = 2
  15611. var bed_fulamt_ownpay_amt float64 = 0
  15612. var operation_fulamt_ownpay_amt float64 = 0
  15613. var other_fulamt_ownpay_amt float64 = 0
  15614. var westernMedicine_fulamt_ownpay_amt float64 = 0
  15615. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  15616. var check_fulamt_ownpay_amt float64 = 0
  15617. var material_fulamt_ownpay_amt float64 = 0
  15618. var laboratory_fulamt_ownpay_amt float64 = 0
  15619. var treat_fulamt_ownpay_amt float64 = 0
  15620. var bed_claa_sunmfee float64 = 0
  15621. var bed_clab_amt float64 = 0
  15622. var bed_other_amt float64 = 0
  15623. var operation_claa_sunmfee float64 = 0
  15624. var operation_clab_amt float64 = 0
  15625. var operation_other_amt float64 = 0
  15626. var other_claa_sunmfee float64 = 0
  15627. var other_clab_amt float64 = 0
  15628. var other_other_amt float64 = 0
  15629. var westernMedicine_claa_sunmfee float64 = 0
  15630. var westernMedicine_clab_amt float64 = 0
  15631. var westernMedicine_other_amt float64 = 0
  15632. var chineseTraditional_claa_sunmfee float64 = 0
  15633. var chineseTraditional_clab_amt float64 = 0
  15634. var chineseTraditional_other_amt float64 = 0
  15635. var check_claa_sunmfee float64 = 0
  15636. var check_clab_amt float64 = 0
  15637. var check_other_amt float64 = 0
  15638. var material_claa_sunmfee float64 = 0
  15639. var material_clab_amt float64 = 0
  15640. var material_other_amt float64 = 0
  15641. var laboratory_claa_sunmfee float64 = 0
  15642. var laboratory_clab_amt float64 = 0
  15643. var laboratory_other_amt float64 = 0
  15644. var treat_claa_sunmfee float64 = 0
  15645. var treat_clab_amt float64 = 0
  15646. var treat_other_amt float64 = 0
  15647. for _, item := range order.HisOrderInfo {
  15648. if item.MedChrgitmType == "01" { //床位费
  15649. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15650. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15651. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15652. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15653. if item.ChrgitmLv == "1" {
  15654. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15655. }
  15656. if item.ChrgitmLv == "2" {
  15657. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15658. }
  15659. if item.ChrgitmLv == "3" {
  15660. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15661. }
  15662. }
  15663. if item.MedChrgitmType == "03" { //检查费
  15664. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15665. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15666. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15667. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15668. if item.ChrgitmLv == "1" {
  15669. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15670. }
  15671. if item.ChrgitmLv == "2" {
  15672. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15673. }
  15674. if item.ChrgitmLv == "3" {
  15675. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15676. }
  15677. }
  15678. if item.MedChrgitmType == "04" { //化验费
  15679. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15680. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15681. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15682. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15683. if item.ChrgitmLv == "1" {
  15684. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15685. }
  15686. if item.ChrgitmLv == "2" {
  15687. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15688. }
  15689. if item.ChrgitmLv == "3" {
  15690. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15691. }
  15692. }
  15693. if item.MedChrgitmType == "05" { //治疗费
  15694. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15695. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15696. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15697. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15698. if item.ChrgitmLv == "1" {
  15699. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15700. }
  15701. if item.ChrgitmLv == "2" {
  15702. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15703. }
  15704. if item.ChrgitmLv == "3" {
  15705. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15706. }
  15707. }
  15708. if item.MedChrgitmType == "06" { //手术费
  15709. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15710. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15711. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15712. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15713. if item.ChrgitmLv == "1" {
  15714. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15715. }
  15716. if item.ChrgitmLv == "2" {
  15717. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15718. }
  15719. if item.ChrgitmLv == "3" {
  15720. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15721. }
  15722. }
  15723. if item.MedChrgitmType == "08" { //材料费
  15724. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15725. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15726. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15727. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15728. if item.ChrgitmLv == "1" {
  15729. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15730. }
  15731. if item.ChrgitmLv == "2" {
  15732. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15733. }
  15734. if item.ChrgitmLv == "3" {
  15735. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15736. }
  15737. }
  15738. if item.MedChrgitmType == "09" { //西药费
  15739. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15740. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15741. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15742. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15743. if item.ChrgitmLv == "1" {
  15744. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15745. }
  15746. if item.ChrgitmLv == "2" {
  15747. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15748. }
  15749. if item.ChrgitmLv == "3" {
  15750. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15751. }
  15752. }
  15753. if item.MedChrgitmType == "11" { //中成费
  15754. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15755. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15756. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15757. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15758. if item.ChrgitmLv == "1" {
  15759. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15760. }
  15761. if item.ChrgitmLv == "2" {
  15762. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15763. }
  15764. if item.ChrgitmLv == "3" {
  15765. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15766. }
  15767. }
  15768. if item.MedChrgitmType == "14" { //其他费
  15769. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15770. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15771. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15772. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15773. if item.ChrgitmLv == "1" {
  15774. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15775. }
  15776. if item.ChrgitmLv == "2" {
  15777. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15778. }
  15779. if item.ChrgitmLv == "3" {
  15780. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15781. }
  15782. }
  15783. }
  15784. var iteminfoStructs []service.IteminfoStruct
  15785. if bedCostTotal != 0 {
  15786. iteminfo.MedChrgitm = "01"
  15787. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  15788. iteminfo.Amt = bedCostTotal
  15789. iteminfo.ClaaSumfee = bed_claa_sunmfee
  15790. iteminfo.ClabAmt = bed_clab_amt
  15791. iteminfo.OthAmt = bed_other_amt
  15792. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15793. }
  15794. if checkCostTotal != 0 {
  15795. iteminfo.MedChrgitm = "03"
  15796. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  15797. iteminfo.Amt = checkCostTotal
  15798. iteminfo.ClaaSumfee = check_claa_sunmfee
  15799. iteminfo.ClabAmt = check_clab_amt
  15800. iteminfo.OthAmt = check_other_amt
  15801. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15802. }
  15803. if laboratoryCostTotal != 0 {
  15804. iteminfo.MedChrgitm = "04"
  15805. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  15806. iteminfo.Amt = laboratoryCostTotal
  15807. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  15808. iteminfo.ClabAmt = laboratory_clab_amt
  15809. iteminfo.OthAmt = laboratory_other_amt
  15810. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15811. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15812. }
  15813. if treatCostTotal != 0 {
  15814. iteminfo.MedChrgitm = "05"
  15815. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  15816. iteminfo.Amt = treatCostTotal
  15817. iteminfo.ClaaSumfee = treat_claa_sunmfee
  15818. iteminfo.ClabAmt = treat_clab_amt
  15819. iteminfo.OthAmt = treat_other_amt
  15820. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15821. //(struct4101.IteminfoStruct, iteminfo)
  15822. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15823. }
  15824. if operationCostTotal != 0 {
  15825. iteminfo.MedChrgitm = "06"
  15826. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  15827. iteminfo.Amt = operationCostTotal
  15828. iteminfo.ClaaSumfee = operation_claa_sunmfee
  15829. iteminfo.ClabAmt = operation_clab_amt
  15830. iteminfo.OthAmt = operation_other_amt
  15831. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15832. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15833. }
  15834. if materialCostTotal != 0 {
  15835. iteminfo.MedChrgitm = "08"
  15836. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  15837. iteminfo.Amt = materialCostTotal
  15838. iteminfo.ClaaSumfee = material_claa_sunmfee
  15839. iteminfo.ClabAmt = material_clab_amt
  15840. iteminfo.OthAmt = material_other_amt
  15841. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15842. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15843. }
  15844. if westernMedicineCostTotal != 0 {
  15845. iteminfo.MedChrgitm = "09"
  15846. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  15847. iteminfo.Amt = westernMedicineCostTotal
  15848. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  15849. iteminfo.ClabAmt = westernMedicine_clab_amt
  15850. iteminfo.OthAmt = westernMedicine_other_amt
  15851. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15852. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15853. }
  15854. if chineseTraditionalMedicineCostTotal != 0 {
  15855. iteminfo.MedChrgitm = "11"
  15856. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  15857. iteminfo.Amt = westernMedicineCostTotal
  15858. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  15859. iteminfo.ClabAmt = westernMedicine_clab_amt
  15860. iteminfo.OthAmt = westernMedicine_other_amt
  15861. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15862. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15863. }
  15864. if otherCostTotal != 0 {
  15865. iteminfo.MedChrgitm = "14"
  15866. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  15867. iteminfo.Amt = otherCostTotal
  15868. iteminfo.ClaaSumfee = other_claa_sunmfee
  15869. iteminfo.ClabAmt = other_clab_amt
  15870. iteminfo.OthAmt = other_other_amt
  15871. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15872. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15873. }
  15874. struct4101.IteminfoStruct = iteminfoStructs
  15875. struct4101.Ntly = "中国"
  15876. struct4101.AdmCaty = "A03.06"
  15877. struct4101.DoctorName = doctor.UserName
  15878. struct4101.DoctorCode = doctor.DoctorNumber
  15879. var res ResultSeventeen
  15880. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15881. struct4101.BillCode = order.Number
  15882. struct4101.BillNo = order.SetlId
  15883. var resOther ResultSeventeenOther
  15884. var pp models.PublicParams
  15885. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  15886. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  15887. pp.FixmedinsName = miConfig.OrgName
  15888. pp.FixmedinsCode = miConfig.Code
  15889. pp.RequestUrl = miConfig.Url
  15890. pp.Cainfo = miConfig.Cainfo
  15891. pp.SecretKey = miConfig.SecretKey
  15892. pp.AccessKey = miConfig.AccessKey
  15893. pp.OpterName = curRoles.UserName
  15894. client := &http.Client{}
  15895. var req *http.Request
  15896. data := make(map[string]interface{})
  15897. data["struct4101"] = struct4101
  15898. data["pp"] = pp
  15899. bytesData, _ := json.Marshal(data)
  15900. if miConfig.MdtrtareaAdmvs == "320921" {
  15901. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  15902. } else {
  15903. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  15904. }
  15905. resp, _ := client.Do(req)
  15906. defer resp.Body.Close()
  15907. body, ioErr := ioutil.ReadAll(resp.Body)
  15908. if ioErr != nil {
  15909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15911. return
  15912. }
  15913. var respJSON map[string]interface{}
  15914. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15917. return
  15918. }
  15919. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15920. userJSONBytes, _ := json.Marshal(respJSON)
  15921. fmt.Println("log")
  15922. fmt.Println(string(userJSONBytes))
  15923. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  15924. utils.ErrorLog("解析失败:%v", err)
  15925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15926. return
  15927. }
  15928. res.InfRefmsgid = resOther.InfRefmsgid
  15929. res.Output = resOther.Output
  15930. res.ErrMsg = resOther.ErrMsg
  15931. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  15932. res.Infcode = infocode
  15933. } else if miConfig.MdtrtareaAdmvs == "360302" {
  15934. var pp models.PublicParams
  15935. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  15936. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  15937. pp.FixmedinsName = miConfig.OrgName
  15938. pp.FixmedinsCode = miConfig.Code
  15939. pp.RequestUrl = miConfig.Url
  15940. pp.Cainfo = miConfig.Cainfo
  15941. pp.SecretKey = miConfig.SecretKey
  15942. pp.AccessKey = miConfig.AccessKey
  15943. pp.OpterName = curRoles.UserName
  15944. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  15945. result, _ := service.Jxyb4101(struct4101, pp)
  15946. var dat map[string]interface{}
  15947. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15948. fmt.Println(dat)
  15949. } else {
  15950. fmt.Println(err)
  15951. }
  15952. userJSONBytes, _ := json.Marshal(dat)
  15953. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15954. utils.ErrorLog("解析失败:%v", err)
  15955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15956. return
  15957. }
  15958. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15959. var pp models.PublicParams
  15960. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  15961. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  15962. pp.FixmedinsName = miConfig.OrgName
  15963. pp.FixmedinsCode = miConfig.Code
  15964. pp.RequestUrl = miConfig.Url
  15965. pp.Cainfo = miConfig.Cainfo
  15966. pp.SecretKey = miConfig.SecretKey
  15967. pp.AccessKey = miConfig.AccessKey
  15968. pp.OpterName = curRoles.UserName
  15969. result, _ := service.Hnyb4101(struct4101, pp)
  15970. var dat map[string]interface{}
  15971. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15972. fmt.Println(dat)
  15973. } else {
  15974. fmt.Println(err)
  15975. }
  15976. userJSONBytes, _ := json.Marshal(dat)
  15977. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15978. utils.ErrorLog("解析失败:%v", err)
  15979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15980. return
  15981. }
  15982. } else if miConfig.MdtrtareaAdmvs == "150499" {
  15983. var resOther ResultSeventeenOther
  15984. var pp models.PublicParams
  15985. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  15986. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  15987. pp.FixmedinsName = miConfig.OrgName
  15988. pp.FixmedinsCode = miConfig.Code
  15989. pp.RequestUrl = miConfig.Url
  15990. pp.Cainfo = miConfig.Cainfo
  15991. pp.SecretKey = miConfig.SecretKey
  15992. pp.AccessKey = miConfig.AccessKey
  15993. pp.OpterName = curRoles.UserName
  15994. client := &http.Client{}
  15995. var req *http.Request
  15996. data := make(map[string]interface{})
  15997. data["struct4101"] = struct4101
  15998. data["pp"] = pp
  15999. bytesData, _ := json.Marshal(data)
  16000. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  16001. resp, _ := client.Do(req)
  16002. defer resp.Body.Close()
  16003. body, ioErr := ioutil.ReadAll(resp.Body)
  16004. if ioErr != nil {
  16005. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16007. return
  16008. }
  16009. var respJSON map[string]interface{}
  16010. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16011. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16013. return
  16014. }
  16015. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16016. userJSONBytes, _ := json.Marshal(respJSON)
  16017. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  16018. utils.ErrorLog("解析失败:%v", err)
  16019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16020. return
  16021. }
  16022. res.InfRefmsgid = resOther.InfRefmsgid
  16023. res.Output = resOther.Output
  16024. res.ErrMsg = resOther.ErrMsg
  16025. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  16026. res.Infcode = infocode
  16027. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16028. var pp models.PublicParams
  16029. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16030. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16031. pp.FixmedinsName = miConfig.OrgName
  16032. pp.FixmedinsCode = miConfig.Code
  16033. pp.RequestUrl = miConfig.Url
  16034. pp.Cainfo = miConfig.Cainfo
  16035. pp.SecretKey = miConfig.SecretKey
  16036. pp.AccessKey = miConfig.AccessKey
  16037. pp.OpterName = curRoles.UserName
  16038. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  16039. fmt.Println(requestLog)
  16040. fmt.Println(errMsgLog)
  16041. saveLog(result, requestLog, "4101a", "上传清单")
  16042. var dat map[string]interface{}
  16043. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16044. fmt.Println(dat)
  16045. } else {
  16046. fmt.Println(err)
  16047. }
  16048. userJSONBytes, _ := json.Marshal(dat)
  16049. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16050. utils.ErrorLog("解析失败:%v", err)
  16051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16052. return
  16053. }
  16054. } else if miConfig.MdtrtareaAdmvs == "441799" {
  16055. var pp models.PublicParams
  16056. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16057. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16058. pp.FixmedinsName = miConfig.OrgName
  16059. pp.FixmedinsCode = miConfig.Code
  16060. pp.RequestUrl = miConfig.Url
  16061. pp.Cainfo = miConfig.Cainfo
  16062. pp.SecretKey = miConfig.SecretKey
  16063. pp.AccessKey = miConfig.AccessKey
  16064. pp.OpterName = curRoles.UserName
  16065. client := &http.Client{}
  16066. var req *http.Request
  16067. data := make(map[string]interface{})
  16068. data["struct4101"] = struct4101
  16069. data["pp"] = pp
  16070. bytesData, _ := json.Marshal(data)
  16071. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  16072. resp, _ := client.Do(req)
  16073. defer resp.Body.Close()
  16074. body, ioErr := ioutil.ReadAll(resp.Body)
  16075. if ioErr != nil {
  16076. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16078. return
  16079. }
  16080. var respJSON map[string]interface{}
  16081. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16082. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16084. return
  16085. }
  16086. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16087. userJSONBytes, _ := json.Marshal(respJSON)
  16088. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16089. utils.ErrorLog("解析失败:%v", err)
  16090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16091. return
  16092. }
  16093. } else {
  16094. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  16095. var dat map[string]interface{}
  16096. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16097. fmt.Println(dat)
  16098. } else {
  16099. fmt.Println(err)
  16100. }
  16101. userJSONBytes, _ := json.Marshal(dat)
  16102. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16103. utils.ErrorLog("解析失败:%v", err)
  16104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16105. return
  16106. }
  16107. }
  16108. if res.Infcode != 0 {
  16109. errlog := &models.HisOrderError{
  16110. UserOrgId: order.UserOrgId,
  16111. Ctime: time.Now().Unix(),
  16112. Mtime: time.Now().Unix(),
  16113. ErrMsg: res.ErrMsg + "解析失败",
  16114. Status: 1,
  16115. PatientId: order.ID,
  16116. Stage: 10485,
  16117. }
  16118. service.CreateErrMsgLog(errlog)
  16119. continue
  16120. //c.ServeSuccessJSON(map[string]interface{}{
  16121. // "failed_code": -10,
  16122. // "msg": res.ErrMsg,
  16123. //})
  16124. } else {
  16125. //order.FaPiaoNumber = zero
  16126. //order.FaPiaoCode = last_order.FaPiaoCode
  16127. //service.UpdateOrder(order)
  16128. hisFundSettleListResult := &models.HisFundSettleListResult{
  16129. Number: res.Output.SetlListId,
  16130. Status: 1,
  16131. Ctime: time.Now().Unix(),
  16132. Mtime: time.Now().Unix(),
  16133. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16134. IsUpload: 1,
  16135. OrderId: order.ID,
  16136. }
  16137. service.CreateUploadRecord(hisFundSettleListResult)
  16138. continue
  16139. }
  16140. }
  16141. }
  16142. func (c *HisApiController) GetSettleList() {
  16143. order_id, _ := c.GetInt64("order_id")
  16144. admin_user_id, _ := c.GetInt64("admin_user_id")
  16145. order, _ := service.GetHisOrderByIDTwo(order_id)
  16146. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  16147. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  16148. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  16149. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  16150. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  16151. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16152. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  16153. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  16154. if order.ID == 0 {
  16155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  16156. return
  16157. }
  16158. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  16159. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  16160. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  16161. //fmt.Println(count)
  16162. //var zero string
  16163. //number := count + 1
  16164. //if number >= 1000 {
  16165. // zero = "0000" + strconv.FormatInt(number, 10)
  16166. //} else if number >= 10000 {
  16167. // zero = "000" + strconv.FormatInt(number, 10)
  16168. //} else if number >= 100000 {
  16169. // zero = "00" + strconv.FormatInt(number, 10)
  16170. //} else if number >= 1000000 {
  16171. // zero = "0" + strconv.FormatInt(number, 10)
  16172. //} else {
  16173. // zero = strconv.FormatInt(number, 10)
  16174. //}
  16175. //fmt.Println(zero)
  16176. struct4101 := service.Struct4101{
  16177. PsnNo: order.PsnNo,
  16178. MdtrtId: order.MdtrtId,
  16179. SetlId: order.SetlId,
  16180. PsnName: order.PsnName,
  16181. Gend: order.Gend,
  16182. Brdy: his.Brdy,
  16183. Age: his.Age,
  16184. Naty: order.Naty,
  16185. PatnCertType: "01",
  16186. Certno: order.Certno,
  16187. Prfs: "90",
  16188. ConerName: roles[0].UserName,
  16189. PatnRlts: "99",
  16190. ConerAddr: miConfig.OrgName,
  16191. ConerTel: admin.Mobile,
  16192. HiType: order.Insutype,
  16193. Insuplc: miConfig.InsuplcAdmdvs,
  16194. MaindiagFlag: "1",
  16195. BillCode: order.SetlId,
  16196. BillNo: order.SetlId,
  16197. BizSn: order.Number,
  16198. PsnSelfPay: order.PsnPartAmt,
  16199. PsnOwnPay: order.PsnPartAmt,
  16200. AcctPay: order.AcctPay,
  16201. PsnCashpay: order.PsnCashPay,
  16202. HiPaymtd: "1",
  16203. Hsorg: miConfig.InsuplcAdmdvs,
  16204. HsorgOpter: miConfig.InsuplcAdmdvs,
  16205. MedinsFillPsn: curRoles.UserName,
  16206. MedinsFillDept: miConfig.OrgName,
  16207. IptMedType: "2",
  16208. }
  16209. struct4101.SetlBegnDate = order.SetlTime
  16210. struct4101.SetlEndDate = order.SetlTime
  16211. time_arr := strings.Split(order.SetlTime, " ")
  16212. struct4101.AdmTime = time_arr[0]
  16213. struct4101.AdmEndTime = time_arr[0]
  16214. //
  16215. //var rf []CustomFundPay
  16216. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  16217. //
  16218. //var tempFunPays []service.CustomStruct
  16219. //for _, item := range rf {
  16220. // var tempFunPay service.CustomStruct
  16221. // tempFunPay.FundPayamt = item.FundPayamt
  16222. // tempFunPay.FundPayType = item.FundPayType
  16223. // tempFunPays = append(tempFunPays, tempFunPay)
  16224. //}
  16225. //struct4101.CustomStruct = tempFunPays
  16226. var tempDiaginfos []service.DiaginfoStructTwo
  16227. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  16228. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  16229. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  16230. var config []*models.HisXtDiagnoseConfig
  16231. for _, item := range diagnosis_ids {
  16232. id, _ := strconv.ParseInt(item, 10, 64)
  16233. diagnosisConfig, _ := service.FindDiagnoseById(id)
  16234. config = append(config, &diagnosisConfig)
  16235. }
  16236. if miConfig.Code == "H15049901371" {
  16237. //for _, item := range config {
  16238. // if item.ID == 138 {
  16239. diagnosisConfig, _ := service.FindDiagnoseById(138)
  16240. var tempDiaginfo service.DiaginfoStructTwo
  16241. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  16242. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  16243. tempDiaginfo.DiagType = "1"
  16244. tempDiaginfo.MaindiagFlag = "1"
  16245. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  16246. //}
  16247. //}
  16248. for _, item := range config {
  16249. if item.ID != 138 {
  16250. var tempDiaginfo service.DiaginfoStructTwo
  16251. tempDiaginfo.DiagCode = item.CountryCode
  16252. tempDiaginfo.DiagName = item.CountryContentName
  16253. tempDiaginfo.DiagType = "1"
  16254. tempDiaginfo.MaindiagFlag = "0"
  16255. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  16256. }
  16257. }
  16258. } else {
  16259. for index, item := range config {
  16260. if index == 0 {
  16261. var tempDiaginfo service.DiaginfoStructTwo
  16262. tempDiaginfo.DiagCode = item.CountryCode
  16263. tempDiaginfo.DiagName = item.CountryContentName
  16264. tempDiaginfo.DiagType = "1"
  16265. tempDiaginfo.MaindiagFlag = "1"
  16266. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  16267. } else {
  16268. var tempDiaginfo service.DiaginfoStructTwo
  16269. tempDiaginfo.DiagCode = item.CountryCode
  16270. tempDiaginfo.DiagName = item.CountryContentName
  16271. tempDiaginfo.DiagType = "1"
  16272. tempDiaginfo.MaindiagFlag = "0"
  16273. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  16274. }
  16275. }
  16276. }
  16277. struct4101.Diseinfo = tempDiaginfos
  16278. sickConfigTwo, _ := service.FindSickById(his.SickType)
  16279. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  16280. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  16281. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  16282. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  16283. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  16284. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  16285. var iteminfo service.IteminfoStruct
  16286. var bedCostTotal float64 = 0 //床位总费
  16287. var bedCostSelfTotal float64 = 0 //床位自费
  16288. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  16289. var operationCostTotal float64 = 0 //手术费
  16290. var operationCostSelfTotal float64 = 0 //手术费
  16291. var operationCostPartSelfTotal float64 = 0 //手术费
  16292. var otherCostTotal float64 = 0 //其他费用
  16293. var otherCostSelfTotal float64 = 0 //其他费用
  16294. var otherCostPartSelfTotal float64 = 0 //其他费用
  16295. var materialCostTotal float64 = 0 //材料费
  16296. var materialCostSelfTotal float64 = 0 //材料费
  16297. var materialCostPartSelfTotal float64 = 0 //材料费
  16298. var westernMedicineCostTotal float64 = 0 //西药费
  16299. var westernMedicineCostSelfTotal float64 = 0 //西药费
  16300. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  16301. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  16302. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  16303. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  16304. var checkCostTotal float64 = 0 //检查费
  16305. var checkCostSelfTotal float64 = 0 //检查费
  16306. var checkCostPartSelfTotal float64 = 0 //检查费
  16307. var laboratoryCostTotal float64 = 0 //化验费
  16308. var laboratoryCostSelfTotal float64 = 0 //化验费
  16309. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  16310. var treatCostTotal float64 = 0 //治疗费用
  16311. var treatCostSelfTotal float64 = 0 //治疗费用
  16312. var treatCostPartSelfTotal float64 = 0 //治疗费用
  16313. decimal.DivisionPrecision = 2
  16314. var bed_fulamt_ownpay_amt float64 = 0
  16315. var operation_fulamt_ownpay_amt float64 = 0
  16316. var other_fulamt_ownpay_amt float64 = 0
  16317. var westernMedicine_fulamt_ownpay_amt float64 = 0
  16318. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  16319. var check_fulamt_ownpay_amt float64 = 0
  16320. var material_fulamt_ownpay_amt float64 = 0
  16321. var laboratory_fulamt_ownpay_amt float64 = 0
  16322. var treat_fulamt_ownpay_amt float64 = 0
  16323. var bed_claa_sunmfee float64 = 0
  16324. var bed_clab_amt float64 = 0
  16325. var bed_other_amt float64 = 0
  16326. var operation_claa_sunmfee float64 = 0
  16327. var operation_clab_amt float64 = 0
  16328. var operation_other_amt float64 = 0
  16329. var other_claa_sunmfee float64 = 0
  16330. var other_clab_amt float64 = 0
  16331. var other_other_amt float64 = 0
  16332. var westernMedicine_claa_sunmfee float64 = 0
  16333. var westernMedicine_clab_amt float64 = 0
  16334. var westernMedicine_other_amt float64 = 0
  16335. var chineseTraditional_claa_sunmfee float64 = 0
  16336. var chineseTraditional_clab_amt float64 = 0
  16337. var chineseTraditional_other_amt float64 = 0
  16338. var check_claa_sunmfee float64 = 0
  16339. var check_clab_amt float64 = 0
  16340. var check_other_amt float64 = 0
  16341. var material_claa_sunmfee float64 = 0
  16342. var material_clab_amt float64 = 0
  16343. var material_other_amt float64 = 0
  16344. var laboratory_claa_sunmfee float64 = 0
  16345. var laboratory_clab_amt float64 = 0
  16346. var laboratory_other_amt float64 = 0
  16347. var treat_claa_sunmfee float64 = 0
  16348. var treat_clab_amt float64 = 0
  16349. var treat_other_amt float64 = 0
  16350. for _, item := range order.HisOrderInfo {
  16351. if item.MedChrgitmType == "01" { //床位费
  16352. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16353. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16354. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16355. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16356. if item.ChrgitmLv == "1" {
  16357. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16358. }
  16359. if item.ChrgitmLv == "2" {
  16360. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16361. }
  16362. if item.ChrgitmLv == "3" {
  16363. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16364. }
  16365. }
  16366. if item.MedChrgitmType == "03" { //检查费
  16367. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16368. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16369. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16370. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16371. if item.ChrgitmLv == "1" {
  16372. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16373. }
  16374. if item.ChrgitmLv == "2" {
  16375. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16376. }
  16377. if item.ChrgitmLv == "3" {
  16378. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16379. }
  16380. }
  16381. if item.MedChrgitmType == "04" { //化验费
  16382. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16383. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16384. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16385. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16386. if item.ChrgitmLv == "1" {
  16387. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16388. }
  16389. if item.ChrgitmLv == "2" {
  16390. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16391. }
  16392. if item.ChrgitmLv == "3" {
  16393. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16394. }
  16395. }
  16396. if item.MedChrgitmType == "05" { //治疗费
  16397. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16398. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16399. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16400. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16401. if item.ChrgitmLv == "1" {
  16402. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16403. }
  16404. if item.ChrgitmLv == "2" {
  16405. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16406. }
  16407. if item.ChrgitmLv == "3" {
  16408. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16409. }
  16410. }
  16411. if item.MedChrgitmType == "06" { //手术费
  16412. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16413. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16414. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16415. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16416. if item.ChrgitmLv == "1" {
  16417. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16418. }
  16419. if item.ChrgitmLv == "2" {
  16420. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16421. }
  16422. if item.ChrgitmLv == "3" {
  16423. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16424. }
  16425. }
  16426. if item.MedChrgitmType == "08" { //材料费
  16427. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16428. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16429. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16430. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16431. if item.ChrgitmLv == "1" {
  16432. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16433. }
  16434. if item.ChrgitmLv == "2" {
  16435. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16436. }
  16437. if item.ChrgitmLv == "3" {
  16438. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16439. }
  16440. }
  16441. if item.MedChrgitmType == "09" { //西药费
  16442. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16443. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16444. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16445. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16446. if item.ChrgitmLv == "1" {
  16447. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16448. }
  16449. if item.ChrgitmLv == "2" {
  16450. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16451. }
  16452. if item.ChrgitmLv == "3" {
  16453. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16454. }
  16455. }
  16456. if item.MedChrgitmType == "11" { //中成费
  16457. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16458. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16459. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16460. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16461. if item.ChrgitmLv == "1" {
  16462. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16463. }
  16464. if item.ChrgitmLv == "2" {
  16465. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16466. }
  16467. if item.ChrgitmLv == "3" {
  16468. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16469. }
  16470. }
  16471. if item.MedChrgitmType == "14" { //其他费
  16472. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16473. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16474. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16475. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16476. if item.ChrgitmLv == "1" {
  16477. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16478. }
  16479. if item.ChrgitmLv == "2" {
  16480. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16481. }
  16482. if item.ChrgitmLv == "3" {
  16483. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16484. }
  16485. }
  16486. }
  16487. var iteminfoStructs []service.IteminfoStruct
  16488. if bedCostTotal != 0 {
  16489. iteminfo.MedChrgitm = "01"
  16490. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  16491. iteminfo.Amt = bedCostTotal
  16492. iteminfo.ClaaSumfee = bed_claa_sunmfee
  16493. iteminfo.ClabAmt = bed_clab_amt
  16494. iteminfo.OthAmt = bed_other_amt
  16495. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16496. }
  16497. if checkCostTotal != 0 {
  16498. iteminfo.MedChrgitm = "03"
  16499. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  16500. iteminfo.Amt = checkCostTotal
  16501. iteminfo.ClaaSumfee = check_claa_sunmfee
  16502. iteminfo.ClabAmt = check_clab_amt
  16503. iteminfo.OthAmt = check_other_amt
  16504. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16505. }
  16506. if laboratoryCostTotal != 0 {
  16507. iteminfo.MedChrgitm = "04"
  16508. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  16509. iteminfo.Amt = laboratoryCostTotal
  16510. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  16511. iteminfo.ClabAmt = laboratory_clab_amt
  16512. iteminfo.OthAmt = laboratory_other_amt
  16513. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16514. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16515. }
  16516. if treatCostTotal != 0 {
  16517. iteminfo.MedChrgitm = "05"
  16518. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  16519. iteminfo.Amt = treatCostTotal
  16520. iteminfo.ClaaSumfee = treat_claa_sunmfee
  16521. iteminfo.ClabAmt = treat_clab_amt
  16522. iteminfo.OthAmt = treat_other_amt
  16523. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16524. //(struct4101.IteminfoStruct, iteminfo)
  16525. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16526. }
  16527. if operationCostTotal != 0 {
  16528. iteminfo.MedChrgitm = "06"
  16529. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  16530. iteminfo.Amt = operationCostTotal
  16531. iteminfo.ClaaSumfee = operation_claa_sunmfee
  16532. iteminfo.ClabAmt = operation_clab_amt
  16533. iteminfo.OthAmt = operation_other_amt
  16534. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16535. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16536. }
  16537. if materialCostTotal != 0 {
  16538. iteminfo.MedChrgitm = "08"
  16539. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  16540. iteminfo.Amt = materialCostTotal
  16541. iteminfo.ClaaSumfee = material_claa_sunmfee
  16542. iteminfo.ClabAmt = material_clab_amt
  16543. iteminfo.OthAmt = material_other_amt
  16544. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16545. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16546. }
  16547. if westernMedicineCostTotal != 0 {
  16548. iteminfo.MedChrgitm = "09"
  16549. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  16550. iteminfo.Amt = westernMedicineCostTotal
  16551. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  16552. iteminfo.ClabAmt = westernMedicine_clab_amt
  16553. iteminfo.OthAmt = westernMedicine_other_amt
  16554. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16555. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16556. }
  16557. if chineseTraditionalMedicineCostTotal != 0 {
  16558. iteminfo.MedChrgitm = "11"
  16559. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  16560. iteminfo.Amt = westernMedicineCostTotal
  16561. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  16562. iteminfo.ClabAmt = westernMedicine_clab_amt
  16563. iteminfo.OthAmt = westernMedicine_other_amt
  16564. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16565. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16566. }
  16567. if otherCostTotal != 0 {
  16568. iteminfo.MedChrgitm = "14"
  16569. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  16570. iteminfo.Amt = otherCostTotal
  16571. iteminfo.ClaaSumfee = other_claa_sunmfee
  16572. iteminfo.ClabAmt = other_clab_amt
  16573. iteminfo.OthAmt = other_other_amt
  16574. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16575. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16576. }
  16577. struct4101.IteminfoStruct = iteminfoStructs
  16578. struct4101.Ntly = "中国"
  16579. struct4101.AdmCaty = "A03.06"
  16580. struct4101.DoctorName = doctor.UserName
  16581. struct4101.DoctorCode = doctor.DoctorNumber
  16582. var res ResultSeventeen
  16583. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16584. struct4101.BillCode = order.Number
  16585. struct4101.BillNo = order.SetlId
  16586. var resOther ResultSeventeenOther
  16587. var pp models.PublicParams
  16588. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16589. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16590. pp.FixmedinsName = miConfig.OrgName
  16591. pp.FixmedinsCode = miConfig.Code
  16592. pp.RequestUrl = miConfig.Url
  16593. pp.Cainfo = miConfig.Cainfo
  16594. pp.SecretKey = miConfig.SecretKey
  16595. pp.AccessKey = miConfig.AccessKey
  16596. pp.OpterName = curRoles.UserName
  16597. client := &http.Client{}
  16598. var req *http.Request
  16599. data := make(map[string]interface{})
  16600. data["struct4101"] = struct4101
  16601. data["pp"] = pp
  16602. bytesData, _ := json.Marshal(data)
  16603. if miConfig.MdtrtareaAdmvs == "320921" {
  16604. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  16605. } else {
  16606. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  16607. }
  16608. resp, _ := client.Do(req)
  16609. defer resp.Body.Close()
  16610. body, ioErr := ioutil.ReadAll(resp.Body)
  16611. if ioErr != nil {
  16612. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16614. return
  16615. }
  16616. var respJSON map[string]interface{}
  16617. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16620. return
  16621. }
  16622. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16623. userJSONBytes, _ := json.Marshal(respJSON)
  16624. fmt.Println("log")
  16625. fmt.Println(string(userJSONBytes))
  16626. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  16627. utils.ErrorLog("解析失败:%v", err)
  16628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16629. return
  16630. }
  16631. res.InfRefmsgid = resOther.InfRefmsgid
  16632. res.Output = resOther.Output
  16633. res.ErrMsg = resOther.ErrMsg
  16634. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  16635. res.Infcode = infocode
  16636. } else if miConfig.MdtrtareaAdmvs == "360302" {
  16637. var pp models.PublicParams
  16638. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  16639. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16640. pp.FixmedinsName = miConfig.OrgName
  16641. pp.FixmedinsCode = miConfig.Code
  16642. pp.RequestUrl = miConfig.Url
  16643. pp.Cainfo = miConfig.Cainfo
  16644. pp.SecretKey = miConfig.SecretKey
  16645. pp.AccessKey = miConfig.AccessKey
  16646. pp.OpterName = curRoles.UserName
  16647. result, _ := service.Jxyb4101(struct4101, pp)
  16648. var dat map[string]interface{}
  16649. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16650. fmt.Println(dat)
  16651. } else {
  16652. fmt.Println(err)
  16653. }
  16654. userJSONBytes, _ := json.Marshal(dat)
  16655. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16656. utils.ErrorLog("解析失败:%v", err)
  16657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16658. return
  16659. }
  16660. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16661. var pp models.PublicParams
  16662. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16663. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16664. pp.FixmedinsName = miConfig.OrgName
  16665. pp.FixmedinsCode = miConfig.Code
  16666. pp.RequestUrl = miConfig.Url
  16667. pp.Cainfo = miConfig.Cainfo
  16668. pp.SecretKey = miConfig.SecretKey
  16669. pp.AccessKey = miConfig.AccessKey
  16670. pp.OpterName = curRoles.UserName
  16671. result, _ := service.Hnyb4101(struct4101, pp)
  16672. var dat map[string]interface{}
  16673. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16674. fmt.Println(dat)
  16675. } else {
  16676. fmt.Println(err)
  16677. }
  16678. userJSONBytes, _ := json.Marshal(dat)
  16679. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16680. utils.ErrorLog("解析失败:%v", err)
  16681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16682. return
  16683. }
  16684. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16685. var resOther ResultSeventeenOther
  16686. var pp models.PublicParams
  16687. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16688. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16689. pp.FixmedinsName = miConfig.OrgName
  16690. pp.FixmedinsCode = miConfig.Code
  16691. pp.RequestUrl = miConfig.Url
  16692. pp.Cainfo = miConfig.Cainfo
  16693. pp.SecretKey = miConfig.SecretKey
  16694. pp.AccessKey = miConfig.AccessKey
  16695. pp.OpterName = curRoles.UserName
  16696. client := &http.Client{}
  16697. var req *http.Request
  16698. data := make(map[string]interface{})
  16699. data["struct4101"] = struct4101
  16700. data["pp"] = pp
  16701. bytesData, _ := json.Marshal(data)
  16702. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  16703. resp, _ := client.Do(req)
  16704. defer resp.Body.Close()
  16705. body, ioErr := ioutil.ReadAll(resp.Body)
  16706. if ioErr != nil {
  16707. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16709. return
  16710. }
  16711. var respJSON map[string]interface{}
  16712. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16713. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16715. return
  16716. }
  16717. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16718. userJSONBytes, _ := json.Marshal(respJSON)
  16719. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  16720. utils.ErrorLog("解析失败:%v", err)
  16721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16722. return
  16723. }
  16724. res.InfRefmsgid = resOther.InfRefmsgid
  16725. res.Output = resOther.Output
  16726. res.ErrMsg = resOther.ErrMsg
  16727. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  16728. res.Infcode = infocode
  16729. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16730. var pp models.PublicParams
  16731. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16732. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16733. pp.FixmedinsName = miConfig.OrgName
  16734. pp.FixmedinsCode = miConfig.Code
  16735. pp.RequestUrl = miConfig.Url
  16736. pp.Cainfo = miConfig.Cainfo
  16737. pp.SecretKey = miConfig.SecretKey
  16738. pp.AccessKey = miConfig.AccessKey
  16739. pp.OpterName = curRoles.UserName
  16740. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  16741. fmt.Println(requestLog)
  16742. fmt.Println(errMsgLog)
  16743. saveLog(result, requestLog, "4101a", "上传清单")
  16744. var dat map[string]interface{}
  16745. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16746. fmt.Println(dat)
  16747. } else {
  16748. fmt.Println(err)
  16749. }
  16750. userJSONBytes, _ := json.Marshal(dat)
  16751. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16752. utils.ErrorLog("解析失败:%v", err)
  16753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16754. return
  16755. }
  16756. } else if miConfig.MdtrtareaAdmvs == "441799" {
  16757. var pp models.PublicParams
  16758. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16759. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16760. pp.FixmedinsName = miConfig.OrgName
  16761. pp.FixmedinsCode = miConfig.Code
  16762. pp.RequestUrl = miConfig.Url
  16763. pp.Cainfo = miConfig.Cainfo
  16764. pp.SecretKey = miConfig.SecretKey
  16765. pp.AccessKey = miConfig.AccessKey
  16766. pp.OpterName = curRoles.UserName
  16767. client := &http.Client{}
  16768. var req *http.Request
  16769. data := make(map[string]interface{})
  16770. data["struct4101"] = struct4101
  16771. data["pp"] = pp
  16772. bytesData, _ := json.Marshal(data)
  16773. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  16774. resp, _ := client.Do(req)
  16775. defer resp.Body.Close()
  16776. body, ioErr := ioutil.ReadAll(resp.Body)
  16777. if ioErr != nil {
  16778. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16780. return
  16781. }
  16782. var respJSON map[string]interface{}
  16783. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16784. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16786. return
  16787. }
  16788. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16789. userJSONBytes, _ := json.Marshal(respJSON)
  16790. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16791. utils.ErrorLog("解析失败:%v", err)
  16792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16793. return
  16794. }
  16795. } else {
  16796. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  16797. var dat map[string]interface{}
  16798. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16799. fmt.Println(dat)
  16800. } else {
  16801. fmt.Println(err)
  16802. }
  16803. userJSONBytes, _ := json.Marshal(dat)
  16804. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16805. utils.ErrorLog("解析失败:%v", err)
  16806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16807. return
  16808. }
  16809. }
  16810. if res.Infcode != 0 {
  16811. c.ServeSuccessJSON(map[string]interface{}{
  16812. "failed_code": -10,
  16813. "msg": res.ErrMsg,
  16814. })
  16815. return
  16816. } else {
  16817. //order.FaPiaoNumber = zero
  16818. //order.FaPiaoCode = last_order.FaPiaoCode
  16819. //service.UpdateOrder(order)
  16820. hisFundSettleListResult := &models.HisFundSettleListResult{
  16821. Number: res.Output.SetlListId,
  16822. Status: 1,
  16823. Ctime: time.Now().Unix(),
  16824. Mtime: time.Now().Unix(),
  16825. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16826. IsUpload: 1,
  16827. OrderId: order_id,
  16828. }
  16829. service.CreateUploadRecord(hisFundSettleListResult)
  16830. c.ServeSuccessJSON(map[string]interface{}{
  16831. "msg": "上传成功",
  16832. "result": hisFundSettleListResult,
  16833. })
  16834. return
  16835. }
  16836. }
  16837. func (c *HisApiController) GetSettleListHospital() {
  16838. order_id, _ := c.GetInt64("order_id")
  16839. admin_user_id, _ := c.GetInt64("admin_user_id")
  16840. order, _ := service.GetHisOrderByIDTwo(order_id)
  16841. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  16842. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  16843. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  16844. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  16845. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  16846. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16847. if order.ID == 0 {
  16848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  16849. return
  16850. }
  16851. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  16852. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  16853. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  16854. fmt.Println(count)
  16855. var zero string
  16856. number := count + 1
  16857. if number >= 1000 {
  16858. zero = "0000" + strconv.FormatInt(number, 10)
  16859. } else if number >= 10000 {
  16860. zero = "000" + strconv.FormatInt(number, 10)
  16861. } else if number >= 100000 {
  16862. zero = "00" + strconv.FormatInt(number, 10)
  16863. } else if number >= 1000000 {
  16864. zero = "0" + strconv.FormatInt(number, 10)
  16865. } else {
  16866. zero = strconv.FormatInt(number, 10)
  16867. }
  16868. fmt.Println(zero)
  16869. struct4101 := service.Struct4101{
  16870. PsnNo: order.PsnNo,
  16871. MdtrtId: order.MdtrtId,
  16872. SetlId: order.SetlId,
  16873. PsnName: order.PsnName,
  16874. Gend: order.Gend,
  16875. Brdy: his.Brdy,
  16876. Age: int64(order.Age),
  16877. Naty: order.Naty,
  16878. PatnCertType: "01",
  16879. Certno: order.Certno,
  16880. Prfs: "90",
  16881. ConerName: roles[0].UserName,
  16882. PatnRlts: "99",
  16883. ConerAddr: miConfig.OrgName,
  16884. ConerTel: admin.Mobile,
  16885. HiType: order.Insutype,
  16886. Insuplc: miConfig.InsuplcAdmdvs,
  16887. MaindiagFlag: "1",
  16888. BillCode: order.SetlId,
  16889. BillNo: order.SetlId,
  16890. BizSn: order.Number,
  16891. PsnSelfPay: order.PsnPartAmt,
  16892. PsnOwnPay: order.PsnPartAmt,
  16893. AcctPay: order.AcctPay,
  16894. PsnCashpay: order.PsnCashPay,
  16895. HiPaymtd: "1",
  16896. Hsorg: miConfig.InsuplcAdmdvs,
  16897. HsorgOpter: miConfig.InsuplcAdmdvs,
  16898. MedinsFillPsn: curRoles.UserName,
  16899. MedinsFillDept: depart.Name,
  16900. IptMedType: "2",
  16901. AdmTime: his.InHosptialTime,
  16902. AdmEndTime: his.OutHosptialTime,
  16903. }
  16904. struct4101.SetlBegnDate = order.SetlTime
  16905. struct4101.SetlEndDate = order.SetlTime
  16906. //var rf []CustomFundPay
  16907. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  16908. //
  16909. //var tempFunPays []service.CustomStruct
  16910. //for _, item := range rf {
  16911. // var tempFunPay service.CustomStruct
  16912. // tempFunPay.FundPayamt = item.FundPayamt
  16913. // tempFunPay.FundPayType = item.FundPayType
  16914. // tempFunPays = append(tempFunPays, tempFunPay)
  16915. //}
  16916. //struct4101.CustomStruct = tempFunPays
  16917. var tempDiaginfos []service.DiaginfoStructTwo
  16918. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  16919. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  16920. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  16921. //for _, item := range infos {
  16922. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  16923. //}
  16924. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  16925. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  16926. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  16927. fmt.Println(diagnosis_ids_arr)
  16928. if order.UserOrgId == 10210 {
  16929. var diagnosis_ids_arr_two []int64
  16930. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  16931. var config []*models.HisXtDiagnoseConfig
  16932. for _, id := range diagnosis_ids_arr_two {
  16933. //id, _ := strconv.ParseInt(item, 10, 64)
  16934. diagnosisConfig, _ := service.FindDiagnoseById(id)
  16935. if diagnosisConfig.ID > 0 {
  16936. config = append(config, &diagnosisConfig)
  16937. }
  16938. }
  16939. for index, item := range config {
  16940. if item.ID > 0 {
  16941. if index == 0 {
  16942. var tempDiaginfo service.DiaginfoStructTwo
  16943. tempDiaginfo.DiagCode = item.CountryCode
  16944. tempDiaginfo.DiagName = item.CountryContentName
  16945. tempDiaginfo.DiagType = "1"
  16946. tempDiaginfo.MaindiagFlag = "1"
  16947. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  16948. } else {
  16949. var tempDiaginfo service.DiaginfoStructTwo
  16950. tempDiaginfo.DiagCode = item.CountryCode
  16951. tempDiaginfo.DiagName = item.CountryContentName
  16952. tempDiaginfo.DiagType = "1"
  16953. tempDiaginfo.MaindiagFlag = "0"
  16954. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  16955. }
  16956. }
  16957. }
  16958. struct4101.Diseinfo = tempDiaginfos
  16959. } else {
  16960. var config []*models.HisXtDiagnoseConfig
  16961. for _, item := range diagnosis_ids_arr {
  16962. id, _ := strconv.ParseInt(item, 10, 64)
  16963. diagnosisConfig, _ := service.FindDiagnoseById(id)
  16964. if diagnosisConfig.ID > 0 {
  16965. config = append(config, &diagnosisConfig)
  16966. }
  16967. }
  16968. for index, item := range config {
  16969. if item.ID > 0 {
  16970. if index == 0 {
  16971. var tempDiaginfo service.DiaginfoStructTwo
  16972. tempDiaginfo.DiagCode = item.CountryCode
  16973. tempDiaginfo.DiagName = item.CountryContentName
  16974. tempDiaginfo.DiagType = "1"
  16975. tempDiaginfo.MaindiagFlag = "1"
  16976. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  16977. } else {
  16978. var tempDiaginfo service.DiaginfoStructTwo
  16979. tempDiaginfo.DiagCode = item.CountryCode
  16980. tempDiaginfo.DiagName = item.CountryContentName
  16981. tempDiaginfo.DiagType = "1"
  16982. tempDiaginfo.MaindiagFlag = "0"
  16983. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  16984. }
  16985. }
  16986. }
  16987. struct4101.Diseinfo = tempDiaginfos
  16988. }
  16989. sickConfigTwo, _ := service.FindSickById(his.SickType)
  16990. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  16991. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  16992. tempOpspdiseinfo2.OprnOprtCode = ""
  16993. tempOpspdiseinfo2.OprnOprtName = ""
  16994. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  16995. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  16996. var iteminfo service.IteminfoStruct
  16997. var bedCostTotal float64 = 0 //床位总费
  16998. var bedCostSelfTotal float64 = 0 //床位自费
  16999. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  17000. var operationCostTotal float64 = 0 //手术费
  17001. var operationCostSelfTotal float64 = 0 //手术费
  17002. var operationCostPartSelfTotal float64 = 0 //手术费
  17003. var otherCostTotal float64 = 0 //其他费用
  17004. var otherCostSelfTotal float64 = 0 //其他费用
  17005. var otherCostPartSelfTotal float64 = 0 //其他费用
  17006. var materialCostTotal float64 = 0 //材料费
  17007. var materialCostSelfTotal float64 = 0 //材料费
  17008. var materialCostPartSelfTotal float64 = 0 //材料费
  17009. var westernMedicineCostTotal float64 = 0 //西药费
  17010. var westernMedicineCostSelfTotal float64 = 0 //西药费
  17011. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  17012. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  17013. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  17014. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  17015. var checkCostTotal float64 = 0 //检查费
  17016. var checkCostSelfTotal float64 = 0 //检查费
  17017. var checkCostPartSelfTotal float64 = 0 //检查费
  17018. var laboratoryCostTotal float64 = 0 //化验费
  17019. var laboratoryCostSelfTotal float64 = 0 //化验费
  17020. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  17021. var treatCostTotal float64 = 0 //治疗费用
  17022. var treatCostSelfTotal float64 = 0 //治疗费用
  17023. var treatCostPartSelfTotal float64 = 0 //治疗费用
  17024. decimal.DivisionPrecision = 2
  17025. var bed_fulamt_ownpay_amt float64 = 0
  17026. var operation_fulamt_ownpay_amt float64 = 0
  17027. var other_fulamt_ownpay_amt float64 = 0
  17028. var westernMedicine_fulamt_ownpay_amt float64 = 0
  17029. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  17030. var check_fulamt_ownpay_amt float64 = 0
  17031. var material_fulamt_ownpay_amt float64 = 0
  17032. var laboratory_fulamt_ownpay_amt float64 = 0
  17033. var treat_fulamt_ownpay_amt float64 = 0
  17034. var bed_claa_sunmfee float64 = 0
  17035. var bed_clab_amt float64 = 0
  17036. var bed_other_amt float64 = 0
  17037. var operation_claa_sunmfee float64 = 0
  17038. var operation_clab_amt float64 = 0
  17039. var operation_other_amt float64 = 0
  17040. var other_claa_sunmfee float64 = 0
  17041. var other_clab_amt float64 = 0
  17042. var other_other_amt float64 = 0
  17043. var westernMedicine_claa_sunmfee float64 = 0
  17044. var westernMedicine_clab_amt float64 = 0
  17045. var westernMedicine_other_amt float64 = 0
  17046. var chineseTraditional_claa_sunmfee float64 = 0
  17047. var chineseTraditional_clab_amt float64 = 0
  17048. var chineseTraditional_other_amt float64 = 0
  17049. var check_claa_sunmfee float64 = 0
  17050. var check_clab_amt float64 = 0
  17051. var check_other_amt float64 = 0
  17052. var material_claa_sunmfee float64 = 0
  17053. var material_clab_amt float64 = 0
  17054. var material_other_amt float64 = 0
  17055. var laboratory_claa_sunmfee float64 = 0
  17056. var laboratory_clab_amt float64 = 0
  17057. var laboratory_other_amt float64 = 0
  17058. var treat_claa_sunmfee float64 = 0
  17059. var treat_clab_amt float64 = 0
  17060. var treat_other_amt float64 = 0
  17061. for _, item := range order.HisOrderInfo {
  17062. if item.MedChrgitmType == "01" { //床位费
  17063. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17064. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17065. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17066. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17067. if item.ChrgitmLv == "1" {
  17068. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17069. }
  17070. if item.ChrgitmLv == "2" {
  17071. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17072. }
  17073. if item.ChrgitmLv == "3" {
  17074. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17075. }
  17076. }
  17077. if item.MedChrgitmType == "03" { //检查费
  17078. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17079. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17080. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17081. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17082. if item.ChrgitmLv == "1" {
  17083. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17084. }
  17085. if item.ChrgitmLv == "2" {
  17086. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17087. }
  17088. if item.ChrgitmLv == "3" {
  17089. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17090. }
  17091. }
  17092. if item.MedChrgitmType == "04" { //化验费
  17093. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17094. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17095. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17096. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17097. if item.ChrgitmLv == "1" {
  17098. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17099. }
  17100. if item.ChrgitmLv == "2" {
  17101. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17102. }
  17103. if item.ChrgitmLv == "3" {
  17104. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17105. }
  17106. }
  17107. if item.MedChrgitmType == "05" { //治疗费
  17108. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17109. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17110. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17111. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17112. if item.ChrgitmLv == "1" {
  17113. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17114. }
  17115. if item.ChrgitmLv == "2" {
  17116. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17117. }
  17118. if item.ChrgitmLv == "3" {
  17119. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17120. }
  17121. }
  17122. if item.MedChrgitmType == "06" { //手术费
  17123. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17124. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17125. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17126. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17127. if item.ChrgitmLv == "1" {
  17128. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17129. }
  17130. if item.ChrgitmLv == "2" {
  17131. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17132. }
  17133. if item.ChrgitmLv == "3" {
  17134. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17135. }
  17136. }
  17137. if item.MedChrgitmType == "08" { //材料费
  17138. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17139. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17140. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17141. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17142. if item.ChrgitmLv == "1" {
  17143. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17144. }
  17145. if item.ChrgitmLv == "2" {
  17146. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17147. }
  17148. if item.ChrgitmLv == "3" {
  17149. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17150. }
  17151. }
  17152. if item.MedChrgitmType == "09" { //西药费
  17153. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17154. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17155. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17156. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17157. if item.ChrgitmLv == "1" {
  17158. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17159. }
  17160. if item.ChrgitmLv == "2" {
  17161. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17162. }
  17163. if item.ChrgitmLv == "3" {
  17164. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17165. }
  17166. }
  17167. if item.MedChrgitmType == "11" { //中成费
  17168. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17169. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17170. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17171. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17172. if item.ChrgitmLv == "1" {
  17173. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17174. }
  17175. if item.ChrgitmLv == "2" {
  17176. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17177. }
  17178. if item.ChrgitmLv == "3" {
  17179. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17180. }
  17181. }
  17182. if item.MedChrgitmType == "14" { //其他费
  17183. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17184. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17185. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17186. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17187. if item.ChrgitmLv == "1" {
  17188. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17189. }
  17190. if item.ChrgitmLv == "2" {
  17191. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17192. }
  17193. if item.ChrgitmLv == "3" {
  17194. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17195. }
  17196. }
  17197. }
  17198. var iteminfoStructs []service.IteminfoStruct
  17199. if bedCostTotal != 0 {
  17200. iteminfo.MedChrgitm = "01"
  17201. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17202. iteminfo.Amt = bedCostTotal
  17203. iteminfo.ClaaSumfee = bed_claa_sunmfee
  17204. iteminfo.ClabAmt = bed_clab_amt
  17205. iteminfo.OthAmt = bed_other_amt
  17206. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17207. }
  17208. if checkCostTotal != 0 {
  17209. iteminfo.MedChrgitm = "03"
  17210. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  17211. iteminfo.Amt = checkCostTotal
  17212. iteminfo.ClaaSumfee = check_claa_sunmfee
  17213. iteminfo.ClabAmt = check_clab_amt
  17214. iteminfo.OthAmt = check_other_amt
  17215. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17216. }
  17217. if laboratoryCostTotal != 0 {
  17218. iteminfo.MedChrgitm = "04"
  17219. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  17220. iteminfo.Amt = laboratoryCostTotal
  17221. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  17222. iteminfo.ClabAmt = laboratory_clab_amt
  17223. iteminfo.OthAmt = laboratory_other_amt
  17224. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17225. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17226. }
  17227. if treatCostTotal != 0 {
  17228. iteminfo.MedChrgitm = "05"
  17229. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  17230. iteminfo.Amt = treatCostTotal
  17231. iteminfo.ClaaSumfee = treat_claa_sunmfee
  17232. iteminfo.ClabAmt = treat_clab_amt
  17233. iteminfo.OthAmt = treat_other_amt
  17234. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17235. //(struct4101.IteminfoStruct, iteminfo)
  17236. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17237. }
  17238. if operationCostTotal != 0 {
  17239. iteminfo.MedChrgitm = "06"
  17240. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17241. iteminfo.Amt = operationCostTotal
  17242. iteminfo.ClaaSumfee = operation_claa_sunmfee
  17243. iteminfo.ClabAmt = operation_clab_amt
  17244. iteminfo.OthAmt = operation_other_amt
  17245. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17246. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17247. }
  17248. if materialCostTotal != 0 {
  17249. iteminfo.MedChrgitm = "08"
  17250. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  17251. iteminfo.Amt = materialCostTotal
  17252. iteminfo.ClaaSumfee = material_claa_sunmfee
  17253. iteminfo.ClabAmt = material_clab_amt
  17254. iteminfo.OthAmt = material_other_amt
  17255. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17256. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17257. }
  17258. if westernMedicineCostTotal != 0 {
  17259. iteminfo.MedChrgitm = "09"
  17260. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  17261. iteminfo.Amt = westernMedicineCostTotal
  17262. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  17263. iteminfo.ClabAmt = westernMedicine_clab_amt
  17264. iteminfo.OthAmt = westernMedicine_other_amt
  17265. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17266. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17267. }
  17268. if chineseTraditionalMedicineCostTotal != 0 {
  17269. iteminfo.MedChrgitm = "11"
  17270. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  17271. iteminfo.Amt = westernMedicineCostTotal
  17272. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  17273. iteminfo.ClabAmt = westernMedicine_clab_amt
  17274. iteminfo.OthAmt = westernMedicine_other_amt
  17275. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17276. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17277. }
  17278. if otherCostTotal != 0 {
  17279. iteminfo.MedChrgitm = "14"
  17280. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  17281. iteminfo.Amt = otherCostTotal
  17282. iteminfo.ClaaSumfee = other_claa_sunmfee
  17283. iteminfo.ClabAmt = other_clab_amt
  17284. iteminfo.OthAmt = other_other_amt
  17285. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17286. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17287. }
  17288. struct4101.IteminfoStruct = iteminfoStructs
  17289. struct4101.Ntly = "中国"
  17290. struct4101.AdmCaty = "A03.06"
  17291. var resOther ResultSeventeenOther
  17292. var res ResultSeventeen
  17293. if miConfig.MdtrtareaAdmvs == "150499" {
  17294. var pp models.PublicParams
  17295. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17296. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17297. pp.FixmedinsName = miConfig.OrgName
  17298. pp.FixmedinsCode = miConfig.Code
  17299. pp.RequestUrl = miConfig.Url
  17300. pp.Cainfo = miConfig.Cainfo
  17301. pp.SecretKey = miConfig.SecretKey
  17302. pp.AccessKey = miConfig.AccessKey
  17303. pp.OpterName = curRoles.UserName
  17304. client := &http.Client{}
  17305. var req *http.Request
  17306. data := make(map[string]interface{})
  17307. data["struct4101"] = struct4101
  17308. data["pp"] = pp
  17309. bytesData, _ := json.Marshal(data)
  17310. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  17311. resp, _ := client.Do(req)
  17312. defer resp.Body.Close()
  17313. body, ioErr := ioutil.ReadAll(resp.Body)
  17314. if ioErr != nil {
  17315. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17317. return
  17318. }
  17319. var respJSON map[string]interface{}
  17320. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17323. return
  17324. }
  17325. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17326. userJSONBytes, _ := json.Marshal(respJSON)
  17327. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  17328. utils.ErrorLog("解析失败:%v", err)
  17329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17330. return
  17331. }
  17332. res.InfRefmsgid = resOther.InfRefmsgid
  17333. res.Output = resOther.Output
  17334. res.ErrMsg = resOther.ErrMsg
  17335. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  17336. res.Infcode = infocode
  17337. } else if miConfig.MdtrtareaAdmvs == "360302" {
  17338. var pp models.PublicParams
  17339. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  17340. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17341. pp.FixmedinsName = miConfig.OrgName
  17342. pp.FixmedinsCode = miConfig.Code
  17343. pp.RequestUrl = miConfig.Url
  17344. pp.Cainfo = miConfig.Cainfo
  17345. pp.SecretKey = miConfig.SecretKey
  17346. pp.AccessKey = miConfig.AccessKey
  17347. pp.OpterName = curRoles.UserName
  17348. result, _ := service.Jxyb4101(struct4101, pp)
  17349. var dat map[string]interface{}
  17350. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17351. fmt.Println(dat)
  17352. } else {
  17353. fmt.Println(err)
  17354. }
  17355. userJSONBytes, _ := json.Marshal(dat)
  17356. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17357. utils.ErrorLog("解析失败:%v", err)
  17358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17359. return
  17360. }
  17361. } else {
  17362. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  17363. var dat map[string]interface{}
  17364. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17365. fmt.Println(dat)
  17366. } else {
  17367. fmt.Println(err)
  17368. }
  17369. userJSONBytes, _ := json.Marshal(dat)
  17370. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17371. utils.ErrorLog("解析失败:%v", err)
  17372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17373. return
  17374. }
  17375. }
  17376. if res.Infcode != 0 {
  17377. c.ServeSuccessJSON(map[string]interface{}{
  17378. "failed_code": -10,
  17379. "msg": res.ErrMsg,
  17380. })
  17381. return
  17382. } else {
  17383. if miConfig.MdtrtareaAdmvs != "150499" {
  17384. order.FaPiaoNumber = zero
  17385. order.FaPiaoCode = last_order.FaPiaoCode
  17386. service.UpdateOrder(order)
  17387. }
  17388. hisFundSettleListResult := &models.HisFundSettleListResult{
  17389. Number: res.Output.SetlListId,
  17390. Status: 1,
  17391. Ctime: time.Now().Unix(),
  17392. Mtime: time.Now().Unix(),
  17393. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17394. IsUpload: 1,
  17395. OrderId: order_id,
  17396. }
  17397. service.CreateUploadRecord(hisFundSettleListResult)
  17398. c.ServeSuccessJSON(map[string]interface{}{
  17399. "msg": "上传成功",
  17400. "result": hisFundSettleListResult,
  17401. })
  17402. return
  17403. }
  17404. }
  17405. //func (c *HisApiController) GetBatchSettleList() {
  17406. // orders, _ := service.GetAllHisOrder(10106)
  17407. // for _, item := range orders {
  17408. // order_id := item.ID
  17409. // order, _ := service.GetHisOrderByIDTwo(order_id)
  17410. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17411. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17412. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17413. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  17414. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17415. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17416. //
  17417. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17418. //
  17419. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17420. //
  17421. // if order.ID == 0 {
  17422. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  17423. // return
  17424. // }
  17425. // if his.BalanceAccountsType == 2 {
  17426. // continue
  17427. // }
  17428. // struct4101 := service.Struct4101{
  17429. // PsnNo: order.PsnNo,
  17430. // MdtrtId: order.MdtrtId,
  17431. // SetlId: order.SetlId,
  17432. // PsnName: order.PsnName,
  17433. // Gend: order.Gend,
  17434. // Brdy: his.Brdy,
  17435. // Age: his.Age,
  17436. // Naty: order.Naty,
  17437. // PatnCertType: "01",
  17438. // Certno: order.Certno,
  17439. // Prfs: "90",
  17440. // ConerName: roles[0].UserName,
  17441. // PatnRlts: "99",
  17442. // ConerAddr: miConfig.OrgName,
  17443. // ConerTel: admin.Mobile,
  17444. // HiType: order.Insutype,
  17445. // Insuplc: his.InsuplcAdmdvs,
  17446. // MaindiagFlag: "1",
  17447. // BillCode: order.SetlId,
  17448. // BillNo: order.SetlId,
  17449. // BizSn: order.Number,
  17450. // PsnSelfPay: order.PsnPartAmt,
  17451. // PsnOwnPay: order.PsnPartAmt,
  17452. // AcctPay: order.AcctPay,
  17453. // PsnCashpay: order.PsnCashPay,
  17454. // HiPaymtd: "1",
  17455. // Hsorg: his.InsuplcAdmdvs,
  17456. // HsorgOpter: his.InsuplcAdmdvs,
  17457. // MedinsFillPsn: curRoles.UserName,
  17458. // MedinsFillDept: depart.Name,
  17459. // IptMedType: "2",
  17460. // }
  17461. // struct4101.SetlBegnDate = order.SetlTime
  17462. // struct4101.SetlEndDate = order.SetlTime
  17463. // //if order.SettleType == 1 {
  17464. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  17465. // // dateStr := t.Format("2006-01-02")
  17466. // // struct4101.SetlBegnDate = dateStr
  17467. // // struct4101.SetlEndDate = dateStr
  17468. // //} else {
  17469. // // t := time.Unix(int64(order.SettleStartTime), 0)
  17470. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  17471. // // dateStartStr := t.Format("2006-01-02")
  17472. // // dateEndStr := t2.Format("2006-01-02")
  17473. // // struct4101.SetlBegnDate = dateStartStr
  17474. // // struct4101.SetlEndDate = dateEndStr
  17475. // //}
  17476. //
  17477. // var rf []CustomFundPay
  17478. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  17479. //
  17480. // var tempFunPays []service.CustomStruct
  17481. // var tempFunPay610100 service.CustomStruct
  17482. //
  17483. // for _, item := range rf {
  17484. // if item.FundPayType == "610100" {
  17485. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  17486. // tempFunPay610100.FundPayType = item.FundPayType
  17487. // } else {
  17488. // var tempFunPay service.CustomStruct
  17489. // tempFunPay.FundPayamt = item.FundPayamt
  17490. // tempFunPay.FundPayType = item.FundPayType
  17491. // tempFunPays = append(tempFunPays, tempFunPay)
  17492. // }
  17493. // }
  17494. // tempFunPays = append(tempFunPays, tempFunPay610100)
  17495. // struct4101.CustomStruct = tempFunPays
  17496. //
  17497. // var tempDiaginfos []service.DiaginfoStructTwo
  17498. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  17499. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  17500. //
  17501. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  17502. // var config []*models.HisXtDiagnoseConfig
  17503. // for _, item := range diagnosis_ids {
  17504. // id, _ := strconv.ParseInt(item, 10, 64)
  17505. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  17506. // config = append(config, &diagnosisConfig)
  17507. // }
  17508. //
  17509. // for index, item := range config {
  17510. // if index == 0 {
  17511. // var tempDiaginfo service.DiaginfoStructTwo
  17512. // tempDiaginfo.DiagCode = item.CountryCode
  17513. // tempDiaginfo.DiagName = item.CountryContentName
  17514. // tempDiaginfo.DiagType = "1"
  17515. // tempDiaginfo.MaindiagFlag = "1"
  17516. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17517. // } else {
  17518. //
  17519. // var tempDiaginfo service.DiaginfoStructTwo
  17520. // tempDiaginfo.DiagCode = item.CountryCode
  17521. // tempDiaginfo.DiagName = item.CountryContentName
  17522. // tempDiaginfo.DiagType = "2"
  17523. // tempDiaginfo.MaindiagFlag = "0"
  17524. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17525. // }
  17526. // }
  17527. // struct4101.Diseinfo = tempDiaginfos
  17528. //
  17529. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  17530. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  17531. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  17532. // tempOpspdiseinfo2.OprnOprtCode = ""
  17533. // tempOpspdiseinfo2.OprnOprtName = ""
  17534. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  17535. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  17536. //
  17537. // var iteminfo service.IteminfoStruct
  17538. //
  17539. // var bedCostTotal float64 = 0 //床位总费
  17540. // var bedCostSelfTotal float64 = 0 //床位自费
  17541. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  17542. //
  17543. // var examineCostTotal float64 = 0 //诊查总费
  17544. // var examineCostSelfTotal float64 = 0 //诊查自费
  17545. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  17546. //
  17547. // var nursingCostTotal float64 = 0 //护理总费
  17548. // var nursingCostSelfTotal float64 = 0 //护理自费
  17549. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  17550. //
  17551. // var chineseMedicineCostTotal float64 = 0 //中成药
  17552. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  17553. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  17554. //
  17555. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  17556. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  17557. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  17558. //
  17559. // var registerCostTotal float64 = 0 //一般诊疗费
  17560. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  17561. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  17562. //
  17563. // var operationCostTotal float64 = 0 //手术费
  17564. // var operationCostSelfTotal float64 = 0 //手术费
  17565. // var operationCostPartSelfTotal float64 = 0 //手术费
  17566. //
  17567. // var otherCostTotal float64 = 0 //其他费用
  17568. // var otherCostSelfTotal float64 = 0 //其他费用
  17569. // var otherCostPartSelfTotal float64 = 0 //其他费用
  17570. //
  17571. // var materialCostTotal float64 = 0 //材料费
  17572. // var materialCostSelfTotal float64 = 0 //材料费
  17573. // var materialCostPartSelfTotal float64 = 0 //材料费
  17574. //
  17575. // var westernMedicineCostTotal float64 = 0 //西药费
  17576. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  17577. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  17578. //
  17579. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  17580. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  17581. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  17582. //
  17583. // var checkCostTotal float64 = 0 //检查费
  17584. // var checkCostSelfTotal float64 = 0 //检查费
  17585. // var checkCostPartSelfTotal float64 = 0 //检查费
  17586. //
  17587. // var laboratoryCostTotal float64 = 0 //化验费
  17588. // var laboratoryCostSelfTotal float64 = 0 //化验费
  17589. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  17590. //
  17591. // var treatCostTotal float64 = 0 //治疗费用
  17592. // var treatCostSelfTotal float64 = 0 //治疗费用
  17593. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  17594. //
  17595. // decimal.DivisionPrecision = 2
  17596. //
  17597. // var bed_fulamt_ownpay_amt float64 = 0
  17598. //
  17599. // var examine_fulamt_ownpay_amt float64 = 0
  17600. //
  17601. // var nursing_fulamt_ownpay_amt float64 = 0
  17602. //
  17603. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  17604. //
  17605. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  17606. //
  17607. // var register_fulamt_ownpay_amt float64 = 0
  17608. //
  17609. // var operation_fulamt_ownpay_amt float64 = 0
  17610. // var other_fulamt_ownpay_amt float64 = 0
  17611. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  17612. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  17613. // var check_fulamt_ownpay_amt float64 = 0
  17614. // var material_fulamt_ownpay_amt float64 = 0
  17615. // var laboratory_fulamt_ownpay_amt float64 = 0
  17616. // var treat_fulamt_ownpay_amt float64 = 0
  17617. //
  17618. // var bed_claa_sunmfee float64 = 0
  17619. // var bed_clab_amt float64 = 0
  17620. // var bed_other_amt float64 = 0
  17621. //
  17622. // var examine_claa_sunmfee float64 = 0
  17623. // var examine_clab_amt float64 = 0
  17624. // var examine_other_amt float64 = 0
  17625. //
  17626. // var nursing_claa_sunmfee float64 = 0
  17627. // var nursing_clab_amt float64 = 0
  17628. // var nursing_other_amt float64 = 0
  17629. //
  17630. // var chinese_medicine_claa_sunmfee float64 = 0
  17631. // var chinese_medicine_clab_amt float64 = 0
  17632. // var chinese_medicine_other_amt float64 = 0
  17633. //
  17634. // var commonly_treatment_claa_sunmfee float64 = 0
  17635. // var commonly_treatment_clab_amt float64 = 0
  17636. // var commonly_treatment_other_amt float64 = 0
  17637. //
  17638. // var operation_claa_sunmfee float64 = 0
  17639. // var operation_clab_amt float64 = 0
  17640. // var operation_other_amt float64 = 0
  17641. //
  17642. // var other_claa_sunmfee float64 = 0
  17643. // var other_clab_amt float64 = 0
  17644. // var other_other_amt float64 = 0
  17645. //
  17646. // var westernMedicine_claa_sunmfee float64 = 0
  17647. // var westernMedicine_clab_amt float64 = 0
  17648. // var westernMedicine_other_amt float64 = 0
  17649. //
  17650. // var chineseTraditional_claa_sunmfee float64 = 0
  17651. // var chineseTraditional_clab_amt float64 = 0
  17652. // var chineseTraditional_other_amt float64 = 0
  17653. //
  17654. // var check_claa_sunmfee float64 = 0
  17655. // var check_clab_amt float64 = 0
  17656. // var check_other_amt float64 = 0
  17657. //
  17658. // var material_claa_sunmfee float64 = 0
  17659. // var material_clab_amt float64 = 0
  17660. // var material_other_amt float64 = 0
  17661. //
  17662. // var laboratory_claa_sunmfee float64 = 0
  17663. // var laboratory_clab_amt float64 = 0
  17664. // var laboratory_other_amt float64 = 0
  17665. //
  17666. // var treat_claa_sunmfee float64 = 0
  17667. // var treat_clab_amt float64 = 0
  17668. // var treat_other_amt float64 = 0
  17669. //
  17670. // var register_claa_sunmfee float64 = 0
  17671. // var register_clab_amt float64 = 0
  17672. // var register_other_amt float64 = 0
  17673. //
  17674. // for _, item := range order.HisOrderInfo {
  17675. // if item.MedChrgitmType == "01" { //床位费
  17676. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17677. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17678. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17679. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17680. // if item.ChrgitmLv == "1" {
  17681. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17682. // }
  17683. // if item.ChrgitmLv == "2" {
  17684. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17685. //
  17686. // }
  17687. // if item.ChrgitmLv == "3" {
  17688. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17689. // }
  17690. //
  17691. // }
  17692. //
  17693. // if item.MedChrgitmType == "02" { //诊查
  17694. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17695. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17696. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17697. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17698. // if item.ChrgitmLv == "1" {
  17699. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17700. // }
  17701. // if item.ChrgitmLv == "2" {
  17702. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17703. //
  17704. // }
  17705. // if item.ChrgitmLv == "3" {
  17706. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17707. // }
  17708. //
  17709. // }
  17710. //
  17711. // if item.MedChrgitmType == "03" { //检查费
  17712. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17713. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17714. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17715. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17716. // if item.ChrgitmLv == "1" {
  17717. //
  17718. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17719. //
  17720. // }
  17721. // if item.ChrgitmLv == "2" {
  17722. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17723. //
  17724. // }
  17725. // if item.ChrgitmLv == "3" {
  17726. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17727. // }
  17728. // }
  17729. //
  17730. // if item.MedChrgitmType == "04" { //化验费
  17731. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17732. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17733. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17734. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17735. // if item.ChrgitmLv == "1" {
  17736. //
  17737. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17738. //
  17739. // }
  17740. // if item.ChrgitmLv == "2" {
  17741. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17742. //
  17743. // }
  17744. // if item.ChrgitmLv == "3" {
  17745. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17746. // }
  17747. // }
  17748. //
  17749. // if item.MedChrgitmType == "05" { //治疗费
  17750. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17751. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17752. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17753. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17754. // if item.ChrgitmLv == "1" {
  17755. //
  17756. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17757. //
  17758. // }
  17759. // if item.ChrgitmLv == "2" {
  17760. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17761. //
  17762. // }
  17763. // if item.ChrgitmLv == "3" {
  17764. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17765. // }
  17766. // }
  17767. //
  17768. // if item.MedChrgitmType == "06" { //手术费
  17769. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17770. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17771. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17772. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17773. //
  17774. // if item.ChrgitmLv == "1" {
  17775. //
  17776. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17777. //
  17778. // }
  17779. // if item.ChrgitmLv == "2" {
  17780. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17781. //
  17782. // }
  17783. // if item.ChrgitmLv == "3" {
  17784. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17785. // }
  17786. // }
  17787. //
  17788. // if item.MedChrgitmType == "07" { //手术费
  17789. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17790. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17791. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17792. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17793. //
  17794. // if item.ChrgitmLv == "1" {
  17795. //
  17796. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17797. //
  17798. // }
  17799. // if item.ChrgitmLv == "2" {
  17800. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17801. //
  17802. // }
  17803. // if item.ChrgitmLv == "3" {
  17804. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17805. // }
  17806. // }
  17807. //
  17808. // if item.MedChrgitmType == "08" { //材料费
  17809. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17810. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17811. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17812. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17813. // if item.ChrgitmLv == "1" {
  17814. //
  17815. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17816. //
  17817. // }
  17818. // if item.ChrgitmLv == "2" {
  17819. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17820. //
  17821. // }
  17822. // if item.ChrgitmLv == "3" {
  17823. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17824. // }
  17825. // }
  17826. // if item.MedChrgitmType == "09" { //西药费
  17827. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17828. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17829. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17830. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17831. // if item.ChrgitmLv == "1" {
  17832. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17833. // }
  17834. // if item.ChrgitmLv == "2" {
  17835. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17836. // }
  17837. // if item.ChrgitmLv == "3" {
  17838. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17839. // }
  17840. // }
  17841. // if item.MedChrgitmType == "10" { //中药饮片
  17842. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17843. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17844. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17845. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17846. // if item.ChrgitmLv == "1" {
  17847. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17848. // }
  17849. // if item.ChrgitmLv == "2" {
  17850. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17851. // }
  17852. // if item.ChrgitmLv == "3" {
  17853. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17854. // }
  17855. // }
  17856. //
  17857. // if item.MedChrgitmType == "11" { //中成费
  17858. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17859. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17860. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17861. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17862. // if item.ChrgitmLv == "1" {
  17863. //
  17864. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17865. //
  17866. // }
  17867. // if item.ChrgitmLv == "2" {
  17868. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17869. //
  17870. // }
  17871. // if item.ChrgitmLv == "3" {
  17872. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17873. // }
  17874. // }
  17875. //
  17876. // if item.MedChrgitmType == "12" { //中成费
  17877. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17878. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17879. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17880. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17881. // if item.ChrgitmLv == "1" {
  17882. //
  17883. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17884. //
  17885. // }
  17886. // if item.ChrgitmLv == "2" {
  17887. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17888. //
  17889. // }
  17890. // if item.ChrgitmLv == "3" {
  17891. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17892. // }
  17893. // }
  17894. //
  17895. // if item.MedChrgitmType == "13" { //中成费
  17896. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17897. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17898. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17899. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17900. // if item.ChrgitmLv == "1" {
  17901. //
  17902. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17903. //
  17904. // }
  17905. // if item.ChrgitmLv == "2" {
  17906. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17907. //
  17908. // }
  17909. // if item.ChrgitmLv == "3" {
  17910. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17911. // }
  17912. // }
  17913. //
  17914. // if item.MedChrgitmType == "14" { //其他费
  17915. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17916. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17917. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17918. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17919. // if item.ChrgitmLv == "1" {
  17920. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17921. //
  17922. // }
  17923. // if item.ChrgitmLv == "2" {
  17924. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17925. //
  17926. // }
  17927. // if item.ChrgitmLv == "3" {
  17928. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17929. // }
  17930. // }
  17931. //
  17932. // }
  17933. //
  17934. // var iteminfoStructs []service.IteminfoStruct
  17935. //
  17936. // if bedCostTotal != 0 {
  17937. // iteminfo.MedChrgitm = "01"
  17938. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17939. // iteminfo.Amt = bedCostTotal
  17940. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  17941. // iteminfo.ClabAmt = bed_clab_amt
  17942. // iteminfo.OthAmt = bed_other_amt
  17943. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17944. // }
  17945. //
  17946. // if examineCostTotal != 0 {
  17947. // iteminfo.MedChrgitm = "02"
  17948. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  17949. // iteminfo.Amt = examineCostTotal
  17950. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  17951. // iteminfo.ClabAmt = examine_clab_amt
  17952. // iteminfo.OthAmt = examine_other_amt
  17953. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17954. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17955. // }
  17956. //
  17957. // if checkCostTotal != 0 {
  17958. // iteminfo.MedChrgitm = "03"
  17959. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  17960. // iteminfo.Amt = checkCostTotal
  17961. // iteminfo.ClaaSumfee = check_claa_sunmfee
  17962. // iteminfo.ClabAmt = check_clab_amt
  17963. // iteminfo.OthAmt = check_other_amt
  17964. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17965. //
  17966. // }
  17967. //
  17968. // if laboratoryCostTotal != 0 {
  17969. // iteminfo.MedChrgitm = "04"
  17970. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  17971. // iteminfo.Amt = laboratoryCostTotal
  17972. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  17973. // iteminfo.ClabAmt = laboratory_clab_amt
  17974. // iteminfo.OthAmt = laboratory_other_amt
  17975. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17976. //
  17977. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17978. //
  17979. // }
  17980. //
  17981. // if treatCostTotal != 0 {
  17982. // iteminfo.MedChrgitm = "05"
  17983. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  17984. // iteminfo.Amt = treatCostTotal
  17985. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  17986. // iteminfo.ClabAmt = treat_clab_amt
  17987. // iteminfo.OthAmt = treat_other_amt
  17988. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17989. // //(struct4101.IteminfoStruct, iteminfo)
  17990. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17991. // }
  17992. //
  17993. // if operationCostTotal != 0 {
  17994. // iteminfo.MedChrgitm = "06"
  17995. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17996. // iteminfo.Amt = operationCostTotal
  17997. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  17998. // iteminfo.ClabAmt = operation_clab_amt
  17999. // iteminfo.OthAmt = operation_other_amt
  18000. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18001. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18002. // }
  18003. //
  18004. // if nursingCostTotal != 0 {
  18005. // iteminfo.MedChrgitm = "07"
  18006. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  18007. // iteminfo.Amt = nursingCostTotal
  18008. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  18009. // iteminfo.ClabAmt = nursing_clab_amt
  18010. // iteminfo.OthAmt = nursing_other_amt
  18011. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18012. // }
  18013. //
  18014. // if materialCostTotal != 0 {
  18015. // iteminfo.MedChrgitm = "08"
  18016. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18017. // iteminfo.Amt = materialCostTotal
  18018. // iteminfo.ClaaSumfee = material_claa_sunmfee
  18019. // iteminfo.ClabAmt = material_clab_amt
  18020. // iteminfo.OthAmt = material_other_amt
  18021. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18022. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18023. // }
  18024. //
  18025. // if westernMedicineCostTotal != 0 {
  18026. // iteminfo.MedChrgitm = "09"
  18027. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18028. // iteminfo.Amt = westernMedicineCostTotal
  18029. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18030. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18031. // iteminfo.OthAmt = westernMedicine_other_amt
  18032. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18033. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18034. //
  18035. // }
  18036. //
  18037. // if chineseMedicineCostTotal != 0 {
  18038. // iteminfo.MedChrgitm = "10"
  18039. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  18040. // iteminfo.Amt = chineseMedicineCostTotal
  18041. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  18042. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  18043. // iteminfo.OthAmt = chinese_medicine_other_amt
  18044. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18045. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18046. //
  18047. // }
  18048. //
  18049. // if chineseTraditionalMedicineCostTotal != 0 {
  18050. // iteminfo.MedChrgitm = "11"
  18051. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18052. // iteminfo.Amt = westernMedicineCostTotal
  18053. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18054. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18055. // iteminfo.OthAmt = westernMedicine_other_amt
  18056. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18057. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18058. //
  18059. // }
  18060. //
  18061. // if commonlyTreatmentCostTotal != 0 {
  18062. // iteminfo.MedChrgitm = "12"
  18063. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  18064. // iteminfo.Amt = commonlyTreatmentCostTotal
  18065. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  18066. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  18067. // iteminfo.OthAmt = commonly_treatment_other_amt
  18068. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18069. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18070. //
  18071. // }
  18072. //
  18073. // if registerCostTotal != 0 {
  18074. // iteminfo.MedChrgitm = "13"
  18075. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  18076. // iteminfo.Amt = registerCostTotal
  18077. // iteminfo.ClaaSumfee = register_claa_sunmfee
  18078. // iteminfo.ClabAmt = register_clab_amt
  18079. // iteminfo.OthAmt = register_other_amt
  18080. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18081. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18082. //
  18083. // }
  18084. //
  18085. // if otherCostTotal != 0 {
  18086. // iteminfo.MedChrgitm = "14"
  18087. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18088. // iteminfo.Amt = otherCostTotal
  18089. // iteminfo.ClaaSumfee = other_claa_sunmfee
  18090. // iteminfo.ClabAmt = other_clab_amt
  18091. // iteminfo.OthAmt = other_other_amt
  18092. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18093. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18094. //
  18095. // }
  18096. // struct4101.IteminfoStruct = iteminfoStructs
  18097. // time_arr := strings.Split(order.SetlTime, " ")
  18098. // struct4101.AdmTime = time_arr[0]
  18099. // struct4101.AdmEndTime = time_arr[0]
  18100. //
  18101. // struct4101.DoctorName = doctor.UserName
  18102. // struct4101.DoctorCode = doctor.DoctorNumber
  18103. //
  18104. // struct4101.Ntly = "中国"
  18105. // struct4101.AdmCaty = "A03.06"
  18106. // var res ResultSeventeen
  18107. // if miConfig.MdtrtareaAdmvs == "421300" {
  18108. // data := make(map[string]interface{})
  18109. // data["struct4101"] = struct4101
  18110. // data["secret_key"] = miConfig.SecretKey
  18111. // data["org_name"] = miConfig.OrgName
  18112. // data["opera"] = curRoles.UserName
  18113. // data["code"] = miConfig.Code
  18114. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  18115. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18116. //
  18117. // client := &http.Client{}
  18118. // bytesData, _ := json.Marshal(data)
  18119. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  18120. // resp, _ := client.Do(req)
  18121. // defer resp.Body.Close()
  18122. // body, ioErr := ioutil.ReadAll(resp.Body)
  18123. // if ioErr != nil {
  18124. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18125. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18126. // return
  18127. // }
  18128. // var respJSON map[string]interface{}
  18129. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18130. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18131. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18132. // return
  18133. // }
  18134. //
  18135. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18136. // userJSONBytes, _ := json.Marshal(respJSON)
  18137. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18138. // utils.ErrorLog("解析失败:%v", err)
  18139. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18140. // adminUser := c.GetAdminUserInfo()
  18141. // errlog := &models.HisOrderError{
  18142. // UserOrgId: adminUser.CurrentOrgId,
  18143. // Ctime: time.Now().Unix(),
  18144. // Mtime: time.Now().Unix(),
  18145. // ErrMsg: res.ErrMsg + "解析失败",
  18146. // Status: 1,
  18147. // PatientId: order_id,
  18148. // Stage: 10088,
  18149. // }
  18150. // service.CreateErrMsgLog(errlog)
  18151. // continue
  18152. // }
  18153. //
  18154. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  18155. // data := make(map[string]interface{})
  18156. // data["struct4101"] = struct4101
  18157. // data["secret_key"] = miConfig.SecretKey
  18158. // data["org_name"] = miConfig.OrgName
  18159. // data["opera"] = curRoles.UserName
  18160. // data["code"] = miConfig.Code
  18161. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  18162. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18163. //
  18164. // client := &http.Client{}
  18165. // bytesData, _ := json.Marshal(data)
  18166. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  18167. // resp, _ := client.Do(req)
  18168. // defer resp.Body.Close()
  18169. // body, ioErr := ioutil.ReadAll(resp.Body)
  18170. // if ioErr != nil {
  18171. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18172. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18173. // return
  18174. // }
  18175. // var respJSON map[string]interface{}
  18176. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18177. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18178. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18179. // return
  18180. // }
  18181. //
  18182. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18183. // userJSONBytes, _ := json.Marshal(respJSON)
  18184. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18185. // utils.ErrorLog("解析失败:%v", err)
  18186. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18187. // adminUser := c.GetAdminUserInfo()
  18188. // errlog := &models.HisOrderError{
  18189. // UserOrgId: adminUser.CurrentOrgId,
  18190. // Ctime: time.Now().Unix(),
  18191. // Mtime: time.Now().Unix(),
  18192. // ErrMsg: res.ErrMsg + "解析失败",
  18193. // Status: 1,
  18194. // PatientId: order_id,
  18195. // Stage: 10088,
  18196. // }
  18197. // service.CreateErrMsgLog(errlog)
  18198. // continue
  18199. // }
  18200. //
  18201. // } else {
  18202. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  18203. // fmt.Println(result)
  18204. //
  18205. // var dat map[string]interface{}
  18206. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18207. // fmt.Println(dat)
  18208. // } else {
  18209. // fmt.Println(err)
  18210. // }
  18211. // userJSONBytes, _ := json.Marshal(dat)
  18212. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18213. // utils.ErrorLog("解析失败:%v", err)
  18214. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18215. // adminUser := c.GetAdminUserInfo()
  18216. // errlog := &models.HisOrderError{
  18217. // UserOrgId: adminUser.CurrentOrgId,
  18218. // Ctime: time.Now().Unix(),
  18219. // Mtime: time.Now().Unix(),
  18220. // ErrMsg: res.ErrMsg + "解析失败",
  18221. // Status: 1,
  18222. // PatientId: order_id,
  18223. // Stage: 10106,
  18224. // }
  18225. // service.CreateErrMsgLog(errlog)
  18226. // continue
  18227. // }
  18228. // }
  18229. //
  18230. // if res.Infcode != 0 {
  18231. // adminUser := c.GetAdminUserInfo()
  18232. // errlog := &models.HisOrderError{
  18233. // UserOrgId: adminUser.CurrentOrgId,
  18234. // Ctime: time.Now().Unix(),
  18235. // Mtime: time.Now().Unix(),
  18236. // ErrMsg: res.ErrMsg,
  18237. // Status: 1,
  18238. // PatientId: order_id,
  18239. // Stage: 10106,
  18240. // }
  18241. // service.CreateErrMsgLog(errlog)
  18242. // continue
  18243. // } else {
  18244. // hisFundSettleListResult := &models.HisFundSettleListResult{
  18245. // Number: res.Output.SetlListId,
  18246. // Status: 1,
  18247. // Ctime: time.Now().Unix(),
  18248. // Mtime: time.Now().Unix(),
  18249. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18250. // IsUpload: 1,
  18251. // OrderId: order_id,
  18252. // }
  18253. // service.CreateUploadRecord(hisFundSettleListResult)
  18254. // continue
  18255. // }
  18256. // }
  18257. //}
  18258. func (c *HisApiController) GetOrgInfo() {
  18259. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  18260. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  18261. }
  18262. func (c *HisApiController) GetHisPatientInfo() {
  18263. medical_insurance_card := c.GetString("medical_insurance_card")
  18264. id_card_type, _ := c.GetInt64("id_card_type")
  18265. id_card := c.GetString("id_card")
  18266. adminInfo := c.GetAdminUserInfo()
  18267. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  18268. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  18269. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  18270. IdCardNo := ""
  18271. if id_card_type == 1 {
  18272. IdCardNo = medical_insurance_card
  18273. } else if id_card_type == 2 {
  18274. IdCardNo = id_card
  18275. }
  18276. if config.IsOpen == 1 {
  18277. 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
  18278. resp, requestErr := http.Get(api)
  18279. if requestErr != nil {
  18280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18281. return
  18282. }
  18283. defer resp.Body.Close()
  18284. body, ioErr := ioutil.ReadAll(resp.Body)
  18285. if ioErr != nil {
  18286. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18288. return
  18289. }
  18290. var respJSON map[string]interface{}
  18291. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18292. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18294. return
  18295. }
  18296. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18297. userJSONBytes, _ := json.Marshal(userJSON)
  18298. var res ResultTwo
  18299. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18300. utils.ErrorLog("解析失败:%v", err)
  18301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18302. return
  18303. }
  18304. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18305. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18306. infoStr := string(Iinfos)
  18307. idetinfoStr := string(Idetinfos)
  18308. if res.Infcode == 0 {
  18309. his := models.VMHisPatient{
  18310. Status: 1,
  18311. Ctime: time.Now().Unix(),
  18312. Mtime: time.Now().Unix(),
  18313. PsnNo: res.Output.Baseinfo.PsnNo,
  18314. PsnCertType: res.Output.Baseinfo.PsnCertType,
  18315. Certno: res.Output.Baseinfo.Certno,
  18316. PsnName: res.Output.Baseinfo.PsnName,
  18317. Gend: res.Output.Baseinfo.Gend,
  18318. Naty: res.Output.Baseinfo.Naty,
  18319. Iinfo: infoStr,
  18320. Idetinfo: idetinfoStr,
  18321. UserOrgId: adminInfo.CurrentOrgId,
  18322. IsReturn: 1,
  18323. IdCardType: id_card_type,
  18324. }
  18325. c.ServeSuccessJSON(map[string]interface{}{
  18326. "info": his,
  18327. })
  18328. } else {
  18329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18330. return
  18331. }
  18332. }
  18333. }
  18334. //func GetBasBaseInfo() (jsonStr string, err error) {
  18335. //
  18336. // handle := syscall.NewLazyDLL("SSCard.dll")
  18337. // add := handle.NewProc("ReadCardBas")
  18338. // str := make([]byte, 1024)
  18339. // str1 := make([]byte, 1024)
  18340. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  18341. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  18342. //
  18343. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  18344. //
  18345. // fmt.Println("> Add(4,5)的结果为:", ret)
  18346. // handle.Release()
  18347. //
  18348. // return "", nil
  18349. //
  18350. //}
  18351. //func GetQRBaseInfo() (jsonStr string, err error) {
  18352. // handle := syscall.LoadDLL("SSCard.dll")
  18353. // ReadCardBas := handle.FindProc("GetQRBase")
  18354. //
  18355. // str := make([]byte, 256)
  18356. // str1 := make([]byte, 256)
  18357. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  18358. //
  18359. // fmt.Println(string(str))
  18360. // fmt.Println(r)
  18361. // return string(str), nil
  18362. //}
  18363. //func CardInit() int {
  18364. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  18365. // add := DllTestDef.MustFindProc("Init")
  18366. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  18367. // if err != nil {
  18368. // fmt.Println("SSCard的运算结果为:", ret)
  18369. // }
  18370. // result := int(ret)
  18371. // return result
  18372. //}
  18373. //func CardInit() int {
  18374. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  18375. // if err != nil {
  18376. // fmt.Println("SSCard的运算结果为:", ret)
  18377. // }
  18378. // fmt.Println(err)
  18379. // result := int(ret)
  18380. // return result
  18381. //}
  18382. func IntPtr(n int) uintptr {
  18383. return uintptr(n)
  18384. }
  18385. func StrPtr(s string) uintptr {
  18386. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  18387. }
  18388. type Result2001 struct {
  18389. Cainfo interface{} `json:"cainfo"`
  18390. ErrMsg string `json:"err_msg"`
  18391. InfRefmsgid string `json:"inf_refmsgid"`
  18392. Infcode int64 `json:"infcode"`
  18393. Output struct {
  18394. Trtinfo struct {
  18395. PsnNo string `json:"psn_no"`
  18396. TrtChkType string `json:"trt_chk_type"`
  18397. FundPayType string `json:"fund_pay_type"`
  18398. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  18399. Begndate string `json:"begndate"`
  18400. Enddate string `json:"enddate"`
  18401. TrtChkRslt string `json:"trt_chk_rslt"`
  18402. } `json:"trtinfo"`
  18403. } `json:"output"`
  18404. RefmsgTime string `json:"refmsg_time"`
  18405. RespondTime string `json:"respond_time"`
  18406. Signtype interface{} `json:"signtype"`
  18407. WarnMsg interface{} `json:"warn_msg"`
  18408. }
  18409. type Result2001Org10265 struct {
  18410. Cainfo interface{} `json:"cainfo"`
  18411. ErrMsg string `json:"err_msg"`
  18412. InfRefmsgid string `json:"inf_refmsgid"`
  18413. Infcode string `json:"infcode"`
  18414. Output struct {
  18415. Trtinfo struct {
  18416. PsnNo string `json:"psn_no"`
  18417. TrtChkType string `json:"trt_chk_type"`
  18418. FundPayType string `json:"fund_pay_type"`
  18419. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  18420. Begndate string `json:"begndate"`
  18421. Enddate string `json:"enddate"`
  18422. TrtChkRslt string `json:"trt_chk_rslt"`
  18423. } `json:"trtinfo"`
  18424. } `json:"output"`
  18425. RefmsgTime string `json:"refmsg_time"`
  18426. RespondTime string `json:"respond_time"`
  18427. Signtype interface{} `json:"signtype"`
  18428. WarnMsg interface{} `json:"warn_msg"`
  18429. }
  18430. type ResultTwo struct {
  18431. ErrMsg string `json:"err_msg"`
  18432. InfRefmsgid string `json:"inf_refmsgid"`
  18433. Infcode int64 `json:"infcode"`
  18434. Output struct {
  18435. Baseinfo struct {
  18436. //Brdy string `json:"brdy"`
  18437. Certno string `json:"certno"`
  18438. Gend string `json:"gend"`
  18439. Naty string `json:"naty"`
  18440. PsnCertType string `json:"psn_cert_type"`
  18441. PsnName string `json:"psn_name"`
  18442. PsnNo string `json:"psn_no"`
  18443. } `json:"baseinfo"`
  18444. Idetinfo []interface{} `json:"idetinfo"`
  18445. Iinfo []struct {
  18446. Balc float64 `json:"balc"`
  18447. CvlservFlag string `json:"cvlserv_flag"`
  18448. EmpName string `json:"emp_name"`
  18449. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  18450. Insutype string `json:"insutype"`
  18451. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  18452. //PausInsuDate string `json:"paus_insu_date"`
  18453. //PsnInsuDate string `json:"psn_insu_date"`
  18454. PsnInsuStas string `json:"psn_insu_stas"`
  18455. PsnType string `json:"psn_type"`
  18456. } `json:"insuinfo"`
  18457. } `json:"output"`
  18458. RefmsgTime string `json:"refmsg_time"`
  18459. RespondTime string `json:"respond_time"`
  18460. Signtype interface{} `json:"signtype"`
  18461. WarnInfo interface{} `json:"warn_info"`
  18462. }
  18463. type ResultTwo10265 struct {
  18464. ErrMsg string `json:"err_msg"`
  18465. InfRefmsgid string `json:"inf_refmsgid"`
  18466. Infcode string `json:"infcode"`
  18467. Output struct {
  18468. Baseinfo struct {
  18469. //Brdy string `json:"brdy"`
  18470. Certno string `json:"certno"`
  18471. Gend string `json:"gend"`
  18472. Naty string `json:"naty"`
  18473. PsnCertType string `json:"psn_cert_type"`
  18474. PsnName string `json:"psn_name"`
  18475. PsnNo string `json:"psn_no"`
  18476. } `json:"baseinfo"`
  18477. Idetinfo []interface{} `json:"idetinfo"`
  18478. Iinfo []struct {
  18479. Balc float64 `json:"balc"`
  18480. CvlservFlag string `json:"cvlserv_flag"`
  18481. EmpName string `json:"emp_name"`
  18482. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  18483. Insutype string `json:"insutype"`
  18484. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  18485. PsnInsuStas string `json:"psn_insu_stas"`
  18486. PsnType string `json:"psn_type"`
  18487. } `json:"insuinfo"`
  18488. } `json:"output"`
  18489. RefmsgTime string `json:"refmsg_time"`
  18490. RespondTime string `json:"respond_time"`
  18491. Signtype interface{} `json:"signtype"`
  18492. WarnInfo interface{} `json:"warn_info"`
  18493. }
  18494. type ResultThree struct {
  18495. Cainfo interface{} `json:"cainfo"`
  18496. ErrMsg string `json:"err_msg"`
  18497. InfRefmsgid string `json:"inf_refmsgid"`
  18498. Infcode int64 `json:"infcode"`
  18499. Output struct {
  18500. Data struct {
  18501. IptOtpNo string `json:"ipt_otp_no"`
  18502. MdtrtID string `json:"mdtrt_id"`
  18503. PsnNo string `json:"psn_no"`
  18504. } `json:"data"`
  18505. } `json:"output"`
  18506. RefmsgTime string `json:"refmsg_time"`
  18507. RespondTime string `json:"respond_time"`
  18508. Signtype interface{} `json:"signtype"`
  18509. WarnMsg interface{} `json:"warn_msg"`
  18510. }
  18511. type ResultThree10265 struct {
  18512. Cainfo interface{} `json:"cainfo"`
  18513. ErrMsg string `json:"err_msg"`
  18514. InfRefmsgid string `json:"inf_refmsgid"`
  18515. Infcode string `json:"infcode"`
  18516. Output struct {
  18517. Data struct {
  18518. IptOtpNo string `json:"ipt_otp_no"`
  18519. MdtrtID string `json:"mdtrt_id"`
  18520. PsnNo string `json:"psn_no"`
  18521. } `json:"data"`
  18522. } `json:"output"`
  18523. RefmsgTime string `json:"refmsg_time"`
  18524. RespondTime string `json:"respond_time"`
  18525. Signtype interface{} `json:"signtype"`
  18526. WarnMsg interface{} `json:"warn_msg"`
  18527. }
  18528. type ResultFour struct {
  18529. Cainfo string `json:"cainfo"`
  18530. ErrMsg string `json:"err_msg"`
  18531. InfRefmsgid string `json:"inf_refmsgid"`
  18532. Infcode int64 `json:"infcode"`
  18533. Output struct {
  18534. Result []struct {
  18535. BasMednFlag string `json:"bas_medn_flag"`
  18536. ChldMedcFlag string `json:"chld_medc_flag"`
  18537. ChrgitmLv string `json:"chrgitm_lv"`
  18538. Cnt float64 `json:"cnt"`
  18539. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  18540. DrtReimFlag string `json:"drt_reim_flag"`
  18541. FeedetlSn string `json:"feedetl_sn"`
  18542. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  18543. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  18544. InscpScpAmt float64 `json:"inscp_scp_amt"`
  18545. ListSpItemFlag string `json:"list_sp_item_flag"`
  18546. LmtUsedFlag string `json:"lmt_used_flag"`
  18547. MedChrgitmType string `json:"med_chrgitm_type"`
  18548. Memo string `json:"memo"`
  18549. OverlmtAmt float64 `json:"overlmt_amt"`
  18550. PreselfpayAmt float64 `json:"preselfpay_amt"`
  18551. Pric float64 `json:"pric"`
  18552. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  18553. SelfpayProp float64 `json:"selfpay_prop"`
  18554. } `json:"result"`
  18555. } `json:"output"`
  18556. RefmsgTime string `json:"refmsg_time"`
  18557. RespondTime string `json:"respond_time"`
  18558. Signtype string `json:"signtype"`
  18559. WarnMsg string `json:"warn_msg"`
  18560. }
  18561. type ResultFour10265 struct {
  18562. Cainfo string `json:"cainfo"`
  18563. ErrMsg string `json:"err_msg"`
  18564. InfRefmsgid string `json:"inf_refmsgid"`
  18565. Infcode string `json:"infcode"`
  18566. Output struct {
  18567. Result []struct {
  18568. BasMednFlag string `json:"bas_medn_flag"`
  18569. ChldMedcFlag string `json:"chld_medc_flag"`
  18570. ChrgitmLv string `json:"chrgitm_lv"`
  18571. Cnt float64 `json:"cnt"`
  18572. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  18573. DrtReimFlag string `json:"drt_reim_flag"`
  18574. FeedetlSn string `json:"feedetl_sn"`
  18575. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  18576. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  18577. InscpScpAmt float64 `json:"inscp_scp_amt"`
  18578. ListSpItemFlag string `json:"list_sp_item_flag"`
  18579. LmtUsedFlag string `json:"lmt_used_flag"`
  18580. MedChrgitmType string `json:"med_chrgitm_type"`
  18581. Memo string `json:"memo"`
  18582. OverlmtAmt float64 `json:"overlmt_amt"`
  18583. PreselfpayAmt float64 `json:"preselfpay_amt"`
  18584. Pric float64 `json:"pric"`
  18585. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  18586. SelfpayProp float64 `json:"selfpay_prop"`
  18587. } `json:"result"`
  18588. } `json:"output"`
  18589. RefmsgTime string `json:"refmsg_time"`
  18590. RespondTime string `json:"respond_time"`
  18591. Signtype string `json:"signtype"`
  18592. WarnMsg string `json:"warn_msg"`
  18593. }
  18594. type ResultMemo struct {
  18595. InsuAdmdvs string `json:"insuAdmdvs"`
  18596. }
  18597. // [{"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}]
  18598. type ResultIDInfo struct {
  18599. Begntime string `json:"begntime"`
  18600. Endtime string `json:"endtime"`
  18601. Memo string `json:"memo"`
  18602. }
  18603. type ResultFive struct {
  18604. Balc float64 `json:"balc"`
  18605. CvlservFlag string `json:"cvlserv_flag"`
  18606. EmpName string `json:"emp_name"`
  18607. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  18608. Insutype string `json:"insutype"`
  18609. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  18610. PausInsuDate string `json:"paus_insu_date"`
  18611. PsnInsuDate string `json:"psn_insu_date"`
  18612. PsnInsuStas string `json:"psn_insu_stas"`
  18613. PsnType string `json:"psn_type"`
  18614. }
  18615. type ResultSix struct {
  18616. Cainfo interface{} `json:"cainfo"`
  18617. ErrMsg string `json:"err_msg"`
  18618. InfRefmsgid string `json:"inf_refmsgid"`
  18619. Infcode int64 `json:"infcode"`
  18620. Output struct {
  18621. } `json:"output"`
  18622. RefmsgTime string `json:"refmsg_time"`
  18623. RespondTime string `json:"respond_time"`
  18624. Signtype interface{} `json:"signtype"`
  18625. WarnMsg interface{} `json:"warn_msg"`
  18626. }
  18627. type FJ3507Result struct {
  18628. Cainfo interface{} `json:"cainfo"`
  18629. ErrMsg string `json:"err_msg"`
  18630. InfRefmsgid string `json:"inf_refmsgid"`
  18631. Infcode int64 `json:"infcode"`
  18632. Output struct {
  18633. retRslt string `json:"retRslt"`
  18634. msgRslt string `json:"msgRslt"`
  18635. } `json:"output"`
  18636. RefmsgTime string `json:"refmsg_time"`
  18637. RespondTime string `json:"respond_time"`
  18638. Signtype interface{} `json:"signtype"`
  18639. WarnMsg interface{} `json:"warn_msg"`
  18640. }
  18641. type FJ3507ResultFor10188 struct {
  18642. Cainfo interface{} `json:"cainfo"`
  18643. ErrMsg string `json:"err_msg"`
  18644. InfRefmsgid string `json:"inf_refmsgid"`
  18645. Infcode string `json:"infcode"`
  18646. RefmsgTime string `json:"refmsg_time"`
  18647. RespondTime string `json:"respond_time"`
  18648. Signtype interface{} `json:"signtype"`
  18649. WarnMsg interface{} `json:"warn_msg"`
  18650. }
  18651. type Result2406 struct {
  18652. Cainfo interface{} `json:"cainfo"`
  18653. ErrMsg string `json:"err_msg"`
  18654. InfRefmsgid string `json:"inf_refmsgid"`
  18655. Infcode int64 `json:"infcode"`
  18656. Output struct {
  18657. Result struct {
  18658. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  18659. } `json:"result"`
  18660. } `json:"output"`
  18661. RefmsgTime string `json:"refmsg_time"`
  18662. RespondTime string `json:"respond_time"`
  18663. Signtype interface{} `json:"signtype"`
  18664. WarnMsg interface{} `json:"warn_msg"`
  18665. }
  18666. type GZResultSix struct {
  18667. Cainfo interface{} `json:"cainfo"`
  18668. ErrMsg string `json:"err_msg"`
  18669. InfRefmsgid string `json:"inf_refmsgid"`
  18670. Infcode int64 `json:"infcode"`
  18671. Output string `json:"output"`
  18672. RefmsgTime string `json:"refmsg_time"`
  18673. RespondTime string `json:"respond_time"`
  18674. Signtype interface{} `json:"signtype"`
  18675. WarnMsg interface{} `json:"warn_msg"`
  18676. }
  18677. type ResultSix10265 struct {
  18678. Cainfo interface{} `json:"cainfo"`
  18679. ErrMsg string `json:"err_msg"`
  18680. InfRefmsgid string `json:"inf_refmsgid"`
  18681. Infcode string `json:"infcode"`
  18682. Output struct {
  18683. } `json:"output"`
  18684. RefmsgTime string `json:"refmsg_time"`
  18685. RespondTime string `json:"respond_time"`
  18686. Signtype interface{} `json:"signtype"`
  18687. WarnMsg interface{} `json:"warn_msg"`
  18688. }
  18689. type ResultSeven struct {
  18690. Cainfo string `json:"cainfo"`
  18691. ErrMsg string `json:"err_msg"`
  18692. InfRefmsgid string `json:"inf_refmsgid"`
  18693. Infcode int64 `json:"infcode"`
  18694. Output struct {
  18695. Setlinfo struct {
  18696. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  18697. AcctPay float64 `json:"acct_pay"`
  18698. ActPayDedc float64 `json:"act_pay_dedc"`
  18699. Age float64 `json:"age"`
  18700. Balc float64 `json:"balc"`
  18701. Certno string `json:"certno"`
  18702. ClrOptins string `json:"clr_optins"`
  18703. ClrType string `json:"clr_type"`
  18704. ClrWay string `json:"clr_way"`
  18705. CvlservFlag string `json:"cvlserv_flag"`
  18706. CvlservPay float64 `json:"cvlserv_pay"`
  18707. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  18708. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  18709. Gend string `json:"gend"`
  18710. HifesPay float64 `json:"hifes_pay"`
  18711. HifmiPay float64 `json:"hifmi_pay"`
  18712. HifpPay float64 `json:"hifp_pay"`
  18713. HospPartAmt float64 `json:"hosp_part_amt"`
  18714. InscpScpAmt float64 `json:"inscp_scp_amt"`
  18715. Insutype string `json:"insutype"`
  18716. MafPay float64 `json:"maf_pay"`
  18717. MdtrtCertType string `json:"mdtrt_cert_type"`
  18718. HifobPay float64 `json:"hifob_pay"`
  18719. MdtrtID string `json:"mdtrt_id"`
  18720. MedType string `json:"med_type"`
  18721. MedfeeSumamt float64 `json:"medfee_sumamt"`
  18722. MedinsSetlID string `json:"medins_setl_id"`
  18723. Naty string `json:"naty"`
  18724. OthPay float64 `json:"oth_pay"`
  18725. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  18726. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  18727. PreselfpayAmt float64 `json:"preselfpay_amt"`
  18728. PsnCashPay float64 `json:"psn_cash_pay"`
  18729. PsnCertType string `json:"psn_cert_type"`
  18730. PsnName string `json:"psn_name"`
  18731. PsnNo string `json:"psn_no"`
  18732. PsnPartAmt float64 `json:"psn_part_amt"`
  18733. PsnType string `json:"psn_type"`
  18734. SetlID string `json:"setl_id"`
  18735. SetlTime string `json:"setl_time"`
  18736. } `json:"setlinfo"`
  18737. Setldetail interface{} `json:"setldetail"`
  18738. } `json:"output"`
  18739. RefmsgTime string `json:"refmsg_time"`
  18740. RespondTime string `json:"respond_time"`
  18741. Signtype interface{} `json:"signtype"`
  18742. WarnMsg interface{} `json:"warn_msg"`
  18743. }
  18744. type ResultSevenAH struct {
  18745. Cainfo string `json:"cainfo"`
  18746. ErrMsg string `json:"err_msg"`
  18747. InfRefmsgid string `json:"inf_refmsgid"`
  18748. Infcode int64 `json:"infcode"`
  18749. Output struct {
  18750. Setlinfo struct {
  18751. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  18752. AcctPay float64 `json:"acct_pay"`
  18753. ActPayDedc float64 `json:"act_pay_dedc"`
  18754. Age float64 `json:"age"`
  18755. Balc float64 `json:"balc"`
  18756. Certno string `json:"certno"`
  18757. ClrOptins string `json:"clr_optins"`
  18758. ClrType string `json:"clr_type"`
  18759. ClrWay string `json:"clr_way"`
  18760. CvlservFlag string `json:"cvlserv_flag"`
  18761. CvlservPay float64 `json:"cvlserv_pay"`
  18762. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  18763. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  18764. Gend string `json:"gend"`
  18765. HifesPay float64 `json:"hifes_pay"`
  18766. HifmiPay float64 `json:"hifmi_pay"`
  18767. HifpPay float64 `json:"hifp_pay"`
  18768. HospPartAmt float64 `json:"hosp_part_amt"`
  18769. InscpScpAmt float64 `json:"inscp_scp_amt"`
  18770. Insutype string `json:"insutype"`
  18771. MafPay float64 `json:"maf_pay"`
  18772. MdtrtCertType string `json:"mdtrt_cert_type"`
  18773. HifobPay float64 `json:"hifob_pay"`
  18774. MdtrtID string `json:"mdtrt_id"`
  18775. MedType string `json:"med_type"`
  18776. MedfeeSumamt float64 `json:"medfee_sumamt"`
  18777. MedinsSetlID string `json:"medins_setl_id"`
  18778. Naty string `json:"naty"`
  18779. OthPay float64 `json:"oth_pay"`
  18780. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  18781. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  18782. PreselfpayAmt float64 `json:"preselfpay_amt"`
  18783. PsnCashPay float64 `json:"psn_cash_pay"`
  18784. PsnCertType string `json:"psn_cert_type"`
  18785. PsnName string `json:"psn_name"`
  18786. PsnNo string `json:"psn_no"`
  18787. PsnPartAmt float64 `json:"psn_part_amt"`
  18788. PsnType string `json:"psn_type"`
  18789. SetlID string `json:"setl_id"`
  18790. SetlTime int64 `json:"setl_time"`
  18791. } `json:"setlinfo"`
  18792. Setldetail interface{} `json:"setldetail"`
  18793. } `json:"output"`
  18794. RefmsgTime string `json:"refmsg_time"`
  18795. RespondTime string `json:"respond_time"`
  18796. Signtype interface{} `json:"signtype"`
  18797. WarnMsg interface{} `json:"warn_msg"`
  18798. }
  18799. type ResultSeven10265 struct {
  18800. Cainfo string `json:"cainfo"`
  18801. ErrMsg string `json:"err_msg"`
  18802. InfRefmsgid string `json:"inf_refmsgid"`
  18803. Infcode string `json:"infcode"`
  18804. Output struct {
  18805. Setlinfo struct {
  18806. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  18807. AcctPay float64 `json:"acct_pay"`
  18808. ActPayDedc float64 `json:"act_pay_dedc"`
  18809. Age float64 `json:"age"`
  18810. Balc float64 `json:"balc"`
  18811. Certno string `json:"certno"`
  18812. ClrOptins string `json:"clr_optins"`
  18813. ClrType string `json:"clr_type"`
  18814. ClrWay string `json:"clr_way"`
  18815. CvlservFlag string `json:"cvlserv_flag"`
  18816. CvlservPay float64 `json:"cvlserv_pay"`
  18817. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  18818. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  18819. Gend string `json:"gend"`
  18820. HifesPay float64 `json:"hifes_pay"`
  18821. HifmiPay float64 `json:"hifmi_pay"`
  18822. HifpPay float64 `json:"hifp_pay"`
  18823. HospPartAmt float64 `json:"hosp_part_amt"`
  18824. InscpScpAmt float64 `json:"inscp_scp_amt"`
  18825. Insutype string `json:"insutype"`
  18826. MafPay float64 `json:"maf_pay"`
  18827. MdtrtCertType string `json:"mdtrt_cert_type"`
  18828. HifobPay float64 `json:"hifob_pay"`
  18829. MdtrtID string `json:"mdtrt_id"`
  18830. MedType string `json:"med_type"`
  18831. MedfeeSumamt float64 `json:"medfee_sumamt"`
  18832. MedinsSetlID string `json:"medins_setl_id"`
  18833. Naty string `json:"naty"`
  18834. OthPay float64 `json:"oth_pay"`
  18835. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  18836. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  18837. PreselfpayAmt float64 `json:"preselfpay_amt"`
  18838. PsnCashPay float64 `json:"psn_cash_pay"`
  18839. PsnCertType string `json:"psn_cert_type"`
  18840. PsnName string `json:"psn_name"`
  18841. PsnNo string `json:"psn_no"`
  18842. PsnPartAmt float64 `json:"psn_part_amt"`
  18843. PsnType string `json:"psn_type"`
  18844. SetlID string `json:"setl_id"`
  18845. SetlTime string `json:"setl_time"`
  18846. } `json:"setlinfo"`
  18847. Setldetail interface{} `json:"setldetail"`
  18848. } `json:"output"`
  18849. RefmsgTime string `json:"refmsg_time"`
  18850. RespondTime string `json:"respond_time"`
  18851. Signtype interface{} `json:"signtype"`
  18852. WarnMsg interface{} `json:"warn_msg"`
  18853. }
  18854. type ResultSeven10265Two struct {
  18855. Cainfo string `json:"cainfo"`
  18856. ErrMsg string `json:"err_msg"`
  18857. InfRefmsgid string `json:"inf_refmsgid"`
  18858. Infcode string `json:"infcode"`
  18859. Output struct {
  18860. Setlinfo struct {
  18861. AcctMulaidPay string `json:"acct_mulaid_pay"`
  18862. AcctPay float64 `json:"acct_pay"`
  18863. ActPayDedc float64 `json:"act_pay_dedc"`
  18864. Age float64 `json:"age"`
  18865. Balc float64 `json:"balc"`
  18866. Certno string `json:"certno"`
  18867. ClrOptins string `json:"clr_optins"`
  18868. ClrType string `json:"clr_type"`
  18869. ClrWay string `json:"clr_way"`
  18870. CvlservFlag string `json:"cvlserv_flag"`
  18871. CvlservPay float64 `json:"cvlserv_pay"`
  18872. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  18873. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  18874. Gend string `json:"gend"`
  18875. HifesPay float64 `json:"hifes_pay"`
  18876. HifmiPay float64 `json:"hifmi_pay"`
  18877. HifpPay float64 `json:"hifp_pay"`
  18878. HospPartAmt string `json:"hosp_part_amt"`
  18879. InscpScpAmt float64 `json:"inscp_scp_amt"`
  18880. Insutype string `json:"insutype"`
  18881. MafPay float64 `json:"maf_pay"`
  18882. MdtrtCertType string `json:"mdtrt_cert_type"`
  18883. HifobPay float64 `json:"hifob_pay"`
  18884. MdtrtID string `json:"mdtrt_id"`
  18885. MedType string `json:"med_type"`
  18886. MedfeeSumamt float64 `json:"medfee_sumamt"`
  18887. MedinsSetlID string `json:"medins_setl_id"`
  18888. Naty string `json:"naty"`
  18889. OthPay float64 `json:"oth_pay"`
  18890. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  18891. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  18892. PreselfpayAmt float64 `json:"preselfpay_amt"`
  18893. PsnCashPay float64 `json:"psn_cash_pay"`
  18894. PsnCertType string `json:"psn_cert_type"`
  18895. PsnName string `json:"psn_name"`
  18896. PsnNo string `json:"psn_no"`
  18897. PsnPartAmt float64 `json:"psn_part_amt"`
  18898. PsnType string `json:"psn_type"`
  18899. SetlID string `json:"setl_id"`
  18900. SetlTime string `json:"setl_time"`
  18901. } `json:"setlinfo"`
  18902. Setldetail interface{} `json:"setldetail"`
  18903. } `json:"output"`
  18904. RefmsgTime string `json:"refmsg_time"`
  18905. RespondTime string `json:"respond_time"`
  18906. Signtype interface{} `json:"signtype"`
  18907. WarnMsg interface{} `json:"warn_msg"`
  18908. }
  18909. type GZResultSeven10265Two struct {
  18910. Cainfo string `json:"cainfo"`
  18911. ErrMsg string `json:"err_msg"`
  18912. InfRefmsgid string `json:"inf_refmsgid"`
  18913. Infcode int64 `json:"infcode"`
  18914. Output struct {
  18915. Setlinfo struct {
  18916. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  18917. AcctPay float64 `json:"acct_pay"`
  18918. ActPayDedc float64 `json:"act_pay_dedc"`
  18919. Age float64 `json:"age"`
  18920. Balc float64 `json:"balc"`
  18921. Certno string `json:"certno"`
  18922. ClrOptins string `json:"clr_optins"`
  18923. ClrType string `json:"clr_type"`
  18924. ClrWay string `json:"clr_way"`
  18925. CvlservFlag string `json:"cvlserv_flag"`
  18926. CvlservPay float64 `json:"cvlserv_pay"`
  18927. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  18928. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  18929. Gend string `json:"gend"`
  18930. HifesPay float64 `json:"hifes_pay"`
  18931. HifmiPay float64 `json:"hifmi_pay"`
  18932. HifpPay float64 `json:"hifp_pay"`
  18933. HospPartAmt float64 `json:"hosp_part_amt"`
  18934. InscpScpAmt float64 `json:"inscp_scp_amt"`
  18935. Insutype string `json:"insutype"`
  18936. MafPay float64 `json:"maf_pay"`
  18937. MdtrtCertType string `json:"mdtrt_cert_type"`
  18938. HifobPay float64 `json:"hifob_pay"`
  18939. MdtrtID string `json:"mdtrt_id"`
  18940. MedType string `json:"med_type"`
  18941. MedfeeSumamt float64 `json:"medfee_sumamt"`
  18942. MedinsSetlID string `json:"medins_setl_id"`
  18943. Naty string `json:"naty"`
  18944. OthPay float64 `json:"oth_pay"`
  18945. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  18946. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  18947. PreselfpayAmt float64 `json:"preselfpay_amt"`
  18948. PsnCashPay float64 `json:"psn_cash_pay"`
  18949. PsnCertType string `json:"psn_cert_type"`
  18950. PsnName string `json:"psn_name"`
  18951. PsnNo string `json:"psn_no"`
  18952. PsnPartAmt float64 `json:"psn_part_amt"`
  18953. PsnType string `json:"psn_type"`
  18954. SetlID string `json:"setl_id"`
  18955. SetlTime string `json:"setl_time"`
  18956. } `json:"setlinfo"`
  18957. Setldetail interface{} `json:"setldetail"`
  18958. } `json:"output"`
  18959. RefmsgTime string `json:"refmsg_time"`
  18960. RespondTime string `json:"respond_time"`
  18961. Signtype interface{} `json:"signtype"`
  18962. WarnMsg interface{} `json:"warn_msg"`
  18963. }
  18964. type ResultEight struct {
  18965. Cainfo string `json:"cainfo"`
  18966. ErrMsg string `json:"err_msg"`
  18967. InfRefmsgid string `json:"inf_refmsgid"`
  18968. Infcode int64 `json:"infcode"`
  18969. Output struct {
  18970. Stmtinfo struct {
  18971. SetlOptins string `json:"setl_optins"`
  18972. StmtRslt string `json:"stmt_rslt"`
  18973. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  18974. } `json:"stmtinfo"`
  18975. } `json:"output"`
  18976. RefmsgTime string `json:"refmsg_time"`
  18977. RespondTime string `json:"respond_time"`
  18978. Signtype interface{} `json:"signtype"`
  18979. WarnMsg interface{} `json:"warn_msg"`
  18980. }
  18981. type ResultEightFor10188 struct {
  18982. Cainfo string `json:"cainfo"`
  18983. ErrMsg string `json:"err_msg"`
  18984. InfRefmsgid string `json:"inf_refmsgid"`
  18985. Infcode string `json:"infcode"`
  18986. Output struct {
  18987. Stmtinfo struct {
  18988. SetlOptins string `json:"setl_optins"`
  18989. StmtRslt string `json:"stmt_rslt"`
  18990. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  18991. } `json:"stmtinfo"`
  18992. } `json:"output"`
  18993. RefmsgTime string `json:"refmsg_time"`
  18994. RespondTime string `json:"respond_time"`
  18995. Signtype interface{} `json:"signtype"`
  18996. WarnMsg interface{} `json:"warn_msg"`
  18997. }
  18998. type ResultNine struct {
  18999. Cainfo string `json:"cainfo"`
  19000. ErrMsg string `json:"err_msg"`
  19001. InfRefmsgid string `json:"inf_refmsgid"`
  19002. Infcode int64 `json:"infcode"`
  19003. Output struct {
  19004. FileQuryNo string `json:"file_qury_no"`
  19005. } `json:"output"`
  19006. RefmsgTime string `json:"refmsg_time"`
  19007. RespondTime string `json:"respond_time"`
  19008. Signtype interface{} `json:"signtype"`
  19009. WarnMsg interface{} `json:"warn_msg"`
  19010. }
  19011. type ResultTen struct {
  19012. Cainfo string `json:"cainfo"`
  19013. ErrMsg string `json:"err_msg"`
  19014. InfRefmsgid string `json:"inf_refmsgid"`
  19015. Infcode int64 `json:"infcode"`
  19016. Output struct {
  19017. Fileinfo struct {
  19018. DldEndtime string `json:"dld_endtime"`
  19019. FileQuryNo string `json:"file_qury_no"`
  19020. Filename string `json:"filename"`
  19021. } `json:"fileinfo"`
  19022. } `json:"output"`
  19023. RefmsgTime string `json:"refmsg_time"`
  19024. RespondTime string `json:"respond_time"`
  19025. Signtype interface{} `json:"signtype"`
  19026. WarnMsg interface{} `json:"warn_msg"`
  19027. }
  19028. type Result5262 struct {
  19029. ErrMsg string `json:"err_msg"`
  19030. InfRefmsgid string `json:"inf_refmsgid"`
  19031. Infcode int64 `json:"infcode"`
  19032. Output struct {
  19033. PageInfo struct {
  19034. Size int `json:"size"`
  19035. RecordCounts int `json:"record_counts"`
  19036. } `json:"page_info"`
  19037. Idetinfo []interface{} `json:"idetinfo"`
  19038. Result []struct {
  19039. SetlID string `json:"setl_id"`
  19040. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  19041. MdtrtID string `json:"mdtrt_id"`
  19042. InitSetlID string `json:"init_setl_id,omitempty"`
  19043. PsnNo string `json:"psn_no"`
  19044. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  19045. PsnName string `json:"psn_name"`
  19046. PsnCertType string `json:"psn_cert_type"`
  19047. Certno string `json:"certno"`
  19048. Gend string `json:"gend,omitempty"`
  19049. Naty string `json:"naty,omitempty"`
  19050. Brdy string `json:"brdy,omitempty"`
  19051. Age float64 `json:"age,omitempty"`
  19052. Insutype string `json:"insutype,omitempty"`
  19053. PsnType string `json:"psn_type"`
  19054. CvlservFlag string `json:"cvlserv_flag"`
  19055. CvlservLv string `json:"cvlserv_lv,omitempty"`
  19056. SpPsnType string `json:"sp_psn_type,omitempty"`
  19057. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  19058. ClctGrde string `json:"clct_grde,omitempty"`
  19059. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  19060. NwbFlag string `json:"nwb_flag,omitempty"`
  19061. InsuAdmdvs string `json:"insu_admdvs"`
  19062. EmpNo string `json:"emp_no,omitempty"`
  19063. EmpName string `json:"emp_name,omitempty"`
  19064. EmpType string `json:"emp_type,omitempty"`
  19065. EconType string `json:"econ_type,omitempty"`
  19066. AfilIndu string `json:"afil_indu,omitempty"`
  19067. AfilRlts string `json:"afil_rlts,omitempty"`
  19068. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  19069. PayLoc string `json:"pay_loc,omitempty"`
  19070. FixmedinsCode string `json:"fixmedins_code"`
  19071. FixmedinsName string `json:"fixmedins_name"`
  19072. HospLv string `json:"hosp_lv,omitempty"`
  19073. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  19074. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  19075. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  19076. Begndate string `json:"begndate"`
  19077. Enddate string `json:"enddate"`
  19078. SetlTime string `json:"setl_time"`
  19079. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  19080. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  19081. MedType string `json:"med_type"`
  19082. SetlType string `json:"setl_type,omitempty"`
  19083. ClrType string `json:"clr_type,omitempty"`
  19084. ClrWay string `json:"clr_way,omitempty"`
  19085. PsnSetlway string `json:"psn_setlway,omitempty"`
  19086. ClrOptins string `json:"clr_optins,omitempty"`
  19087. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  19088. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  19089. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  19090. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  19091. InscpAmt float64 `json:"inscp_amt,omitempty"`
  19092. DedcStd float64 `json:"dedc_std,omitempty"`
  19093. CrtDedc float64 `json:"crt_dedc,omitempty"`
  19094. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  19095. HifpPay float64 `json:"hifp_pay,omitempty"`
  19096. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  19097. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  19098. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  19099. HifesPay float64 `json:"hifes_pay,omitempty"`
  19100. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  19101. HifobPay float64 `json:"hifob_pay,omitempty"`
  19102. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  19103. MafPay float64 `json:"maf_pay,omitempty"`
  19104. OthfundPay float64 `json:"othfund_pay,omitempty"`
  19105. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  19106. PsnPay float64 `json:"psn_pay,omitempty"`
  19107. AcctPay float64 `json:"acct_pay,omitempty"`
  19108. CashPayamt float64 `json:"cash_payamt,omitempty"`
  19109. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  19110. Balc float64 `json:"balc,omitempty"`
  19111. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  19112. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  19113. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  19114. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  19115. Year string `json:"year,omitempty"`
  19116. DiseNo string `json:"dise_no,omitempty"`
  19117. DiseName string `json:"dise_name,omitempty"`
  19118. Invono string `json:"invono,omitempty"`
  19119. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  19120. ValiFlag string `json:"vali_flag,omitempty"`
  19121. Memo string `json:"memo,omitempty"`
  19122. Rid string `json:"rid"`
  19123. UpdtTime string `json:"updt_time,omitempty"`
  19124. CrterID string `json:"crter_id,omitempty"`
  19125. CrterName string `json:"crter_name,omitempty"`
  19126. CrteTime string `json:"crte_time,omitempty"`
  19127. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  19128. OpterID string `json:"opter_id,omitempty"`
  19129. OpterName string `json:"opter_name,omitempty"`
  19130. OptTime string `json:"opt_time,omitempty"`
  19131. OptinsNo string `json:"optins_no,omitempty"`
  19132. PoolareaNo string `json:"poolarea_no,omitempty"`
  19133. } `json:"result"`
  19134. } `json:"output"`
  19135. RefmsgTime string `json:"refmsg_time"`
  19136. RespondTime string `json:"respond_time"`
  19137. Signtype interface{} `json:"signtype"`
  19138. WarnInfo interface{} `json:"warn_info"`
  19139. }
  19140. type Result5267 struct {
  19141. ErrMsg string `json:"err_msg"`
  19142. InfRefmsgid string `json:"inf_refmsgid"`
  19143. Infcode int64 `json:"infcode"`
  19144. Output struct {
  19145. PageInfo struct {
  19146. Size int `json:"size"`
  19147. RecordCounts int `json:"record_counts"`
  19148. } `json:"pageinfo"`
  19149. Result []struct {
  19150. SetlID string `json:"setl_id"`
  19151. ClrOptins string `json:"clr_optins"`
  19152. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  19153. MdtrtID string `json:"mdtrt_id"`
  19154. InitSetlID string `json:"init_setl_id,omitempty"`
  19155. PsnNo string `json:"psn_no"`
  19156. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  19157. PsnName string `json:"psn_name"`
  19158. PsnCertType string `json:"psn_cert_type"`
  19159. Certno string `json:"certno"`
  19160. Gend string `json:"gend,omitempty"`
  19161. Naty string `json:"naty,omitempty"`
  19162. Brdy string `json:"brdy,omitempty"`
  19163. Age float64 `json:"age,omitempty"`
  19164. Insutype string `json:"insutype,omitempty"`
  19165. PsnType string `json:"psn_type"`
  19166. CvlservFlag string `json:"cvlserv_flag"`
  19167. CvlservLv string `json:"cvlserv_lv,omitempty"`
  19168. SpPsnType string `json:"sp_psn_type,omitempty"`
  19169. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  19170. ClctGrde string `json:"clct_grde,omitempty"`
  19171. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  19172. NwbFlag string `json:"nwb_flag,omitempty"`
  19173. InsuAdmdvs string `json:"insu_admdvs"`
  19174. EmpNo string `json:"emp_no,omitempty"`
  19175. EmpName string `json:"emp_name,omitempty"`
  19176. EmpType string `json:"emp_type,omitempty"`
  19177. EconType string `json:"econ_type,omitempty"`
  19178. AfilIndu string `json:"afil_indu,omitempty"`
  19179. AfilRlts string `json:"afil_rlts,omitempty"`
  19180. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  19181. PayLoc string `json:"pay_loc,omitempty"`
  19182. FixmedinsCode string `json:"fixmedins_code"`
  19183. FixmedinsName string `json:"fixmedins_name"`
  19184. HospLv string `json:"hosp_lv,omitempty"`
  19185. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  19186. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  19187. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  19188. Begndate string `json:"begndate,omitempty"`
  19189. Enddate string `json:"enddate,omitempty"`
  19190. SetlTime string `json:"setl_time,omitempty"`
  19191. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  19192. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  19193. MedType string `json:"med_type"`
  19194. SetlType string `json:"setl_type,omitempty"`
  19195. ClrType string `json:"clr_type,omitempty"`
  19196. ClrWay string `json:"clr_way,omitempty"`
  19197. PsnSetlway string `json:"psn_setlway,omitempty"`
  19198. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  19199. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  19200. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  19201. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  19202. InscpAmt float64 `json:"inscp_amt,omitempty"`
  19203. DedcStd float64 `json:"dedc_std,omitempty"`
  19204. CrtDedc float64 `json:"crt_dedc,omitempty"`
  19205. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  19206. HifpPay float64 `json:"hifp_pay,omitempty"`
  19207. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  19208. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  19209. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  19210. HifesPay float64 `json:"hifes_pay,omitempty"`
  19211. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  19212. HifobPay float64 `json:"hifob_pay,omitempty"`
  19213. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  19214. MafPay float64 `json:"maf_pay,omitempty"`
  19215. OthfundPay float64 `json:"othfund_pay,omitempty"`
  19216. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  19217. PsnPay float64 `json:"psn_pay,omitempty"`
  19218. AcctPay float64 `json:"acct_pay,omitempty"`
  19219. CashPayamt float64 `json:"cash_payamt,omitempty"`
  19220. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  19221. Balc float64 `json:"balc,omitempty"`
  19222. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  19223. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  19224. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  19225. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  19226. Year string `json:"year,omitempty"`
  19227. DiseNo string `json:"dise_no,omitempty"`
  19228. DiseName string `json:"dise_name,omitempty"`
  19229. Invono string `json:"invono,omitempty"`
  19230. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  19231. Memo string `json:"memo,omitempty"`
  19232. UpdtTime string `json:"updt_time,omitempty"`
  19233. OpterID string `json:"opter_id,omitempty"`
  19234. OpterName string `json:"opter_name,omitempty"`
  19235. OptTime string `json:"opt_time,omitempty"`
  19236. OptinsNo string `json:"optins_no,omitempty"`
  19237. PoolareaNo string `json:"poolarea_no,omitempty"`
  19238. } `json:"result"`
  19239. } `json:"output"`
  19240. RefmsgTime string `json:"refmsg_time"`
  19241. RespondTime string `json:"respond_time"`
  19242. Signtype interface{} `json:"signtype"`
  19243. WarnInfo interface{} `json:"warn_info"`
  19244. }
  19245. // type Autogenerated struct {
  19246. // Output struct {
  19247. // Setlinfo struct {
  19248. // SetlTime string `json:"setl_time"`
  19249. // CvlservPay float64 `json:"cvlserv_pay"`
  19250. // Year string `json:"year"`
  19251. // MedType string `json:"med_type"`
  19252. // PsnPay float64 `json:"psn_pay"`
  19253. // OpterID string `json:"opter_id"`
  19254. // Begndate string `json:"begndate"`
  19255. // FlxempeFlag string `json:"flxempe_flag"`
  19256. // HifmiPay float64 `json:"hifmi_pay"`
  19257. // PsnNo string `json:"psn_no"`
  19258. // ActPayDedc float64 `json:"act_pay_dedc"`
  19259. // MedinsSetlID interface{} `json:"medins_setl_id"`
  19260. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  19261. // ClrWay string `json:"clr_way"`
  19262. // OthPay float64 `json:"oth_pay"`
  19263. // Gend string `json:"gend"`
  19264. // MdtrtID string `json:"mdtrt_id"`
  19265. // AcctPay float64 `json:"acct_pay"`
  19266. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  19267. // Insutype string `json:"insutype"`
  19268. // Invono interface{} `json:"invono"`
  19269. // Enddate string `json:"enddate"`
  19270. // CashPayamt float64 `json:"cash_payamt"`
  19271. // PsnType string `json:"psn_type"`
  19272. // FixmedinsName string `json:"fixmedins_name"`
  19273. // HifpPay float64 `json:"hifp_pay"`
  19274. // NewFlag interface{} `json:"new_flag"`
  19275. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  19276. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  19277. // PayLoc string `json:"pay_loc"`
  19278. // ClrType string `json:"clr_type"`
  19279. // RefdSetlFlag string `json:"refd_setl_flag"`
  19280. // CvlservFlag string `json:"cvlserv_flag"`
  19281. // EmpName string `json:"emp_name"`
  19282. // Brdy string `json:"brdy"`
  19283. // Naty string `json:"naty"`
  19284. // Certno string `json:"certno"`
  19285. // DiseCode string `json:"dise_code"`
  19286. // FixmedinsCode string `json:"fixmedins_code"`
  19287. // DedcHospLv string `json:"dedc_hosp_lv"`
  19288. // OpterName string `json:"opter_name"`
  19289. // Balc float64 `json:"balc"`
  19290. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  19291. // PsnCertType string `json:"psn_cert_type"`
  19292. // HifobPay float64 `json:"hifob_pay"`
  19293. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  19294. // HifesPay float64 `json:"hifes_pay"`
  19295. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  19296. // OptTime string `json:"opt_time"`
  19297. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  19298. // SetlID string `json:"setl_id"`
  19299. // MafPay float64 `json:"maf_pay"`
  19300. // PsnName string `json:"psn_name"`
  19301. // InsuOptins interface{} `json:"insu_optins"`
  19302. // PrefFundPay interface{} `json:"pref_fund_pay"`
  19303. // ClrOptins string `json:"clr_optins"`
  19304. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  19305. // DiseName string `json:"dise_name"`
  19306. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  19307. // Age float64 `json:"age"`
  19308. // DtrtCertType string `json:"dtrt_cert_type"`
  19309. // HospLv string `json:"hosp_lv"`
  19310. // } `json:"setlinfo"`
  19311. // Setldetail []struct {
  19312. // FundPayType string `json:"fund_pay_type"`
  19313. // FundPayamt float64 `json:"fund_payamt"`
  19314. // SetlProcInfo interface{} `json:"setl_proc_info"`
  19315. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  19316. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  19317. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  19318. // PrefFundPay interface{} `json:"pref_fund_pay"`
  19319. // } `json:"setldetail"`
  19320. // } `json:"output"`
  19321. // Infcode int `json:"infcode"`
  19322. // WarnMsg interface{} `json:"warn_msg"`
  19323. // Cainfo interface{} `json:"cainfo"`
  19324. // ErrMsg interface{} `json:"err_msg"`
  19325. // RefmsgTime string `json:"refmsg_time"`
  19326. // Signtype interface{} `json:"signtype"`
  19327. // RespondTime string `json:"respond_time"`
  19328. // InfRefmsgid string `json:"inf_refmsgid"`
  19329. // }
  19330. type Result002 struct {
  19331. Cainfo interface{} `json:"cainfo"`
  19332. ErrMsg string `json:"err_msg"`
  19333. InfRefmsgid string `json:"inf_refmsgid"`
  19334. Infcode int64 `json:"infcode"`
  19335. Output struct {
  19336. RxFile string `json:"rx_file"`
  19337. SignDigest string `json:"sign_digest"`
  19338. SignCertSn string `json:"sign_cert_sn"`
  19339. SignCertDn string `json:"sign_cert_dn"`
  19340. } `json:"output"`
  19341. RefmsgTime string `json:"refmsg_time"`
  19342. RespondTime string `json:"respond_time"`
  19343. Signtype interface{} `json:"signtype"`
  19344. WarnMsg interface{} `json:"warn_msg"`
  19345. }
  19346. type Result003 struct {
  19347. Cainfo interface{} `json:"cainfo"`
  19348. ErrMsg string `json:"err_msg"`
  19349. InfRefmsgid string `json:"inf_refmsgid"`
  19350. Infcode int64 `json:"infcode"`
  19351. Output struct {
  19352. HiRxno string `json:"hi_rxno"`
  19353. RxStasCodg string `json:"rx_stas_codg"`
  19354. RxStasName string `json:"rx_stas_name"`
  19355. } `json:"output"`
  19356. RefmsgTime string `json:"refmsg_time"`
  19357. RespondTime string `json:"respond_time"`
  19358. Signtype interface{} `json:"signtype"`
  19359. WarnMsg interface{} `json:"warn_msg"`
  19360. }
  19361. type ResultEleven struct {
  19362. Cainfo string `json:"cainfo"`
  19363. ErrMsg string `json:"err_msg"`
  19364. InfRefmsgid string `json:"inf_refmsgid"`
  19365. Infcode int64 `json:"infcode"`
  19366. Output struct {
  19367. Setlinfo struct {
  19368. SetlTime string `json:"setl_time"`
  19369. CvlservPay float64 `json:"cvlserv_pay"`
  19370. Year string `json:"year"`
  19371. MedType string `json:"med_type"`
  19372. PsnPay float64 `json:"psn_pay"`
  19373. OpterID string `json:"opter_id"`
  19374. Begndate string `json:"begndate"`
  19375. FlxempeFlag string `json:"flxempe_flag"`
  19376. HifmiPay float64 `json:"hifmi_pay"`
  19377. PsnNo string `json:"psn_no"`
  19378. ActPayDedc float64 `json:"act_pay_dedc"`
  19379. MedinsSetlID interface{} `json:"medins_setl_id"`
  19380. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  19381. ClrWay string `json:"clr_way"`
  19382. OthPay float64 `json:"oth_pay"`
  19383. Gend string `json:"gend"`
  19384. MdtrtID string `json:"mdtrt_id"`
  19385. AcctPay float64 `json:"acct_pay"`
  19386. InscpScpAmt float64 `json:"inscp_scp_amt"`
  19387. Insutype string `json:"insutype"`
  19388. Invono interface{} `json:"invono"`
  19389. Enddate string `json:"enddate"`
  19390. CashPayamt float64 `json:"cash_payamt"`
  19391. PsnType string `json:"psn_type"`
  19392. FixmedinsName string `json:"fixmedins_name"`
  19393. HifpPay float64 `json:"hifp_pay"`
  19394. NewFlag interface{} `json:"new_flag"`
  19395. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  19396. PreselfpayAmt float64 `json:"preselfpay_amt"`
  19397. PayLoc string `json:"pay_loc"`
  19398. ClrType string `json:"clr_type"`
  19399. RefdSetlFlag string `json:"refd_setl_flag"`
  19400. CvlservFlag string `json:"cvlserv_flag"`
  19401. EmpName string `json:"emp_name"`
  19402. Brdy string `json:"brdy"`
  19403. Naty string `json:"naty"`
  19404. Certno string `json:"certno"`
  19405. DiseCode string `json:"dise_code"`
  19406. FixmedinsCode string `json:"fixmedins_code"`
  19407. DedcHospLv string `json:"dedc_hosp_lv"`
  19408. OpterName string `json:"opter_name"`
  19409. Balc float64 `json:"balc"`
  19410. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  19411. PsnCertType string `json:"psn_cert_type"`
  19412. HifobPay float64 `json:"hifob_pay"`
  19413. MedfeeSumamt float64 `json:"medfee_sumamt"`
  19414. HifesPay float64 `json:"hifes_pay"`
  19415. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  19416. OptTime string `json:"opt_time"`
  19417. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  19418. SetlID string `json:"setl_id"`
  19419. MafPay float64 `json:"maf_pay"`
  19420. PsnName string `json:"psn_name"`
  19421. InsuOptins interface{} `json:"insu_optins"`
  19422. PrefFundPay interface{} `json:"pref_fund_pay"`
  19423. ClrOptins string `json:"clr_optins"`
  19424. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  19425. DiseName string `json:"dise_name"`
  19426. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  19427. Age float64 `json:"age"`
  19428. DtrtCertType string `json:"dtrt_cert_type"`
  19429. HospLv string `json:"hosp_lv"`
  19430. PsnCashPay float64 `json:"psn_cash_pay"`
  19431. } `json:"setlinfo"`
  19432. } `json:"output"`
  19433. RefmsgTime string `json:"refmsg_time"`
  19434. RespondTime string `json:"respond_time"`
  19435. Signtype interface{} `json:"signtype"`
  19436. WarnMsg interface{} `json:"warn_msg"`
  19437. }
  19438. type ResultElevenah struct {
  19439. Cainfo string `json:"cainfo"`
  19440. ErrMsg string `json:"err_msg"`
  19441. InfRefmsgid string `json:"inf_refmsgid"`
  19442. Infcode int64 `json:"infcode"`
  19443. Output struct {
  19444. Setlinfo struct {
  19445. SetlTime int64 `json:"setl_time"`
  19446. CvlservPay float64 `json:"cvlserv_pay"`
  19447. Year string `json:"year"`
  19448. MedType string `json:"med_type"`
  19449. PsnPay float64 `json:"psn_pay"`
  19450. OpterID string `json:"opter_id"`
  19451. Begndate int64 `json:"begndate"`
  19452. FlxempeFlag string `json:"flxempe_flag"`
  19453. HifmiPay float64 `json:"hifmi_pay"`
  19454. PsnNo string `json:"psn_no"`
  19455. ActPayDedc float64 `json:"act_pay_dedc"`
  19456. MedinsSetlID interface{} `json:"medins_setl_id"`
  19457. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  19458. ClrWay string `json:"clr_way"`
  19459. OthPay float64 `json:"oth_pay"`
  19460. Gend string `json:"gend"`
  19461. MdtrtID string `json:"mdtrt_id"`
  19462. AcctPay float64 `json:"acct_pay"`
  19463. InscpScpAmt float64 `json:"inscp_scp_amt"`
  19464. Insutype string `json:"insutype"`
  19465. Invono interface{} `json:"invono"`
  19466. Enddate int64 `json:"enddate"`
  19467. CashPayamt float64 `json:"cash_payamt"`
  19468. PsnType string `json:"psn_type"`
  19469. FixmedinsName string `json:"fixmedins_name"`
  19470. HifpPay float64 `json:"hifp_pay"`
  19471. NewFlag interface{} `json:"new_flag"`
  19472. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  19473. PreselfpayAmt float64 `json:"preselfpay_amt"`
  19474. PayLoc string `json:"pay_loc"`
  19475. ClrType string `json:"clr_type"`
  19476. RefdSetlFlag string `json:"refd_setl_flag"`
  19477. CvlservFlag string `json:"cvlserv_flag"`
  19478. EmpName string `json:"emp_name"`
  19479. Brdy int64 `json:"brdy"`
  19480. Naty string `json:"naty"`
  19481. Certno string `json:"certno"`
  19482. DiseCode string `json:"dise_code"`
  19483. FixmedinsCode string `json:"fixmedins_code"`
  19484. DedcHospLv string `json:"dedc_hosp_lv"`
  19485. OpterName string `json:"opter_name"`
  19486. Balc float64 `json:"balc"`
  19487. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  19488. PsnCertType string `json:"psn_cert_type"`
  19489. HifobPay float64 `json:"hifob_pay"`
  19490. MedfeeSumamt float64 `json:"medfee_sumamt"`
  19491. HifesPay float64 `json:"hifes_pay"`
  19492. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  19493. OptTime int64 `json:"opt_time"`
  19494. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  19495. SetlID string `json:"setl_id"`
  19496. MafPay float64 `json:"maf_pay"`
  19497. PsnName string `json:"psn_name"`
  19498. InsuOptins interface{} `json:"insu_optins"`
  19499. PrefFundPay interface{} `json:"pref_fund_pay"`
  19500. ClrOptins string `json:"clr_optins"`
  19501. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  19502. DiseName string `json:"dise_name"`
  19503. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  19504. Age float64 `json:"age"`
  19505. DtrtCertType string `json:"dtrt_cert_type"`
  19506. HospLv string `json:"hosp_lv"`
  19507. PsnCashPay float64 `json:"psn_cash_pay"`
  19508. } `json:"setlinfo"`
  19509. } `json:"output"`
  19510. RefmsgTime string `json:"refmsg_time"`
  19511. RespondTime string `json:"respond_time"`
  19512. Signtype interface{} `json:"signtype"`
  19513. WarnMsg interface{} `json:"warn_msg"`
  19514. }
  19515. type ResultEleven10265 struct {
  19516. Cainfo string `json:"cainfo"`
  19517. ErrMsg string `json:"err_msg"`
  19518. InfRefmsgid string `json:"inf_refmsgid"`
  19519. Infcode string `json:"infcode"`
  19520. Output struct {
  19521. Setlinfo struct {
  19522. SetlTime string `json:"setl_time"`
  19523. CvlservPay float64 `json:"cvlserv_pay"`
  19524. Year string `json:"year"`
  19525. MedType string `json:"med_type"`
  19526. PsnPay float64 `json:"psn_pay"`
  19527. OpterID string `json:"opter_id"`
  19528. Begndate string `json:"begndate"`
  19529. FlxempeFlag string `json:"flxempe_flag"`
  19530. HifmiPay float64 `json:"hifmi_pay"`
  19531. PsnNo string `json:"psn_no"`
  19532. ActPayDedc float64 `json:"act_pay_dedc"`
  19533. MedinsSetlID interface{} `json:"medins_setl_id"`
  19534. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  19535. ClrWay string `json:"clr_way"`
  19536. OthPay float64 `json:"oth_pay"`
  19537. Gend string `json:"gend"`
  19538. MdtrtID string `json:"mdtrt_id"`
  19539. AcctPay float64 `json:"acct_pay"`
  19540. InscpScpAmt float64 `json:"inscp_scp_amt"`
  19541. Insutype string `json:"insutype"`
  19542. Invono interface{} `json:"invono"`
  19543. Enddate string `json:"enddate"`
  19544. CashPayamt float64 `json:"cash_payamt"`
  19545. PsnType string `json:"psn_type"`
  19546. FixmedinsName string `json:"fixmedins_name"`
  19547. HifpPay float64 `json:"hifp_pay"`
  19548. NewFlag interface{} `json:"new_flag"`
  19549. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  19550. PreselfpayAmt float64 `json:"preselfpay_amt"`
  19551. PayLoc string `json:"pay_loc"`
  19552. ClrType string `json:"clr_type"`
  19553. RefdSetlFlag string `json:"refd_setl_flag"`
  19554. CvlservFlag string `json:"cvlserv_flag"`
  19555. EmpName string `json:"emp_name"`
  19556. Brdy string `json:"brdy"`
  19557. Naty string `json:"naty"`
  19558. Certno string `json:"certno"`
  19559. DiseCode string `json:"dise_code"`
  19560. FixmedinsCode string `json:"fixmedins_code"`
  19561. DedcHospLv string `json:"dedc_hosp_lv"`
  19562. OpterName string `json:"opter_name"`
  19563. Balc float64 `json:"balc"`
  19564. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  19565. PsnCertType string `json:"psn_cert_type"`
  19566. HifobPay float64 `json:"hifob_pay"`
  19567. MedfeeSumamt float64 `json:"medfee_sumamt"`
  19568. HifesPay float64 `json:"hifes_pay"`
  19569. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  19570. OptTime string `json:"opt_time"`
  19571. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  19572. SetlID string `json:"setl_id"`
  19573. MafPay float64 `json:"maf_pay"`
  19574. PsnName string `json:"psn_name"`
  19575. InsuOptins interface{} `json:"insu_optins"`
  19576. PrefFundPay interface{} `json:"pref_fund_pay"`
  19577. ClrOptins string `json:"clr_optins"`
  19578. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  19579. DiseName string `json:"dise_name"`
  19580. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  19581. Age float64 `json:"age"`
  19582. DtrtCertType string `json:"dtrt_cert_type"`
  19583. HospLv string `json:"hosp_lv"`
  19584. PsnCashPay float64 `json:"psn_cash_pay"`
  19585. } `json:"setlinfo"`
  19586. } `json:"output"`
  19587. RefmsgTime string `json:"refmsg_time"`
  19588. RespondTime string `json:"respond_time"`
  19589. Signtype interface{} `json:"signtype"`
  19590. WarnMsg interface{} `json:"warn_msg"`
  19591. }
  19592. type ResultTwelve struct {
  19593. Cainfo string `json:"cainfo"`
  19594. ErrMsg string `json:"err_msg"`
  19595. InfRefmsgid string `json:"inf_refmsgid"`
  19596. Infcode int64 `json:"infcode"`
  19597. Output struct {
  19598. MdtrtId string `json:"mdtrt_id"`
  19599. ChrgBchno string `json:"chrg_bchno"`
  19600. PsnNo string `json:"psn_no"`
  19601. } `json:"output"`
  19602. RefmsgTime string `json:"refmsg_time"`
  19603. RespondTime string `json:"respond_time"`
  19604. Signtype interface{} `json:"signtype"`
  19605. WarnMsg interface{} `json:"warn_msg"`
  19606. }
  19607. type ResultThirteen struct {
  19608. ErrMsg string `json:"err_msg"`
  19609. InfRefmsgid string `json:"inf_refmsgid"`
  19610. Infcode int64 `json:"infcode"`
  19611. Output struct {
  19612. Result struct {
  19613. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  19614. } `json:"result"`
  19615. } `json:"output"`
  19616. RefmsgTime string `json:"refmsg_time"`
  19617. RespondTime string `json:"respond_time"`
  19618. Signtype interface{} `json:"signtype"`
  19619. WarnInfo interface{} `json:"warn_info"`
  19620. }
  19621. type ResultThirteen10265 struct {
  19622. ErrMsg string `json:"err_msg"`
  19623. InfRefmsgid string `json:"inf_refmsgid"`
  19624. Infcode string `json:"infcode"`
  19625. Output struct {
  19626. Result struct {
  19627. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  19628. } `json:"result"`
  19629. } `json:"output"`
  19630. RefmsgTime string `json:"refmsg_time"`
  19631. RespondTime string `json:"respond_time"`
  19632. Signtype interface{} `json:"signtype"`
  19633. WarnInfo interface{} `json:"warn_info"`
  19634. }
  19635. type ResultFourteen struct {
  19636. ErrMsg string `json:"err_msg"`
  19637. InfRefmsgid string `json:"inf_refmsgid"`
  19638. Infcode int64 `json:"infcode"`
  19639. Output struct {
  19640. } `json:"output"`
  19641. RefmsgTime string `json:"refmsg_time"`
  19642. RespondTime string `json:"respond_time"`
  19643. Signtype interface{} `json:"signtype"`
  19644. WarnInfo interface{} `json:"warn_info"`
  19645. }
  19646. type ResultCFYLJG001 struct {
  19647. ErrMsg string `json:"err_msg"`
  19648. InfRefmsgid string `json:"inf_refmsgid"`
  19649. Infcode int64 `json:"infcode"`
  19650. Output struct {
  19651. RxTraceCode string `json:"rx_trace_code"`
  19652. HiRxno string `json:"hi_rxno"`
  19653. } `json:"output"`
  19654. RefmsgTime string `json:"refmsg_time"`
  19655. RespondTime string `json:"respond_time"`
  19656. Signtype interface{} `json:"signtype"`
  19657. WarnInfo interface{} `json:"warn_info"`
  19658. }
  19659. type ResultCFYLJG007 struct {
  19660. ErrMsg string `json:"err_msg"`
  19661. InfRefmsgid string `json:"inf_refmsgid"`
  19662. Infcode int64 `json:"infcode"`
  19663. Output struct {
  19664. HiRxno string `json:"hi_rxno"`
  19665. RxStasName string `json:"rx_stas_name"`
  19666. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  19667. Seltdelts []interface{} `json:"seltdelts"`
  19668. RxUsedStasName string `json:"rx_used_stas_name"`
  19669. RxStasCodg string `json:"rx_stas_codg"`
  19670. } `json:"output"`
  19671. RefmsgTime string `json:"refmsg_time"`
  19672. RespondTime string `json:"respond_time"`
  19673. Signtype interface{} `json:"signtype"`
  19674. WarnInfo interface{} `json:"warn_info"`
  19675. }
  19676. type ResultCFYLJG002 struct {
  19677. ErrMsg string `json:"err_msg"`
  19678. InfRefmsgid string `json:"inf_refmsgid"`
  19679. Infcode int64 `json:"infcode"`
  19680. Output struct {
  19681. RxFile string `json:"rx_file"`
  19682. SignDigest string `json:"sign_digest"`
  19683. SignCertSn string `json:"sign_cert_sn"`
  19684. SignCertDn string `json:"sign_cert_dn"`
  19685. } `json:"output"`
  19686. RefmsgTime string `json:"refmsg_time"`
  19687. RespondTime string `json:"respond_time"`
  19688. Signtype interface{} `json:"signtype"`
  19689. WarnInfo interface{} `json:"warn_info"`
  19690. }
  19691. type ResultCFYLJG003 struct {
  19692. ErrMsg string `json:"err_msg"`
  19693. InfRefmsgid string `json:"inf_refmsgid"`
  19694. Infcode int64 `json:"infcode"`
  19695. Output struct {
  19696. HiRxno string `json:"hi_rxno"`
  19697. RxStasCodg string `json:"rx_stas_codg"`
  19698. RxStasName string `json:"rx_stas_name"`
  19699. } `json:"output"`
  19700. RefmsgTime string `json:"refmsg_time"`
  19701. RespondTime string `json:"respond_time"`
  19702. Signtype interface{} `json:"signtype"`
  19703. WarnInfo interface{} `json:"warn_info"`
  19704. }
  19705. type ResultCFYLJG004 struct {
  19706. ErrMsg string `json:"err_msg"`
  19707. InfRefmsgid string `json:"inf_refmsgid"`
  19708. Infcode int64 `json:"infcode"`
  19709. Output struct {
  19710. HiRxno string `json:"hi_rxno"`
  19711. RxStasCodg string `json:"rx_stas_codg"`
  19712. RxStasName string `json:"rx_stas_name"`
  19713. } `json:"output"`
  19714. RefmsgTime string `json:"refmsg_time"`
  19715. RespondTime string `json:"respond_time"`
  19716. Signtype interface{} `json:"signtype"`
  19717. WarnInfo interface{} `json:"warn_info"`
  19718. }
  19719. type ResultCFYLJG008 struct {
  19720. ErrMsg string `json:"err_msg"`
  19721. InfRefmsgid string `json:"inf_refmsgid"`
  19722. Infcode int64 `json:"infcode"`
  19723. Output struct {
  19724. PoolareaNo string `json:"poolareaNo"`
  19725. AdmdvsName string `json:"admdvsName"`
  19726. Count string `json:"count"`
  19727. } `json:"output"`
  19728. RefmsgTime string `json:"refmsg_time"`
  19729. RespondTime string `json:"respond_time"`
  19730. Signtype interface{} `json:"signtype"`
  19731. WarnInfo interface{} `json:"warn_info"`
  19732. }
  19733. type ResultCFYLJG005 struct {
  19734. ErrMsg string `json:"err_msg"`
  19735. InfRefmsgid string `json:"inf_refmsgid"`
  19736. Infcode int64 `json:"infcode"`
  19737. Output struct {
  19738. HiRxNo string `json:"hi_rxno"`
  19739. FixMedinsCode string `json:"fixmedins_code"`
  19740. FixMedinsName string `json:"fixmedins_name"`
  19741. RxStasCodg string `json:"rx_stas_codg"`
  19742. RxStasName string `json:"rx_stas_name"`
  19743. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  19744. RxUserdStasName string `json:"rx_userd_stas_name"`
  19745. PrscTime string `json:"prsc_time"`
  19746. RxDrugCnt float64 `json:"rx_drug_cnt"`
  19747. RxUsedWayCodg string `json:"rx_used_way_codg"`
  19748. RxUsedWayName string `json:"rx_used_way_name"`
  19749. RxFrquCodg string `json:"rx_frqu_codg"`
  19750. RxFrquName string `json:"rx_frqu_name"`
  19751. RxDosunt string `json:"rx_dosunt"`
  19752. RxDoscnt float64 `json:"rx_doscnt"`
  19753. RxDrordDscr string `json:"rx_drord_dscr"`
  19754. ValiDays int64 `json:"vali_days"`
  19755. ValiEndTime string `json:"vali_end_time"`
  19756. ReptFlag string `json:"rept_flag"`
  19757. MaxReptCnt int64 `json:"max_rept_cnt"`
  19758. ReptdCnt int64 `json:"reptd_cnt"`
  19759. MinInrvDays int64 `json:"min_inrv_days"`
  19760. RxTypeCode string `json:"rx_type_code"`
  19761. RxTypeName string `json:"rx_type_name"`
  19762. LongRxFlag string `json:"long_rx_flag"`
  19763. RxDetlList []struct {
  19764. MedListCodg string `json:"med_list_codg"`
  19765. MedinsListCodg string `json:"medins_list_codg"`
  19766. HospPrepFlag string `json:"hosp_prep_flag"`
  19767. RxItemTypeCode string `json:"rx_item_type_code"`
  19768. RxItemTypeName string `json:"rx_item_type_name"`
  19769. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  19770. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  19771. TcmHerbFoote string `json:"tcmherb_foote"`
  19772. MednTypeCode string `json:"medn_type_code"`
  19773. MednTypeName string `json:"medn_type_name"`
  19774. MainMedcFlag string `json:"main_medc_flag"`
  19775. UrgtFlag string `json:"urgt_flag"`
  19776. BasMednFlag string `json:"bas_medn_flag"`
  19777. ImpDrugFlag string `json:"imp_drug_flag"`
  19778. ProdBarc string `json:"prod_barc"`
  19779. DrugProdname string `json:"drug_prodname"`
  19780. GennameCodg string `json:"genname_codg"`
  19781. DrugGenname string `json:"drug_genname"`
  19782. DrugDosform string `json:"drug_dosform"`
  19783. DrugSpec string `json:"drug_spec"`
  19784. PrdrName string `json:"prdr_name"`
  19785. MedcWayCodg string `json:"medc_way_codg"`
  19786. MedcWayDscr string `json:"medc_way_dscr"`
  19787. MedcBegntime string `json:"medc_begntime"`
  19788. MedcEndtime string `json:"medc_endtime"`
  19789. MedcDays float64 `json:"medc_days"`
  19790. DrugPric float64 `json:"drug_pric"`
  19791. DrugSumamt float64 `json:"drug_sumamt"`
  19792. DrugCnt float64 `json:"drug_cnt"`
  19793. DrugDosunt string `json:"drug_dosunt"`
  19794. SinDoscnt float64 `json:"sin_doscnt"`
  19795. SinDosunt string `json:"sin_dosunt"`
  19796. UsedFrquCodg string `json:"used_frqu_codg"`
  19797. UsedFrquName string `json:"used_frqu_name"`
  19798. DrugTotlcnt string `json:"drug_totlcnt"`
  19799. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  19800. DiseCodg string `json:"dise_codg"`
  19801. HospApprFlag string `json:"hosp_appr_flag"`
  19802. } `json:"rx_detl_list"`
  19803. RxOtpinfo struct {
  19804. MedType string `json:"med_type"`
  19805. IptOtpNo string `json:"ipt_otp_no"`
  19806. OtpIptFlag string `json:"otp_ipt_flag"`
  19807. PatnName string `json:"patn_name"`
  19808. PatnAge float64 `json:"patn_age"`
  19809. PatnHgt float64 `json:"patn_hgt"`
  19810. PatnWt float64 `json:"patn_wt"`
  19811. Gend string `json:"gend"`
  19812. GesoVal float64 `json:"geso_val"`
  19813. NwbFlag string `json:"nwb_flag"`
  19814. NwbAge string `json:"nwb_age"`
  19815. SuckPrdFlag string `json:"suck_prd_flag"`
  19816. AlgsHis string `json:"algs_his"`
  19817. Insutype string `json:"insutype"`
  19818. PrscDeptName string `json:"prsc_dept_name"`
  19819. PrscDrName string `json:"prsc_dr_name"`
  19820. PharName string `json:"phar_name"`
  19821. PharChkTime string `json:"phar_chk_time"`
  19822. MdtrtTime string `json:"mdtrt_time"`
  19823. DiseCodg string `json:"dise_codg"`
  19824. DiseName string `json:"dise_name"`
  19825. SpDiseFlag string `json:"sp_dise_flag"`
  19826. MaindiagCode string `json:"maindiag_code"`
  19827. MaindiagName string `json:"maindiag_name"`
  19828. DiseCondDscr string `json:"dise_cond_dscr"`
  19829. FstdiagFlag string `json:"fstdiag_flag"`
  19830. } `json:"rx_otpinfo"`
  19831. RxDiseList []struct {
  19832. DiagType string `json:"diag_type"`
  19833. MaindiagFlag string `json:"maindiag_flag"`
  19834. DiagSrtNo string `json:"diag_srt_no"`
  19835. DiagCode string `json:"diag_code"`
  19836. DiagName string `json:"diag_name"`
  19837. DiagDept string `json:"diag_dept"`
  19838. DiagDrNo string `json:"diag_dr_no"`
  19839. DiagDrName string `json:"diag_dr_name"`
  19840. DiagTime string `json:"diag_time"`
  19841. TcmDiseCode string `json:"tcm_dise_code"`
  19842. TcmDiseName string `json:"tcm_dise_name"`
  19843. TcmSympCode string `json:"tcmsymp_code"`
  19844. TcmSymp string `json:"tcmsymp"`
  19845. } `json:"rx_dise_list"`
  19846. } `json:"output"`
  19847. RefmsgTime string `json:"refmsg_time"`
  19848. RespondTime string `json:"respond_time"`
  19849. Signtype interface{} `json:"signtype"`
  19850. WarnInfo interface{} `json:"warn_info"`
  19851. }
  19852. type ResultCFYLJG006 struct {
  19853. ErrMsg string `json:"err_msg"`
  19854. InfRefmsgid string `json:"inf_refmsgid"`
  19855. Infcode int64 `json:"infcode"`
  19856. Output struct {
  19857. HiRxNo string `json:"hi_rxno"`
  19858. PharCode string `json:"phar_code"`
  19859. PharName string `json:"phar_name"`
  19860. RxChkOpnn string `json:"rx_chk_opnn"`
  19861. RxChkTime string `json:"rx_chk_time"`
  19862. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  19863. RxChkStasName string `json:"rx_chk_stas_name"`
  19864. RxStasCodg string `json:"rx_stas_codg"`
  19865. RxStasName string `json:"rx_stas_name"`
  19866. } `json:"output"`
  19867. RefmsgTime string `json:"refmsg_time"`
  19868. RespondTime string `json:"respond_time"`
  19869. Signtype interface{} `json:"signtype"`
  19870. WarnInfo interface{} `json:"warn_info"`
  19871. }
  19872. type ResultFourteen10265 struct {
  19873. ErrMsg string `json:"err_msg"`
  19874. InfRefmsgid string `json:"inf_refmsgid"`
  19875. Infcode string `json:"infcode"`
  19876. Output struct {
  19877. } `json:"output"`
  19878. RefmsgTime string `json:"refmsg_time"`
  19879. RespondTime string `json:"respond_time"`
  19880. Signtype interface{} `json:"signtype"`
  19881. WarnInfo interface{} `json:"warn_info"`
  19882. }
  19883. type ResultSixteen struct {
  19884. Cainfo string `json:"cainfo"`
  19885. ErrMsg string `json:"err_msg"`
  19886. InfRefmsgid string `json:"inf_refmsgid"`
  19887. Infcode int64 `json:"infcode"`
  19888. Output struct {
  19889. Setlinfo struct {
  19890. MdtrtID string `json:"mdtrt_id"`
  19891. SetlID string `json:"setl_id"`
  19892. ClrOptins string `json:"clr_optins"`
  19893. SetlTime string `json:"setl_time"`
  19894. MedfeeSumamt float64 `json:"medfee_sumamt"`
  19895. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  19896. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  19897. PreselfpayAmt float64 `json:"preselfpay_amt"`
  19898. InscpScpAmt float64 `json:"inscp_scp_amt"`
  19899. ActPayDedc float64 `json:"act_pay_dedc"`
  19900. HifpPay float64 `json:"hifp_pay"`
  19901. PoolPropSe float64 `json:"pool_prop_selfpay"`
  19902. Lfpay float64 `json:"selfpay"`
  19903. CvlservPay float64 `json:"cvlserv_pay"`
  19904. HifesPay float64 `json:"hifes_pay"`
  19905. HifmiPay float64 `json:"hifmi_pay"`
  19906. HifobPay float64 `json:"hifob_pay"`
  19907. MafPay float64 `json:"maf_pay"`
  19908. OthPay float64 `json:"oth_pay"`
  19909. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  19910. PsnPartAmt float64 `json:"psn_part_amt"`
  19911. AcctPay float64 `json:"acct_pay"`
  19912. Balc float64 `json:"balc"`
  19913. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  19914. HospPartAmt float64 `json:"hosp_part_amt"`
  19915. MedinsSetlID string `json:"medins_setl_id"`
  19916. PdnCashPay string `json:"pdn_cash_pay"`
  19917. } `json:"setlinfo"`
  19918. } `json:"output"`
  19919. RefmsgTime string `json:"refmsg_time"`
  19920. RespondTime string `json:"respond_time"`
  19921. Signtype interface{} `json:"signtype"`
  19922. WarnMsg interface{} `json:"warn_msg"`
  19923. }
  19924. type ResultSixteen10265 struct {
  19925. Cainfo string `json:"cainfo"`
  19926. ErrMsg string `json:"err_msg"`
  19927. InfRefmsgid string `json:"inf_refmsgid"`
  19928. Infcode string `json:"infcode"`
  19929. Output struct {
  19930. Setlinfo struct {
  19931. MdtrtID string `json:"mdtrt_id"`
  19932. SetlID string `json:"setl_id"`
  19933. ClrOptins string `json:"clr_optins"`
  19934. SetlTime string `json:"setl_time"`
  19935. MedfeeSumamt float64 `json:"medfee_sumamt"`
  19936. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  19937. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  19938. PreselfpayAmt float64 `json:"preselfpay_amt"`
  19939. InscpScpAmt float64 `json:"inscp_scp_amt"`
  19940. ActPayDedc float64 `json:"act_pay_dedc"`
  19941. HifpPay float64 `json:"hifp_pay"`
  19942. PoolPropSe float64 `json:"pool_prop_selfpay"`
  19943. Lfpay float64 `json:"selfpay"`
  19944. CvlservPay float64 `json:"cvlserv_pay"`
  19945. HifesPay float64 `json:"hifes_pay"`
  19946. HifmiPay float64 `json:"hifmi_pay"`
  19947. HifobPay float64 `json:"hifob_pay"`
  19948. MafPay float64 `json:"maf_pay"`
  19949. OthPay float64 `json:"oth_pay"`
  19950. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  19951. PsnPartAmt float64 `json:"psn_part_amt"`
  19952. AcctPay float64 `json:"acct_pay"`
  19953. Balc float64 `json:"balc"`
  19954. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  19955. HospPartAmt float64 `json:"hosp_part_amt"`
  19956. MedinsSetlID string `json:"medins_setl_id"`
  19957. PdnCashPay string `json:"pdn_cash_pay"`
  19958. } `json:"setlinfo"`
  19959. } `json:"output"`
  19960. RefmsgTime string `json:"refmsg_time"`
  19961. RespondTime string `json:"respond_time"`
  19962. Signtype interface{} `json:"signtype"`
  19963. WarnMsg interface{} `json:"warn_msg"`
  19964. }
  19965. type ResultSixteen10265Two struct {
  19966. Cainfo string `json:"cainfo"`
  19967. ErrMsg string `json:"err_msg"`
  19968. InfRefmsgid string `json:"inf_refmsgid"`
  19969. Infcode string `json:"infcode"`
  19970. Output struct {
  19971. Setlinfo interface{} `json:"setlinfo"`
  19972. } `json:"output"`
  19973. RefmsgTime string `json:"refmsg_time"`
  19974. RespondTime string `json:"respond_time"`
  19975. Signtype interface{} `json:"signtype"`
  19976. WarnMsg interface{} `json:"warn_msg"`
  19977. }
  19978. type ResultgzSixteen10265Two struct {
  19979. Cainfo string `json:"cainfo"`
  19980. ErrMsg string `json:"err_msg"`
  19981. InfRefmsgid string `json:"inf_refmsgid"`
  19982. Infcode int64 `json:"infcode"`
  19983. Output struct {
  19984. Setlinfo interface{} `json:"setlinfo"`
  19985. } `json:"output"`
  19986. RefmsgTime string `json:"refmsg_time"`
  19987. RespondTime string `json:"respond_time"`
  19988. Signtype interface{} `json:"signtype"`
  19989. WarnMsg interface{} `json:"warn_msg"`
  19990. }
  19991. type ResultSeventeen struct {
  19992. ErrMsg string `json:"err_msg"`
  19993. InfRefmsgid string `json:"inf_refmsgid"`
  19994. Infcode int64 `json:"infcode"`
  19995. Output struct {
  19996. SetlListId string `json:"setl_list_id"`
  19997. } `json:"output"`
  19998. RefmsgTime string `json:"refmsg_time"`
  19999. RespondTime string `json:"respond_time"`
  20000. Signtype string `json:"signtype"`
  20001. WarnInfo string `json:"warn_info"`
  20002. }
  20003. type ResultSeventeenOther struct {
  20004. ErrMsg string `json:"err_msg"`
  20005. InfRefmsgid string `json:"inf_refmsgid"`
  20006. Infcode string `json:"infcode"`
  20007. Output struct {
  20008. SetlListId string `json:"setl_list_id"`
  20009. } `json:"output"`
  20010. RefmsgTime string `json:"refmsg_time"`
  20011. RespondTime string `json:"respond_time"`
  20012. Signtype string `json:"signtype"`
  20013. WarnInfo string `json:"warn_info"`
  20014. }
  20015. type Result90991 struct {
  20016. ErrMsg string `json:"err_msg"`
  20017. InfRefmsgid string `json:"inf_refmsgid"`
  20018. Infcode int64 `json:"infcode"`
  20019. Output struct {
  20020. Result struct {
  20021. PsnNo string `json:"psn_no"`
  20022. CardStat string `json:"card_stat"`
  20023. Certno string `json:"certno"`
  20024. PsnName string `json:"psn_name"`
  20025. CheckStat string `json:"check_stat"`
  20026. SscnoCheckStat string `json:"sscno_check_stat"`
  20027. } `json:"result"`
  20028. } `json:"output"`
  20029. RefmsgTime string `json:"refmsg_time"`
  20030. RespondTime string `json:"respond_time"`
  20031. Signtype interface{} `json:"signtype"`
  20032. WarnInfo interface{} `json:"warn_info"`
  20033. }
  20034. type Result90100 struct {
  20035. ErrMsg string `json:"err_msg"`
  20036. InfRefmsgid string `json:"inf_refmsgid"`
  20037. Infcode int64 `json:"infcode"`
  20038. Output struct {
  20039. PoolareaNo string `json:"poolarea_no"`
  20040. PoolareaNoName string `json:"poolarea_no_name"`
  20041. Insutype string `json:"insutype"`
  20042. InsutypeName string `json:"insutype_name"`
  20043. ClctType string `json:"clct_type"`
  20044. ClctTypeName string `json:"clct_type_name"`
  20045. ClctFlag string `json:"clct_flag"`
  20046. ClctFlagName string `json:"clct_flag_name"`
  20047. AccrymBegn string `json:"accrym_begn"`
  20048. AccrymEnd string `json:"accrym_end"`
  20049. ClctTime string `json:"clct_time"`
  20050. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  20051. } `json:"output"`
  20052. RefmsgTime string `json:"refmsg_time"`
  20053. RespondTime string `json:"respond_time"`
  20054. Signtype interface{} `json:"signtype"`
  20055. WarnInfo interface{} `json:"warn_info"`
  20056. }
  20057. type Custom struct {
  20058. DetItemFeeSumamt string
  20059. Cut string
  20060. FeedetlSn string
  20061. Price string
  20062. MedListCodg string
  20063. Type int64
  20064. AdviceId int64
  20065. ProjectId int64
  20066. ItemId int64
  20067. }
  20068. type Result5301 struct {
  20069. ErrMsg string `json:"err_msg"`
  20070. InfRefmsgid string `json:"inf_refmsgid"`
  20071. Infcode int64 `json:"infcode"`
  20072. Output struct {
  20073. Result []struct {
  20074. OpspDiseCode string `json:"opsp_dise_code"`
  20075. OpspDiseName string `json:"opsp_dise_name"`
  20076. Begndate string `json:"begndate"`
  20077. Enddate string `json:"enddate"`
  20078. } `json:"feedetail"`
  20079. } `json:"output"`
  20080. RefmsgTime string `json:"refmsg_time"`
  20081. RespondTime string `json:"respond_time"`
  20082. Signtype interface{} `json:"signtype"`
  20083. WarnInfo interface{} `json:"warn_info"`
  20084. }
  20085. type Result5301For10265 struct {
  20086. ErrMsg string `json:"err_msg"`
  20087. InfRefmsgid string `json:"inf_refmsgid"`
  20088. Infcode string `json:"infcode"`
  20089. Output struct {
  20090. Result []struct {
  20091. OpspDiseCode string `json:"opsp_dise_code"`
  20092. OpspDiseName string `json:"opsp_dise_name"`
  20093. Begndate string `json:"begndate"`
  20094. Enddate string `json:"enddate"`
  20095. } `json:"feedetail"`
  20096. } `json:"output"`
  20097. RefmsgTime string `json:"refmsg_time"`
  20098. RespondTime string `json:"respond_time"`
  20099. Signtype interface{} `json:"signtype"`
  20100. WarnInfo interface{} `json:"warn_info"`
  20101. }
  20102. //获取个人信息----挂号-----上传就诊信息
  20103. func (c *HisApiController) GetRegisterInfo() {
  20104. id, _ := c.GetInt64("id")
  20105. record_time := c.GetString("record_time")
  20106. settlementValue, _ := c.GetInt64("settlement_value")
  20107. medical_insurance_card := c.GetString("medical_insurance_card")
  20108. name := c.GetString("name")
  20109. id_card_type, _ := c.GetInt64("id_card_type")
  20110. certificates, _ := c.GetInt64("certificates")
  20111. medical_care, _ := c.GetInt64("medical_care")
  20112. birthday := c.GetString("birthday")
  20113. id_card := c.GetString("id_card")
  20114. register_type, _ := c.GetInt64("register")
  20115. doctor, _ := c.GetInt64("doctor")
  20116. department, _ := c.GetInt64("department")
  20117. gender, _ := c.GetInt64("sex")
  20118. registration_fee, _ := c.GetFloat("registration_fee")
  20119. medical_expenses, _ := c.GetFloat("medical_expenses")
  20120. social_type, _ := c.GetInt64("social_type")
  20121. admin_user_id, _ := c.GetInt64("admin_user_id")
  20122. insuplc_admdvs := c.GetString("insuplc_admdvs")
  20123. mdtrt_type := c.GetString("mdtrt_type")
  20124. if id_card_type == 5 {
  20125. id_card_type = 4
  20126. }
  20127. timeLayout := "2006-01-02"
  20128. loc, _ := time.LoadLocation("Local")
  20129. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  20130. birthUnix := birthdays.Unix()
  20131. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  20132. if err != nil {
  20133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  20134. return
  20135. }
  20136. recordDateTime := theTime.Unix()
  20137. adminInfo := c.GetAdminUserInfo()
  20138. var patient service.Patients
  20139. if id == 0 {
  20140. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  20141. } else {
  20142. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  20143. }
  20144. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  20145. if patientPrescription.ID == 0 {
  20146. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  20147. }
  20148. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  20149. if patient.ID == 0 {
  20150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  20151. return
  20152. }
  20153. if len(patient.IdCardNo) == 0 {
  20154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  20155. return
  20156. }
  20157. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  20158. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  20159. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  20160. //就诊结算未完成,不能进行二次挂号
  20161. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  20162. if len(his) >= 1 {
  20163. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  20164. if len(his) >= 1 && order.ID == 0 {
  20165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  20166. return
  20167. }
  20168. }
  20169. //var register_log string
  20170. if config.IsOpen == 1 {
  20171. var res ResultTwo
  20172. var res10265 ResultTwo10265
  20173. var PsnNo string
  20174. var PsnCertType string
  20175. var Certno string
  20176. var PsnName string
  20177. var Gend string
  20178. var Naty string
  20179. var Brdy string
  20180. var Age float64
  20181. var infoStr string
  20182. var idetinfoStr string
  20183. var infocode int64
  20184. var verify_number string
  20185. fmt.Println(verify_number)
  20186. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  20187. psn_info, _ := service.GetPsnByPatientId(id)
  20188. PsnNo = psn_info.PsnNo
  20189. PsnCertType = psn_info.PsnCertType
  20190. Certno = psn_info.Certno
  20191. PsnName = psn_info.PsnName
  20192. Gend = psn_info.Gend
  20193. Naty = psn_info.Naty
  20194. Brdy = psn_info.Brdy
  20195. Age = psn_info.Age
  20196. infoStr = psn_info.Insuinfo
  20197. idetinfoStr = psn_info.Idetinfo
  20198. infocode = 0
  20199. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20200. psn_info, _ := service.GetPsnByPatientId(id)
  20201. PsnNo = psn_info.PsnNo
  20202. PsnCertType = psn_info.PsnCertType
  20203. Certno = psn_info.Certno
  20204. PsnName = psn_info.PsnName
  20205. Gend = psn_info.Gend
  20206. Naty = psn_info.Naty
  20207. Brdy = psn_info.Brdy
  20208. Age = psn_info.Age
  20209. infoStr = psn_info.Insuinfo
  20210. idetinfoStr = psn_info.Idetinfo
  20211. infocode = 0
  20212. verify_number = psn_info.VerifyNumber
  20213. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20214. if id_card_type == 2 {
  20215. //请求内网数据
  20216. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  20217. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20218. "&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
  20219. resp, requestErr := http.Get(api)
  20220. if requestErr != nil {
  20221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20222. return
  20223. }
  20224. body, ioErr := ioutil.ReadAll(resp.Body)
  20225. if ioErr != nil {
  20226. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20228. return
  20229. }
  20230. var respJSON map[string]interface{}
  20231. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20232. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20234. return
  20235. }
  20236. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20237. result_byte, _ := json.Marshal(respJSON)
  20238. result := string(result_byte)
  20239. var dat map[string]interface{}
  20240. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20241. fmt.Println(dat)
  20242. } else {
  20243. fmt.Println(err)
  20244. }
  20245. userJSONBytes, _ := json.Marshal(dat)
  20246. var res ResultTwo
  20247. var resTwo10265 ResultTwo10265
  20248. if miConfig.Code == "H15049901371" {
  20249. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  20250. utils.ErrorLog("解析失败:%v", err)
  20251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20252. return
  20253. }
  20254. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  20255. res.Infcode = Infcode
  20256. res.ErrMsg = resTwo10265.ErrMsg
  20257. res.Output = resTwo10265.Output
  20258. res.InfRefmsgid = resTwo10265.InfRefmsgid
  20259. res.RespondTime = resTwo10265.RespondTime
  20260. res.WarnInfo = resTwo10265.WarnInfo
  20261. } else {
  20262. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20263. utils.ErrorLog("解析失败:%v", err)
  20264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20265. return
  20266. }
  20267. }
  20268. //var insutypes []string
  20269. //var insutype string
  20270. //var is390 int = 0
  20271. //var is310 int = 0
  20272. //for _, item := range res.Output.Iinfo {
  20273. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20274. // insutypes = append(insutypes, item.Insutype)
  20275. // }
  20276. //}
  20277. //if len(insutypes) == 1 {
  20278. // insutype = insutypes[0]
  20279. //} else {
  20280. // for _, i := range insutypes {
  20281. // if i == "390" {
  20282. // is390 = 1
  20283. // }
  20284. //
  20285. // if i == "310" {
  20286. // is310 = 1
  20287. // }
  20288. // }
  20289. //}
  20290. //if is390 == 1 {
  20291. // insutype = "390"
  20292. //}
  20293. //if is310 == 1 {
  20294. // insutype = "310"
  20295. //}
  20296. //if len(insutypes) == 0 {
  20297. // insutype = "310"
  20298. //}
  20299. PsnNo = res.Output.Baseinfo.PsnNo
  20300. PsnCertType = res.Output.Baseinfo.PsnCertType
  20301. Certno = res.Output.Baseinfo.Certno
  20302. PsnName = res.Output.Baseinfo.PsnName
  20303. Gend = res.Output.Baseinfo.Gend
  20304. Naty = res.Output.Baseinfo.Naty
  20305. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  20306. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  20307. infoStr = string(Iinfos)
  20308. idetinfoStr = string(Idetinfos)
  20309. infocode = res.Infcode
  20310. //infocode = 0
  20311. //verify_number = psn_info.VerifyNumber
  20312. } else {
  20313. psn_info, _ := service.GetPsnByPatientId(id)
  20314. PsnNo = psn_info.PsnNo
  20315. PsnCertType = psn_info.PsnCertType
  20316. Certno = psn_info.Certno
  20317. PsnName = psn_info.PsnName
  20318. Gend = psn_info.Gend
  20319. Naty = psn_info.Naty
  20320. Brdy = psn_info.Brdy
  20321. Age = psn_info.Age
  20322. infoStr = psn_info.Insuinfo
  20323. idetinfoStr = psn_info.Idetinfo
  20324. infocode = 0
  20325. verify_number = psn_info.VerifyNumber
  20326. }
  20327. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20328. if id_card_type == 1 {
  20329. psn_info, _ := service.GetPsnByPatientId(id)
  20330. PsnNo = psn_info.PsnNo
  20331. PsnCertType = psn_info.PsnCertType
  20332. Certno = psn_info.Certno
  20333. PsnName = psn_info.PsnName
  20334. Gend = psn_info.Gend
  20335. Naty = psn_info.Naty
  20336. Brdy = psn_info.Brdy
  20337. Age = psn_info.Age
  20338. infoStr = psn_info.Insuinfo
  20339. idetinfoStr = psn_info.Idetinfo
  20340. infocode = 0
  20341. verify_number = psn_info.VerifyNumber
  20342. } else if id_card_type == 2 {
  20343. 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)
  20344. fmt.Println(errMsgLog)
  20345. saveLog(result, requestLog, "1101", "人员基本信息获取")
  20346. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20347. utils.ErrorLog("解析失败:%v", err)
  20348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20349. return
  20350. }
  20351. PsnNo = res.Output.Baseinfo.PsnNo
  20352. PsnCertType = res.Output.Baseinfo.PsnCertType
  20353. Certno = res.Output.Baseinfo.Certno
  20354. PsnName = res.Output.Baseinfo.PsnName
  20355. Gend = res.Output.Baseinfo.Gend
  20356. Naty = res.Output.Baseinfo.Naty
  20357. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  20358. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  20359. infoStr = string(Iinfos)
  20360. idetinfoStr = string(Idetinfos)
  20361. infocode = res.Infcode
  20362. }
  20363. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20364. if id_card_type == 1 {
  20365. psn_info, _ := service.GetPsnByPatientId(id)
  20366. PsnNo = psn_info.PsnNo
  20367. PsnCertType = psn_info.PsnCertType
  20368. Certno = psn_info.Certno
  20369. PsnName = psn_info.PsnName
  20370. Gend = psn_info.Gend
  20371. Naty = psn_info.Naty
  20372. Brdy = psn_info.Brdy
  20373. Age = psn_info.Age
  20374. infoStr = psn_info.Insuinfo
  20375. idetinfoStr = psn_info.Idetinfo
  20376. infocode = 0
  20377. verify_number = psn_info.VerifyNumber
  20378. } else if id_card_type == 2 {
  20379. 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, "")
  20380. saveLog(result, requestLog, "1101", "人员基本信息获取")
  20381. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20382. utils.ErrorLog("解析失败:%v", err)
  20383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20384. return
  20385. }
  20386. PsnNo = res.Output.Baseinfo.PsnNo
  20387. PsnCertType = res.Output.Baseinfo.PsnCertType
  20388. Certno = res.Output.Baseinfo.Certno
  20389. PsnName = res.Output.Baseinfo.PsnName
  20390. Gend = res.Output.Baseinfo.Gend
  20391. Naty = res.Output.Baseinfo.Naty
  20392. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  20393. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  20394. infoStr = string(Iinfos)
  20395. idetinfoStr = string(Idetinfos)
  20396. infocode = res.Infcode
  20397. } else {
  20398. psn_info, _ := service.GetPsnByPatientId(id)
  20399. PsnNo = psn_info.PsnNo
  20400. PsnCertType = psn_info.PsnCertType
  20401. Certno = psn_info.Certno
  20402. PsnName = psn_info.PsnName
  20403. Gend = psn_info.Gend
  20404. Naty = psn_info.Naty
  20405. Brdy = psn_info.Brdy
  20406. Age = psn_info.Age
  20407. infoStr = psn_info.Insuinfo
  20408. idetinfoStr = psn_info.Idetinfo
  20409. infocode = 0
  20410. verify_number = psn_info.VerifyNumber
  20411. }
  20412. } else if miConfig.MdtrtareaAdmvs == "341203" {
  20413. psn_info, _ := service.GetPsnByPatientId(id)
  20414. PsnNo = psn_info.PsnNo
  20415. PsnCertType = psn_info.PsnCertType
  20416. Certno = psn_info.Certno
  20417. PsnName = psn_info.PsnName
  20418. Gend = psn_info.Gend
  20419. Naty = psn_info.Naty
  20420. Brdy = psn_info.Brdy
  20421. Age = psn_info.Age
  20422. infoStr = psn_info.Insuinfo
  20423. idetinfoStr = psn_info.Idetinfo
  20424. infocode = 0
  20425. verify_number = psn_info.VerifyNumber
  20426. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20427. if id_card_type == 1 {
  20428. psn_info, _ := service.GetPsnByPatientId(id)
  20429. PsnNo = psn_info.PsnNo
  20430. PsnCertType = psn_info.PsnCertType
  20431. Certno = psn_info.Certno
  20432. PsnName = psn_info.PsnName
  20433. Gend = psn_info.Gend
  20434. Naty = psn_info.Naty
  20435. Brdy = psn_info.Brdy
  20436. Age = psn_info.Age
  20437. infoStr = psn_info.Insuinfo
  20438. idetinfoStr = psn_info.Idetinfo
  20439. infocode = 0
  20440. verify_number = psn_info.VerifyNumber
  20441. } else if id_card_type == 2 {
  20442. 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)
  20443. saveLog(result, requestLog, "1101", "人员基本信息获取")
  20444. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20445. utils.ErrorLog("解析失败:%v", err)
  20446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20447. return
  20448. }
  20449. PsnNo = res.Output.Baseinfo.PsnNo
  20450. PsnCertType = res.Output.Baseinfo.PsnCertType
  20451. Certno = res.Output.Baseinfo.Certno
  20452. PsnName = res.Output.Baseinfo.PsnName
  20453. Gend = res.Output.Baseinfo.Gend
  20454. Naty = res.Output.Baseinfo.Naty
  20455. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  20456. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  20457. infoStr = string(Iinfos)
  20458. idetinfoStr = string(Idetinfos)
  20459. infocode = res.Infcode
  20460. } else if id_card_type == 4 {
  20461. psn_info, _ := service.GetPsnByPatientId(id)
  20462. PsnNo = psn_info.PsnNo
  20463. PsnCertType = psn_info.PsnCertType
  20464. Certno = psn_info.Certno
  20465. PsnName = psn_info.PsnName
  20466. Gend = psn_info.Gend
  20467. Naty = psn_info.Naty
  20468. Brdy = psn_info.Brdy
  20469. Age = psn_info.Age
  20470. infoStr = psn_info.Insuinfo
  20471. idetinfoStr = psn_info.Idetinfo
  20472. infocode = 0
  20473. verify_number = psn_info.VerifyNumber
  20474. }
  20475. } else if miConfig.MdtrtareaAdmvs == "131023" {
  20476. var result string
  20477. var requestLog string
  20478. 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), "")
  20479. if id_card_type == 4 {
  20480. psn_info, _ := service.GetPsnByPatientId(id)
  20481. PsnNo = psn_info.PsnNo
  20482. PsnCertType = psn_info.PsnCertType
  20483. Certno = psn_info.Certno
  20484. PsnName = psn_info.PsnName
  20485. Gend = psn_info.Gend
  20486. Naty = psn_info.Naty
  20487. Brdy = psn_info.Brdy
  20488. Age = psn_info.Age
  20489. infoStr = psn_info.Insuinfo
  20490. idetinfoStr = psn_info.Idetinfo
  20491. infocode = 0
  20492. verify_number = psn_info.VerifyNumber
  20493. } else {
  20494. saveLog(result, requestLog, "1101", "人员基本信息获取")
  20495. if miConfig.Code == "H15049901371" {
  20496. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  20497. utils.ErrorLog("解析失败:%v", err)
  20498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20499. return
  20500. }
  20501. res.ErrMsg = res10265.ErrMsg
  20502. res.Output = res10265.Output
  20503. res.InfRefmsgid = res10265.InfRefmsgid
  20504. } else {
  20505. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20506. utils.ErrorLog("解析失败:%v", err)
  20507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20508. return
  20509. }
  20510. }
  20511. PsnNo = res.Output.Baseinfo.PsnNo
  20512. PsnCertType = res.Output.Baseinfo.PsnCertType
  20513. Certno = res.Output.Baseinfo.Certno
  20514. PsnName = res.Output.Baseinfo.PsnName
  20515. Gend = res.Output.Baseinfo.Gend
  20516. Naty = res.Output.Baseinfo.Naty
  20517. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  20518. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  20519. infoStr = string(Iinfos)
  20520. idetinfoStr = string(Idetinfos)
  20521. if miConfig.Code == "H15049901371" {
  20522. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  20523. } else {
  20524. infocode = res.Infcode
  20525. }
  20526. }
  20527. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20528. psn_info, _ := service.GetPsnByPatientId(id)
  20529. PsnNo = psn_info.PsnNo
  20530. PsnCertType = psn_info.PsnCertType
  20531. Certno = psn_info.Certno
  20532. PsnName = psn_info.PsnName
  20533. Gend = psn_info.Gend
  20534. Naty = psn_info.Naty
  20535. Brdy = psn_info.Brdy
  20536. Age = psn_info.Age
  20537. infoStr = psn_info.Insuinfo
  20538. idetinfoStr = psn_info.Idetinfo
  20539. infocode = 0
  20540. verify_number = psn_info.VerifyNumber
  20541. } else if miConfig.MdtrtareaAdmvs == "450721" {
  20542. psn_info, _ := service.GetPsnByPatientId(id)
  20543. PsnNo = psn_info.PsnNo
  20544. PsnCertType = psn_info.PsnCertType
  20545. Certno = psn_info.Certno
  20546. PsnName = psn_info.PsnName
  20547. Gend = psn_info.Gend
  20548. Naty = psn_info.Naty
  20549. Brdy = psn_info.Brdy
  20550. Age = psn_info.Age
  20551. infoStr = psn_info.Insuinfo
  20552. idetinfoStr = psn_info.Idetinfo
  20553. infocode = 0
  20554. verify_number = psn_info.VerifyNumber
  20555. } else {
  20556. var result string
  20557. var requestLog string
  20558. //if miConfig.UserOrgId == 10138 {
  20559. if id_card_type != 4 || id_card_type != 1 {
  20560. var insa string
  20561. if len(patient.InsuplcAdmdvs) > 0 {
  20562. insa = patient.InsuplcAdmdvs
  20563. } else {
  20564. insa = miConfig.InsuplcAdmdvs
  20565. }
  20566. //psn_info, _ := service.GetPsnByPatientId(id)
  20567. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  20568. 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)
  20569. }
  20570. //}
  20571. //else {
  20572. // var insa string
  20573. // if len(patient.InsuplcAdmdvs) > 0 {
  20574. // insa = patient.InsuplcAdmdvs
  20575. // } else {
  20576. // insa = miConfig.InsuplcAdmdvs
  20577. // }
  20578. // 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)
  20579. //}
  20580. if id_card_type == 4 || id_card_type == 1 {
  20581. psn_info, _ := service.GetPsnByPatientId(id)
  20582. PsnNo = psn_info.PsnNo
  20583. PsnCertType = psn_info.PsnCertType
  20584. Certno = psn_info.Certno
  20585. PsnName = psn_info.PsnName
  20586. Gend = psn_info.Gend
  20587. Naty = psn_info.Naty
  20588. Brdy = psn_info.Brdy
  20589. Age = psn_info.Age
  20590. infoStr = psn_info.Insuinfo
  20591. idetinfoStr = psn_info.Idetinfo
  20592. infocode = 0
  20593. verify_number = psn_info.VerifyNumber
  20594. } else {
  20595. saveLog(result, requestLog, "1101", "人员基本信息获取")
  20596. if miConfig.Code == "H15049901371" {
  20597. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  20598. utils.ErrorLog("解析失败:%v", err)
  20599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20600. return
  20601. }
  20602. res.ErrMsg = res10265.ErrMsg
  20603. res.Output = res10265.Output
  20604. res.InfRefmsgid = res10265.InfRefmsgid
  20605. } else {
  20606. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20607. utils.ErrorLog("解析失败:%v", err)
  20608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20609. return
  20610. }
  20611. }
  20612. PsnNo = res.Output.Baseinfo.PsnNo
  20613. PsnCertType = res.Output.Baseinfo.PsnCertType
  20614. Certno = res.Output.Baseinfo.Certno
  20615. PsnName = res.Output.Baseinfo.PsnName
  20616. Gend = res.Output.Baseinfo.Gend
  20617. Naty = res.Output.Baseinfo.Naty
  20618. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  20619. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  20620. infoStr = string(Iinfos)
  20621. idetinfoStr = string(Idetinfos)
  20622. if miConfig.Code == "H15049901371" {
  20623. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  20624. } else {
  20625. infocode = res.Infcode
  20626. }
  20627. }
  20628. }
  20629. if infocode == 0 {
  20630. his := models.VMHisPatient{
  20631. Name: name,
  20632. Gender: gender,
  20633. Birthday: birthUnix,
  20634. MedicalTreatmentType: medical_care,
  20635. IdType: certificates,
  20636. IdCardNo: id_card,
  20637. BalanceAccountsType: settlementValue,
  20638. SocialType: social_type,
  20639. MedicalInsuranceNumber: medical_insurance_card,
  20640. RegisterType: register_type,
  20641. RegisterCost: registration_fee,
  20642. TreatmentCost: medical_expenses,
  20643. Status: 1,
  20644. Ctime: time.Now().Unix(),
  20645. Mtime: time.Now().Unix(),
  20646. PsnNo: PsnNo,
  20647. PsnCertType: PsnCertType,
  20648. Certno: Certno,
  20649. PsnName: PsnName,
  20650. Gend: Gend,
  20651. Naty: Naty,
  20652. Brdy: Brdy,
  20653. Age: Age,
  20654. Iinfo: infoStr,
  20655. Idetinfo: idetinfoStr,
  20656. PatientId: patient.ID,
  20657. RecordDate: theTime.Unix(),
  20658. UserOrgId: adminInfo.CurrentOrgId,
  20659. AdminUserId: admin_user_id,
  20660. IsReturn: 1,
  20661. IdCardType: id_card_type,
  20662. Doctor: doctor,
  20663. Departments: department,
  20664. MdtrtGrpType: mdtrt_type,
  20665. }
  20666. timestamp := time.Now().Unix()
  20667. tempTime := time.Unix(timestamp, 0)
  20668. timeFormat := tempTime.Format("20060102150405")
  20669. chrgBchno := rand.Intn(100000) + 10000
  20670. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  20671. his.Number = ipt_otp_no
  20672. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  20673. department, _ := service.GetDepartMentDetail(department)
  20674. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  20675. IdCardNo := ""
  20676. if id_card_type == 1 {
  20677. // IdCardNo = medical_insurance_card
  20678. IdCardNo = patient.IdCardNo
  20679. } else {
  20680. IdCardNo = patient.IdCardNo
  20681. }
  20682. var rf []*ResultFive
  20683. json.Unmarshal([]byte(his.Iinfo), &rf)
  20684. var insutypes []*ResultFive
  20685. var insutype string
  20686. var insuplc_admdvs_temp string
  20687. var is390 int = 0
  20688. var is310 int = 0
  20689. for _, item := range rf {
  20690. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20691. insutypes = append(insutypes, item)
  20692. }
  20693. }
  20694. if len(insutypes) == 1 {
  20695. insutype = insutypes[0].Insutype
  20696. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  20697. if insutype == "390" {
  20698. is390 = 1
  20699. }
  20700. if insutype == "310" {
  20701. is310 = 1
  20702. }
  20703. } else {
  20704. for _, i := range insutypes {
  20705. if i.Insutype == "390" {
  20706. is390 = 1
  20707. }
  20708. if i.Insutype == "310" {
  20709. is310 = 1
  20710. }
  20711. }
  20712. }
  20713. if is390 == 1 {
  20714. insutype = "390"
  20715. }
  20716. if is310 == 1 {
  20717. insutype = "310"
  20718. }
  20719. fmt.Println(social_type)
  20720. if social_type > 0 {
  20721. insutype = strconv.FormatInt(social_type, 10)
  20722. }
  20723. var infocode int64
  20724. var resThree ResultThree
  20725. var resThree10265 ResultThree10265
  20726. if len(insuplc_admdvs) == 0 {
  20727. psn_info, _ := service.GetPsnByPatientId(id)
  20728. //if len(psn_info.InsuplcAdmdvs) > 0 {
  20729. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  20730. //}
  20731. } else {
  20732. insuplc_admdvs_temp = insuplc_admdvs
  20733. }
  20734. if miConfig.MdtrtareaAdmvs == "421300" {
  20735. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  20736. psn_info, _ := service.GetPsnByPatientId(id)
  20737. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  20738. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  20739. "&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
  20740. resp, requestErr := http.Get(api)
  20741. if requestErr != nil {
  20742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20743. return
  20744. }
  20745. body, ioErr := ioutil.ReadAll(resp.Body)
  20746. if ioErr != nil {
  20747. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20749. return
  20750. }
  20751. var respJSON map[string]interface{}
  20752. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20753. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20755. return
  20756. }
  20757. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20758. result, _ := json.Marshal(respJSON)
  20759. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  20760. utils.ErrorLog("解析失败:%v", err)
  20761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20762. return
  20763. }
  20764. infocode = resThree.Infcode
  20765. } else if miConfig.MdtrtareaAdmvs == "420200" {
  20766. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  20767. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  20768. // insuplc_admdvs_temp =
  20769. //}
  20770. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  20771. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  20772. //}
  20773. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  20774. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  20775. "&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
  20776. resp, requestErr := http.Get(api)
  20777. if requestErr != nil {
  20778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20779. return
  20780. }
  20781. body, ioErr := ioutil.ReadAll(resp.Body)
  20782. if ioErr != nil {
  20783. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20785. return
  20786. }
  20787. var respJSON map[string]interface{}
  20788. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20789. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20791. return
  20792. }
  20793. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20794. result, _ := json.Marshal(respJSON)
  20795. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  20796. utils.ErrorLog("解析失败:%v", err)
  20797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20798. return
  20799. }
  20800. infocode = resThree.Infcode
  20801. } else if miConfig.MdtrtareaAdmvs == "420902" {
  20802. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  20803. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  20804. // insuplc_admdvs_temp =
  20805. //}
  20806. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  20807. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  20808. //}
  20809. utils.ErrorLog("解析失败:%v", insutype)
  20810. utils.ErrorLog("解析失败:%v", PsnNo)
  20811. utils.ErrorLog("解析失败:%v", Certno)
  20812. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  20813. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  20814. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  20815. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  20816. utils.ErrorLog("解析失败:%v", PsnNo)
  20817. utils.ErrorLog("解析失败:%v", department.Number)
  20818. utils.ErrorLog("解析失败:%v", department.Name)
  20819. utils.ErrorLog("解析失败:%v", roles.UserName)
  20820. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  20821. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  20822. "&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
  20823. resp, requestErr := http.Get(api)
  20824. if requestErr != nil {
  20825. utils.ErrorLog("解析失败:%v", requestErr)
  20826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20827. return
  20828. }
  20829. body, ioErr := ioutil.ReadAll(resp.Body)
  20830. if ioErr != nil {
  20831. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20833. return
  20834. }
  20835. var respJSON map[string]interface{}
  20836. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20837. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20839. return
  20840. }
  20841. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20842. result, _ := json.Marshal(respJSON)
  20843. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  20844. utils.ErrorLog("解析失败:%v", err)
  20845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20846. return
  20847. }
  20848. infocode = resThree.Infcode
  20849. } else if miConfig.MdtrtareaAdmvs == "421182" {
  20850. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  20851. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  20852. // insuplc_admdvs_temp =
  20853. //}
  20854. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  20855. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  20856. //}
  20857. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  20858. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  20859. "&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
  20860. resp, requestErr := http.Get(api)
  20861. if requestErr != nil {
  20862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20863. return
  20864. }
  20865. body, ioErr := ioutil.ReadAll(resp.Body)
  20866. if ioErr != nil {
  20867. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20869. return
  20870. }
  20871. var respJSON map[string]interface{}
  20872. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20873. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20875. return
  20876. }
  20877. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20878. result, _ := json.Marshal(respJSON)
  20879. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  20880. utils.ErrorLog("解析失败:%v", err)
  20881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20882. return
  20883. }
  20884. infocode = resThree.Infcode
  20885. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20886. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  20887. psn_info, _ := service.GetPsnByPatientId(id)
  20888. var verify_number string
  20889. if id_card_type == 4 {
  20890. verify_number = psn_info.VerifyNumber
  20891. } else if id_card_type == 1 {
  20892. bas := strings.Split(psn_info.CardInfo, "|")
  20893. cardNumber := bas[2]
  20894. verify_number = cardNumber
  20895. }
  20896. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  20897. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  20898. "&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
  20899. resp, requestErr := http.Get(api)
  20900. if requestErr != nil {
  20901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20902. return
  20903. }
  20904. body, ioErr := ioutil.ReadAll(resp.Body)
  20905. if ioErr != nil {
  20906. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20908. return
  20909. }
  20910. var respJSON map[string]interface{}
  20911. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20912. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20914. return
  20915. }
  20916. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20917. result, _ := json.Marshal(respJSON)
  20918. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  20919. // utils.ErrorLog("解析失败:%v", err)
  20920. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20921. // return
  20922. //}
  20923. //infocode = resThree.Infcode
  20924. //result, _ := json.Marshal(respJSON)
  20925. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  20926. utils.ErrorLog("解析失败:%v", err)
  20927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20928. return
  20929. }
  20930. resThree.ErrMsg = resThree10265.ErrMsg
  20931. resThree.Output = resThree10265.Output
  20932. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  20933. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  20934. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20935. psn_info, _ := service.GetPsnByPatientId(id)
  20936. his.PsnNo = psn_info.PsnNo
  20937. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20938. var cert_no string
  20939. if id_card_type == 3 {
  20940. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  20941. cert_no = IdCardNo
  20942. } else if id_card_type == 4 {
  20943. cert_no = IdCardNo
  20944. psn_info.VerifyNumber = psn_info.VerifyNumber
  20945. } else {
  20946. bas := strings.Split(psn_info.CardInfo, "|")
  20947. cert_no = bas[2]
  20948. }
  20949. var hisPrescription []*models.HisPrescription
  20950. for _, item := range rf {
  20951. if item.Insutype == insutype {
  20952. //insuplc_admdvs = item.InsuplcAdmdvs
  20953. his.InsuplcAdmdvs = insuplc_admdvs
  20954. }
  20955. }
  20956. his.Insutype = insutype
  20957. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription,department)
  20958. fmt.Println(res3101)
  20959. fmt.Println(res3101.Infcode)
  20960. if res3101.Infcode == "0" {
  20961. fmt.Println("33333333")
  20962. if len(res3101.Output.Result) > 0 {
  20963. fmt.Println("222222")
  20964. for _, item := range res3101.Output.Result {
  20965. if len(res3101.ErrMsg) == 0 {
  20966. res3101.ErrMsg = item.VolaCont
  20967. } else {
  20968. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  20969. }
  20970. }
  20971. c.ServeSuccessJSON(map[string]interface{}{
  20972. "failed_code": -10,
  20973. "msg": res3101.ErrMsg,
  20974. })
  20975. return
  20976. } else {
  20977. fmt.Println("11111")
  20978. var api string
  20979. if miConfig.MdtrtareaAdmvs == "320921" {
  20980. ipt_otp_no = timeFormat
  20981. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  20982. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  20983. "&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
  20984. } else {
  20985. ipt_otp_no = timeFormat
  20986. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  20987. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  20988. "&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
  20989. }
  20990. resp, requestErr := http.Get(api)
  20991. if requestErr != nil {
  20992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20993. return
  20994. }
  20995. body, ioErr := ioutil.ReadAll(resp.Body)
  20996. if ioErr != nil {
  20997. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20999. return
  21000. }
  21001. var respJSON map[string]interface{}
  21002. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21003. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21005. return
  21006. }
  21007. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21008. result, _ := json.Marshal(respJSON)
  21009. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  21010. utils.ErrorLog("解析失败:%v", err)
  21011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21012. return
  21013. }
  21014. resThree.ErrMsg = resThree10265.ErrMsg
  21015. resThree.Output = resThree10265.Output
  21016. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  21017. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  21018. }
  21019. } else if res3101.Infcode != "0" {
  21020. c.ServeSuccessJSON(map[string]interface{}{
  21021. "failed_code": -10,
  21022. "msg": res3101.ErrMsg,
  21023. })
  21024. return
  21025. }
  21026. } else if miConfig.MdtrtareaAdmvs == "350500" {
  21027. psn_info, _ := service.GetPsnByPatientId(id)
  21028. var cert_no string
  21029. if id_card_type == 1 {
  21030. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  21031. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  21032. } else if id_card_type == 4 {
  21033. cert_no = psn_info.VerifyNumber
  21034. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  21035. } else {
  21036. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  21037. cert_no = psn_info.VerifyNumber
  21038. }
  21039. 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)
  21040. saveLog(result, requestLog, "2201", "挂号")
  21041. if miConfig.Code == "H15049901371" {
  21042. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  21043. utils.ErrorLog("解析失败:%v", err)
  21044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21045. return
  21046. }
  21047. resThree.ErrMsg = resThree10265.ErrMsg
  21048. resThree.Output = resThree10265.Output
  21049. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  21050. } else {
  21051. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  21052. utils.ErrorLog("解析失败:%v", err)
  21053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21054. return
  21055. }
  21056. }
  21057. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  21058. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  21059. psn_info, _ := service.GetPsnByPatientId(id)
  21060. var result string
  21061. var requestLog string
  21062. if id_card_type == 1 {
  21063. bas := strings.Split(psn_info.CardInfo, "|")
  21064. basNumber := bas[2]
  21065. card_sn := bas[3]
  21066. 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)
  21067. saveLog(result, requestLog, "2201A", "挂号")
  21068. } else if id_card_type == 2 {
  21069. 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, "", "", "", "", "", "")
  21070. saveLog(result, requestLog, "2201A", "挂号")
  21071. } else {
  21072. 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)
  21073. saveLog(result, requestLog, "2201A", "挂号")
  21074. }
  21075. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  21076. utils.ErrorLog("解析失败:%v", err)
  21077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21078. return
  21079. }
  21080. infocode = resThree.Infcode
  21081. } else if miConfig.MdtrtareaAdmvs == "341203" {
  21082. psn_info, _ := service.GetPsnByPatientId(id)
  21083. his.PsnNo = psn_info.PsnNo
  21084. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  21085. var cert_no string
  21086. if id_card_type == 1 {
  21087. bas := strings.Split(psn_info.CardInfo, "|")
  21088. cert_no = bas[2]
  21089. } else if id_card_type == 4 {
  21090. cert_no = IdCardNo
  21091. psn_info.VerifyNumber = psn_info.VerifyNumber
  21092. } else {
  21093. cert_no = IdCardNo
  21094. psn_info.VerifyNumber = cert_no
  21095. }
  21096. for _, item := range rf {
  21097. if item.Insutype == insutype {
  21098. his.InsuplcAdmdvs = insuplc_admdvs
  21099. }
  21100. }
  21101. his.Insutype = insutype
  21102. var api string
  21103. ipt_otp_no = timeFormat
  21104. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  21105. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  21106. "&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
  21107. resp, requestErr := http.Get(api)
  21108. if requestErr != nil {
  21109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21110. return
  21111. }
  21112. body, ioErr := ioutil.ReadAll(resp.Body)
  21113. if ioErr != nil {
  21114. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21116. return
  21117. }
  21118. var respJSON map[string]interface{}
  21119. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21120. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21122. return
  21123. }
  21124. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21125. if status == "0" {
  21126. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21127. c.ServeSuccessJSON(map[string]interface{}{
  21128. "failed_code": -10,
  21129. "msg": err_msg,
  21130. })
  21131. return
  21132. }
  21133. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21134. result, _ := json.Marshal(respJSON)
  21135. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  21136. utils.ErrorLog("解析失败:%v", err)
  21137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21138. return
  21139. }
  21140. infocode = resThree.Infcode
  21141. } else if miConfig.MdtrtareaAdmvs == "430800" {
  21142. psn_info, _ := service.GetPsnByPatientId(id)
  21143. var result string
  21144. var requestLog string
  21145. if id_card_type == 1 {
  21146. bas := strings.Split(psn_info.CardInfo, "|")
  21147. basNumber := bas[2]
  21148. card_sn := bas[3]
  21149. 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)
  21150. saveLog(result, requestLog, "2201A", "挂号")
  21151. } else if id_card_type == 2 {
  21152. 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, "", "")
  21153. saveLog(result, requestLog, "2201A", "挂号")
  21154. } else {
  21155. 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, "", "")
  21156. saveLog(result, requestLog, "2201A", "挂号")
  21157. }
  21158. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  21159. utils.ErrorLog("解析失败:%v", err)
  21160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21161. return
  21162. }
  21163. infocode = resThree.Infcode
  21164. } else if miConfig.MdtrtareaAdmvs == "131023" {
  21165. psn_info, _ := service.GetPsnByPatientId(id)
  21166. 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)
  21167. saveLog(result, requestLog, "2201A", "挂号")
  21168. if miConfig.Code == "H15049901371" {
  21169. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  21170. utils.ErrorLog("解析失败:%v", err)
  21171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21172. return
  21173. }
  21174. resThree.ErrMsg = resThree10265.ErrMsg
  21175. resThree.Output = resThree10265.Output
  21176. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  21177. } else {
  21178. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  21179. utils.ErrorLog("解析失败:%v", err)
  21180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21181. return
  21182. }
  21183. }
  21184. if miConfig.Code == "H15049901371" {
  21185. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  21186. } else {
  21187. infocode = resThree.Infcode
  21188. }
  21189. } else {
  21190. psn_info, _ := service.GetPsnByPatientId(id)
  21191. if id_card_type == 4 || id_card_type == 1 {
  21192. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  21193. }
  21194. var rf []*ResultFive
  21195. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  21196. var insutypes []*ResultFive
  21197. var insutype string
  21198. var is390 int = 0
  21199. var is310 int = 0
  21200. for _, item := range rf {
  21201. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  21202. insutypes = append(insutypes, item)
  21203. }
  21204. }
  21205. if len(insutypes) == 1 {
  21206. insutype = insutypes[0].Insutype
  21207. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  21208. } else {
  21209. for _, i := range insutypes {
  21210. if i.Insutype == "390" {
  21211. is390 = 1
  21212. }
  21213. if i.Insutype == "310" {
  21214. is310 = 1
  21215. }
  21216. }
  21217. }
  21218. if is390 == 1 {
  21219. insutype = "390"
  21220. }
  21221. if is310 == 1 {
  21222. insutype = "310"
  21223. }
  21224. fmt.Println(len(insutypes))
  21225. if len(insutypes) == 0 {
  21226. for index, item := range rf {
  21227. if index == 0 {
  21228. insutype = item.Insutype
  21229. insuplc_admdvs = item.InsuplcAdmdvs
  21230. }
  21231. }
  21232. fmt.Println(insutype)
  21233. fmt.Println(insuplc_admdvs)
  21234. }
  21235. if social_type > 0 {
  21236. insutype = strconv.FormatInt(social_type, 10)
  21237. }
  21238. fmt.Println("--------")
  21239. fmt.Println(psn_info)
  21240. fmt.Println(psn_info.PsnNo)
  21241. if miConfig.MdtrtareaAdmvs == "441202" {
  21242. var hisPrescription []*models.HisPrescription
  21243. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription,department)
  21244. if res3101.Infcode == 0 {
  21245. fmt.Println("33333333")
  21246. if len(res3101.Output.Result) > 0 {
  21247. fmt.Println("222222")
  21248. for _, item := range res3101.Output.Result {
  21249. if len(res3101.ErrMsg) == 0 {
  21250. res3101.ErrMsg = item.VolaCont
  21251. } else {
  21252. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  21253. }
  21254. }
  21255. c.ServeSuccessJSON(map[string]interface{}{
  21256. "failed_code": -10,
  21257. "msg": res3101.ErrMsg,
  21258. })
  21259. return
  21260. } else {
  21261. hour := time.Now().Format("15")
  21262. min := time.Now().Format("04")
  21263. sec := time.Now().Format("05")
  21264. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  21265. fmt.Println(record_time_two)
  21266. 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)
  21267. saveLog(result, requestLog, "2201A", "挂号")
  21268. if miConfig.Code == "H15049901371" {
  21269. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  21270. utils.ErrorLog("解析失败:%v", err)
  21271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21272. return
  21273. }
  21274. resThree.ErrMsg = resThree10265.ErrMsg
  21275. resThree.Output = resThree10265.Output
  21276. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  21277. } else {
  21278. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  21279. utils.ErrorLog("解析失败:%v", err)
  21280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21281. return
  21282. }
  21283. }
  21284. if miConfig.Code == "H15049901371" {
  21285. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  21286. } else {
  21287. infocode = resThree.Infcode
  21288. }
  21289. }
  21290. } else if res3101.Infcode != 0 {
  21291. c.ServeSuccessJSON(map[string]interface{}{
  21292. "failed_code": -10,
  21293. "msg": res3101.ErrMsg,
  21294. })
  21295. return
  21296. }
  21297. } else if miConfig.MdtrtareaAdmvs == "440205" {
  21298. var hisPrescription []*models.HisPrescription
  21299. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription,department)
  21300. if res3101.Infcode == 0 {
  21301. fmt.Println("33333333")
  21302. if len(res3101.Output.Result) > 0 {
  21303. fmt.Println("222222")
  21304. for _, item := range res3101.Output.Result {
  21305. if len(res3101.ErrMsg) == 0 {
  21306. res3101.ErrMsg = item.VolaCont
  21307. } else {
  21308. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  21309. }
  21310. }
  21311. c.ServeSuccessJSON(map[string]interface{}{
  21312. "failed_code": -10,
  21313. "msg": res3101.ErrMsg,
  21314. })
  21315. return
  21316. } else {
  21317. hour := time.Now().Format("15")
  21318. min := time.Now().Format("04")
  21319. sec := time.Now().Format("05")
  21320. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  21321. fmt.Println(record_time_two)
  21322. 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)
  21323. saveLog(result, requestLog, "2201A", "挂号")
  21324. if miConfig.Code == "H15049901371" {
  21325. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  21326. utils.ErrorLog("解析失败:%v", err)
  21327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21328. return
  21329. }
  21330. resThree.ErrMsg = resThree10265.ErrMsg
  21331. resThree.Output = resThree10265.Output
  21332. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  21333. } else {
  21334. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  21335. utils.ErrorLog("解析失败:%v", err)
  21336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21337. return
  21338. }
  21339. }
  21340. if miConfig.Code == "H15049901371" {
  21341. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  21342. } else {
  21343. infocode = resThree.Infcode
  21344. }
  21345. }
  21346. } else if res3101.Infcode != 0 {
  21347. c.ServeSuccessJSON(map[string]interface{}{
  21348. "failed_code": -10,
  21349. "msg": res3101.ErrMsg,
  21350. })
  21351. return
  21352. }
  21353. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21354. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  21355. psn_info, _ := service.GetPsnByPatientId(id)
  21356. var verify_number string
  21357. if id_card_type == 4 {
  21358. verify_number = psn_info.VerifyNumber
  21359. } else if id_card_type == 1 {
  21360. bas := strings.Split(psn_info.CardInfo, "|")
  21361. cardNumber := bas[2]
  21362. verify_number = cardNumber
  21363. } else {
  21364. verify_number = psn_info.Certno
  21365. }
  21366. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  21367. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  21368. "&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
  21369. resp, requestErr := http.Get(api)
  21370. if requestErr != nil {
  21371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21372. return
  21373. }
  21374. body, ioErr := ioutil.ReadAll(resp.Body)
  21375. if ioErr != nil {
  21376. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21378. return
  21379. }
  21380. var respJSON map[string]interface{}
  21381. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21382. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21384. return
  21385. }
  21386. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21387. result, _ := json.Marshal(respJSON)
  21388. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  21389. utils.ErrorLog("解析失败:%v", err)
  21390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21391. return
  21392. }
  21393. infocode = resThree.Infcode
  21394. } else {
  21395. hour := time.Now().Format("15")
  21396. min := time.Now().Format("04")
  21397. sec := time.Now().Format("05")
  21398. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  21399. if id_card_type == 1{
  21400. for _, item := range rf {
  21401. if item.Insutype == strconv.FormatInt(social_type, 10) {
  21402. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  21403. insuplc_admdvs_temp = item.InsuplcAdmdvs
  21404. } else if strconv.FormatInt(social_type, 10) == "390" {
  21405. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  21406. } else {
  21407. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  21408. }
  21409. }
  21410. }
  21411. }
  21412. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  21413. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  21414. }
  21415. if id_card_type == 1 {
  21416. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  21417. bas := strings.Split(psn_info.CardInfo, "|")
  21418. basNumber := bas[1]
  21419. IdCardNo = basNumber
  21420. }
  21421. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  21422. IdCardNo = psn_info.VerifyNumber
  21423. }
  21424. if len(insuplc_admdvs_temp) == 0{
  21425. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  21426. }
  21427. 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)
  21428. saveLog(result, requestLog, "2201A", "挂号")
  21429. if miConfig.Code == "H15049901371" {
  21430. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  21431. utils.ErrorLog("解析失败:%v", err)
  21432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21433. return
  21434. }
  21435. resThree.ErrMsg = resThree10265.ErrMsg
  21436. resThree.Output = resThree10265.Output
  21437. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  21438. } else {
  21439. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  21440. utils.ErrorLog("解析失败:%v", err)
  21441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21442. return
  21443. }
  21444. }
  21445. if miConfig.Code == "H15049901371" {
  21446. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  21447. } else {
  21448. infocode = resThree.Infcode
  21449. }
  21450. }
  21451. }
  21452. if infocode == -1 {
  21453. adminUser := c.GetAdminUserInfo()
  21454. errlog := &models.HisOrderError{
  21455. UserOrgId: adminUser.CurrentOrgId,
  21456. Ctime: time.Now().Unix(),
  21457. Mtime: time.Now().Unix(),
  21458. ErrMsg: resThree.ErrMsg,
  21459. Status: 1,
  21460. PatientId: id,
  21461. RecordTime: recordDateTime,
  21462. Stage: 2,
  21463. }
  21464. service.CreateErrMsgLog(errlog)
  21465. c.ServeSuccessJSON(map[string]interface{}{
  21466. "failed_code": -10,
  21467. "msg": resThree.ErrMsg,
  21468. })
  21469. return
  21470. }
  21471. his.Number = resThree.Output.Data.MdtrtID
  21472. his.PsnNo = resThree.Output.Data.PsnNo
  21473. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  21474. his.IdCardNo = patient.IdCardNo
  21475. his.PhoneNumber = patient.Phone
  21476. his.UserOrgId = adminInfo.CurrentOrgId
  21477. his.Insutype = insutype
  21478. his.Ctime = time.Now().Unix()
  21479. his.Mtime = time.Now().Unix()
  21480. his.InsuplcAdmdvs = insuplc_admdvs_temp
  21481. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  21482. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  21483. }
  21484. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  21485. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  21486. }
  21487. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  21488. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  21489. }
  21490. his.Status = 1
  21491. his.MdtrtGrpType = mdtrt_type
  21492. service.UpdateHisPatientStatus(&his)
  21493. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  21494. c.ServeSuccessJSON(map[string]interface{}{
  21495. "his_info": his,
  21496. })
  21497. } else {
  21498. adminUser := c.GetAdminUserInfo()
  21499. errlog := &models.HisOrderError{
  21500. UserOrgId: adminUser.CurrentOrgId,
  21501. Ctime: time.Now().Unix(),
  21502. Mtime: time.Now().Unix(),
  21503. ErrMsg: res.ErrMsg,
  21504. Status: 1,
  21505. PatientId: id,
  21506. RecordTime: recordDateTime,
  21507. Stage: 1,
  21508. }
  21509. service.CreateErrMsgLog(errlog)
  21510. c.ServeSuccessJSON(map[string]interface{}{
  21511. "failed_code": -10,
  21512. "msg": res.ErrMsg,
  21513. })
  21514. return
  21515. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  21516. }
  21517. }
  21518. }
  21519. func (c *HisApiController) GetUploadInfo() {
  21520. id, _ := c.GetInt64("id")
  21521. record_time := c.GetString("record_time")
  21522. his_patient_id, _ := c.GetInt64("his_patient_id")
  21523. order_id, _ := c.GetInt64("order_id")
  21524. pay_way, _ := c.GetInt64("pay_way")
  21525. pay_ways := c.GetString("pay_ways")
  21526. oth_desc := c.GetString("oth_desc")
  21527. pay_price, _ := c.GetFloat("pay_price")
  21528. pay_card_no := c.GetString("pay_card_no")
  21529. discount_price, _ := c.GetFloat("discount_price")
  21530. preferential_price, _ := c.GetFloat("preferential_price")
  21531. reality_price, _ := c.GetFloat("reality_price")
  21532. found_price, _ := c.GetFloat("found_price")
  21533. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  21534. private_price, _ := c.GetFloat("private_price")
  21535. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  21536. admin_user_id, _ := c.GetInt64("admin_user_id")
  21537. fapiao_code := c.GetString("fapiao_code")
  21538. fapiao_number := c.GetString("fapiao_number")
  21539. diagnosis_id := c.GetString("diagnosis")
  21540. sick_type, _ := c.GetInt64("sick_type")
  21541. reg_type, _ := c.GetInt64("p_type")
  21542. begin_time := c.GetString("begin_time")
  21543. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  21544. cash_pay := c.GetString("cash_pay")
  21545. band_card_pay := c.GetString("band_card_pay")
  21546. wechat_pay := c.GetString("wechat_pay")
  21547. ali_pay := c.GetString("ali_pay")
  21548. jifen_pay := c.GetString("jifen_pay")
  21549. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  21550. fmt.Println(acct_used_flag)
  21551. id_str := c.GetString("ids")
  21552. ids_arr := strings.Split(id_str, ",")
  21553. timeLayout := "2006-01-02"
  21554. loc, _ := time.LoadLocation("Local")
  21555. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  21556. if err != nil {
  21557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21558. return
  21559. }
  21560. recordDateTime := theTime.Unix()
  21561. adminUser := c.GetAdminUserInfo()
  21562. var tempOrder models.HisOrder
  21563. tempOrder, _ = service.GetHisOrderByID(order_id)
  21564. var prescriptions []*models.HisPrescription
  21565. var start_time int64
  21566. var end_time int64
  21567. //押金模块
  21568. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  21569. tmp_decimal := c.GetString("tmp_decimal")
  21570. var decimal float64 //本次使用的押金
  21571. var errmsg error
  21572. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  21573. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  21574. return
  21575. }
  21576. if len(tmp_decimal) > 0 {
  21577. if tmp_decimal[0] == 45 {
  21578. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  21579. return
  21580. }
  21581. }
  21582. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  21583. fmt.Println(errs)
  21584. decimal = tt
  21585. //if adminUser.CurrentOrgId == 10106{
  21586. // if len(fapiao_code) == 0{
  21587. // fapiao_code = "144072080589"
  21588. // }
  21589. // if len(fapiao_number) == 0{
  21590. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  21591. // if order.ID == 0{
  21592. // fapiao_number = "00001520"
  21593. // }else{
  21594. // //fapiao_code = "00001520"
  21595. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  21596. // var zero string
  21597. // if fpNumber >= 1000{
  21598. // zero = "0000" + strconv.Itoa(fpNumber)
  21599. // }else if fpNumber >= 10000{
  21600. // zero = "000" + strconv.Itoa(fpNumber)
  21601. // } else if fpNumber >= 100000{
  21602. // zero = "00" + strconv.Itoa(fpNumber)
  21603. // } else if fpNumber >= 1000000{
  21604. // zero = "0" + strconv.Itoa(fpNumber)
  21605. // }else {
  21606. // zero = strconv.Itoa(fpNumber)
  21607. // }
  21608. // fapiao_number = zero
  21609. // }
  21610. // }
  21611. //}
  21612. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  21613. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  21614. var patientPrescription models.HisPrescriptionInfo
  21615. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  21616. if patientPrescription.ID == 0 {
  21617. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  21618. }
  21619. //if patientPrescription.Do
  21620. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  21621. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  21622. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  21623. diagnosis_ids := strings.Split(diagnosis_id, ",")
  21624. var config []*models.HisXtDiagnoseConfig
  21625. for _, item := range diagnosis_ids {
  21626. id, _ := strconv.ParseInt(item, 10, 64)
  21627. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21628. config = append(config, &diagnosisConfig)
  21629. }
  21630. sickConfig, _ := service.FindSickById(sick_type)
  21631. //if tempOrder.ID == 0 {
  21632. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  21633. //}
  21634. if tempOrder.ID == 0 {
  21635. var result string
  21636. var requestLog string
  21637. var res2 ResultSix
  21638. var res3 GZResultSix
  21639. var ressix10265 ResultSix10265
  21640. if miConfig.MdtrtareaAdmvs == "421300" {
  21641. data := make(map[string]interface{})
  21642. client := &http.Client{}
  21643. data["psn_no"] = his.PsnNo
  21644. data["mdtrt_id"] = his.Number
  21645. data["opter"] = roles.UserName
  21646. data["org_name"] = miConfig.OrgName
  21647. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21648. data["doctor_id"] = doctor_info.DoctorNumber
  21649. data["doctor_name"] = doctor_info.UserName
  21650. data["department"] = department.Name
  21651. data["fixmedins_code"] = miConfig.Code
  21652. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21653. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21654. data["secret_key"] = miConfig.SecretKey
  21655. data["sick_code"] = sickConfig.CountryCode
  21656. data["sick_name"] = sickConfig.ClassName
  21657. data["dept"] = strconv.FormatInt(department.ID, 10)
  21658. data["config"] = config
  21659. data["begin_time"] = begin_time
  21660. bytesData, _ := json.Marshal(data)
  21661. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  21662. resp, _ := client.Do(req)
  21663. defer resp.Body.Close()
  21664. body, ioErr := ioutil.ReadAll(resp.Body)
  21665. if ioErr != nil {
  21666. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21668. return
  21669. }
  21670. var respJSON map[string]interface{}
  21671. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21674. return
  21675. }
  21676. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21677. userJSONBytes, _ := json.Marshal(respJSON)
  21678. fmt.Println("log")
  21679. fmt.Println(string(userJSONBytes))
  21680. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21681. utils.ErrorLog("解析失败:%v", err)
  21682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21683. return
  21684. }
  21685. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21686. data := make(map[string]interface{})
  21687. client := &http.Client{}
  21688. data["psn_no"] = his.PsnNo
  21689. data["mdtrt_id"] = his.Number
  21690. data["opter"] = roles.UserName
  21691. data["org_name"] = miConfig.OrgName
  21692. if reg_type == 11 && his.Insutype == "390" {
  21693. data["med_type"] = "110104"
  21694. } else {
  21695. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21696. }
  21697. data["doctor_id"] = doctor_info.DoctorNumber
  21698. data["doctor_name"] = doctor_info.UserName
  21699. data["department"] = department.Name
  21700. data["fixmedins_code"] = miConfig.Code
  21701. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21702. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21703. data["secret_key"] = miConfig.SecretKey
  21704. data["sick_code"] = sickConfig.CountryCode
  21705. data["sick_name"] = sickConfig.ClassName
  21706. data["dept"] = strconv.FormatInt(department.ID, 10)
  21707. data["config"] = config
  21708. data["begin_time"] = begin_time
  21709. bytesData, _ := json.Marshal(data)
  21710. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  21711. resp, _ := client.Do(req)
  21712. defer resp.Body.Close()
  21713. body, ioErr := ioutil.ReadAll(resp.Body)
  21714. if ioErr != nil {
  21715. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21717. return
  21718. }
  21719. var respJSON map[string]interface{}
  21720. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21721. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21723. return
  21724. }
  21725. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21726. userJSONBytes, _ := json.Marshal(respJSON)
  21727. fmt.Println("log")
  21728. fmt.Println(string(userJSONBytes))
  21729. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21730. utils.ErrorLog("解析失败:%v", err)
  21731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21732. return
  21733. }
  21734. } else if miConfig.MdtrtareaAdmvs == "420902" {
  21735. data := make(map[string]interface{})
  21736. client := &http.Client{}
  21737. data["psn_no"] = his.PsnNo
  21738. data["mdtrt_id"] = his.Number
  21739. data["opter"] = roles.UserName
  21740. data["org_name"] = miConfig.OrgName
  21741. if reg_type == 11 && his.Insutype == "390" {
  21742. data["med_type"] = "110104"
  21743. } else {
  21744. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21745. }
  21746. data["doctor_id"] = doctor_info.DoctorNumber
  21747. data["doctor_name"] = doctor_info.UserName
  21748. data["department"] = department.Name
  21749. data["fixmedins_code"] = miConfig.Code
  21750. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21751. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21752. data["secret_key"] = miConfig.SecretKey
  21753. data["sick_code"] = sickConfig.CountryCode
  21754. data["sick_name"] = sickConfig.ClassName
  21755. data["dept"] = strconv.FormatInt(department.ID, 10)
  21756. data["config"] = config
  21757. data["begin_time"] = begin_time
  21758. bytesData, _ := json.Marshal(data)
  21759. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  21760. resp, _ := client.Do(req)
  21761. defer resp.Body.Close()
  21762. body, ioErr := ioutil.ReadAll(resp.Body)
  21763. if ioErr != nil {
  21764. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21766. return
  21767. }
  21768. var respJSON map[string]interface{}
  21769. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21770. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21772. return
  21773. }
  21774. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21775. userJSONBytes, _ := json.Marshal(respJSON)
  21776. fmt.Println("log")
  21777. fmt.Println(string(userJSONBytes))
  21778. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21779. utils.ErrorLog("解析失败:%v", err)
  21780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21781. return
  21782. }
  21783. } else if miConfig.MdtrtareaAdmvs == "421182" {
  21784. data := make(map[string]interface{})
  21785. client := &http.Client{}
  21786. data["psn_no"] = his.PsnNo
  21787. data["mdtrt_id"] = his.Number
  21788. data["opter"] = roles.UserName
  21789. data["org_name"] = miConfig.OrgName
  21790. if reg_type == 11 && his.Insutype == "390" {
  21791. data["med_type"] = "110104"
  21792. } else {
  21793. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21794. }
  21795. data["doctor_id"] = doctor_info.DoctorNumber
  21796. data["doctor_name"] = doctor_info.UserName
  21797. data["department"] = department.Name
  21798. data["fixmedins_code"] = miConfig.Code
  21799. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21800. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21801. data["secret_key"] = miConfig.SecretKey
  21802. data["sick_code"] = sickConfig.CountryCode
  21803. data["sick_name"] = sickConfig.ClassName
  21804. data["dept"] = strconv.FormatInt(department.ID, 10)
  21805. data["config"] = config
  21806. data["begin_time"] = begin_time
  21807. bytesData, _ := json.Marshal(data)
  21808. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  21809. resp, _ := client.Do(req)
  21810. defer resp.Body.Close()
  21811. body, ioErr := ioutil.ReadAll(resp.Body)
  21812. if ioErr != nil {
  21813. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21815. return
  21816. }
  21817. var respJSON map[string]interface{}
  21818. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21819. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21821. return
  21822. }
  21823. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21824. userJSONBytes, _ := json.Marshal(respJSON)
  21825. fmt.Println("log")
  21826. fmt.Println(string(userJSONBytes))
  21827. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21828. utils.ErrorLog("解析失败:%v", err)
  21829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21830. return
  21831. }
  21832. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21833. data := make(map[string]interface{})
  21834. client := &http.Client{}
  21835. data["psn_no"] = his.PsnNo
  21836. data["mdtrt_id"] = his.Number
  21837. data["doctor"] = roles.UserName
  21838. data["department"] = department.Name
  21839. data["org_name"] = miConfig.OrgName
  21840. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21841. data["doctor_id"] = doctor_info.DoctorNumber
  21842. data["new_doctor_name"] = doctor_info.UserName
  21843. data["fixmedins_code"] = miConfig.Code
  21844. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21845. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21846. data["secret_key"] = miConfig.SecretKey
  21847. data["sick_code"] = sickConfig.CountryCode
  21848. data["sick_name"] = sickConfig.ClassName
  21849. data["url"] = miConfig.Url
  21850. data["ak"] = miConfig.AccessKey
  21851. data["begin_time"] = begin_time
  21852. data["cainfo"] = miConfig.Cainfo
  21853. data["dept"] = strconv.FormatInt(department.ID, 10)
  21854. data["config"] = config
  21855. bytesData, _ := json.Marshal(data)
  21856. var req *http.Request
  21857. if miConfig.MdtrtareaAdmvs == "320921" {
  21858. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  21859. //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 +
  21860. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  21861. } else {
  21862. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  21863. }
  21864. resp, _ := client.Do(req)
  21865. defer resp.Body.Close()
  21866. body, ioErr := ioutil.ReadAll(resp.Body)
  21867. if ioErr != nil {
  21868. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21870. return
  21871. }
  21872. var respJSON map[string]interface{}
  21873. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21874. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21876. return
  21877. }
  21878. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21879. userJSONBytes, _ := json.Marshal(respJSON)
  21880. fmt.Println("log")
  21881. fmt.Println(string(userJSONBytes))
  21882. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  21883. utils.ErrorLog("解析失败:%v", err)
  21884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21885. return
  21886. }
  21887. res2.InfRefmsgid = ressix10265.InfRefmsgid
  21888. res2.Output = ressix10265.Output
  21889. res2.ErrMsg = ressix10265.ErrMsg
  21890. res2.Cainfo = ressix10265.Cainfo
  21891. res2.WarnMsg = ressix10265.WarnMsg
  21892. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  21893. res2.Infcode = infocode
  21894. } else if miConfig.MdtrtareaAdmvs == "150499" {
  21895. data := make(map[string]interface{})
  21896. client := &http.Client{}
  21897. data["psn_no"] = his.PsnNo
  21898. data["mdtrt_id"] = his.Number
  21899. data["doctor"] = roles.UserName
  21900. data["department"] = department.Name
  21901. data["org_name"] = miConfig.OrgName
  21902. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21903. data["doctor_id"] = doctor_info.DoctorNumber
  21904. data["new_doctor_name"] = doctor_info.UserName
  21905. data["fixmedins_code"] = miConfig.Code
  21906. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21907. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21908. data["secret_key"] = miConfig.SecretKey
  21909. data["sick_code"] = sickConfig.CountryCode
  21910. data["sick_name"] = sickConfig.ClassName
  21911. data["url"] = miConfig.Url
  21912. data["ak"] = miConfig.AccessKey
  21913. data["begin_time"] = begin_time
  21914. data["cainfo"] = miConfig.Cainfo
  21915. data["dept"] = strconv.FormatInt(department.ID, 10)
  21916. data["config"] = config
  21917. bytesData, _ := json.Marshal(data)
  21918. var req *http.Request
  21919. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  21920. resp, _ := client.Do(req)
  21921. defer resp.Body.Close()
  21922. body, ioErr := ioutil.ReadAll(resp.Body)
  21923. if ioErr != nil {
  21924. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21926. return
  21927. }
  21928. var respJSON map[string]interface{}
  21929. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21930. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21932. return
  21933. }
  21934. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21935. userJSONBytes, _ := json.Marshal(respJSON)
  21936. fmt.Println("log")
  21937. fmt.Println(string(userJSONBytes))
  21938. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  21939. utils.ErrorLog("解析失败:%v", err)
  21940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21941. return
  21942. }
  21943. res2.InfRefmsgid = ressix10265.InfRefmsgid
  21944. res2.Output = ressix10265.Output
  21945. res2.ErrMsg = ressix10265.ErrMsg
  21946. res2.Cainfo = ressix10265.Cainfo
  21947. res2.WarnMsg = ressix10265.WarnMsg
  21948. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  21949. res2.Infcode = infocode
  21950. } else if miConfig.MdtrtareaAdmvs == "350500" {
  21951. 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)
  21952. saveLog(result, requestLog, "2203", "上传就诊信息")
  21953. var respJSON2 map[string]interface{}
  21954. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21955. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21957. return
  21958. }
  21959. userJSONBytes2, _ := json.Marshal(respJSON2)
  21960. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21961. utils.ErrorLog("解析失败:%v", err)
  21962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21963. return
  21964. }
  21965. 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)
  21966. fmt.Println(result2)
  21967. fmt.Println(src_request)
  21968. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21969. data := make(map[string]interface{})
  21970. client := &http.Client{}
  21971. data["psn_no"] = his.PsnNo
  21972. data["mdtrt_id"] = his.Number
  21973. data["doctor"] = roles.UserName
  21974. data["department"] = department.Name
  21975. data["org_name"] = miConfig.OrgName
  21976. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21977. data["doctor_id"] = doctor_info.DoctorNumber
  21978. data["new_doctor_name"] = doctor_info.UserName
  21979. data["fixmedins_code"] = miConfig.Code
  21980. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21981. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21982. data["secret_key"] = miConfig.SecretKey
  21983. data["sick_code"] = sickConfig.CountryCode
  21984. data["sick_name"] = sickConfig.ClassName
  21985. data["url"] = miConfig.Url
  21986. data["ak"] = miConfig.AccessKey
  21987. data["begin_time"] = begin_time
  21988. data["cainfo"] = miConfig.Cainfo
  21989. data["dept"] = strconv.FormatInt(department.ID, 10)
  21990. data["config"] = config
  21991. bytesData, _ := json.Marshal(data)
  21992. var req *http.Request
  21993. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  21994. resp, _ := client.Do(req)
  21995. defer resp.Body.Close()
  21996. body, ioErr := ioutil.ReadAll(resp.Body)
  21997. if ioErr != nil {
  21998. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22000. return
  22001. }
  22002. var respJSON map[string]interface{}
  22003. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22006. return
  22007. }
  22008. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22009. userJSONBytes, _ := json.Marshal(respJSON)
  22010. fmt.Println("log")
  22011. fmt.Println(string(userJSONBytes))
  22012. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22013. utils.ErrorLog("解析失败:%v", err)
  22014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22015. return
  22016. }
  22017. } else {
  22018. if miConfig.MdtrtareaAdmvs == "440781" { //
  22019. 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)
  22020. } else {
  22021. if miConfig.Code == "H15049901371" {
  22022. //赤峰地区国家医保医疗类别
  22023. //职工透析:医疗类别选特殊情况门诊990502
  22024. //居民定额血透门慢: 医疗类别选门诊慢病140104
  22025. var med_type string
  22026. if his.Insutype == "390" {
  22027. if reg_type == 14 {
  22028. med_type = "9933"
  22029. } else if reg_type == 11 {
  22030. med_type = "11"
  22031. }
  22032. } else if his.Insutype == "310" {
  22033. if reg_type == 14 {
  22034. med_type = "990502"
  22035. } else if reg_type == 11 {
  22036. med_type = "11"
  22037. }
  22038. }
  22039. 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)
  22040. } else {
  22041. 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)
  22042. }
  22043. }
  22044. saveLog(result, requestLog, "2203", "上传就诊信息")
  22045. var respJSON2 map[string]interface{}
  22046. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  22047. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22049. return
  22050. }
  22051. userJSONBytes2, _ := json.Marshal(respJSON2)
  22052. if miConfig.Code == "H15049901371" {
  22053. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  22054. utils.ErrorLog("解析失败:%v", err)
  22055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22056. return
  22057. }
  22058. res2.InfRefmsgid = ressix10265.InfRefmsgid
  22059. res2.Output = ressix10265.Output
  22060. res2.ErrMsg = ressix10265.ErrMsg
  22061. res2.Cainfo = ressix10265.Cainfo
  22062. res2.WarnMsg = ressix10265.WarnMsg
  22063. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  22064. res2.Infcode = infocode
  22065. } else {
  22066. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  22067. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  22068. utils.ErrorLog("解析失败:%v", err)
  22069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22070. return
  22071. }
  22072. res2.Infcode = res3.Infcode
  22073. } else {
  22074. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  22075. utils.ErrorLog("解析失败:%v", err)
  22076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22077. return
  22078. }
  22079. }
  22080. }
  22081. }
  22082. if res2.Infcode == -1 {
  22083. adminUser := c.GetAdminUserInfo()
  22084. errlog := &models.HisOrderError{
  22085. UserOrgId: adminUser.CurrentOrgId,
  22086. Ctime: time.Now().Unix(),
  22087. Mtime: time.Now().Unix(),
  22088. ErrMsg: res2.ErrMsg,
  22089. Status: 1,
  22090. PatientId: id,
  22091. RecordTime: recordDateTime,
  22092. Stage: 3,
  22093. }
  22094. service.CreateErrMsgLog(errlog)
  22095. c.ServeSuccessJSON(map[string]interface{}{
  22096. "failed_code": -10,
  22097. "msg": res2.ErrMsg,
  22098. })
  22099. return
  22100. } else {
  22101. his.Diagnosis = diagnosis_id
  22102. his.SickType = sickConfig.ID
  22103. //var p_type int64
  22104. //if reg_type == 1111 || reg_type == 1112 {
  22105. // p_type = 11
  22106. //
  22107. //}
  22108. his.PType = fmt.Sprintf("%d", reg_type)
  22109. service.UpdateHisPatientThree(&his)
  22110. data := make(map[string]interface{})
  22111. if settle_accounts_type == 1 { //日结
  22112. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  22113. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  22114. } else {
  22115. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  22116. }
  22117. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  22118. data["pre"] = prescriptions
  22119. } else { //月结
  22120. start_time_str := c.GetString("start_time")
  22121. end_time_str := c.GetString("end_time")
  22122. timeLayout := "2006-01-02"
  22123. loc, _ := time.LoadLocation("Local")
  22124. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  22125. if err != nil {
  22126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22127. return
  22128. }
  22129. recordStartTime := theStartTime.Unix()
  22130. start_time = recordStartTime
  22131. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  22132. if err != nil {
  22133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22134. return
  22135. }
  22136. recordEndTime := theEndTime.Unix()
  22137. end_time = recordEndTime
  22138. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  22139. data["pre"] = prescriptions
  22140. }
  22141. timestamp := time.Now().Unix()
  22142. tempTime := time.Unix(timestamp, 0)
  22143. timeFormat := tempTime.Format("20060102150405")
  22144. chrgBchno := rand.Intn(100000) + 10000
  22145. new_chrg_bchno := ""
  22146. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  22147. new_chrg_bchno = chrg_bchno
  22148. strconv.FormatInt(his.PatientId, 10)
  22149. client := &http.Client{}
  22150. if adminUser.CurrentOrgId == 10265 {
  22151. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  22152. new_chrg_bchno = "0000"
  22153. }
  22154. }
  22155. data["psn_no"] = his.PsnNo
  22156. data["mdtrt_id"] = his.Number
  22157. data["chrg_bchno"] = new_chrg_bchno
  22158. data["org_name"] = miConfig.OrgName
  22159. data["doctor"] = doctor_info.UserName
  22160. data["doctor_id"] = doctor_info.DoctorNumber
  22161. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  22162. data["fixmedins_code"] = miConfig.Code
  22163. data["dept_code"] = department.Number
  22164. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22165. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22166. data["secret_key"] = miConfig.SecretKey
  22167. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  22168. data["url"] = miConfig.Url
  22169. data["ak"] = miConfig.AccessKey
  22170. data["new_doctor_name"] = patientPrescription.Doctor
  22171. data["diag_code"] = sickConfig.CountryCode
  22172. data["cainfo"] = miConfig.Cainfo
  22173. data["opter"] = roles.UserName
  22174. var ids []int64
  22175. for _, item := range prescriptions {
  22176. ids = append(ids, item.ID)
  22177. }
  22178. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  22179. if config.IsOpen == 1 { //对接了医保,走医保流程
  22180. var res ResultFour
  22181. var resFour10265 ResultFour10265
  22182. if miConfig.MdtrtareaAdmvs == "421300" {
  22183. bytesData, _ := json.Marshal(data)
  22184. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  22185. resp, _ := client.Do(req)
  22186. defer resp.Body.Close()
  22187. body, ioErr := ioutil.ReadAll(resp.Body)
  22188. if ioErr != nil {
  22189. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22191. return
  22192. }
  22193. var respJSON map[string]interface{}
  22194. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22195. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22197. return
  22198. }
  22199. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22200. userJSONBytes, _ := json.Marshal(respJSON)
  22201. fmt.Println("log")
  22202. fmt.Println(string(userJSONBytes))
  22203. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22204. utils.ErrorLog("解析失败:%v", err)
  22205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22206. return
  22207. }
  22208. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22209. bytesData, _ := json.Marshal(data)
  22210. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  22211. resp, _ := client.Do(req)
  22212. defer resp.Body.Close()
  22213. body, ioErr := ioutil.ReadAll(resp.Body)
  22214. if ioErr != nil {
  22215. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22217. return
  22218. }
  22219. var respJSON map[string]interface{}
  22220. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22221. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22223. return
  22224. }
  22225. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22226. userJSONBytes, _ := json.Marshal(respJSON)
  22227. fmt.Println("log")
  22228. fmt.Println(string(userJSONBytes))
  22229. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22230. utils.ErrorLog("解析失败:%v", err)
  22231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22232. return
  22233. }
  22234. } else if miConfig.MdtrtareaAdmvs == "420902" {
  22235. bytesData, _ := json.Marshal(data)
  22236. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  22237. resp, _ := client.Do(req)
  22238. defer resp.Body.Close()
  22239. body, ioErr := ioutil.ReadAll(resp.Body)
  22240. if ioErr != nil {
  22241. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22243. return
  22244. }
  22245. var respJSON map[string]interface{}
  22246. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22247. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22249. return
  22250. }
  22251. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22252. userJSONBytes, _ := json.Marshal(respJSON)
  22253. fmt.Println("log")
  22254. fmt.Println(string(userJSONBytes))
  22255. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22256. utils.ErrorLog("解析失败:%v", err)
  22257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22258. return
  22259. }
  22260. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22261. bytesData, _ := json.Marshal(data)
  22262. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  22263. resp, _ := client.Do(req)
  22264. defer resp.Body.Close()
  22265. body, ioErr := ioutil.ReadAll(resp.Body)
  22266. if ioErr != nil {
  22267. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22269. return
  22270. }
  22271. var respJSON map[string]interface{}
  22272. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22275. return
  22276. }
  22277. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22278. userJSONBytes, _ := json.Marshal(respJSON)
  22279. fmt.Println("log")
  22280. fmt.Println(string(userJSONBytes))
  22281. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22282. utils.ErrorLog("解析失败:%v", err)
  22283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22284. return
  22285. }
  22286. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22287. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  22288. if result3101.Infcode == "0" {
  22289. if len(result3101.Output.Result) > 0 {
  22290. var errMsgs []string
  22291. for _, item := range result3101.Output.Result {
  22292. errMsgs = append(errMsgs, item.VolaCont)
  22293. }
  22294. c.ServeSuccessJSON(map[string]interface{}{
  22295. "failed_code": -10,
  22296. "msg": errMsgs,
  22297. })
  22298. return
  22299. }
  22300. }
  22301. bytesData, _ := json.Marshal(data)
  22302. var req *http.Request
  22303. if miConfig.MdtrtareaAdmvs == "320921" {
  22304. data["diag_code"] = sickConfig.CountryCode
  22305. fmt.Println(data)
  22306. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22307. } else {
  22308. data["diag_code"] = sickConfig.CountryCode
  22309. fmt.Println(data)
  22310. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22311. }
  22312. resp, _ := client.Do(req)
  22313. defer resp.Body.Close()
  22314. body, ioErr := ioutil.ReadAll(resp.Body)
  22315. if ioErr != nil {
  22316. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22318. return
  22319. }
  22320. var respJSON map[string]interface{}
  22321. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22324. return
  22325. }
  22326. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22327. userJSONBytes, _ := json.Marshal(respJSON)
  22328. fmt.Println("log")
  22329. fmt.Println(string(userJSONBytes))
  22330. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22331. utils.ErrorLog("解析失败:%v", err)
  22332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22333. return
  22334. }
  22335. res.InfRefmsgid = resFour10265.InfRefmsgid
  22336. res.Output = resFour10265.Output
  22337. res.ErrMsg = resFour10265.ErrMsg
  22338. res.Cainfo = resFour10265.Cainfo
  22339. res.WarnMsg = resFour10265.WarnMsg
  22340. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22341. res.Infcode = infocode
  22342. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22343. var pagesize int = 2
  22344. var start int = 1
  22345. var stop int
  22346. var pagecount int
  22347. var curpage int
  22348. var isSuccess bool = true
  22349. data["doctor_id"] = doctor_info.DoctorNumber
  22350. //总页数,向上取整,注意除之前要先转换类型为float64
  22351. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  22352. for curpage = 1; curpage <= pagecount; curpage++ {
  22353. if curpage == 1 {
  22354. start = 1
  22355. } else {
  22356. start = (curpage-1)*pagesize + 1
  22357. }
  22358. stop = curpage * pagesize
  22359. if stop > len(prescriptions) {
  22360. stop = len(prescriptions)
  22361. }
  22362. //var requestLog string
  22363. data["pre"] = prescriptions[start-1 : stop]
  22364. fmt.Println(data["pre"])
  22365. bytesData, _ := json.Marshal(data)
  22366. var req *http.Request
  22367. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  22368. resp, _ := client.Do(req)
  22369. defer resp.Body.Close()
  22370. body, ioErr := ioutil.ReadAll(resp.Body)
  22371. if ioErr != nil {
  22372. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22374. return
  22375. }
  22376. var respJSON map[string]interface{}
  22377. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22378. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22380. return
  22381. }
  22382. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22383. userJSONBytes, _ := json.Marshal(respJSON)
  22384. fmt.Println("log")
  22385. fmt.Println(string(userJSONBytes))
  22386. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22387. utils.ErrorLog("解析失败:%v", err)
  22388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22389. return
  22390. }
  22391. res.InfRefmsgid = resFour10265.InfRefmsgid
  22392. res.Output = resFour10265.Output
  22393. res.ErrMsg = resFour10265.ErrMsg
  22394. res.Cainfo = resFour10265.Cainfo
  22395. res.WarnMsg = resFour10265.WarnMsg
  22396. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22397. res.Infcode = infocode
  22398. if infocode == 0 {
  22399. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  22400. } else {
  22401. isSuccess = false
  22402. errlog := &models.HisOrderError{
  22403. UserOrgId: adminUser.CurrentOrgId,
  22404. Ctime: time.Now().Unix(),
  22405. Mtime: time.Now().Unix(),
  22406. Number: chrg_bchno,
  22407. ErrMsg: "",
  22408. Status: 1,
  22409. PatientId: id,
  22410. RecordTime: recordDateTime,
  22411. Stage: 4,
  22412. }
  22413. service.CreateErrMsgLog(errlog)
  22414. c.ServeSuccessJSON(map[string]interface{}{
  22415. "failed_code": -10,
  22416. "msg": res.ErrMsg,
  22417. })
  22418. return
  22419. }
  22420. }
  22421. if isSuccess {
  22422. res.Infcode = 0
  22423. }
  22424. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22425. 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)
  22426. var dat map[string]interface{}
  22427. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22428. fmt.Println(dat)
  22429. } else {
  22430. fmt.Println(err)
  22431. }
  22432. saveLog(result, request_log, "2204", "上传费用明细")
  22433. userJSONBytes, _ := json.Marshal(dat)
  22434. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22435. utils.ErrorLog("解析失败:%v", err)
  22436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22437. return
  22438. }
  22439. res.InfRefmsgid = resFour10265.InfRefmsgid
  22440. res.Output = resFour10265.Output
  22441. res.ErrMsg = resFour10265.ErrMsg
  22442. res.Cainfo = resFour10265.Cainfo
  22443. res.WarnMsg = resFour10265.WarnMsg
  22444. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22445. res.Infcode = infocode
  22446. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22447. bytesData, _ := json.Marshal(data)
  22448. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  22449. resp, _ := client.Do(req)
  22450. defer resp.Body.Close()
  22451. body, ioErr := ioutil.ReadAll(resp.Body)
  22452. if ioErr != nil {
  22453. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22455. return
  22456. }
  22457. var respJSON map[string]interface{}
  22458. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22459. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22461. return
  22462. }
  22463. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22464. userJSONBytes, _ := json.Marshal(respJSON)
  22465. fmt.Println("log")
  22466. fmt.Println(string(userJSONBytes))
  22467. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22468. utils.ErrorLog("解析失败:%v", err)
  22469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22470. return
  22471. }
  22472. } else {
  22473. if miConfig.Code == "H15049901371" {
  22474. 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)
  22475. var dat map[string]interface{}
  22476. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22477. fmt.Println(dat)
  22478. } else {
  22479. fmt.Println(err)
  22480. }
  22481. saveLog(result, request_log, "2204", "上传费用明细")
  22482. userJSONBytes, _ := json.Marshal(dat)
  22483. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22484. utils.ErrorLog("解析失败:%v", err)
  22485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22486. return
  22487. }
  22488. res.InfRefmsgid = resFour10265.InfRefmsgid
  22489. res.Output = resFour10265.Output
  22490. res.ErrMsg = resFour10265.ErrMsg
  22491. res.Cainfo = resFour10265.Cainfo
  22492. res.WarnMsg = resFour10265.WarnMsg
  22493. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22494. res.Infcode = infocode
  22495. } else {
  22496. 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)
  22497. var dat map[string]interface{}
  22498. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22499. fmt.Println(dat)
  22500. } else {
  22501. fmt.Println(err)
  22502. }
  22503. saveLog(result, request_log, "2204", "上传费用明细")
  22504. userJSONBytes, _ := json.Marshal(dat)
  22505. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22506. utils.ErrorLog("解析失败:%v", err)
  22507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22508. return
  22509. }
  22510. }
  22511. }
  22512. if res.Infcode == 0 {
  22513. order := &models.HisOrder{
  22514. UserOrgId: adminUser.CurrentOrgId,
  22515. HisPatientId: his.ID,
  22516. PatientId: his.PatientId,
  22517. SettleAccountsDate: recordDateTime,
  22518. MdtrtId: his.Number,
  22519. PsnNo: his.PsnNo,
  22520. MedType: strconv.FormatInt(reg_type, 10),
  22521. Ctime: time.Now().Unix(),
  22522. Mtime: time.Now().Unix(),
  22523. Status: 1,
  22524. Number: chrg_bchno,
  22525. Infcode: res.Infcode,
  22526. WarnMsg: res.WarnMsg,
  22527. Cainfo: res.Cainfo,
  22528. ErrMsg: res.ErrMsg,
  22529. RespondTime: res.RefmsgTime,
  22530. InfRefmsgid: res.InfRefmsgid,
  22531. OrderStatus: 1,
  22532. PayWay: pay_way,
  22533. PayWays: pay_ways,
  22534. OthDesc: oth_desc,
  22535. PayPrice: pay_price,
  22536. PayCardNo: pay_card_no,
  22537. DiscountPrice: discount_price,
  22538. PreferentialPrice: preferential_price,
  22539. RealityPrice: reality_price,
  22540. FoundPrice: found_price,
  22541. MedicalInsurancePrice: medical_insurance_price,
  22542. PrivatePrice: private_price,
  22543. IsMedicineInsurance: 1,
  22544. SettleType: settle_accounts_type,
  22545. SettleStartTime: start_time,
  22546. SettleEndTime: end_time,
  22547. Creator: roles.AdminUserId,
  22548. Modify: roles.AdminUserId,
  22549. FaPiaoNumber: fapiao_number,
  22550. FaPiaoCode: fapiao_code,
  22551. PType: 2,
  22552. Diagnosis: diagnosis_id,
  22553. CashPay: cash_pay,
  22554. WechatPay: wechat_pay,
  22555. AliPay: ali_pay,
  22556. JifenPay: jifen_pay,
  22557. BandCardPay: band_card_pay,
  22558. }
  22559. err = service.CreateOrder(order)
  22560. if err != nil {
  22561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  22562. return
  22563. }
  22564. for _, item := range res.Output.Result {
  22565. temp := strings.Split(item.FeedetlSn, "-")
  22566. var advice_id int64 = 0
  22567. var project_id int64 = 0
  22568. var types int64 = 0
  22569. id, _ := strconv.ParseInt(temp[2], 10, 64)
  22570. types, _ = strconv.ParseInt(temp[1], 10, 64)
  22571. if temp[1] == "1" {
  22572. advice_id = id
  22573. project_id = 0
  22574. } else if temp[1] == "2" {
  22575. advice_id = 0
  22576. project_id = id
  22577. }
  22578. if item.MedChrgitmType == "9" {
  22579. item.MedChrgitmType = "09"
  22580. }
  22581. info := &models.HisOrderInfo{
  22582. OrderNumber: order.Number,
  22583. FeedetlSn: item.FeedetlSn,
  22584. UploadDate: time.Now().Unix(),
  22585. AdviceId: advice_id,
  22586. DetItemFeeSumamt: item.DetItemFeeSumamt,
  22587. Cnt: item.Cnt,
  22588. Pric: float64(item.Pric),
  22589. PatientId: his.PatientId,
  22590. PricUplmtAmt: item.PricUplmtAmt,
  22591. SelfpayProp: item.SelfpayProp,
  22592. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  22593. OverlmtAmt: item.OverlmtAmt,
  22594. PreselfpayAmt: item.PreselfpayAmt,
  22595. BasMednFlag: item.BasMednFlag,
  22596. MedChrgitmType: item.MedChrgitmType,
  22597. HiNegoDrugFlag: item.HiNegoDrugFlag,
  22598. Status: 1,
  22599. Memo: item.Memo,
  22600. Mtime: time.Now().Unix(),
  22601. InscpScpAmt: item.InscpScpAmt,
  22602. DrtReimFlag: item.DrtReimFlag,
  22603. Ctime: time.Now().Unix(),
  22604. ListSpItemFlag: item.ListSpItemFlag,
  22605. ChldMedcFlag: item.ChldMedcFlag,
  22606. LmtUsedFlag: item.LmtUsedFlag,
  22607. ChrgitmLv: item.ChrgitmLv,
  22608. UserOrgId: adminUser.CurrentOrgId,
  22609. HisPatientId: his.ID,
  22610. OrderId: order.ID,
  22611. ProjectId: project_id,
  22612. Type: types,
  22613. }
  22614. service.CreateOrderInfo(info)
  22615. }
  22616. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  22617. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  22618. var total float64
  22619. for _, item := range prescriptions {
  22620. if item.Type == 1 { //药品
  22621. for _, subItem := range item.HisDoctorAdviceInfo {
  22622. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  22623. total_one := price * subItem.PrescribingNumber
  22624. total = total + total_one
  22625. }
  22626. }
  22627. if item.Type == 2 { //项目
  22628. for _, subItem := range item.HisPrescriptionProject {
  22629. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  22630. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  22631. total_one := price * cnt
  22632. total = total + total_one
  22633. }
  22634. }
  22635. }
  22636. allTotal := fmt.Sprintf("%.2f", total)
  22637. //if adminUser.CurrentOrgId == 9919 {
  22638. //
  22639. // allTotal = fmt.Sprintf("%.2f", total)
  22640. //
  22641. //} else {
  22642. //
  22643. // allTotal = fmt.Sprintf("%.2f", total)
  22644. //
  22645. //}
  22646. if res.Infcode == 0 {
  22647. var rf []*ResultFive
  22648. json.Unmarshal([]byte(his.Iinfo), &rf)
  22649. chrg_bchno := chrg_bchno
  22650. cert_no := his.Certno
  22651. var insutypes []string
  22652. var insutype string
  22653. var is390 int = 0
  22654. var is310 int = 0
  22655. for _, item := range rf {
  22656. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  22657. insutypes = append(insutypes, item.Insutype)
  22658. }
  22659. }
  22660. if len(insutypes) == 1 {
  22661. insutype = insutypes[0]
  22662. } else {
  22663. for _, i := range insutypes {
  22664. if i == "390" {
  22665. is390 = 1
  22666. }
  22667. if i == "310" {
  22668. is310 = 1
  22669. }
  22670. }
  22671. }
  22672. if is390 == 1 {
  22673. insutype = "390"
  22674. }
  22675. if is310 == 1 {
  22676. insutype = "310"
  22677. }
  22678. if len(insutypes) == 0 {
  22679. insutype = "310"
  22680. }
  22681. if len(insutypes) == 2 {
  22682. insutype = strconv.FormatInt(his.SocialType, 10)
  22683. }
  22684. insutype = strconv.FormatInt(his.SocialType, 10)
  22685. //insutype = "390"
  22686. if his.IdCardType == 1 {
  22687. // cert_no = his.MedicalInsuranceNumber
  22688. cert_no = his.Certno
  22689. } else {
  22690. cert_no = his.Certno
  22691. }
  22692. var res ResultSeven
  22693. var resSeven10265 ResultSeven10265
  22694. var gzresSeven10265Two GZResultSeven10265Two
  22695. var src_resquest string
  22696. var result2 string
  22697. if miConfig.MdtrtareaAdmvs == "421300" {
  22698. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22699. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22700. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22701. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22702. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22703. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22704. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  22705. resp, requestErr := http.Get(api)
  22706. if requestErr != nil {
  22707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22708. return
  22709. }
  22710. body, ioErr := ioutil.ReadAll(resp.Body)
  22711. if ioErr != nil {
  22712. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22714. return
  22715. }
  22716. var respJSON map[string]interface{}
  22717. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22718. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22720. return
  22721. }
  22722. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22723. result, _ := json.Marshal(respJSON)
  22724. if miConfig.Code == "H15049901371" {
  22725. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  22726. utils.ErrorLog("解析失败:%v", err)
  22727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22728. return
  22729. }
  22730. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22731. res.Output = resSeven10265.Output
  22732. res.ErrMsg = resSeven10265.ErrMsg
  22733. res.Cainfo = resSeven10265.Cainfo
  22734. res.WarnMsg = resSeven10265.WarnMsg
  22735. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22736. res.Infcode = infocode
  22737. } else {
  22738. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22739. utils.ErrorLog("解析失败:%v", err)
  22740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22741. return
  22742. }
  22743. }
  22744. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22745. if reg_type == 11 && his.Insutype == "390" {
  22746. reg_type = 110104
  22747. }
  22748. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22749. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22750. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22751. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22752. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22753. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22754. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  22755. resp, requestErr := http.Get(api)
  22756. if requestErr != nil {
  22757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22758. return
  22759. }
  22760. body, ioErr := ioutil.ReadAll(resp.Body)
  22761. if ioErr != nil {
  22762. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22764. return
  22765. }
  22766. var respJSON map[string]interface{}
  22767. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22770. return
  22771. }
  22772. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22773. result, _ := json.Marshal(respJSON)
  22774. if miConfig.Code == "H15049901371" {
  22775. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  22776. utils.ErrorLog("解析失败:%v", err)
  22777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22778. return
  22779. }
  22780. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22781. res.Output = resSeven10265.Output
  22782. res.ErrMsg = resSeven10265.ErrMsg
  22783. res.Cainfo = resSeven10265.Cainfo
  22784. res.WarnMsg = resSeven10265.WarnMsg
  22785. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22786. res.Infcode = infocode
  22787. } else {
  22788. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22789. utils.ErrorLog("解析失败:%v", err)
  22790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22791. return
  22792. }
  22793. }
  22794. } else if miConfig.MdtrtareaAdmvs == "420902" {
  22795. if reg_type == 11 && his.Insutype == "390" {
  22796. reg_type = 110104
  22797. }
  22798. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22799. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22800. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22801. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22802. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22803. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22804. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  22805. resp, requestErr := http.Get(api)
  22806. if requestErr != nil {
  22807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22808. return
  22809. }
  22810. body, ioErr := ioutil.ReadAll(resp.Body)
  22811. if ioErr != nil {
  22812. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22814. return
  22815. }
  22816. var respJSON map[string]interface{}
  22817. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22818. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22820. return
  22821. }
  22822. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22823. result, _ := json.Marshal(respJSON)
  22824. if miConfig.Code == "H15049901371" {
  22825. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  22826. utils.ErrorLog("解析失败:%v", err)
  22827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22828. return
  22829. }
  22830. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22831. res.Output = resSeven10265.Output
  22832. res.ErrMsg = resSeven10265.ErrMsg
  22833. res.Cainfo = resSeven10265.Cainfo
  22834. res.WarnMsg = resSeven10265.WarnMsg
  22835. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22836. res.Infcode = infocode
  22837. } else {
  22838. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22839. utils.ErrorLog("解析失败:%v", err)
  22840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22841. return
  22842. }
  22843. }
  22844. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22845. if reg_type == 11 && his.Insutype == "390" {
  22846. reg_type = 110104
  22847. }
  22848. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22849. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22850. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22851. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22852. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22853. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22854. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  22855. resp, requestErr := http.Get(api)
  22856. if requestErr != nil {
  22857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22858. return
  22859. }
  22860. body, ioErr := ioutil.ReadAll(resp.Body)
  22861. if ioErr != nil {
  22862. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22864. return
  22865. }
  22866. var respJSON map[string]interface{}
  22867. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22868. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22870. return
  22871. }
  22872. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22873. result, _ := json.Marshal(respJSON)
  22874. if miConfig.Code == "H15049901371" {
  22875. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  22876. utils.ErrorLog("解析失败:%v", err)
  22877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22878. return
  22879. }
  22880. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22881. res.Output = resSeven10265.Output
  22882. res.ErrMsg = resSeven10265.ErrMsg
  22883. res.Cainfo = resSeven10265.Cainfo
  22884. res.WarnMsg = resSeven10265.WarnMsg
  22885. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22886. res.Infcode = infocode
  22887. } else {
  22888. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22889. utils.ErrorLog("解析失败:%v", err)
  22890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22891. return
  22892. }
  22893. }
  22894. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22895. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  22896. if result3101.Infcode == "0" {
  22897. if len(result3101.Output.Result) > 0 {
  22898. var errMsgs []string
  22899. for _, item := range result3101.Output.Result {
  22900. errMsgs = append(errMsgs, item.VolaCont)
  22901. }
  22902. c.ServeSuccessJSON(map[string]interface{}{
  22903. "failed_code": -10,
  22904. "msg": errMsgs,
  22905. })
  22906. return
  22907. } else {
  22908. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22909. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  22910. bas := strings.Split(psn_info.CardInfo, "|")
  22911. if his.IdCardType == 1 {
  22912. cert_no = bas[2]
  22913. } else if his.IdCardType == 3 {
  22914. cert_no = his.Certno
  22915. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  22916. } else if his.IdCardType == 4 {
  22917. cert_no = his.Certno
  22918. psn_info.VerifyNumber = psn_info.VerifyNumber
  22919. }
  22920. var api string
  22921. if miConfig.MdtrtareaAdmvs == "320921" {
  22922. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22923. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22924. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22925. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22926. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22927. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22928. "&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
  22929. } else {
  22930. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22931. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22932. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22933. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22934. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22935. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22936. "&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
  22937. }
  22938. resp, requestErr := http.Get(api)
  22939. if requestErr != nil {
  22940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22941. return
  22942. }
  22943. body, ioErr := ioutil.ReadAll(resp.Body)
  22944. if ioErr != nil {
  22945. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22947. return
  22948. }
  22949. var respJSON map[string]interface{}
  22950. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22953. return
  22954. }
  22955. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22956. result, _ := json.Marshal(respJSON)
  22957. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  22958. utils.ErrorLog("解析失败:%v", err)
  22959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22960. return
  22961. }
  22962. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22963. res.Output = resSeven10265.Output
  22964. res.ErrMsg = resSeven10265.ErrMsg
  22965. res.Cainfo = resSeven10265.Cainfo
  22966. res.WarnMsg = resSeven10265.WarnMsg
  22967. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22968. res.Infcode = infocode
  22969. }
  22970. }
  22971. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22972. psn_info, _ := service.GetPsnByPatientId(id)
  22973. var verify_number string
  22974. if psn_info.IdCardType == 4 {
  22975. verify_number = psn_info.VerifyNumber
  22976. } else if psn_info.IdCardType == 1 {
  22977. bas := strings.Split(psn_info.CardInfo, "|")
  22978. cardNumber := bas[2]
  22979. verify_number = cardNumber
  22980. } else {
  22981. psn_info.IdCardType = 2
  22982. verify_number = psn_info.Certno
  22983. }
  22984. var api string
  22985. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22986. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22987. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22988. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22989. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22990. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22991. "&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
  22992. resp, requestErr := http.Get(api)
  22993. if requestErr != nil {
  22994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22995. return
  22996. }
  22997. body, ioErr := ioutil.ReadAll(resp.Body)
  22998. if ioErr != nil {
  22999. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23001. return
  23002. }
  23003. var respJSON map[string]interface{}
  23004. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23005. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23007. return
  23008. }
  23009. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23010. result, _ := json.Marshal(respJSON)
  23011. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  23012. utils.ErrorLog("解析失败:%v", err)
  23013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23014. return
  23015. }
  23016. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23017. res.Output = resSeven10265.Output
  23018. res.ErrMsg = resSeven10265.ErrMsg
  23019. res.Cainfo = resSeven10265.Cainfo
  23020. res.WarnMsg = resSeven10265.WarnMsg
  23021. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23022. res.Infcode = infocode
  23023. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23024. var cert_no string
  23025. if his.IdCardType == 4 {
  23026. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23027. cert_no = psn_info.VerifyNumber
  23028. 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)
  23029. } else if his.IdCardType == 1 {
  23030. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23031. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  23032. 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)
  23033. }
  23034. //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)
  23035. var dat map[string]interface{}
  23036. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23037. fmt.Println(dat)
  23038. } else {
  23039. fmt.Println(err)
  23040. }
  23041. saveLog(result2, src_resquest, "2207", "结算")
  23042. userJSONBytes, _ := json.Marshal(dat)
  23043. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  23044. utils.ErrorLog("解析失败:%v", err)
  23045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23046. return
  23047. }
  23048. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23049. res.Output = resSeven10265.Output
  23050. res.ErrMsg = resSeven10265.ErrMsg
  23051. res.Cainfo = resSeven10265.Cainfo
  23052. res.WarnMsg = resSeven10265.WarnMsg
  23053. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23054. res.Infcode = infocode
  23055. } else if miConfig.MdtrtareaAdmvs == "450721" {
  23056. res2 := c.GetoleInfo()
  23057. if res2.Infcode == 0 {
  23058. var result string
  23059. var request_log string
  23060. var result_log string
  23061. if res2.Output.MdtrtCertType == "02" {
  23062. 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)
  23063. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  23064. } else if res2.Output.MdtrtCertType == "01" {
  23065. 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)
  23066. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  23067. } else {
  23068. 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)
  23069. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  23070. }
  23071. var dat map[string]interface{}
  23072. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23073. fmt.Println(dat)
  23074. } else {
  23075. fmt.Println(err)
  23076. }
  23077. userJSONBytes, _ := json.Marshal(dat)
  23078. var res5 ResultTwo
  23079. //var resTwo10265 ResultTwo10265
  23080. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  23081. utils.ErrorLog("解析失败:%v", err)
  23082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23083. return
  23084. }
  23085. if res5.Infcode == -1 {
  23086. c.ServeSuccessJSON(map[string]interface{}{
  23087. "failed_code": -10,
  23088. "msg": res5.ErrMsg,
  23089. })
  23090. return
  23091. }
  23092. var insutypes []string
  23093. var insutype string
  23094. var is390 int = 0
  23095. var is310 int = 0
  23096. for _, item := range res5.Output.Iinfo {
  23097. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23098. insutypes = append(insutypes, item.Insutype)
  23099. }
  23100. }
  23101. if len(insutypes) == 1 {
  23102. insutype = insutypes[0]
  23103. } else {
  23104. for _, i := range insutypes {
  23105. if i == "390" {
  23106. is390 = 1
  23107. }
  23108. if i == "310" {
  23109. is310 = 1
  23110. }
  23111. }
  23112. }
  23113. if is390 == 1 {
  23114. insutype = "390"
  23115. }
  23116. if is310 == 1 {
  23117. insutype = "310"
  23118. }
  23119. if len(insutypes) == 0 {
  23120. insutype = "310"
  23121. }
  23122. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  23123. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  23124. infoStr := string(Iinfos)
  23125. idetinfoStr := string(Idetinfos)
  23126. psn := &models.HisPsn{
  23127. PsnNo: res5.Output.Baseinfo.PsnNo,
  23128. PatientId: id,
  23129. Certno: res5.Output.Baseinfo.Certno,
  23130. Gend: res5.Output.Baseinfo.Gend,
  23131. Naty: res5.Output.Baseinfo.Naty,
  23132. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  23133. PsnName: res5.Output.Baseinfo.PsnName,
  23134. Idetinfo: idetinfoStr,
  23135. Insuinfo: infoStr,
  23136. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  23137. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  23138. VerifyNumber: res2.Output.EcToken,
  23139. }
  23140. if res2.Output.MdtrtCertType == "01" {
  23141. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23142. psn.VerifyNumber = res2.Output.EcToken
  23143. } else if res2.Output.MdtrtCertType == "02" {
  23144. psn.VerifyNumber = res2.Output.CardNo
  23145. } else {
  23146. psn.VerifyNumber = res2.Output.MdtrtCertNo
  23147. }
  23148. service.CreateHisPsn(psn)
  23149. if res2.Output.MdtrtCertType == "01" {
  23150. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23151. token := res2.Output.EcToken
  23152. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 4, acct_used_flag, token, admin_user_id)
  23153. } else if res2.Output.MdtrtCertType == "02" {
  23154. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 2, acct_used_flag, "", admin_user_id)
  23155. } else {
  23156. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 1, acct_used_flag, "", admin_user_id)
  23157. }
  23158. var dat2 map[string]interface{}
  23159. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  23160. fmt.Println(dat2)
  23161. } else {
  23162. fmt.Println(err)
  23163. }
  23164. userJSONBytes3, _ := json.Marshal(dat2)
  23165. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23166. utils.ErrorLog("解析失败:%v", err)
  23167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23168. return
  23169. }
  23170. saveLog(result2, src_resquest, "2207", "结算")
  23171. } else {
  23172. c.ServeSuccessJSON(map[string]interface{}{
  23173. "failed_code": -10,
  23174. "msg": res2.ErrMsg,
  23175. })
  23176. return
  23177. }
  23178. } else {
  23179. if miConfig.Code == "H15049901371" {
  23180. //赤峰地区国家医保医疗类别
  23181. //职工透析:医疗类别选特殊情况门诊990502
  23182. //居民定额血透门慢: 医疗类别选门诊慢病140104
  23183. var med_type string
  23184. if his.Insutype == "390" {
  23185. if reg_type == 14 {
  23186. med_type = "9933"
  23187. } else if reg_type == 11 {
  23188. med_type = "11"
  23189. }
  23190. } else if his.Insutype == "310" {
  23191. if reg_type == 14 {
  23192. med_type = "990502"
  23193. } else if reg_type == 11 {
  23194. med_type = "11"
  23195. }
  23196. }
  23197. 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)
  23198. } else {
  23199. if his.IdCardType == 4 {
  23200. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23201. var token string
  23202. token = psn_info.VerifyNumber
  23203. 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)
  23204. } else {
  23205. if his.IdCardType == 1 {
  23206. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23207. bas := strings.Split(psn_info.CardInfo, "|")
  23208. basNumber := bas[2]
  23209. cert_no = basNumber
  23210. }
  23211. 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)
  23212. }
  23213. }
  23214. //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)
  23215. var dat map[string]interface{}
  23216. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23217. fmt.Println(dat)
  23218. } else {
  23219. fmt.Println(err)
  23220. }
  23221. saveLog(result2, src_resquest, "2207", "结算")
  23222. userJSONBytes, _ := json.Marshal(dat)
  23223. if miConfig.Code == "H15049901371" {
  23224. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  23225. utils.ErrorLog("解析失败:%v", err)
  23226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23227. return
  23228. }
  23229. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23230. res.Output = resSeven10265.Output
  23231. res.ErrMsg = resSeven10265.ErrMsg
  23232. res.Cainfo = resSeven10265.Cainfo
  23233. res.WarnMsg = resSeven10265.WarnMsg
  23234. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23235. res.Infcode = infocode
  23236. } else {
  23237. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23238. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  23239. utils.ErrorLog("解析失败:%v", err)
  23240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23241. return
  23242. }
  23243. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  23244. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  23245. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  23246. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  23247. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  23248. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  23249. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  23250. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  23251. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  23252. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23253. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23254. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23255. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23256. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  23257. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  23258. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  23259. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  23260. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  23261. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  23262. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  23263. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23264. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  23265. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  23266. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  23267. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  23268. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  23269. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  23270. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  23271. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  23272. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  23273. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  23274. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  23275. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  23276. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  23277. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  23278. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  23279. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  23280. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  23281. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23282. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  23283. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  23284. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  23285. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  23286. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  23287. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  23288. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  23289. res.ErrMsg = gzresSeven10265Two.ErrMsg
  23290. res.Cainfo = gzresSeven10265Two.Cainfo
  23291. res.WarnMsg = gzresSeven10265Two.WarnMsg
  23292. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  23293. //res.Infcode = infocode
  23294. } else {
  23295. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23296. utils.ErrorLog("解析失败:%v", err)
  23297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23298. return
  23299. }
  23300. }
  23301. }
  23302. }
  23303. if res.Infcode == -1 {
  23304. errlog := &models.HisOrderError{
  23305. UserOrgId: adminUser.CurrentOrgId,
  23306. Ctime: time.Now().Unix(),
  23307. Mtime: time.Now().Unix(),
  23308. Number: chrg_bchno,
  23309. ErrMsg: res.ErrMsg,
  23310. Status: 1,
  23311. PatientId: id,
  23312. RecordTime: recordDateTime,
  23313. Stage: 6,
  23314. }
  23315. service.CreateErrMsgLog(errlog)
  23316. c.ServeSuccessJSON(map[string]interface{}{
  23317. "failed_code": -10,
  23318. "msg": res.ErrMsg,
  23319. })
  23320. return
  23321. } else {
  23322. sickConfig, _ := service.FindSickById(his.SickType)
  23323. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  23324. order.OrderStatus = 2
  23325. order.Status = 1
  23326. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  23327. order.SetlId = res.Output.Setlinfo.SetlID
  23328. order.PsnNo = res.Output.Setlinfo.PsnNo
  23329. order.PsnName = res.Output.Setlinfo.PsnName
  23330. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  23331. order.Certno = res.Output.Setlinfo.Certno
  23332. order.Gend = res.Output.Setlinfo.Gend
  23333. order.Naty = res.Output.Setlinfo.Naty
  23334. order.Age = res.Output.Setlinfo.Age
  23335. order.Insutype = res.Output.Setlinfo.Insutype
  23336. order.PsnType = res.Output.Setlinfo.PsnType
  23337. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  23338. order.SetlTime = res.Output.Setlinfo.SetlTime
  23339. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  23340. if res.Output.Setlinfo.MedType == "140101" {
  23341. order.MedType = "14"
  23342. } else {
  23343. if res.Output.Setlinfo.MedType == "110104" {
  23344. order.MedType = "11"
  23345. } else {
  23346. order.MedType = res.Output.Setlinfo.MedType
  23347. }
  23348. }
  23349. if reg_type == 1112 {
  23350. order.MedType = "1112"
  23351. }
  23352. if reg_type == 1111 {
  23353. order.MedType = "1111"
  23354. }
  23355. order.ClrType = res.Output.Setlinfo.ClrType
  23356. if adminUser.CurrentOrgId == 10480 {
  23357. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  23358. order.ClrType = "11"
  23359. } else {
  23360. order.ClrType = "9903"
  23361. }
  23362. }
  23363. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  23364. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  23365. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  23366. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  23367. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  23368. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  23369. order.HifpPay = res.Output.Setlinfo.HifpPay
  23370. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  23371. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  23372. order.HifesPay = res.Output.Setlinfo.HifesPay
  23373. order.HifobPay = res.Output.Setlinfo.HifobPay
  23374. order.MafPay = res.Output.Setlinfo.MafPay
  23375. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  23376. order.OthPay = res.Output.Setlinfo.OthPay
  23377. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  23378. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  23379. order.AcctPay = res.Output.Setlinfo.AcctPay
  23380. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  23381. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  23382. order.Balc = res.Output.Setlinfo.Balc
  23383. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  23384. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  23385. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  23386. //order.ClrType = res.Output.Setlinfo.ClrType
  23387. order.ClrWay = res.Output.Setlinfo.ClrWay
  23388. order.Creator = order.Creator
  23389. order.Modify = roles.AdminUserId
  23390. order.RequestLog = src_resquest
  23391. order.FaPiaoNumber = fapiao_number
  23392. order.FaPiaoCode = fapiao_code
  23393. order.SickName = sickConfig.ClassName
  23394. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  23395. //detailStr := string(setlDetail)
  23396. //order.SetlDetail = detailStr
  23397. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  23398. err = service.UpDateOrder(order)
  23399. if err == nil {
  23400. //判断是否使用了押金
  23401. if dec_way == "true" {
  23402. tmpstring := strconv.FormatInt(order.ID, 10)
  23403. order.Decimal = decimal
  23404. service.UpDateOrder(order)
  23405. //扣押金
  23406. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  23407. if errmsg != nil {
  23408. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  23409. return
  23410. }
  23411. }
  23412. c.ServeSuccessJSON(map[string]interface{}{
  23413. "msg": "结算成功",
  23414. })
  23415. } else {
  23416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  23417. return
  23418. }
  23419. }
  23420. } else {
  23421. adminUser := c.GetAdminUserInfo()
  23422. errlog := &models.HisOrderError{
  23423. UserOrgId: adminUser.CurrentOrgId,
  23424. Ctime: time.Now().Unix(),
  23425. Mtime: time.Now().Unix(),
  23426. ErrMsg: res.ErrMsg,
  23427. Status: 1,
  23428. PatientId: id,
  23429. RecordTime: recordDateTime,
  23430. Stage: 4,
  23431. }
  23432. service.CreateErrMsgLog(errlog)
  23433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  23434. return
  23435. }
  23436. } else {
  23437. adminUser := c.GetAdminUserInfo()
  23438. errlog := &models.HisOrderError{
  23439. UserOrgId: adminUser.CurrentOrgId,
  23440. Ctime: time.Now().Unix(),
  23441. Mtime: time.Now().Unix(),
  23442. ErrMsg: res.ErrMsg,
  23443. Status: 1,
  23444. PatientId: id,
  23445. RecordTime: recordDateTime,
  23446. Stage: 4,
  23447. }
  23448. service.CreateErrMsgLog(errlog)
  23449. c.ServeSuccessJSON(map[string]interface{}{
  23450. "failed_code": -10,
  23451. "msg": res.ErrMsg,
  23452. })
  23453. return
  23454. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  23455. //return
  23456. }
  23457. }
  23458. }
  23459. } else if tempOrder.ID > 0 {
  23460. if tempOrder.IsPre == 1 {
  23461. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  23462. var rf []*ResultFive
  23463. json.Unmarshal([]byte(his.Iinfo), &rf)
  23464. chrg_bchno := tempOrder.Number
  23465. cert_no := his.Certno
  23466. var insutypes []string
  23467. var insutype string
  23468. var is390 int = 0
  23469. var is310 int = 0
  23470. for _, item := range rf {
  23471. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23472. insutypes = append(insutypes, item.Insutype)
  23473. }
  23474. }
  23475. if len(insutypes) == 1 {
  23476. insutype = insutypes[0]
  23477. } else {
  23478. for _, i := range insutypes {
  23479. if i == "390" {
  23480. is390 = 1
  23481. }
  23482. if i == "310" {
  23483. is310 = 1
  23484. }
  23485. }
  23486. }
  23487. if is390 == 1 {
  23488. insutype = "390"
  23489. }
  23490. if is310 == 1 {
  23491. insutype = "310"
  23492. }
  23493. if len(insutypes) == 0 {
  23494. insutype = "310"
  23495. }
  23496. if len(insutypes) == 2 {
  23497. insutype = strconv.FormatInt(his.SocialType, 10)
  23498. }
  23499. //insutype = "390"
  23500. if his.IdCardType == 1 {
  23501. // cert_no = his.MedicalInsuranceNumber
  23502. cert_no = his.Certno
  23503. } else {
  23504. cert_no = his.Certno
  23505. }
  23506. var res ResultSeven
  23507. var ahres ResultSevenAH
  23508. var resSeven10265 ResultSeven10265
  23509. var gzresSeven10265Two GZResultSeven10265Two
  23510. var src_resquest string
  23511. var result2 string
  23512. if miConfig.MdtrtareaAdmvs == "450721" {
  23513. res2 := c.GetoleInfo()
  23514. if res2.Infcode == 0 {
  23515. var result string
  23516. var request_log string
  23517. var result_log string
  23518. if res2.Output.MdtrtCertType == "02" {
  23519. 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)
  23520. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  23521. } else if res2.Output.MdtrtCertType == "01" {
  23522. 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)
  23523. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  23524. } else {
  23525. 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)
  23526. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  23527. }
  23528. var dat map[string]interface{}
  23529. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23530. fmt.Println(dat)
  23531. } else {
  23532. fmt.Println(err)
  23533. }
  23534. userJSONBytes, _ := json.Marshal(dat)
  23535. var res5 ResultTwo
  23536. //var resTwo10265 ResultTwo10265
  23537. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  23538. utils.ErrorLog("解析失败:%v", err)
  23539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23540. return
  23541. }
  23542. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  23543. if res5.Infcode == -1 {
  23544. c.ServeSuccessJSON(map[string]interface{}{
  23545. "failed_code": -10,
  23546. "msg": res5.ErrMsg,
  23547. })
  23548. return
  23549. }
  23550. var insutypes []string
  23551. var insutype string
  23552. var is390 int = 0
  23553. var is310 int = 0
  23554. for _, item := range res5.Output.Iinfo {
  23555. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23556. insutypes = append(insutypes, item.Insutype)
  23557. }
  23558. }
  23559. if len(insutypes) == 1 {
  23560. insutype = insutypes[0]
  23561. } else {
  23562. for _, i := range insutypes {
  23563. if i == "390" {
  23564. is390 = 1
  23565. }
  23566. if i == "310" {
  23567. is310 = 1
  23568. }
  23569. }
  23570. }
  23571. if is390 == 1 {
  23572. insutype = "390"
  23573. }
  23574. if is310 == 1 {
  23575. insutype = "310"
  23576. }
  23577. if len(insutypes) == 0 {
  23578. insutype = "310"
  23579. }
  23580. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  23581. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  23582. infoStr := string(Iinfos)
  23583. idetinfoStr := string(Idetinfos)
  23584. psn := &models.HisPsn{
  23585. PsnNo: res5.Output.Baseinfo.PsnNo,
  23586. PatientId: id,
  23587. Certno: res5.Output.Baseinfo.Certno,
  23588. Gend: res5.Output.Baseinfo.Gend,
  23589. Naty: res5.Output.Baseinfo.Naty,
  23590. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  23591. PsnName: res5.Output.Baseinfo.PsnName,
  23592. Idetinfo: idetinfoStr,
  23593. Insuinfo: infoStr,
  23594. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  23595. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  23596. VerifyNumber: res2.Output.EcToken,
  23597. }
  23598. service.CreateHisPsn(psn)
  23599. if res2.Output.MdtrtCertType == "01" {
  23600. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23601. token := res2.Output.EcToken
  23602. 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)
  23603. } else if res2.Output.MdtrtCertType == "02" {
  23604. 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)
  23605. } else {
  23606. 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)
  23607. }
  23608. var dat2 map[string]interface{}
  23609. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  23610. fmt.Println(dat2)
  23611. } else {
  23612. fmt.Println(err)
  23613. }
  23614. userJSONBytes3, _ := json.Marshal(dat2)
  23615. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23616. utils.ErrorLog("解析失败:%v", err)
  23617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23618. return
  23619. }
  23620. saveLog(result2, src_resquest, "2207", "结算")
  23621. } else {
  23622. c.ServeSuccessJSON(map[string]interface{}{
  23623. "failed_code": -10,
  23624. "msg": res2.ErrMsg,
  23625. })
  23626. return
  23627. }
  23628. } else if miConfig.MdtrtareaAdmvs == "421300" {
  23629. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23630. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23631. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23632. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23633. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23634. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23635. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  23636. resp, requestErr := http.Get(api)
  23637. if requestErr != nil {
  23638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23639. return
  23640. }
  23641. body, ioErr := ioutil.ReadAll(resp.Body)
  23642. if ioErr != nil {
  23643. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23645. return
  23646. }
  23647. var respJSON map[string]interface{}
  23648. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23649. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23651. return
  23652. }
  23653. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23654. result, _ := json.Marshal(respJSON)
  23655. fmt.Println("log")
  23656. fmt.Println(string(result))
  23657. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23658. utils.ErrorLog("解析失败:%v", err)
  23659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23660. return
  23661. }
  23662. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23663. if reg_type == 11 && his.Insutype == "390" {
  23664. reg_type = 110104
  23665. }
  23666. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23667. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23668. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23669. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23670. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23671. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23672. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  23673. resp, requestErr := http.Get(api)
  23674. if requestErr != nil {
  23675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23676. return
  23677. }
  23678. body, ioErr := ioutil.ReadAll(resp.Body)
  23679. if ioErr != nil {
  23680. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23682. return
  23683. }
  23684. var respJSON map[string]interface{}
  23685. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23686. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23688. return
  23689. }
  23690. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23691. result, _ := json.Marshal(respJSON)
  23692. fmt.Println("log")
  23693. fmt.Println(string(result))
  23694. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23695. utils.ErrorLog("解析失败:%v", err)
  23696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23697. return
  23698. }
  23699. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23700. if reg_type == 11 && his.Insutype == "390" {
  23701. reg_type = 110104
  23702. }
  23703. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23704. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23705. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23706. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23707. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23708. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23709. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  23710. resp, requestErr := http.Get(api)
  23711. if requestErr != nil {
  23712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23713. return
  23714. }
  23715. body, ioErr := ioutil.ReadAll(resp.Body)
  23716. if ioErr != nil {
  23717. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23719. return
  23720. }
  23721. var respJSON map[string]interface{}
  23722. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23723. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23725. return
  23726. }
  23727. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23728. result, _ := json.Marshal(respJSON)
  23729. fmt.Println("log")
  23730. fmt.Println(string(result))
  23731. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23732. utils.ErrorLog("解析失败:%v", err)
  23733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23734. return
  23735. }
  23736. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23737. if reg_type == 11 && his.Insutype == "390" {
  23738. reg_type = 110104
  23739. }
  23740. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23741. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23742. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23743. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23744. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23745. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23746. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  23747. resp, requestErr := http.Get(api)
  23748. if requestErr != nil {
  23749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23750. return
  23751. }
  23752. body, ioErr := ioutil.ReadAll(resp.Body)
  23753. if ioErr != nil {
  23754. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23756. return
  23757. }
  23758. var respJSON map[string]interface{}
  23759. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23760. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23762. return
  23763. }
  23764. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23765. result, _ := json.Marshal(respJSON)
  23766. fmt.Println("log")
  23767. fmt.Println(string(result))
  23768. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23769. utils.ErrorLog("解析失败:%v", err)
  23770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23771. return
  23772. }
  23773. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23774. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  23775. if result3101.Infcode == "0" {
  23776. if len(result3101.Output.Result) > 0 {
  23777. var errMsgs []string
  23778. for _, item := range result3101.Output.Result {
  23779. errMsgs = append(errMsgs, item.VolaCont)
  23780. }
  23781. c.ServeSuccessJSON(map[string]interface{}{
  23782. "failed_code": -10,
  23783. "msg": errMsgs,
  23784. })
  23785. return
  23786. } else {
  23787. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23788. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23789. bas := strings.Split(psn_info.CardInfo, "|")
  23790. if his.IdCardType == 1 {
  23791. cert_no = bas[2]
  23792. } else if his.IdCardType == 3 {
  23793. cert_no = his.Certno
  23794. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  23795. } else if his.IdCardType == 4 {
  23796. cert_no = his.Certno
  23797. psn_info.VerifyNumber = psn_info.VerifyNumber
  23798. }
  23799. //江苏地区国家医保医疗类别
  23800. //职工透析:医疗类别选特殊情况门诊9933
  23801. //居民血透门慢: 医疗类别选门诊慢病1402
  23802. //var med_type string
  23803. //if his.Insutype == "310" {
  23804. // if reg_type == 14 {
  23805. // med_type = "9933"
  23806. // } else if reg_type == 11 {
  23807. // med_type = "11"
  23808. //
  23809. // }
  23810. //} else if his.Insutype == "390" {
  23811. // if reg_type == 14 {
  23812. // med_type = "1402"
  23813. // } else if reg_type == 11 {
  23814. // med_type = "11"
  23815. // }
  23816. //}
  23817. var api string
  23818. if miConfig.MdtrtareaAdmvs == "320921" {
  23819. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23820. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23821. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23822. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23823. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23824. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23825. "&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
  23826. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23827. } else {
  23828. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23829. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23830. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23831. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23832. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23833. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23834. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23835. "&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
  23836. }
  23837. resp, requestErr := http.Get(api)
  23838. if requestErr != nil {
  23839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23840. return
  23841. }
  23842. body, ioErr := ioutil.ReadAll(resp.Body)
  23843. if ioErr != nil {
  23844. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23846. return
  23847. }
  23848. var respJSON map[string]interface{}
  23849. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23850. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23852. return
  23853. }
  23854. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23855. result, _ := json.Marshal(respJSON)
  23856. fmt.Println("log")
  23857. fmt.Println(string(result))
  23858. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  23859. utils.ErrorLog("解析失败:%v", err)
  23860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23861. return
  23862. }
  23863. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23864. res.Output = resSeven10265.Output
  23865. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23866. res.ErrMsg = resSeven10265.ErrMsg
  23867. res.Cainfo = resSeven10265.Cainfo
  23868. res.WarnMsg = resSeven10265.WarnMsg
  23869. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23870. res.Infcode = infocode
  23871. }
  23872. }
  23873. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23874. psn_info, _ := service.GetPsnByPatientId(id)
  23875. var verify_number string
  23876. if psn_info.IdCardType == 4 {
  23877. verify_number = psn_info.VerifyNumber
  23878. } else if psn_info.IdCardType == 1 {
  23879. bas := strings.Split(psn_info.CardInfo, "|")
  23880. cardNumber := bas[2]
  23881. verify_number = cardNumber
  23882. } else {
  23883. verify_number = psn_info.Certno
  23884. psn_info.IdCardType = 2
  23885. }
  23886. var api string
  23887. new_chrg_bchno := chrg_bchno
  23888. if adminUser.CurrentOrgId == 10265 {
  23889. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  23890. new_chrg_bchno = "0000"
  23891. }
  23892. }
  23893. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23894. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  23895. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23896. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23897. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  23898. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23899. "&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
  23900. resp, requestErr := http.Get(api)
  23901. if requestErr != nil {
  23902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23903. return
  23904. }
  23905. body, ioErr := ioutil.ReadAll(resp.Body)
  23906. if ioErr != nil {
  23907. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23909. return
  23910. }
  23911. var respJSON map[string]interface{}
  23912. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23913. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23915. return
  23916. }
  23917. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23918. result, _ := json.Marshal(respJSON)
  23919. fmt.Println("log")
  23920. fmt.Println(string(result))
  23921. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  23922. utils.ErrorLog("解析失败:%v", err)
  23923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23924. return
  23925. }
  23926. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23927. res.Output = resSeven10265.Output
  23928. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23929. res.ErrMsg = resSeven10265.ErrMsg
  23930. res.Cainfo = resSeven10265.Cainfo
  23931. res.WarnMsg = resSeven10265.WarnMsg
  23932. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23933. res.Infcode = infocode
  23934. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23935. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23936. var cert_no string
  23937. if his.IdCardType == 1 {
  23938. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  23939. } else {
  23940. cert_no = psn_info.VerifyNumber
  23941. }
  23942. 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)
  23943. var dat map[string]interface{}
  23944. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23945. fmt.Println(dat)
  23946. } else {
  23947. fmt.Println(err)
  23948. }
  23949. saveLog(result2, src_resquest, "2207", "结算")
  23950. userJSONBytes, _ := json.Marshal(dat)
  23951. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23952. utils.ErrorLog("解析失败:%v", err)
  23953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23954. return
  23955. }
  23956. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23957. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23958. var cert_no string
  23959. var card_sn string
  23960. if his.IdCardType == 1 {
  23961. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  23962. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23963. bas := strings.Split(psn_info.CardInfo, "|")
  23964. card_sn = bas[3]
  23965. } else if his.IdCardType == 2 {
  23966. cert_no = his.IdCardNo
  23967. } else {
  23968. cert_no = psn_info.VerifyNumber
  23969. }
  23970. var rf []*ResultFive
  23971. json.Unmarshal([]byte(his.Iinfo), &rf)
  23972. var psn_type string
  23973. for _, item := range rf {
  23974. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  23975. psn_type = item.PsnType
  23976. }
  23977. }
  23978. 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)
  23979. var dat map[string]interface{}
  23980. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23981. fmt.Println(dat)
  23982. } else {
  23983. fmt.Println(err)
  23984. }
  23985. saveLog(result2, src_resquest, "2207", "结算")
  23986. userJSONBytes, _ := json.Marshal(dat)
  23987. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23988. utils.ErrorLog("解析失败:%v", err)
  23989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23990. return
  23991. }
  23992. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23993. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23994. if his.IdCardType == 1 {
  23995. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23996. bas := strings.Split(psn_info.CardInfo, "|")
  23997. cert_no = bas[2]
  23998. } else if his.IdCardType == 3 {
  23999. cert_no = his.Certno
  24000. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  24001. } else if his.IdCardType == 4 {
  24002. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24003. cert_no = his.Certno
  24004. psn_info.VerifyNumber = psn_info.VerifyNumber
  24005. } else {
  24006. cert_no = his.Certno
  24007. psn_info.VerifyNumber = his.Certno
  24008. }
  24009. var api string
  24010. var med_type string
  24011. if his.Insutype == "390" {
  24012. if reg_type == 992102 {
  24013. med_type = "992102"
  24014. }
  24015. if reg_type == 140104 {
  24016. med_type = "140104"
  24017. }
  24018. if reg_type == 14 {
  24019. med_type = "14"
  24020. }
  24021. } else if his.Insutype == "310" {
  24022. if reg_type == 992102 {
  24023. med_type = "992102"
  24024. }
  24025. if reg_type == 14 {
  24026. med_type = "14"
  24027. }
  24028. }
  24029. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24030. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24031. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24032. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24033. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24034. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24035. "&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
  24036. resp, requestErr := http.Get(api)
  24037. if requestErr != nil {
  24038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24039. return
  24040. }
  24041. body, ioErr := ioutil.ReadAll(resp.Body)
  24042. if ioErr != nil {
  24043. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24045. return
  24046. }
  24047. var respJSON map[string]interface{}
  24048. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24049. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24051. return
  24052. }
  24053. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24054. if status == "0" {
  24055. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24056. c.ServeSuccessJSON(map[string]interface{}{
  24057. "failed_code": -10,
  24058. "msg": err_msg,
  24059. })
  24060. return
  24061. }
  24062. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24063. result, _ := json.Marshal(respJSON)
  24064. fmt.Println("log")
  24065. fmt.Println(string(result))
  24066. if err := json.Unmarshal(result, &ahres); err != nil {
  24067. utils.ErrorLog("解析失败:%v", err)
  24068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24069. return
  24070. }
  24071. res.InfRefmsgid = ahres.InfRefmsgid
  24072. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  24073. // 创建对应的Time类型
  24074. t := time.UnixMilli(timestamp)
  24075. // 格式化成指定的日期字符串
  24076. str := t.Format("2006-01-02 15:04:05")
  24077. res.Output.Setlinfo.SetlTime = str
  24078. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  24079. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  24080. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  24081. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  24082. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  24083. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  24084. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  24085. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  24086. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  24087. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  24088. res.Output.Setlinfo.ClrType = "11"
  24089. } else {
  24090. res.Output.Setlinfo.ClrType = "9903"
  24091. }
  24092. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  24093. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  24094. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  24095. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  24096. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  24097. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  24098. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  24099. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  24100. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  24101. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  24102. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  24103. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  24104. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  24105. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  24106. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  24107. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  24108. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  24109. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  24110. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  24111. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  24112. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  24113. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  24114. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  24115. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  24116. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  24117. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  24118. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  24119. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  24120. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  24121. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  24122. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  24123. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  24124. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  24125. res.Output.Setldetail = ahres.Output.Setldetail
  24126. res.ErrMsg = ahres.ErrMsg
  24127. res.Cainfo = ahres.Cainfo
  24128. res.WarnMsg = ahres.WarnMsg
  24129. res.Infcode = ahres.Infcode
  24130. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24131. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24132. var cert_no string
  24133. if his.IdCardType == 1 {
  24134. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  24135. } else if his.IdCardType == 2 {
  24136. cert_no = his.IdCardNo
  24137. } else {
  24138. cert_no = psn_info.VerifyNumber
  24139. }
  24140. 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, "")
  24141. var dat map[string]interface{}
  24142. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24143. fmt.Println(dat)
  24144. } else {
  24145. fmt.Println(err)
  24146. }
  24147. saveLog(result2, src_resquest, "2207", "结算")
  24148. userJSONBytes, _ := json.Marshal(dat)
  24149. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24150. utils.ErrorLog("解析失败:%v", err)
  24151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24152. return
  24153. }
  24154. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24155. psn_info, _ := service.GetPsnByPatientId(id)
  24156. var verify_number string
  24157. if psn_info.IdCardType == 4 {
  24158. verify_number = psn_info.VerifyNumber
  24159. } else if psn_info.IdCardType == 1 {
  24160. bas := strings.Split(psn_info.CardInfo, "|")
  24161. cardNumber := bas[2]
  24162. verify_number = cardNumber
  24163. } else {
  24164. verify_number = psn_info.Certno
  24165. psn_info.IdCardType = 2
  24166. }
  24167. var api string
  24168. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24169. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24170. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24171. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24172. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  24173. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24174. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  24175. resp, requestErr := http.Get(api)
  24176. if requestErr != nil {
  24177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24178. return
  24179. }
  24180. body, ioErr := ioutil.ReadAll(resp.Body)
  24181. if ioErr != nil {
  24182. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24184. return
  24185. }
  24186. var respJSON map[string]interface{}
  24187. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24188. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24190. return
  24191. }
  24192. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24193. result, _ := json.Marshal(respJSON)
  24194. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24195. utils.ErrorLog("解析失败:%v", err)
  24196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24197. return
  24198. }
  24199. } else {
  24200. var src_resquest string
  24201. if miConfig.Code == "H15049901371" {
  24202. //赤峰地区国家医保医疗类别
  24203. //职工透析:医疗类别选特殊情况门诊990502
  24204. //居民定额血透门慢: 医疗类别选门诊慢病140104
  24205. var med_type string
  24206. if his.Insutype == "390" {
  24207. if reg_type == 14 {
  24208. med_type = "9933"
  24209. } else if reg_type == 11 {
  24210. med_type = "11"
  24211. }
  24212. } else if his.Insutype == "310" {
  24213. if reg_type == 14 {
  24214. med_type = "990502"
  24215. } else if reg_type == 11 {
  24216. med_type = "11"
  24217. }
  24218. }
  24219. 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)
  24220. } else {
  24221. if his.IdCardType == 4 {
  24222. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24223. token := psn_info.VerifyNumber
  24224. 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)
  24225. } else {
  24226. 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)
  24227. }
  24228. }
  24229. var dat map[string]interface{}
  24230. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24231. fmt.Println(dat)
  24232. } else {
  24233. fmt.Println(err)
  24234. }
  24235. saveLog(result2, src_resquest, "2207", "结算")
  24236. userJSONBytes, _ := json.Marshal(dat)
  24237. if miConfig.Code == "H15049901371" {
  24238. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  24239. utils.ErrorLog("解析失败:%v", err)
  24240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24241. return
  24242. }
  24243. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24244. res.Output = resSeven10265.Output
  24245. res.ErrMsg = resSeven10265.ErrMsg
  24246. res.Cainfo = resSeven10265.Cainfo
  24247. res.WarnMsg = resSeven10265.WarnMsg
  24248. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24249. res.Infcode = infocode
  24250. } else {
  24251. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24252. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  24253. utils.ErrorLog("解析失败:%v", err)
  24254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24255. return
  24256. }
  24257. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  24258. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  24259. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  24260. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  24261. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  24262. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  24263. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  24264. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  24265. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  24266. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24267. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24268. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24269. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24270. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  24271. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  24272. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  24273. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  24274. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  24275. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  24276. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  24277. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  24278. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  24279. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  24280. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  24281. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  24282. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  24283. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  24284. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  24285. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  24286. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  24287. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  24288. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  24289. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  24290. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  24291. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  24292. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  24293. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  24294. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  24295. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24296. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  24297. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  24298. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  24299. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  24300. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  24301. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  24302. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  24303. res.ErrMsg = gzresSeven10265Two.ErrMsg
  24304. res.Cainfo = gzresSeven10265Two.Cainfo
  24305. res.WarnMsg = gzresSeven10265Two.WarnMsg
  24306. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  24307. //res.Infcode = infocode
  24308. } else {
  24309. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24310. utils.ErrorLog("解析失败:%v", err)
  24311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24312. return
  24313. }
  24314. }
  24315. }
  24316. }
  24317. if res.Infcode == -1 {
  24318. errlog := &models.HisOrderError{
  24319. UserOrgId: adminUser.CurrentOrgId,
  24320. Ctime: time.Now().Unix(),
  24321. Mtime: time.Now().Unix(),
  24322. Number: chrg_bchno,
  24323. ErrMsg: res.ErrMsg,
  24324. Status: 1,
  24325. PatientId: id,
  24326. RecordTime: recordDateTime,
  24327. Stage: 6,
  24328. }
  24329. service.CreateErrMsgLog(errlog)
  24330. c.ServeSuccessJSON(map[string]interface{}{
  24331. "failed_code": -10,
  24332. "msg": res.ErrMsg,
  24333. })
  24334. return
  24335. } else {
  24336. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  24337. order.OrderStatus = 2
  24338. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  24339. order.SetlId = res.Output.Setlinfo.SetlID
  24340. order.PsnNo = res.Output.Setlinfo.PsnNo
  24341. order.PsnName = res.Output.Setlinfo.PsnName
  24342. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  24343. order.Certno = res.Output.Setlinfo.Certno
  24344. order.Gend = res.Output.Setlinfo.Gend
  24345. order.Naty = res.Output.Setlinfo.Naty
  24346. order.Age = res.Output.Setlinfo.Age
  24347. order.Insutype = res.Output.Setlinfo.Insutype
  24348. order.PsnType = res.Output.Setlinfo.PsnType
  24349. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  24350. order.SetlTime = res.Output.Setlinfo.SetlTime
  24351. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  24352. order.PayWays = pay_ways
  24353. order.AcctUsedFlag = acct_used_flag
  24354. order.WechatPay = wechat_pay
  24355. order.AliPay = ali_pay
  24356. order.JifenPay = jifen_pay
  24357. order.BandCardPay = band_card_pay
  24358. order.CashPay = cash_pay
  24359. order.OthDesc = oth_desc
  24360. //order.MedType = res.Output.Setlinfo.MedType
  24361. if reg_type == 1112 {
  24362. order.MedType = "1112"
  24363. }
  24364. if reg_type == 1111 {
  24365. order.MedType = "1111"
  24366. }
  24367. order.ClrType = res.Output.Setlinfo.ClrType
  24368. if adminUser.CurrentOrgId == 10480 {
  24369. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  24370. order.ClrType = "11"
  24371. } else {
  24372. order.ClrType = "9903"
  24373. }
  24374. }
  24375. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  24376. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  24377. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  24378. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  24379. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  24380. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  24381. order.HifpPay = res.Output.Setlinfo.HifpPay
  24382. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  24383. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  24384. order.HifesPay = res.Output.Setlinfo.HifesPay
  24385. order.HifobPay = res.Output.Setlinfo.HifobPay
  24386. order.MafPay = res.Output.Setlinfo.MafPay
  24387. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  24388. order.OthPay = res.Output.Setlinfo.OthPay
  24389. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  24390. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  24391. order.AcctPay = res.Output.Setlinfo.AcctPay
  24392. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  24393. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  24394. order.Balc = res.Output.Setlinfo.Balc
  24395. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  24396. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  24397. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  24398. order.ClrWay = res.Output.Setlinfo.ClrWay
  24399. order.Creator = order.Creator
  24400. order.Modify = roles.AdminUserId
  24401. order.RequestLog = src_resquest
  24402. order.Diagnosis = diagnosis_id
  24403. order.FaPiaoNumber = fapiao_number
  24404. order.FaPiaoCode = fapiao_code
  24405. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  24406. detailStr := string(setlDetail)
  24407. order.SetlDetail = detailStr
  24408. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  24409. err = service.UpDateOrder(order)
  24410. if err == nil {
  24411. //判断是否使用了押金
  24412. if dec_way == "true" {
  24413. tmpstring := strconv.FormatInt(order.ID, 10)
  24414. //扣押金
  24415. order.Decimal = decimal
  24416. service.UpDateOrder(order)
  24417. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  24418. if errmsg != nil {
  24419. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  24420. return
  24421. }
  24422. }
  24423. c.ServeSuccessJSON(map[string]interface{}{
  24424. "msg": "结算成功",
  24425. })
  24426. } else {
  24427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  24428. return
  24429. }
  24430. }
  24431. }
  24432. }
  24433. }
  24434. // 上传明细-预结算-
  24435. func (c *HisApiController) GetPreUploadInfo() {
  24436. id, _ := c.GetInt64("id")
  24437. record_time := c.GetString("record_time")
  24438. his_patient_id, _ := c.GetInt64("his_patient_id")
  24439. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  24440. admin_user_id, _ := c.GetInt64("admin_user_id")
  24441. diagnosis_id := c.GetString("diagnosis")
  24442. sick_type, _ := c.GetInt64("sick_type")
  24443. reg_type, _ := c.GetInt64("p_type")
  24444. begin_time := c.GetString("begin_time")
  24445. acct_used_flag := c.GetString("acct_used_flag")
  24446. id_str := c.GetString("ids")
  24447. ids_arr := strings.Split(id_str, ",")
  24448. timeLayout := "2006-01-02"
  24449. loc, _ := time.LoadLocation("Local")
  24450. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24451. if err != nil {
  24452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24453. return
  24454. }
  24455. recordDateTime := theTime.Unix()
  24456. adminUser := c.GetAdminUserInfo()
  24457. diagnosis_ids := strings.Split(diagnosis_id, ",")
  24458. var config []*models.HisXtDiagnoseConfig
  24459. for _, item := range diagnosis_ids {
  24460. id, _ := strconv.ParseInt(item, 10, 64)
  24461. diagnosisConfig, _ := service.FindDiagnoseById(id)
  24462. config = append(config, &diagnosisConfig)
  24463. }
  24464. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  24465. sickConfig, _ := service.FindSickById(sick_type)
  24466. var prescriptions []*models.HisPrescription
  24467. var start_time int64
  24468. var end_time int64
  24469. var isSuccess bool = true
  24470. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24471. fmt.Println(his_patient_id)
  24472. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24473. timestamp := time.Now().Unix()
  24474. tempTime := time.Unix(timestamp, 0)
  24475. timeFormat := tempTime.Format("20060102150405")
  24476. chrgBchno := rand.Intn(100000) + 10000
  24477. new_chrg_bchno := ""
  24478. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  24479. new_chrg_bchno = chrg_bchno
  24480. if adminUser.CurrentOrgId == 10265 {
  24481. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  24482. new_chrg_bchno = "0000"
  24483. }
  24484. }
  24485. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24486. var patientPrescription models.HisPrescriptionInfo
  24487. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24488. if patientPrescription.ID == 0 {
  24489. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  24490. }
  24491. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24492. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  24493. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  24494. strconv.FormatInt(his.PatientId, 10)
  24495. var res2406 Result2406
  24496. //安徽单病种处理
  24497. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  24498. data := make(map[string]interface{})
  24499. client := &http.Client{}
  24500. data["psn_no"] = his.PsnNo
  24501. data["mdtrt_id"] = his.Number
  24502. data["operator"] = roles.UserName
  24503. data["cert_no"] = his.IdCardNo
  24504. data["org_name"] = miConfig.OrgName
  24505. data["psn_name"] = his.Name
  24506. data["ipt_otp_no"] = his.IptOtpNo
  24507. data["ipt_psn_sp_flag_type"] = "0901"
  24508. data["ipt_psn_sp_flag"] = "1"
  24509. data["fixmedins_code"] = miConfig.Code
  24510. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24511. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24512. data["url"] = miConfig.Url
  24513. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  24514. bytesData, _ := json.Marshal(data)
  24515. var req *http.Request
  24516. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  24517. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  24518. resp, _ := client.Do(req)
  24519. defer resp.Body.Close()
  24520. body, ioErr := ioutil.ReadAll(resp.Body)
  24521. if ioErr != nil {
  24522. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24524. return
  24525. }
  24526. var respJSON map[string]interface{}
  24527. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24528. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24530. return
  24531. }
  24532. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24533. if status == "0" {
  24534. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24535. c.ServeSuccessJSON(map[string]interface{}{
  24536. "failed_code": -10,
  24537. "msg": err_msg,
  24538. })
  24539. return
  24540. }
  24541. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24542. userJSONBytes, _ := json.Marshal(respJSON)
  24543. fmt.Println("log")
  24544. fmt.Println(string(userJSONBytes))
  24545. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  24546. utils.ErrorLog("解析失败:%v", err)
  24547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24548. return
  24549. }
  24550. }
  24551. if res2406.Infcode != 0 {
  24552. adminUser := c.GetAdminUserInfo()
  24553. errlog := &models.HisOrderError{
  24554. UserOrgId: adminUser.CurrentOrgId,
  24555. Ctime: time.Now().Unix(),
  24556. Mtime: time.Now().Unix(),
  24557. ErrMsg: res2406.ErrMsg,
  24558. Status: 1,
  24559. PatientId: id,
  24560. RecordTime: recordDateTime,
  24561. Stage: 3,
  24562. }
  24563. service.CreateErrMsgLog(errlog)
  24564. c.ServeSuccessJSON(map[string]interface{}{
  24565. "failed_code": -10,
  24566. "msg": res2406.ErrMsg,
  24567. })
  24568. return
  24569. }
  24570. var res2 ResultSix
  24571. var res3 GZResultSix
  24572. var resSix10265 ResultSix10265
  24573. //var time_stamp string
  24574. if miConfig.MdtrtareaAdmvs == "421300" {
  24575. data := make(map[string]interface{})
  24576. client := &http.Client{}
  24577. data["psn_no"] = his.PsnNo
  24578. data["mdtrt_id"] = his.Number
  24579. data["department"] = department.Name
  24580. data["org_name"] = miConfig.OrgName
  24581. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24582. data["doctor_id"] = doctor_info.DoctorNumber
  24583. data["doctor_name"] = roles.UserName
  24584. data["fixmedins_code"] = miConfig.Code
  24585. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24586. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24587. data["secret_key"] = miConfig.SecretKey
  24588. data["sick_code"] = sickConfig.CountryCode
  24589. data["sick_name"] = sickConfig.ClassName
  24590. data["begin_time"] = begin_time
  24591. data["dept"] = strconv.FormatInt(department.ID, 10)
  24592. data["config"] = config
  24593. data["opter"] = roles.UserName
  24594. fmt.Println(data)
  24595. bytesData, _ := json.Marshal(data)
  24596. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24597. resp, _ := client.Do(req)
  24598. defer resp.Body.Close()
  24599. body, ioErr := ioutil.ReadAll(resp.Body)
  24600. if ioErr != nil {
  24601. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24603. return
  24604. }
  24605. var respJSON map[string]interface{}
  24606. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24607. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24609. return
  24610. }
  24611. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24612. userJSONBytes, _ := json.Marshal(respJSON)
  24613. fmt.Println("log")
  24614. fmt.Println(string(userJSONBytes))
  24615. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24616. utils.ErrorLog("解析失败:%v", err)
  24617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24618. return
  24619. }
  24620. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24621. data := make(map[string]interface{})
  24622. client := &http.Client{}
  24623. data["psn_no"] = his.PsnNo
  24624. data["mdtrt_id"] = his.Number
  24625. data["department"] = department.Name
  24626. data["org_name"] = miConfig.OrgName
  24627. if reg_type == 11 && his.Insutype == "390" {
  24628. data["med_type"] = "110104"
  24629. } else {
  24630. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24631. }
  24632. data["doctor_id"] = doctor_info.DoctorNumber
  24633. data["doctor_name"] = roles.UserName
  24634. data["fixmedins_code"] = miConfig.Code
  24635. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24636. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24637. data["secret_key"] = miConfig.SecretKey
  24638. data["sick_code"] = sickConfig.CountryCode
  24639. data["sick_name"] = sickConfig.ClassName
  24640. data["begin_time"] = begin_time
  24641. data["dept"] = strconv.FormatInt(department.ID, 10)
  24642. data["config"] = config
  24643. data["opter"] = roles.UserName
  24644. fmt.Println(data)
  24645. bytesData, _ := json.Marshal(data)
  24646. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24647. resp, _ := client.Do(req)
  24648. defer resp.Body.Close()
  24649. body, ioErr := ioutil.ReadAll(resp.Body)
  24650. if ioErr != nil {
  24651. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24653. return
  24654. }
  24655. var respJSON map[string]interface{}
  24656. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24659. return
  24660. }
  24661. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24662. userJSONBytes, _ := json.Marshal(respJSON)
  24663. fmt.Println("log")
  24664. fmt.Println(string(userJSONBytes))
  24665. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24666. utils.ErrorLog("解析失败:%v", err)
  24667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24668. return
  24669. }
  24670. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24671. data := make(map[string]interface{})
  24672. client := &http.Client{}
  24673. data["psn_no"] = his.PsnNo
  24674. data["mdtrt_id"] = his.Number
  24675. data["department"] = department.Name
  24676. data["org_name"] = miConfig.OrgName
  24677. if reg_type == 11 && his.Insutype == "390" {
  24678. data["med_type"] = "110104"
  24679. } else {
  24680. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24681. }
  24682. data["doctor_id"] = doctor_info.DoctorNumber
  24683. data["doctor_name"] = roles.UserName
  24684. data["fixmedins_code"] = miConfig.Code
  24685. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24686. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24687. data["secret_key"] = miConfig.SecretKey
  24688. data["sick_code"] = sickConfig.CountryCode
  24689. data["sick_name"] = sickConfig.ClassName
  24690. data["begin_time"] = begin_time
  24691. data["dept"] = strconv.FormatInt(department.ID, 10)
  24692. data["config"] = config
  24693. data["opter"] = roles.UserName
  24694. fmt.Println(data)
  24695. bytesData, _ := json.Marshal(data)
  24696. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  24697. resp, _ := client.Do(req)
  24698. defer resp.Body.Close()
  24699. body, ioErr := ioutil.ReadAll(resp.Body)
  24700. if ioErr != nil {
  24701. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24703. return
  24704. }
  24705. var respJSON map[string]interface{}
  24706. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24707. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24709. return
  24710. }
  24711. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24712. userJSONBytes, _ := json.Marshal(respJSON)
  24713. fmt.Println("log")
  24714. fmt.Println(string(userJSONBytes))
  24715. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24716. utils.ErrorLog("解析失败:%v", err)
  24717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24718. return
  24719. }
  24720. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24721. data := make(map[string]interface{})
  24722. client := &http.Client{}
  24723. data["psn_no"] = his.PsnNo
  24724. data["mdtrt_id"] = his.Number
  24725. data["department"] = department.Name
  24726. data["org_name"] = miConfig.OrgName
  24727. if reg_type == 11 && his.Insutype == "390" {
  24728. data["med_type"] = "110104"
  24729. } else {
  24730. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24731. }
  24732. data["doctor_id"] = doctor_info.DoctorNumber
  24733. data["doctor_name"] = roles.UserName
  24734. data["fixmedins_code"] = miConfig.Code
  24735. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24736. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24737. data["secret_key"] = miConfig.SecretKey
  24738. data["sick_code"] = sickConfig.CountryCode
  24739. data["sick_name"] = sickConfig.ClassName
  24740. data["begin_time"] = begin_time
  24741. data["dept"] = strconv.FormatInt(department.ID, 10)
  24742. data["config"] = config
  24743. data["opter"] = roles.UserName
  24744. fmt.Println(data)
  24745. bytesData, _ := json.Marshal(data)
  24746. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  24747. resp, _ := client.Do(req)
  24748. defer resp.Body.Close()
  24749. body, ioErr := ioutil.ReadAll(resp.Body)
  24750. if ioErr != nil {
  24751. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24753. return
  24754. }
  24755. var respJSON map[string]interface{}
  24756. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24757. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24759. return
  24760. }
  24761. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24762. userJSONBytes, _ := json.Marshal(respJSON)
  24763. fmt.Println("log")
  24764. fmt.Println(string(userJSONBytes))
  24765. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24766. utils.ErrorLog("解析失败:%v", err)
  24767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24768. return
  24769. }
  24770. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24771. data := make(map[string]interface{})
  24772. client := &http.Client{}
  24773. data["psn_no"] = his.PsnNo
  24774. data["mdtrt_id"] = his.Number
  24775. data["doctor"] = roles.UserName
  24776. data["department"] = department.Name
  24777. data["org_name"] = miConfig.OrgName
  24778. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24779. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  24780. data["fixmedins_code"] = miConfig.Code
  24781. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24782. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24783. data["secret_key"] = miConfig.SecretKey
  24784. data["sick_code"] = sickConfig.CountryCode
  24785. data["sick_name"] = sickConfig.ClassName
  24786. data["begin_time"] = begin_time
  24787. data["dept"] = strconv.FormatInt(department.ID, 10)
  24788. data["config"] = config
  24789. data["url"] = miConfig.Url
  24790. data["ak"] = miConfig.AccessKey
  24791. data["cainfo"] = miConfig.Cainfo
  24792. bytesData, _ := json.Marshal(data)
  24793. var req *http.Request
  24794. if miConfig.MdtrtareaAdmvs == "320921" {
  24795. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  24796. } else {
  24797. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  24798. }
  24799. resp, _ := client.Do(req)
  24800. defer resp.Body.Close()
  24801. body, ioErr := ioutil.ReadAll(resp.Body)
  24802. if ioErr != nil {
  24803. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24805. return
  24806. }
  24807. var respJSON map[string]interface{}
  24808. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24809. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24811. return
  24812. }
  24813. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  24814. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  24815. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  24816. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24817. userJSONBytes, _ := json.Marshal(respJSON)
  24818. fmt.Println("log")
  24819. fmt.Println(string(userJSONBytes))
  24820. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  24821. utils.ErrorLog("解析失败:%v", err)
  24822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24823. return
  24824. }
  24825. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24826. res2.Output = resSix10265.Output
  24827. res2.ErrMsg = resSix10265.ErrMsg
  24828. res2.Cainfo = resSix10265.Cainfo
  24829. res2.WarnMsg = resSix10265.WarnMsg
  24830. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24831. res2.Infcode = infocode
  24832. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24833. data := make(map[string]interface{})
  24834. client := &http.Client{}
  24835. data["psn_no"] = his.PsnNo
  24836. data["mdtrt_id"] = his.Number
  24837. data["doctor"] = roles.UserName
  24838. data["department"] = department.Name
  24839. data["org_name"] = miConfig.OrgName
  24840. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24841. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  24842. data["fixmedins_code"] = miConfig.Code
  24843. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24844. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24845. data["secret_key"] = miConfig.SecretKey
  24846. data["sick_code"] = sickConfig.CountryCode
  24847. data["sick_name"] = sickConfig.ClassName
  24848. data["begin_time"] = begin_time
  24849. data["dept"] = strconv.FormatInt(department.ID, 10)
  24850. data["config"] = config
  24851. //data["url"] = miConfig.Url
  24852. //data["ak"] = miConfig.AccessKey
  24853. data["cainfo"] = miConfig.Cainfo
  24854. fmt.Println(data)
  24855. bytesData, _ := json.Marshal(data)
  24856. var req *http.Request
  24857. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  24858. resp, _ := client.Do(req)
  24859. defer resp.Body.Close()
  24860. body, ioErr := ioutil.ReadAll(resp.Body)
  24861. if ioErr != nil {
  24862. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24864. return
  24865. }
  24866. var respJSON map[string]interface{}
  24867. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24868. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24870. return
  24871. }
  24872. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  24873. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  24874. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  24875. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24876. userJSONBytes, _ := json.Marshal(respJSON)
  24877. fmt.Println("log")
  24878. fmt.Println(string(userJSONBytes))
  24879. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  24880. utils.ErrorLog("解析失败:%v", err)
  24881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24882. return
  24883. }
  24884. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24885. res2.Output = resSix10265.Output
  24886. res2.ErrMsg = resSix10265.ErrMsg
  24887. res2.Cainfo = resSix10265.Cainfo
  24888. res2.WarnMsg = resSix10265.WarnMsg
  24889. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24890. res2.Infcode = infocode
  24891. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24892. 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)
  24893. saveLog(result, requestLog, "2203", "上传就诊信息")
  24894. var respJSON2 map[string]interface{}
  24895. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  24896. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24898. return
  24899. }
  24900. userJSONBytes2, _ := json.Marshal(respJSON2)
  24901. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  24902. utils.ErrorLog("解析失败:%v", err)
  24903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24904. return
  24905. }
  24906. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24907. var result string
  24908. var requestLog string
  24909. 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, "")
  24910. saveLog(result, requestLog, "2203", "上传就诊信息")
  24911. var respJSON2 map[string]interface{}
  24912. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  24913. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24915. return
  24916. }
  24917. userJSONBytes2, _ := json.Marshal(respJSON2)
  24918. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  24919. utils.ErrorLog("解析失败:%v", err)
  24920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24921. return
  24922. }
  24923. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24924. data := make(map[string]interface{})
  24925. client := &http.Client{}
  24926. data["psn_no"] = his.PsnNo
  24927. data["mdtrt_id"] = his.Number
  24928. data["operator"] = roles.UserName
  24929. data["department"] = department.Name
  24930. data["org_name"] = miConfig.OrgName
  24931. var med_type string
  24932. if his.Insutype == "390" {
  24933. if reg_type == 992102 {
  24934. med_type = "992102"
  24935. data["sick_code"] = "ZDZ940"
  24936. data["sick_name"] = "慢性肾衰竭"
  24937. }
  24938. if reg_type == 140104 {
  24939. med_type = "140104"
  24940. data["sick_code"] = sickConfig.CountryCode
  24941. data["sick_name"] = sickConfig.ClassName
  24942. }
  24943. if reg_type == 14 {
  24944. med_type = "140104"
  24945. data["sick_code"] = sickConfig.CountryCode
  24946. data["sick_name"] = sickConfig.ClassName
  24947. }
  24948. } else if his.Insutype == "310" {
  24949. if reg_type == 992102 {
  24950. med_type = "992102"
  24951. data["sick_code"] = "ZDZ940"
  24952. data["sick_name"] = "慢性肾衰竭"
  24953. }
  24954. if reg_type == 140104 {
  24955. med_type = "140104"
  24956. data["sick_code"] = sickConfig.CountryCode
  24957. data["sick_name"] = sickConfig.ClassName
  24958. }
  24959. if reg_type == 14 {
  24960. med_type = "14"
  24961. data["sick_code"] = sickConfig.CountryCode
  24962. data["sick_name"] = sickConfig.ClassName
  24963. }
  24964. }
  24965. data["med_type"] = med_type
  24966. data["doctor_number"] = doctor_info.DoctorNumber
  24967. data["doctor_name"] = doctor_info.UserName
  24968. data["fixmedins_code"] = miConfig.Code
  24969. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24970. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24971. data["secret_key"] = miConfig.SecretKey
  24972. data["begin_time"] = begin_time
  24973. data["dept"] = strconv.FormatInt(department.ID, 10)
  24974. data["config"] = config
  24975. data["url"] = miConfig.Url
  24976. data["ak"] = miConfig.AccessKey
  24977. data["cainfo"] = miConfig.Cainfo
  24978. bytesData, _ := json.Marshal(data)
  24979. var req *http.Request
  24980. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  24981. resp, _ := client.Do(req)
  24982. defer resp.Body.Close()
  24983. body, ioErr := ioutil.ReadAll(resp.Body)
  24984. if ioErr != nil {
  24985. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24987. return
  24988. }
  24989. var respJSON map[string]interface{}
  24990. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24991. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24993. return
  24994. }
  24995. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24996. if status == "0" {
  24997. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24998. c.ServeSuccessJSON(map[string]interface{}{
  24999. "failed_code": -10,
  25000. "msg": err_msg,
  25001. })
  25002. return
  25003. }
  25004. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25005. userJSONBytes, _ := json.Marshal(respJSON)
  25006. fmt.Println("log")
  25007. fmt.Println(string(userJSONBytes))
  25008. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25009. utils.ErrorLog("解析失败:%v", err)
  25010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25011. return
  25012. }
  25013. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25014. var result string
  25015. var requestLog string
  25016. 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, "")
  25017. saveLog(result, requestLog, "2203", "上传就诊信息")
  25018. var respJSON2 map[string]interface{}
  25019. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25020. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25022. return
  25023. }
  25024. userJSONBytes2, _ := json.Marshal(respJSON2)
  25025. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25026. utils.ErrorLog("解析失败:%v", err)
  25027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25028. return
  25029. }
  25030. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25031. data := make(map[string]interface{})
  25032. client := &http.Client{}
  25033. data["psn_no"] = his.PsnNo
  25034. data["mdtrt_id"] = his.Number
  25035. data["doctor"] = roles.UserName
  25036. data["department"] = department.Name
  25037. data["org_name"] = miConfig.OrgName
  25038. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25039. data["doctor_id"] = doctor_info.DoctorNumber
  25040. data["fixmedins_code"] = miConfig.Code
  25041. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25042. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25043. data["secret_key"] = miConfig.SecretKey
  25044. data["sick_code"] = sickConfig.CountryCode
  25045. data["sick_name"] = sickConfig.ClassName
  25046. data["begin_time"] = begin_time
  25047. data["new_doctor_name"] = doctor_info.UserName
  25048. data["dept"] = strconv.FormatInt(department.ID, 10)
  25049. data["config"] = config
  25050. bytesData, _ := json.Marshal(data)
  25051. var req *http.Request
  25052. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  25053. resp, _ := client.Do(req)
  25054. defer resp.Body.Close()
  25055. body, ioErr := ioutil.ReadAll(resp.Body)
  25056. if ioErr != nil {
  25057. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25059. return
  25060. }
  25061. var respJSON map[string]interface{}
  25062. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25063. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25065. return
  25066. }
  25067. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25068. userJSONBytes, _ := json.Marshal(respJSON)
  25069. fmt.Println("log")
  25070. fmt.Println(string(userJSONBytes))
  25071. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25072. utils.ErrorLog("解析失败:%v", err)
  25073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25074. return
  25075. }
  25076. } else {
  25077. var result string
  25078. var requestLog string
  25079. if miConfig.MdtrtareaAdmvs == "440781" { //
  25080. 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)
  25081. } else {
  25082. if miConfig.Code == "H15049901371" {
  25083. //赤峰地区国家医保医疗类别
  25084. //职工透析:医疗类别选特殊情况门诊990502
  25085. //居民定额血透门慢: 医疗类别选门诊慢病140104
  25086. var med_type string
  25087. if his.Insutype == "390" {
  25088. if reg_type == 14 {
  25089. med_type = "9933"
  25090. } else if reg_type == 11 {
  25091. med_type = "11"
  25092. }
  25093. } else if his.Insutype == "310" {
  25094. if reg_type == 14 {
  25095. med_type = "990502"
  25096. } else if reg_type == 11 {
  25097. med_type = "11"
  25098. }
  25099. }
  25100. 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)
  25101. } else {
  25102. 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)
  25103. }
  25104. saveLog(result, requestLog, "2203", "上传就诊信息")
  25105. var respJSON2 map[string]interface{}
  25106. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25107. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25109. return
  25110. }
  25111. userJSONBytes2, _ := json.Marshal(respJSON2)
  25112. if miConfig.Code == "H15049901371" {
  25113. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  25114. utils.ErrorLog("解析失败:%v", err)
  25115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25116. return
  25117. }
  25118. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25119. res2.Output = resSix10265.Output
  25120. res2.ErrMsg = resSix10265.ErrMsg
  25121. res2.Cainfo = resSix10265.Cainfo
  25122. res2.WarnMsg = resSix10265.WarnMsg
  25123. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25124. res2.Infcode = infocode
  25125. } else {
  25126. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25127. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  25128. utils.ErrorLog("解析失败:%v", err)
  25129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25130. return
  25131. }
  25132. res2.Infcode = res3.Infcode
  25133. } else {
  25134. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25135. utils.ErrorLog("解析失败:%v", err)
  25136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25137. return
  25138. }
  25139. }
  25140. }
  25141. }
  25142. }
  25143. if res2.Infcode == -1 {
  25144. adminUser := c.GetAdminUserInfo()
  25145. errlog := &models.HisOrderError{
  25146. UserOrgId: adminUser.CurrentOrgId,
  25147. Ctime: time.Now().Unix(),
  25148. Mtime: time.Now().Unix(),
  25149. ErrMsg: res2.ErrMsg,
  25150. Status: 1,
  25151. PatientId: id,
  25152. RecordTime: recordDateTime,
  25153. Stage: 3,
  25154. }
  25155. service.CreateErrMsgLog(errlog)
  25156. c.ServeSuccessJSON(map[string]interface{}{
  25157. "failed_code": -10,
  25158. "msg": res2.ErrMsg,
  25159. })
  25160. return
  25161. }
  25162. if res2.Infcode != 0 {
  25163. adminUser := c.GetAdminUserInfo()
  25164. errlog := &models.HisOrderError{
  25165. UserOrgId: adminUser.CurrentOrgId,
  25166. Ctime: time.Now().Unix(),
  25167. Mtime: time.Now().Unix(),
  25168. ErrMsg: res2.ErrMsg,
  25169. Status: 1,
  25170. PatientId: id,
  25171. RecordTime: recordDateTime,
  25172. Stage: 3,
  25173. }
  25174. service.CreateErrMsgLog(errlog)
  25175. c.ServeSuccessJSON(map[string]interface{}{
  25176. "failed_code": -10,
  25177. "msg": res2.ErrMsg,
  25178. })
  25179. return
  25180. } else {
  25181. his.Diagnosis = diagnosis_id
  25182. his.SickType = sickConfig.ID
  25183. his.PType = fmt.Sprintf("%d", reg_type)
  25184. service.UpdateHisPatientThree(&his)
  25185. data := make(map[string]interface{})
  25186. if settle_accounts_type == 1 { //日结
  25187. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  25188. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  25189. } else {
  25190. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  25191. }
  25192. data["pre"] = prescriptions
  25193. } else { //月结
  25194. start_time_str := c.GetString("start_time")
  25195. end_time_str := c.GetString("end_time")
  25196. timeLayout := "2006-01-02"
  25197. loc, _ := time.LoadLocation("Local")
  25198. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  25199. if err != nil {
  25200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25201. return
  25202. }
  25203. recordStartTime := theStartTime.Unix()
  25204. start_time = recordStartTime
  25205. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  25206. if err != nil {
  25207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25208. return
  25209. }
  25210. recordEndTime := theEndTime.Unix()
  25211. end_time = recordEndTime
  25212. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  25213. data["pre"] = prescriptions
  25214. }
  25215. client := &http.Client{}
  25216. data["psn_no"] = his.PsnNo
  25217. data["mdtrt_id"] = his.Number
  25218. data["chrg_bchno"] = new_chrg_bchno
  25219. data["org_name"] = miConfig.OrgName
  25220. data["doctor"] = doctor_info.UserName
  25221. data["doctor_id"] = doctor_info.DoctorNumber
  25222. data["dept"] = department.Name
  25223. data["fixmedins_code"] = miConfig.Code
  25224. data["opter"] = roles.UserName
  25225. data["dept_code"] = department.Number
  25226. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25227. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25228. data["secret_key"] = miConfig.SecretKey
  25229. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  25230. data["url"] = miConfig.Url
  25231. data["ak"] = miConfig.AccessKey
  25232. data["new_doctor_name"] = patientPrescription.Doctor
  25233. if his.Insutype == "390" {
  25234. if reg_type == 992102 {
  25235. data["diag_code"] = "ZDZ940"
  25236. }
  25237. if reg_type == 140104 {
  25238. data["diag_code"] = sickConfig.CountryCode
  25239. }
  25240. if reg_type == 14 {
  25241. data["diag_code"] = sickConfig.CountryCode
  25242. }
  25243. } else if his.Insutype == "310" {
  25244. if reg_type == 992102 {
  25245. data["diag_code"] = "ZDZ940"
  25246. }
  25247. if reg_type == 14 {
  25248. data["diag_code"] = sickConfig.CountryCode
  25249. }
  25250. }
  25251. data["cainfo"] = miConfig.Cainfo
  25252. data["opter"] = roles.UserName
  25253. var ids []int64
  25254. for _, item := range prescriptions {
  25255. ids = append(ids, item.ID)
  25256. }
  25257. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25258. if config.IsOpen == 1 { //对接了医保,走医保流程
  25259. var res ResultFour
  25260. var resFour10265 ResultFour10265
  25261. if miConfig.MdtrtareaAdmvs == "421300" {
  25262. bytesData, _ := json.Marshal(data)
  25263. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25264. resp, _ := client.Do(req)
  25265. defer resp.Body.Close()
  25266. body, ioErr := ioutil.ReadAll(resp.Body)
  25267. if ioErr != nil {
  25268. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25270. return
  25271. }
  25272. var respJSON map[string]interface{}
  25273. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25274. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25276. return
  25277. }
  25278. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25279. userJSONBytes, _ := json.Marshal(respJSON)
  25280. fmt.Println("log")
  25281. fmt.Println(string(userJSONBytes))
  25282. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25283. utils.ErrorLog("解析失败:%v", err)
  25284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25285. return
  25286. }
  25287. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25288. bytesData, _ := json.Marshal(data)
  25289. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25290. resp, _ := client.Do(req)
  25291. defer resp.Body.Close()
  25292. body, ioErr := ioutil.ReadAll(resp.Body)
  25293. if ioErr != nil {
  25294. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25296. return
  25297. }
  25298. var respJSON map[string]interface{}
  25299. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25300. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25302. return
  25303. }
  25304. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25305. userJSONBytes, _ := json.Marshal(respJSON)
  25306. fmt.Println("log")
  25307. fmt.Println(string(userJSONBytes))
  25308. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25309. utils.ErrorLog("解析失败:%v", err)
  25310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25311. return
  25312. }
  25313. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25314. bytesData, _ := json.Marshal(data)
  25315. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25316. resp, _ := client.Do(req)
  25317. defer resp.Body.Close()
  25318. body, ioErr := ioutil.ReadAll(resp.Body)
  25319. if ioErr != nil {
  25320. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25322. return
  25323. }
  25324. var respJSON map[string]interface{}
  25325. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25326. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25328. return
  25329. }
  25330. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25331. userJSONBytes, _ := json.Marshal(respJSON)
  25332. fmt.Println("log")
  25333. fmt.Println(string(userJSONBytes))
  25334. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25335. utils.ErrorLog("解析失败:%v", err)
  25336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25337. return
  25338. }
  25339. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25340. bytesData, _ := json.Marshal(data)
  25341. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25342. resp, _ := client.Do(req)
  25343. defer resp.Body.Close()
  25344. body, ioErr := ioutil.ReadAll(resp.Body)
  25345. if ioErr != nil {
  25346. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25348. return
  25349. }
  25350. var respJSON map[string]interface{}
  25351. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25352. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25354. return
  25355. }
  25356. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25357. userJSONBytes, _ := json.Marshal(respJSON)
  25358. fmt.Println("log")
  25359. fmt.Println(string(userJSONBytes))
  25360. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25361. utils.ErrorLog("解析失败:%v", err)
  25362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25363. return
  25364. }
  25365. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25366. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  25367. if result3101.Infcode == "0" {
  25368. if len(result3101.Output.Result) > 0 {
  25369. var errMsgs []string
  25370. for _, item := range result3101.Output.Result {
  25371. errMsgs = append(errMsgs, item.VolaCont)
  25372. }
  25373. c.ServeSuccessJSON(map[string]interface{}{
  25374. "failed_code": -10,
  25375. "msg": errMsgs,
  25376. })
  25377. return
  25378. } else {
  25379. if miConfig.MdtrtareaAdmvs == "320921" {
  25380. data["doctor_id"] = "D320923012139"
  25381. } else {
  25382. data["doctor_id"] = "D371621008686"
  25383. }
  25384. bytesData, _ := json.Marshal(data)
  25385. var req *http.Request
  25386. if miConfig.MdtrtareaAdmvs == "320921" {
  25387. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25388. } else {
  25389. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25390. }
  25391. resp, _ := client.Do(req)
  25392. defer resp.Body.Close()
  25393. body, ioErr := ioutil.ReadAll(resp.Body)
  25394. if ioErr != nil {
  25395. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25397. return
  25398. }
  25399. var respJSON map[string]interface{}
  25400. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25401. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25403. return
  25404. }
  25405. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25406. userJSONBytes, _ := json.Marshal(respJSON)
  25407. fmt.Println("log")
  25408. fmt.Println(string(userJSONBytes))
  25409. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25410. utils.ErrorLog("解析失败:%v", err)
  25411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25412. return
  25413. }
  25414. res.InfRefmsgid = resFour10265.InfRefmsgid
  25415. res.Output = resFour10265.Output
  25416. res.ErrMsg = resFour10265.ErrMsg
  25417. res.Cainfo = resFour10265.Cainfo
  25418. res.WarnMsg = resFour10265.WarnMsg
  25419. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25420. res.Infcode = infocode
  25421. }
  25422. }
  25423. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25424. var pagesize int = 5
  25425. var start int = 1
  25426. var stop int
  25427. var pagecount int
  25428. var curpage int
  25429. data["doctor_id"] = doctor_info.DoctorNumber
  25430. var res2 ResultFour
  25431. //var result res.
  25432. //总页数,向上取整,注意除之前要先转换类型为float64
  25433. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  25434. for curpage = 1; curpage <= pagecount; curpage++ {
  25435. if curpage == 1 {
  25436. start = 1
  25437. } else {
  25438. start = (curpage-1)*pagesize + 1
  25439. }
  25440. stop = curpage * pagesize
  25441. if stop > len(prescriptions) {
  25442. stop = len(prescriptions)
  25443. }
  25444. //var requestLog string
  25445. data["pre"] = prescriptions[start-1 : stop]
  25446. fmt.Println(data["pre"])
  25447. bytesData, _ := json.Marshal(data)
  25448. var req *http.Request
  25449. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  25450. resp, _ := client.Do(req)
  25451. defer resp.Body.Close()
  25452. body, ioErr := ioutil.ReadAll(resp.Body)
  25453. if ioErr != nil {
  25454. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25456. return
  25457. }
  25458. var respJSON map[string]interface{}
  25459. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25460. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25462. return
  25463. }
  25464. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25465. userJSONBytes, _ := json.Marshal(respJSON)
  25466. fmt.Println("log")
  25467. fmt.Println(string(userJSONBytes))
  25468. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25469. utils.ErrorLog("解析失败:%v", err)
  25470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25471. return
  25472. }
  25473. res.InfRefmsgid = resFour10265.InfRefmsgid
  25474. res.Output = resFour10265.Output
  25475. res.ErrMsg = resFour10265.ErrMsg
  25476. res.Cainfo = resFour10265.Cainfo
  25477. res.WarnMsg = resFour10265.WarnMsg
  25478. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25479. res.Infcode = infocode
  25480. if infocode == 0 {
  25481. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  25482. } else {
  25483. isSuccess = false
  25484. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  25485. res.Infcode = -1
  25486. res.ErrMsg = resFour10265.ErrMsg
  25487. errlog := &models.HisOrderError{
  25488. UserOrgId: adminUser.CurrentOrgId,
  25489. Ctime: time.Now().Unix(),
  25490. Mtime: time.Now().Unix(),
  25491. Number: chrg_bchno,
  25492. ErrMsg: "",
  25493. Status: 1,
  25494. PatientId: id,
  25495. RecordTime: recordDateTime,
  25496. Stage: 4,
  25497. }
  25498. service.CreateErrMsgLog(errlog)
  25499. }
  25500. }
  25501. if isSuccess {
  25502. res.Infcode = 0
  25503. res.Output.Result = res2.Output.Result
  25504. } else {
  25505. order := &models.HisOrder{
  25506. UserOrgId: adminUser.CurrentOrgId,
  25507. HisPatientId: his.ID,
  25508. PatientId: his.PatientId,
  25509. SettleAccountsDate: recordDateTime,
  25510. Ctime: time.Now().Unix(),
  25511. Mtime: time.Now().Unix(),
  25512. MdtrtId: his.Number,
  25513. PsnNo: his.PsnNo,
  25514. MedType: strconv.FormatInt(reg_type, 10),
  25515. Status: 1,
  25516. Number: chrg_bchno,
  25517. Infcode: res.Infcode,
  25518. WarnMsg: res.WarnMsg,
  25519. Cainfo: res.Cainfo,
  25520. ErrMsg: res.ErrMsg,
  25521. RespondTime: res.RefmsgTime,
  25522. InfRefmsgid: res.InfRefmsgid,
  25523. OrderStatus: 1,
  25524. IsMedicineInsurance: 1,
  25525. SettleType: settle_accounts_type,
  25526. SettleStartTime: start_time,
  25527. SettleEndTime: end_time,
  25528. Creator: roles.AdminUserId,
  25529. Modify: roles.AdminUserId,
  25530. PType: 2,
  25531. Diagnosis: diagnosis_id,
  25532. }
  25533. err = service.CreateOrder(order)
  25534. if err != nil {
  25535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  25536. return
  25537. }
  25538. c.ServeSuccessJSON(map[string]interface{}{
  25539. "failed_code": -10,
  25540. "msg": res2.ErrMsg,
  25541. })
  25542. return
  25543. }
  25544. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25545. 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)
  25546. var dat map[string]interface{}
  25547. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25548. fmt.Println(dat)
  25549. } else {
  25550. fmt.Println(err)
  25551. }
  25552. saveLog(result, request_log, "2204", "上传费用明细")
  25553. userJSONBytes, _ := json.Marshal(dat)
  25554. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25555. utils.ErrorLog("解析失败:%v", err)
  25556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25557. return
  25558. }
  25559. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25560. 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, "", "")
  25561. var dat map[string]interface{}
  25562. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25563. fmt.Println(dat)
  25564. } else {
  25565. fmt.Println(err)
  25566. }
  25567. saveLog(result, request_log, "2204", "上传费用明细")
  25568. userJSONBytes, _ := json.Marshal(dat)
  25569. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25570. utils.ErrorLog("解析失败:%v", err)
  25571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25572. return
  25573. }
  25574. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25575. bytesData, _ := json.Marshal(data)
  25576. var req *http.Request
  25577. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  25578. resp, _ := client.Do(req)
  25579. defer resp.Body.Close()
  25580. body, ioErr := ioutil.ReadAll(resp.Body)
  25581. if ioErr != nil {
  25582. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25584. return
  25585. }
  25586. var respJSON map[string]interface{}
  25587. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25588. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25590. return
  25591. }
  25592. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25593. if status == "0" {
  25594. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25595. c.ServeSuccessJSON(map[string]interface{}{
  25596. "failed_code": -10,
  25597. "msg": err_msg,
  25598. })
  25599. return
  25600. }
  25601. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25602. userJSONBytes, _ := json.Marshal(respJSON)
  25603. fmt.Println("log")
  25604. fmt.Println(string(userJSONBytes))
  25605. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25606. utils.ErrorLog("解析失败:%v", err)
  25607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25608. return
  25609. }
  25610. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25611. 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, "", "")
  25612. var dat map[string]interface{}
  25613. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25614. fmt.Println(dat)
  25615. } else {
  25616. fmt.Println(err)
  25617. }
  25618. saveLog(result, request_log, "2204", "上传费用明细")
  25619. userJSONBytes, _ := json.Marshal(dat)
  25620. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25621. utils.ErrorLog("解析失败:%v", err)
  25622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25623. return
  25624. }
  25625. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25626. bytesData, _ := json.Marshal(data)
  25627. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  25628. resp, _ := client.Do(req)
  25629. defer resp.Body.Close()
  25630. body, ioErr := ioutil.ReadAll(resp.Body)
  25631. if ioErr != nil {
  25632. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25634. return
  25635. }
  25636. var respJSON map[string]interface{}
  25637. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25640. return
  25641. }
  25642. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25643. userJSONBytes, _ := json.Marshal(respJSON)
  25644. fmt.Println("log")
  25645. fmt.Println(string(userJSONBytes))
  25646. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25647. utils.ErrorLog("解析失败:%v", err)
  25648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25649. return
  25650. }
  25651. } else {
  25652. if miConfig.MdtrtareaAdmvs == "441202" {
  25653. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  25654. if result3101.Infcode == 0 {
  25655. if len(result3101.Output.Result) > 0 {
  25656. var errMsgs []string
  25657. for _, item := range result3101.Output.Result {
  25658. errMsgs = append(errMsgs, item.VolaCont)
  25659. }
  25660. c.ServeSuccessJSON(map[string]interface{}{
  25661. "failed_code": -10,
  25662. "msg": errMsgs,
  25663. })
  25664. return
  25665. } else {
  25666. 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)
  25667. var dat map[string]interface{}
  25668. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25669. fmt.Println(dat)
  25670. } else {
  25671. fmt.Println(err)
  25672. }
  25673. saveLog(result, request_log, "2204", "上传费用明细")
  25674. userJSONBytes, _ := json.Marshal(dat)
  25675. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25676. utils.ErrorLog("解析失败:%v", err)
  25677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25678. return
  25679. }
  25680. }
  25681. } else {
  25682. c.ServeSuccessJSON(map[string]interface{}{
  25683. "failed_code": -10,
  25684. "msg": result3101.ErrMsg,
  25685. })
  25686. return
  25687. }
  25688. } else if miConfig.MdtrtareaAdmvs == "440205" {
  25689. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  25690. if result3101.Infcode == 0 {
  25691. if len(result3101.Output.Result) > 0 {
  25692. var errMsgs []string
  25693. for _, item := range result3101.Output.Result {
  25694. errMsgs = append(errMsgs, item.VolaCont)
  25695. }
  25696. c.ServeSuccessJSON(map[string]interface{}{
  25697. "failed_code": -10,
  25698. "msg": errMsgs,
  25699. })
  25700. return
  25701. } else {
  25702. 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)
  25703. var dat map[string]interface{}
  25704. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25705. fmt.Println(dat)
  25706. } else {
  25707. fmt.Println(err)
  25708. }
  25709. saveLog(result, request_log, "2204", "上传费用明细")
  25710. userJSONBytes, _ := json.Marshal(dat)
  25711. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25712. utils.ErrorLog("解析失败:%v", err)
  25713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25714. return
  25715. }
  25716. }
  25717. } else {
  25718. c.ServeSuccessJSON(map[string]interface{}{
  25719. "failed_code": -10,
  25720. "msg": result3101.ErrMsg,
  25721. })
  25722. return
  25723. }
  25724. } else {
  25725. if miConfig.Code == "H15049901371" {
  25726. 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)
  25727. var dat map[string]interface{}
  25728. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25729. fmt.Println(dat)
  25730. } else {
  25731. fmt.Println(err)
  25732. }
  25733. saveLog(result, request_log, "2204", "上传费用明细")
  25734. userJSONBytes, _ := json.Marshal(dat)
  25735. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25736. utils.ErrorLog("解析失败:%v", err)
  25737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25738. return
  25739. }
  25740. res.InfRefmsgid = resFour10265.InfRefmsgid
  25741. res.Output = resFour10265.Output
  25742. res.ErrMsg = resFour10265.ErrMsg
  25743. res.Cainfo = resFour10265.Cainfo
  25744. res.WarnMsg = resFour10265.WarnMsg
  25745. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25746. res.Infcode = infocode
  25747. } else {
  25748. 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)
  25749. var dat map[string]interface{}
  25750. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25751. fmt.Println(dat)
  25752. } else {
  25753. fmt.Println(err)
  25754. }
  25755. saveLog(result, request_log, "2204", "上传费用明细")
  25756. userJSONBytes, _ := json.Marshal(dat)
  25757. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25758. utils.ErrorLog("解析失败:%v", err)
  25759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25760. return
  25761. }
  25762. }
  25763. }
  25764. }
  25765. var total_two float64
  25766. if res.Infcode == -1 {
  25767. errlog := &models.HisOrderError{
  25768. UserOrgId: adminUser.CurrentOrgId,
  25769. Ctime: time.Now().Unix(),
  25770. Mtime: time.Now().Unix(),
  25771. Number: chrg_bchno,
  25772. ErrMsg: res.ErrMsg,
  25773. Status: 1,
  25774. PatientId: id,
  25775. RecordTime: recordDateTime,
  25776. Stage: 4,
  25777. }
  25778. service.CreateErrMsgLog(errlog)
  25779. c.ServeSuccessJSON(map[string]interface{}{
  25780. "failed_code": -10,
  25781. "msg": res.ErrMsg,
  25782. })
  25783. return
  25784. }
  25785. if res.Infcode == 0 {
  25786. order := &models.HisOrder{
  25787. UserOrgId: adminUser.CurrentOrgId,
  25788. HisPatientId: his.ID,
  25789. PatientId: his.PatientId,
  25790. SettleAccountsDate: recordDateTime,
  25791. Ctime: time.Now().Unix(),
  25792. Mtime: time.Now().Unix(),
  25793. MdtrtId: his.Number,
  25794. PsnNo: his.PsnNo,
  25795. MedType: strconv.FormatInt(reg_type, 10),
  25796. Status: 1,
  25797. Number: chrg_bchno,
  25798. Infcode: res.Infcode,
  25799. WarnMsg: res.WarnMsg,
  25800. Cainfo: res.Cainfo,
  25801. ErrMsg: res.ErrMsg,
  25802. RespondTime: res.RefmsgTime,
  25803. InfRefmsgid: res.InfRefmsgid,
  25804. OrderStatus: 1,
  25805. IsMedicineInsurance: 1,
  25806. SettleType: settle_accounts_type,
  25807. SettleStartTime: start_time,
  25808. SettleEndTime: end_time,
  25809. Creator: roles.AdminUserId,
  25810. Modify: roles.AdminUserId,
  25811. PType: 2,
  25812. Diagnosis: diagnosis_id,
  25813. }
  25814. err = service.CreateOrder(order)
  25815. if err != nil {
  25816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  25817. return
  25818. }
  25819. for _, item := range res.Output.Result {
  25820. temp := strings.Split(item.FeedetlSn, "-")
  25821. var advice_id int64 = 0
  25822. var project_id int64 = 0
  25823. var types int64 = 0
  25824. id, _ := strconv.ParseInt(temp[2], 10, 64)
  25825. types, _ = strconv.ParseInt(temp[1], 10, 64)
  25826. if temp[1] == "1" {
  25827. advice_id = id
  25828. project_id = 0
  25829. } else if temp[1] == "2" {
  25830. advice_id = 0
  25831. project_id = id
  25832. }
  25833. total_two = total_two + item.DetItemFeeSumamt
  25834. info := &models.HisOrderInfo{
  25835. OrderNumber: order.Number,
  25836. FeedetlSn: item.FeedetlSn,
  25837. UploadDate: time.Now().Unix(),
  25838. AdviceId: advice_id,
  25839. DetItemFeeSumamt: item.DetItemFeeSumamt,
  25840. Cnt: item.Cnt,
  25841. Pric: float64(item.Pric),
  25842. PatientId: his.PatientId,
  25843. PricUplmtAmt: item.PricUplmtAmt,
  25844. SelfpayProp: item.SelfpayProp,
  25845. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  25846. OverlmtAmt: item.OverlmtAmt,
  25847. PreselfpayAmt: item.PreselfpayAmt,
  25848. BasMednFlag: item.BasMednFlag,
  25849. MedChrgitmType: item.MedChrgitmType,
  25850. HiNegoDrugFlag: item.HiNegoDrugFlag,
  25851. Status: 1,
  25852. Memo: item.Memo,
  25853. Mtime: time.Now().Unix(),
  25854. InscpScpAmt: item.InscpScpAmt,
  25855. DrtReimFlag: item.DrtReimFlag,
  25856. Ctime: time.Now().Unix(),
  25857. ListSpItemFlag: item.ListSpItemFlag,
  25858. ChldMedcFlag: item.ChldMedcFlag,
  25859. LmtUsedFlag: item.LmtUsedFlag,
  25860. ChrgitmLv: item.ChrgitmLv,
  25861. UserOrgId: adminUser.CurrentOrgId,
  25862. HisPatientId: his.ID,
  25863. OrderId: order.ID,
  25864. ProjectId: project_id,
  25865. Type: types,
  25866. }
  25867. service.CreateOrderInfo(info)
  25868. }
  25869. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  25870. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  25871. var total float64
  25872. for _, item := range prescriptions {
  25873. if item.Type == 1 { //药品
  25874. for _, subItem := range item.HisDoctorAdviceInfo {
  25875. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25876. total_one := price * subItem.PrescribingNumber
  25877. fmt.Println("subItem")
  25878. fmt.Println(subItem.Price)
  25879. fmt.Println("price")
  25880. fmt.Println(price)
  25881. fmt.Println("total_one")
  25882. fmt.Println(total_one)
  25883. total = total + total_one
  25884. fmt.Println(total)
  25885. }
  25886. }
  25887. if item.Type == 2 { //项目
  25888. for _, subItem := range item.HisPrescriptionProject {
  25889. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  25890. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25891. total_one := price * cnt
  25892. total = total + total_one
  25893. }
  25894. }
  25895. }
  25896. allTotal := fmt.Sprintf("%.2f", total)
  25897. if res.Infcode == 0 {
  25898. var rf []*ResultFive
  25899. json.Unmarshal([]byte(his.Iinfo), &rf)
  25900. chrg_bchno := chrg_bchno
  25901. cert_no := his.Certno
  25902. var insutypes []string
  25903. var insutype string
  25904. var is390 int = 0
  25905. var is310 int = 0
  25906. for _, item := range rf {
  25907. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25908. insutypes = append(insutypes, item.Insutype)
  25909. }
  25910. }
  25911. if len(insutypes) == 1 {
  25912. insutype = insutypes[0]
  25913. } else {
  25914. for _, i := range insutypes {
  25915. if i == "390" {
  25916. is390 = 1
  25917. }
  25918. if i == "310" {
  25919. is310 = 1
  25920. }
  25921. }
  25922. }
  25923. if is390 == 1 {
  25924. insutype = "390"
  25925. }
  25926. if is310 == 1 {
  25927. insutype = "310"
  25928. }
  25929. if len(insutypes) == 0 {
  25930. insutype = "390"
  25931. }
  25932. if len(insutypes) == 2 {
  25933. insutype = strconv.FormatInt(his.SocialType, 10)
  25934. }
  25935. //insutype = "390"
  25936. if his.IdCardType == 1 {
  25937. cert_no = his.MedicalInsuranceNumber
  25938. } else {
  25939. cert_no = his.Certno
  25940. }
  25941. var res ResultSeven
  25942. var ahres ResultSevenAH
  25943. var resSeven10265 ResultSeven10265
  25944. var resSeven10265Two ResultSeven10265Two
  25945. var gzresSeven10265Two GZResultSeven10265Two
  25946. if miConfig.MdtrtareaAdmvs == "421300" {
  25947. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  25948. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25949. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25950. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25951. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25952. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25953. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25954. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  25955. resp, requestErr := http.Get(api)
  25956. if requestErr != nil {
  25957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25958. return
  25959. }
  25960. body, ioErr := ioutil.ReadAll(resp.Body)
  25961. if ioErr != nil {
  25962. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25964. return
  25965. }
  25966. var respJSON map[string]interface{}
  25967. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25968. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25970. return
  25971. }
  25972. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25973. result, _ := json.Marshal(respJSON)
  25974. fmt.Println("log")
  25975. fmt.Println(string(result))
  25976. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25977. utils.ErrorLog("解析失败:%v", err)
  25978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25979. return
  25980. }
  25981. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25982. if reg_type == 11 && his.Insutype == "390" {
  25983. reg_type = 110104
  25984. }
  25985. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25986. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25987. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25988. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25989. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25990. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25991. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  25992. resp, requestErr := http.Get(api)
  25993. if requestErr != nil {
  25994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25995. return
  25996. }
  25997. body, ioErr := ioutil.ReadAll(resp.Body)
  25998. if ioErr != nil {
  25999. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26001. return
  26002. }
  26003. var respJSON map[string]interface{}
  26004. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26005. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26007. return
  26008. }
  26009. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26010. result, _ := json.Marshal(respJSON)
  26011. fmt.Println("log")
  26012. fmt.Println(string(result))
  26013. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26014. utils.ErrorLog("解析失败:%v", err)
  26015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26016. return
  26017. }
  26018. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26019. if reg_type == 11 && his.Insutype == "390" {
  26020. reg_type = 110104
  26021. }
  26022. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26023. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26024. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26025. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26026. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26027. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26028. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  26029. resp, requestErr := http.Get(api)
  26030. if requestErr != nil {
  26031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26032. return
  26033. }
  26034. body, ioErr := ioutil.ReadAll(resp.Body)
  26035. if ioErr != nil {
  26036. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26038. return
  26039. }
  26040. var respJSON map[string]interface{}
  26041. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26042. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26044. return
  26045. }
  26046. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26047. result, _ := json.Marshal(respJSON)
  26048. fmt.Println("log")
  26049. fmt.Println(string(result))
  26050. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26051. utils.ErrorLog("解析失败:%v", err)
  26052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26053. return
  26054. }
  26055. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26056. if reg_type == 11 && his.Insutype == "390" {
  26057. reg_type = 110104
  26058. }
  26059. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26060. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26061. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26062. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26063. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26064. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26065. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  26066. resp, requestErr := http.Get(api)
  26067. if requestErr != nil {
  26068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26069. return
  26070. }
  26071. body, ioErr := ioutil.ReadAll(resp.Body)
  26072. if ioErr != nil {
  26073. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26075. return
  26076. }
  26077. var respJSON map[string]interface{}
  26078. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26079. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26081. return
  26082. }
  26083. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26084. result, _ := json.Marshal(respJSON)
  26085. fmt.Println("log")
  26086. fmt.Println(string(result))
  26087. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26088. utils.ErrorLog("解析失败:%v", err)
  26089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26090. return
  26091. }
  26092. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26093. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  26094. if result3101.Infcode == "0" {
  26095. if len(result3101.Output.Result) > 0 {
  26096. var errMsgs []string
  26097. for _, item := range result3101.Output.Result {
  26098. errMsgs = append(errMsgs, item.VolaCont)
  26099. }
  26100. c.ServeSuccessJSON(map[string]interface{}{
  26101. "failed_code": -10,
  26102. "msg": errMsgs,
  26103. })
  26104. return
  26105. } else {
  26106. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26107. if his.IdCardType != 4 {
  26108. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26109. bas := strings.Split(psn_info.CardInfo, "|")
  26110. if his.IdCardType == 1 {
  26111. cert_no = bas[2]
  26112. } else {
  26113. cert_no = bas[1]
  26114. }
  26115. } else {
  26116. cert_no = his.Certno
  26117. }
  26118. //江苏地区国家医保医疗类别
  26119. //职工透析:医疗类别选特殊情况门诊9933
  26120. //居民血透门慢: 医疗类别选门诊慢病1402
  26121. //var med_type string
  26122. //if his.Insutype == "310" {
  26123. // if reg_type == 14 {
  26124. // med_type = "9933"
  26125. // } else if reg_type == 11 {
  26126. // med_type = "11"
  26127. //
  26128. // }
  26129. //} else if his.Insutype == "390" {
  26130. // if reg_type == 14 {
  26131. // med_type = "1402"
  26132. // } else if reg_type == 11 {
  26133. // med_type = "11"
  26134. // }
  26135. //}
  26136. var api string
  26137. if miConfig.MdtrtareaAdmvs == "320921" {
  26138. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26139. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26140. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26141. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26142. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26143. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26144. "&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
  26145. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26146. } else {
  26147. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26148. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26149. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26150. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26151. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26152. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26153. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26154. "&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
  26155. }
  26156. resp, requestErr := http.Get(api)
  26157. if requestErr != nil {
  26158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26159. return
  26160. }
  26161. body, ioErr := ioutil.ReadAll(resp.Body)
  26162. if ioErr != nil {
  26163. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26165. return
  26166. }
  26167. var respJSON map[string]interface{}
  26168. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26169. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26171. return
  26172. }
  26173. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26174. result, _ := json.Marshal(respJSON)
  26175. fmt.Println("log")
  26176. fmt.Println(string(result))
  26177. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  26178. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26179. utils.ErrorLog("解析失败:%v", err)
  26180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26181. return
  26182. }
  26183. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26184. res.Output = resSeven10265.Output
  26185. res.ErrMsg = resSeven10265.ErrMsg
  26186. res.Cainfo = resSeven10265.Cainfo
  26187. res.WarnMsg = resSeven10265.WarnMsg
  26188. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26189. res.Infcode = infocode
  26190. } else {
  26191. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  26192. utils.ErrorLog("解析失败:%v", err)
  26193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26194. return
  26195. }
  26196. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  26197. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  26198. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  26199. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  26200. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  26201. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  26202. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  26203. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  26204. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  26205. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  26206. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  26207. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  26208. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  26209. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  26210. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  26211. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  26212. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  26213. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  26214. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  26215. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  26216. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  26217. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26218. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  26219. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  26220. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  26221. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  26222. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  26223. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  26224. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  26225. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  26226. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  26227. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  26228. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  26229. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  26230. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  26231. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  26232. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  26233. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  26234. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  26235. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  26236. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  26237. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  26238. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  26239. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  26240. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  26241. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  26242. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  26243. res.ErrMsg = resSeven10265Two.ErrMsg
  26244. res.Cainfo = resSeven10265Two.Cainfo
  26245. res.WarnMsg = resSeven10265Two.WarnMsg
  26246. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  26247. res.Infcode = infocode
  26248. }
  26249. }
  26250. }
  26251. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26252. psn_info, _ := service.GetPsnByPatientId(id)
  26253. var verify_number string
  26254. if psn_info.IdCardType == 4 {
  26255. verify_number = psn_info.VerifyNumber
  26256. } else if psn_info.IdCardType == 1 {
  26257. bas := strings.Split(psn_info.CardInfo, "|")
  26258. cardNumber := bas[2]
  26259. verify_number = cardNumber
  26260. } else {
  26261. psn_info.IdCardType = 2
  26262. verify_number = psn_info.Certno
  26263. }
  26264. var api string
  26265. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26266. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  26267. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26268. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26269. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  26270. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26271. "&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
  26272. resp, requestErr := http.Get(api)
  26273. if requestErr != nil {
  26274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26275. return
  26276. }
  26277. body, ioErr := ioutil.ReadAll(resp.Body)
  26278. if ioErr != nil {
  26279. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26281. return
  26282. }
  26283. var respJSON map[string]interface{}
  26284. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26285. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26287. return
  26288. }
  26289. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26290. result, _ := json.Marshal(respJSON)
  26291. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26292. utils.ErrorLog("解析失败:%v", err)
  26293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26294. return
  26295. }
  26296. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26297. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  26298. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  26299. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  26300. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  26301. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  26302. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  26303. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  26304. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  26305. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  26306. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  26307. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  26308. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  26309. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  26310. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  26311. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  26312. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  26313. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  26314. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  26315. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  26316. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26317. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  26318. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  26319. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  26320. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  26321. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  26322. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  26323. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  26324. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  26325. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  26326. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  26327. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  26328. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  26329. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  26330. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  26331. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  26332. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  26333. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  26334. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  26335. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  26336. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  26337. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  26338. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  26339. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  26340. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  26341. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  26342. res.ErrMsg = resSeven10265.ErrMsg
  26343. res.Cainfo = resSeven10265.Cainfo
  26344. res.WarnMsg = resSeven10265.WarnMsg
  26345. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26346. res.Infcode = infocode
  26347. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26348. acct_used_flag := "1"
  26349. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  26350. var result string
  26351. var request_log string
  26352. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  26353. 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)
  26354. } else {
  26355. 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)
  26356. }
  26357. var dat map[string]interface{}
  26358. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26359. fmt.Println(dat)
  26360. } else {
  26361. fmt.Println(err)
  26362. }
  26363. saveLog(result, request_log, "2206", "预结算")
  26364. userJSONBytes, _ := json.Marshal(dat)
  26365. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26366. utils.ErrorLog("解析失败:%v", err)
  26367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26368. return
  26369. }
  26370. } else if miConfig.MdtrtareaAdmvs == "360302" {
  26371. var result string
  26372. var request_log string
  26373. if his.IdCardType == 2 {
  26374. 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, "")
  26375. } else if his.IdCardType == 1 {
  26376. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26377. bas := strings.Split(psn_info.CardInfo, "|")
  26378. basNumber := bas[2]
  26379. card_sn := bas[3]
  26380. var rf []*ResultFive
  26381. json.Unmarshal([]byte(his.Iinfo), &rf)
  26382. var psn_type string
  26383. for _, item := range rf {
  26384. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  26385. psn_type = item.PsnType
  26386. }
  26387. }
  26388. 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)
  26389. } else {
  26390. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26391. //bas := strings.Split(psn_info.CardInfo, "|")
  26392. //basNumber := bas[2]
  26393. //card_sn := bas[3]
  26394. var rf []*ResultFive
  26395. json.Unmarshal([]byte(his.Iinfo), &rf)
  26396. var psn_type string
  26397. for _, item := range rf {
  26398. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  26399. psn_type = item.PsnType
  26400. }
  26401. }
  26402. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26403. 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)
  26404. }
  26405. var dat map[string]interface{}
  26406. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26407. fmt.Println(dat)
  26408. } else {
  26409. fmt.Println(err)
  26410. }
  26411. saveLog(result, request_log, "2206", "预结算")
  26412. userJSONBytes, _ := json.Marshal(dat)
  26413. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26414. utils.ErrorLog("解析失败:%v", err)
  26415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26416. return
  26417. }
  26418. } else if miConfig.MdtrtareaAdmvs == "341203" {
  26419. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26420. if his.IdCardType == 4 {
  26421. psn_info.VerifyNumber = psn_info.VerifyNumber
  26422. cert_no = psn_info.Certno
  26423. } else if his.IdCardType == 2 {
  26424. cert_no = psn_info.Certno
  26425. psn_info.VerifyNumber = psn_info.Certno
  26426. } else {
  26427. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26428. bas := strings.Split(psn_info.CardInfo, "|")
  26429. if his.IdCardType == 1 {
  26430. cert_no = bas[2]
  26431. } else {
  26432. cert_no = bas[1]
  26433. }
  26434. }
  26435. var api string
  26436. var med_type string
  26437. if his.Insutype == "390" {
  26438. if reg_type == 992102 {
  26439. med_type = "992102"
  26440. }
  26441. if reg_type == 140104 {
  26442. med_type = "140104"
  26443. }
  26444. if reg_type == 14 {
  26445. med_type = "140104"
  26446. }
  26447. } else if his.Insutype == "310" {
  26448. if reg_type == 992102 {
  26449. med_type = "992102"
  26450. }
  26451. if reg_type == 14 {
  26452. med_type = "14"
  26453. }
  26454. }
  26455. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26456. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26457. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26458. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26459. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26460. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26461. "&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
  26462. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26463. resp, requestErr := http.Get(api)
  26464. if requestErr != nil {
  26465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26466. return
  26467. }
  26468. body, ioErr := ioutil.ReadAll(resp.Body)
  26469. if ioErr != nil {
  26470. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26472. return
  26473. }
  26474. var respJSON map[string]interface{}
  26475. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26476. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26478. return
  26479. }
  26480. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26481. if status == "0" {
  26482. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26483. c.ServeSuccessJSON(map[string]interface{}{
  26484. "failed_code": -10,
  26485. "msg": err_msg,
  26486. })
  26487. return
  26488. }
  26489. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26490. result, _ := json.Marshal(respJSON)
  26491. fmt.Println("log")
  26492. fmt.Println(string(result))
  26493. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  26494. utils.ErrorLog("解析失败:%v", err)
  26495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26496. return
  26497. }
  26498. res.InfRefmsgid = ahres.InfRefmsgid
  26499. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  26500. // 创建对应的Time类型
  26501. t := time.UnixMilli(timestamp)
  26502. // 格式化成指定的日期字符串
  26503. str := t.Format("2006-01-02 15:04:05")
  26504. res.Output.Setlinfo.SetlTime = str
  26505. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  26506. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  26507. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  26508. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  26509. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  26510. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  26511. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26512. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  26513. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  26514. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  26515. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  26516. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  26517. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  26518. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  26519. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  26520. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  26521. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  26522. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  26523. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  26524. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26525. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  26526. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  26527. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  26528. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  26529. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  26530. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  26531. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  26532. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  26533. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  26534. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  26535. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  26536. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  26537. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  26538. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  26539. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  26540. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  26541. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  26542. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  26543. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  26544. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  26545. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  26546. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  26547. //res.Output.Setldetail = ahres.Output.Setldetail
  26548. res.ErrMsg = ahres.ErrMsg
  26549. res.Cainfo = ahres.Cainfo
  26550. res.WarnMsg = ahres.WarnMsg
  26551. res.Infcode = ahres.Infcode
  26552. } else if miConfig.MdtrtareaAdmvs == "430800" {
  26553. var result string
  26554. var request_log string
  26555. if his.IdCardType == 2 {
  26556. 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")
  26557. } else if his.IdCardType == 1 {
  26558. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26559. bas := strings.Split(psn_info.CardInfo, "|")
  26560. basNumber := bas[2]
  26561. card_sn := bas[3]
  26562. 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")
  26563. } else {
  26564. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26565. 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")
  26566. }
  26567. var dat map[string]interface{}
  26568. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26569. fmt.Println(dat)
  26570. } else {
  26571. fmt.Println(err)
  26572. }
  26573. saveLog(result, request_log, "2206", "预结算")
  26574. userJSONBytes, _ := json.Marshal(dat)
  26575. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26576. utils.ErrorLog("解析失败:%v", err)
  26577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26578. return
  26579. }
  26580. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26581. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26582. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26583. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26584. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26585. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26586. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26587. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  26588. resp, requestErr := http.Get(api)
  26589. if requestErr != nil {
  26590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26591. return
  26592. }
  26593. body, ioErr := ioutil.ReadAll(resp.Body)
  26594. if ioErr != nil {
  26595. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26597. return
  26598. }
  26599. var respJSON map[string]interface{}
  26600. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26601. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26603. return
  26604. }
  26605. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26606. result, _ := json.Marshal(respJSON)
  26607. fmt.Println("log")
  26608. fmt.Println(string(result))
  26609. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26610. utils.ErrorLog("解析失败:%v", err)
  26611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26612. return
  26613. }
  26614. } else {
  26615. if miConfig.MdtrtareaAdmvs == "441202" {
  26616. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  26617. if result3101.Infcode == 0 {
  26618. if len(result3101.Output.Result) > 0 {
  26619. var errMsgs []string
  26620. for _, item := range result3101.Output.Result {
  26621. errMsgs = append(errMsgs, item.VolaCont)
  26622. }
  26623. c.ServeSuccessJSON(map[string]interface{}{
  26624. "failed_code": -10,
  26625. "msg": errMsgs,
  26626. })
  26627. return
  26628. } else {
  26629. var result string
  26630. var request_log string
  26631. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26632. allTotal = fmt.Sprintf("%.2f", total_two)
  26633. if his.IdCardType == 4 {
  26634. 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)
  26635. } else {
  26636. 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)
  26637. }
  26638. var dat map[string]interface{}
  26639. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26640. fmt.Println(dat)
  26641. } else {
  26642. fmt.Println(err)
  26643. }
  26644. saveLog(result, request_log, "2206", "预结算")
  26645. //userJSONBytes, _ := json.Marshal(dat)
  26646. //
  26647. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26648. // utils.ErrorLog("解析失败:%v", err)
  26649. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26650. // return
  26651. //}
  26652. userJSONBytes, _ := json.Marshal(dat)
  26653. if miConfig.Code == "H15049901371" {
  26654. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26655. utils.ErrorLog("解析失败:%v", err)
  26656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26657. return
  26658. }
  26659. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26660. res.Output = resSeven10265.Output
  26661. res.ErrMsg = resSeven10265.ErrMsg
  26662. res.Cainfo = resSeven10265.Cainfo
  26663. res.WarnMsg = resSeven10265.WarnMsg
  26664. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26665. res.Infcode = infocode
  26666. } else {
  26667. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26668. utils.ErrorLog("解析失败:%v", err)
  26669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26670. return
  26671. }
  26672. }
  26673. }
  26674. } else {
  26675. c.ServeSuccessJSON(map[string]interface{}{
  26676. "failed_code": -10,
  26677. "msg": result3101.ErrMsg,
  26678. })
  26679. return
  26680. }
  26681. } else if miConfig.MdtrtareaAdmvs == "440205" {
  26682. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  26683. if result3101.Infcode == 0 {
  26684. if len(result3101.Output.Result) > 0 {
  26685. var errMsgs []string
  26686. for _, item := range result3101.Output.Result {
  26687. errMsgs = append(errMsgs, item.VolaCont)
  26688. }
  26689. c.ServeSuccessJSON(map[string]interface{}{
  26690. "failed_code": -10,
  26691. "msg": errMsgs,
  26692. })
  26693. return
  26694. } else {
  26695. var result string
  26696. var request_log string
  26697. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26698. allTotal = fmt.Sprintf("%.2f", total_two)
  26699. if his.IdCardType == 4 {
  26700. 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)
  26701. } else {
  26702. 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)
  26703. }
  26704. var dat map[string]interface{}
  26705. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26706. fmt.Println(dat)
  26707. } else {
  26708. fmt.Println(err)
  26709. }
  26710. saveLog(result, request_log, "2206", "预结算")
  26711. //userJSONBytes, _ := json.Marshal(dat)
  26712. //
  26713. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26714. // utils.ErrorLog("解析失败:%v", err)
  26715. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26716. // return
  26717. //}
  26718. userJSONBytes, _ := json.Marshal(dat)
  26719. if miConfig.Code == "H15049901371" {
  26720. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26721. utils.ErrorLog("解析失败:%v", err)
  26722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26723. return
  26724. }
  26725. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26726. res.Output = resSeven10265.Output
  26727. res.ErrMsg = resSeven10265.ErrMsg
  26728. res.Cainfo = resSeven10265.Cainfo
  26729. res.WarnMsg = resSeven10265.WarnMsg
  26730. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26731. res.Infcode = infocode
  26732. } else {
  26733. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26734. utils.ErrorLog("解析失败:%v", err)
  26735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26736. return
  26737. }
  26738. }
  26739. }
  26740. } else {
  26741. c.ServeSuccessJSON(map[string]interface{}{
  26742. "failed_code": -10,
  26743. "msg": result3101.ErrMsg,
  26744. })
  26745. return
  26746. }
  26747. }else {
  26748. var result string
  26749. var request_log string
  26750. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26751. allTotal = fmt.Sprintf("%.2f", total_two)
  26752. if his.IdCardType == 4 {
  26753. 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)
  26754. } else {
  26755. 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)
  26756. }
  26757. var dat map[string]interface{}
  26758. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26759. fmt.Println(dat)
  26760. } else {
  26761. fmt.Println(err)
  26762. }
  26763. saveLog(result, request_log, "2206", "预结算")
  26764. //userJSONBytes, _ := json.Marshal(dat)
  26765. //
  26766. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26767. // utils.ErrorLog("解析失败:%v", err)
  26768. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26769. // return
  26770. //}
  26771. userJSONBytes, _ := json.Marshal(dat)
  26772. if miConfig.Code == "H15049901371" {
  26773. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26774. utils.ErrorLog("解析失败:%v", err)
  26775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26776. return
  26777. }
  26778. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26779. res.Output = resSeven10265.Output
  26780. res.ErrMsg = resSeven10265.ErrMsg
  26781. res.Cainfo = resSeven10265.Cainfo
  26782. res.WarnMsg = resSeven10265.WarnMsg
  26783. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26784. res.Infcode = infocode
  26785. } else {
  26786. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26787. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  26788. utils.ErrorLog("解析失败:%v", err)
  26789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26790. return
  26791. }
  26792. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  26793. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  26794. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  26795. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26796. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  26797. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  26798. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  26799. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26800. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  26801. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26802. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26803. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26804. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26805. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26806. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  26807. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  26808. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  26809. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  26810. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  26811. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  26812. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26813. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  26814. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  26815. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  26816. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  26817. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  26818. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  26819. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  26820. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  26821. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  26822. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  26823. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  26824. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  26825. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  26826. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  26827. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  26828. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  26829. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  26830. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26831. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  26832. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  26833. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  26834. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  26835. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  26836. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  26837. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  26838. res.ErrMsg = gzresSeven10265Two.ErrMsg
  26839. res.Cainfo = gzresSeven10265Two.Cainfo
  26840. res.WarnMsg = gzresSeven10265Two.WarnMsg
  26841. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  26842. //res.Infcode = infocode
  26843. } else {
  26844. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26845. utils.ErrorLog("解析失败:%v", err)
  26846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26847. return
  26848. }
  26849. }
  26850. }
  26851. }
  26852. }
  26853. utils.ErrorLog("解析失败:%v", res.Infcode)
  26854. if res.Infcode == -1 {
  26855. errlog := &models.HisOrderError{
  26856. UserOrgId: adminUser.CurrentOrgId,
  26857. Ctime: time.Now().Unix(),
  26858. Mtime: time.Now().Unix(),
  26859. Number: chrg_bchno,
  26860. ErrMsg: res.ErrMsg,
  26861. Status: 1,
  26862. PatientId: id,
  26863. RecordTime: recordDateTime,
  26864. Stage: 20,
  26865. }
  26866. service.CreateErrMsgLog(errlog)
  26867. c.ServeSuccessJSON(map[string]interface{}{
  26868. "failed_code": -10,
  26869. "msg": res.ErrMsg,
  26870. })
  26871. return
  26872. }
  26873. if res.Infcode != 0 {
  26874. errlog := &models.HisOrderError{
  26875. UserOrgId: adminUser.CurrentOrgId,
  26876. Ctime: time.Now().Unix(),
  26877. Mtime: time.Now().Unix(),
  26878. Number: chrg_bchno,
  26879. ErrMsg: res.ErrMsg,
  26880. Status: 1,
  26881. PatientId: id,
  26882. RecordTime: recordDateTime,
  26883. Stage: 20,
  26884. }
  26885. service.CreateErrMsgLog(errlog)
  26886. c.ServeSuccessJSON(map[string]interface{}{
  26887. "failed_code": -10,
  26888. "msg": res.ErrMsg,
  26889. })
  26890. return
  26891. } else {
  26892. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  26893. order.OrderStatus = 1
  26894. order.IsPre = 1
  26895. order.Status = 1
  26896. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  26897. order.SetlId = res.Output.Setlinfo.SetlID
  26898. order.PsnNo = res.Output.Setlinfo.PsnNo
  26899. order.PsnName = res.Output.Setlinfo.PsnName
  26900. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  26901. order.Certno = res.Output.Setlinfo.Certno
  26902. order.Gend = res.Output.Setlinfo.Gend
  26903. order.Naty = res.Output.Setlinfo.Naty
  26904. order.Age = res.Output.Setlinfo.Age
  26905. order.Insutype = res.Output.Setlinfo.Insutype
  26906. order.PsnType = res.Output.Setlinfo.PsnType
  26907. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  26908. order.SetlTime = res.Output.Setlinfo.SetlTime
  26909. order.AcctUsedFlag = acct_used_flag
  26910. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  26911. if res.Output.Setlinfo.MedType == "140101" {
  26912. order.MedType = "14"
  26913. } else {
  26914. if res.Output.Setlinfo.MedType == "110104" {
  26915. order.MedType = "11"
  26916. } else {
  26917. order.MedType = res.Output.Setlinfo.MedType
  26918. }
  26919. }
  26920. if res.Output.Setlinfo.MedType == "992102" {
  26921. order.MedType = "992102"
  26922. }
  26923. if res.Output.Setlinfo.MedType == "140104" {
  26924. order.MedType = "140104"
  26925. }
  26926. if res.Output.Setlinfo.MedType == "14" {
  26927. order.MedType = "14"
  26928. }
  26929. if reg_type == 1112 {
  26930. order.MedType = "1112"
  26931. }
  26932. if reg_type == 1111 {
  26933. order.MedType = "1111"
  26934. }
  26935. order.ClrType = res.Output.Setlinfo.ClrType
  26936. if adminUser.CurrentOrgId == 10480 {
  26937. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  26938. order.ClrType = "11"
  26939. } else {
  26940. order.ClrType = "9903"
  26941. }
  26942. }
  26943. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  26944. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  26945. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  26946. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  26947. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  26948. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  26949. order.HifpPay = res.Output.Setlinfo.HifpPay
  26950. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  26951. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  26952. order.HifesPay = res.Output.Setlinfo.HifesPay
  26953. order.HifobPay = res.Output.Setlinfo.HifobPay
  26954. order.MafPay = res.Output.Setlinfo.MafPay
  26955. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  26956. order.OthPay = res.Output.Setlinfo.OthPay
  26957. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  26958. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  26959. order.AcctPay = res.Output.Setlinfo.AcctPay
  26960. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  26961. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  26962. order.Balc = res.Output.Setlinfo.Balc
  26963. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  26964. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  26965. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  26966. order.ClrWay = res.Output.Setlinfo.ClrWay
  26967. order.Creator = order.Creator
  26968. order.Modify = roles.AdminUserId
  26969. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  26970. //detailStr := string(setlDetail)
  26971. //order.SetlDetail = detailStr
  26972. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  26973. err = service.UpDateOrder(order)
  26974. if err == nil {
  26975. c.ServeSuccessJSON(map[string]interface{}{
  26976. "msg": "预结算成功",
  26977. })
  26978. } else {
  26979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  26980. return
  26981. }
  26982. }
  26983. } else {
  26984. adminUser := c.GetAdminUserInfo()
  26985. errlog := &models.HisOrderError{
  26986. UserOrgId: adminUser.CurrentOrgId,
  26987. Ctime: time.Now().Unix(),
  26988. Mtime: time.Now().Unix(),
  26989. ErrMsg: res.ErrMsg,
  26990. Status: 1,
  26991. PatientId: id,
  26992. RecordTime: recordDateTime,
  26993. Stage: 4,
  26994. }
  26995. service.CreateErrMsgLog(errlog)
  26996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  26997. return
  26998. }
  26999. } else {
  27000. if miConfig.MdtrtareaAdmvs == "150499" {
  27001. order := &models.HisOrder{
  27002. UserOrgId: adminUser.CurrentOrgId,
  27003. HisPatientId: his.ID,
  27004. PatientId: his.PatientId,
  27005. SettleAccountsDate: recordDateTime,
  27006. Ctime: time.Now().Unix(),
  27007. Mtime: time.Now().Unix(),
  27008. MdtrtId: his.Number,
  27009. PsnNo: his.PsnNo,
  27010. MedType: strconv.FormatInt(reg_type, 10),
  27011. Status: 1,
  27012. Number: chrg_bchno,
  27013. Infcode: res.Infcode,
  27014. WarnMsg: res.WarnMsg,
  27015. Cainfo: res.Cainfo,
  27016. ErrMsg: res.ErrMsg,
  27017. RespondTime: res.RefmsgTime,
  27018. InfRefmsgid: res.InfRefmsgid,
  27019. OrderStatus: 1,
  27020. IsMedicineInsurance: 1,
  27021. SettleType: settle_accounts_type,
  27022. SettleStartTime: start_time,
  27023. SettleEndTime: end_time,
  27024. Creator: roles.AdminUserId,
  27025. Modify: roles.AdminUserId,
  27026. PType: 2,
  27027. Diagnosis: diagnosis_id,
  27028. }
  27029. err = service.CreateOrder(order)
  27030. if err != nil {
  27031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  27032. return
  27033. }
  27034. }
  27035. adminUser := c.GetAdminUserInfo()
  27036. errlog := &models.HisOrderError{
  27037. UserOrgId: adminUser.CurrentOrgId,
  27038. Ctime: time.Now().Unix(),
  27039. Mtime: time.Now().Unix(),
  27040. ErrMsg: res.ErrMsg,
  27041. Status: 1,
  27042. PatientId: id,
  27043. RecordTime: recordDateTime,
  27044. Stage: 4,
  27045. }
  27046. service.CreateErrMsgLog(errlog)
  27047. c.ServeSuccessJSON(map[string]interface{}{
  27048. "failed_code": -10,
  27049. "msg": res.ErrMsg,
  27050. })
  27051. return
  27052. }
  27053. }
  27054. }
  27055. }
  27056. // 退款
  27057. func (c *HisApiController) Refund() {
  27058. order_id, _ := c.GetInt64("order_id")
  27059. admin_user_id, _ := c.GetInt64("admin_user_id")
  27060. adminUser := c.GetAdminUserInfo()
  27061. var order models.HisOrder
  27062. order, _ = service.GetHisOrderByID(order_id)
  27063. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  27064. if fapiao.ID > 0 {
  27065. c.ServeSuccessJSON(map[string]interface{}{
  27066. "failed_code": -10,
  27067. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  27068. })
  27069. return
  27070. }
  27071. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27072. if order.ID == 0 {
  27073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27074. return
  27075. }
  27076. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  27077. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27078. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27079. if config.IsOpen == 1 { //对接了医保,走医保流程
  27080. var res ResultSixteen
  27081. var ahres ResultSevenAH
  27082. var resSixteen10265 ResultSixteen10265
  27083. var resSixteen10265Two ResultSixteen10265Two
  27084. var gz ResultgzSixteen10265Two
  27085. var src_resquest string
  27086. var result string
  27087. if miConfig.MdtrtareaAdmvs == "421300" {
  27088. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  27089. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  27090. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27091. resp3, requestErr3 := http.Get(api3)
  27092. if requestErr3 != nil {
  27093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27094. return
  27095. }
  27096. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  27097. if ioErr3 != nil {
  27098. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  27099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27100. return
  27101. }
  27102. var respJSON3 map[string]interface{}
  27103. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  27104. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27106. return
  27107. }
  27108. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27109. userJSONBytes3, _ := json.Marshal(respJSON3)
  27110. fmt.Println("log")
  27111. fmt.Println(string(userJSONBytes3))
  27112. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  27113. utils.ErrorLog("解析失败:%v", err)
  27114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27115. return
  27116. }
  27117. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27118. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  27119. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  27120. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27121. resp3, requestErr3 := http.Get(api3)
  27122. if requestErr3 != nil {
  27123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27124. return
  27125. }
  27126. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  27127. if ioErr3 != nil {
  27128. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  27129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27130. return
  27131. }
  27132. var respJSON3 map[string]interface{}
  27133. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  27134. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27136. return
  27137. }
  27138. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27139. userJSONBytes3, _ := json.Marshal(respJSON3)
  27140. fmt.Println("log")
  27141. fmt.Println(string(userJSONBytes3))
  27142. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  27143. utils.ErrorLog("解析失败:%v", err)
  27144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27145. return
  27146. }
  27147. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27148. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  27149. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  27150. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27151. resp3, requestErr3 := http.Get(api3)
  27152. if requestErr3 != nil {
  27153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27154. return
  27155. }
  27156. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  27157. if ioErr3 != nil {
  27158. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  27159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27160. return
  27161. }
  27162. var respJSON3 map[string]interface{}
  27163. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  27164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27166. return
  27167. }
  27168. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27169. userJSONBytes3, _ := json.Marshal(respJSON3)
  27170. fmt.Println("log")
  27171. fmt.Println(string(userJSONBytes3))
  27172. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  27173. utils.ErrorLog("解析失败:%v", err)
  27174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27175. return
  27176. }
  27177. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27178. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  27179. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  27180. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27181. resp3, requestErr3 := http.Get(api3)
  27182. if requestErr3 != nil {
  27183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27184. return
  27185. }
  27186. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  27187. if ioErr3 != nil {
  27188. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  27189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27190. return
  27191. }
  27192. var respJSON3 map[string]interface{}
  27193. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  27194. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27196. return
  27197. }
  27198. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27199. userJSONBytes3, _ := json.Marshal(respJSON3)
  27200. fmt.Println("log")
  27201. fmt.Println(string(userJSONBytes3))
  27202. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  27203. utils.ErrorLog("解析失败:%v", err)
  27204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27205. return
  27206. }
  27207. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27208. var api3 string
  27209. if miConfig.MdtrtareaAdmvs == "320921" {
  27210. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  27211. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  27212. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27213. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27214. } else {
  27215. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27216. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  27217. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  27218. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27219. }
  27220. resp3, requestErr3 := http.Get(api3)
  27221. if requestErr3 != nil {
  27222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27223. return
  27224. }
  27225. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  27226. if ioErr3 != nil {
  27227. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  27228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27229. return
  27230. }
  27231. var respJSON3 map[string]interface{}
  27232. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  27233. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27235. return
  27236. }
  27237. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27238. userJSONBytes3, _ := json.Marshal(respJSON3)
  27239. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  27240. utils.ErrorLog("解析失败:%v", err)
  27241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27242. return
  27243. }
  27244. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  27245. res.Output = resSixteen10265.Output
  27246. res.ErrMsg = resSixteen10265.ErrMsg
  27247. res.Cainfo = resSixteen10265.Cainfo
  27248. res.WarnMsg = resSixteen10265.WarnMsg
  27249. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  27250. res.Infcode = infocode
  27251. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27252. var api3 string
  27253. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  27254. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  27255. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27256. resp3, requestErr3 := http.Get(api3)
  27257. if requestErr3 != nil {
  27258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27259. return
  27260. }
  27261. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  27262. if ioErr3 != nil {
  27263. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  27264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27265. return
  27266. }
  27267. var respJSON3 map[string]interface{}
  27268. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  27269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27271. return
  27272. }
  27273. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27274. userJSONBytes3, _ := json.Marshal(respJSON3)
  27275. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  27276. utils.ErrorLog("解析失败:%v", err)
  27277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27278. return
  27279. }
  27280. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  27281. res.Output = resSixteen10265.Output
  27282. res.ErrMsg = resSixteen10265.ErrMsg
  27283. res.Cainfo = resSixteen10265.Cainfo
  27284. res.WarnMsg = resSixteen10265.WarnMsg
  27285. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  27286. res.Infcode = infocode
  27287. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27288. 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)
  27289. var dat map[string]interface{}
  27290. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27291. fmt.Println(dat)
  27292. } else {
  27293. fmt.Println(err)
  27294. }
  27295. saveLog(result, src_resquest, "2208", "退费")
  27296. userJSONBytes, _ := json.Marshal(dat)
  27297. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27298. utils.ErrorLog("解析失败:%v", err)
  27299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27300. return
  27301. }
  27302. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27303. 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, "")
  27304. var dat map[string]interface{}
  27305. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27306. fmt.Println(dat)
  27307. } else {
  27308. fmt.Println(err)
  27309. }
  27310. saveLog(result, src_resquest, "2208", "退费")
  27311. userJSONBytes, _ := json.Marshal(dat)
  27312. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27313. utils.ErrorLog("解析失败:%v", err)
  27314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27315. return
  27316. }
  27317. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27318. var api3 string
  27319. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  27320. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  27321. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27322. resp3, requestErr3 := http.Get(api3)
  27323. if requestErr3 != nil {
  27324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27325. return
  27326. }
  27327. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  27328. if ioErr3 != nil {
  27329. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  27330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27331. return
  27332. }
  27333. var respJSON3 map[string]interface{}
  27334. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  27335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27337. return
  27338. }
  27339. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  27340. if status == "0" {
  27341. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  27342. c.ServeSuccessJSON(map[string]interface{}{
  27343. "failed_code": -10,
  27344. "msg": err_msg,
  27345. })
  27346. return
  27347. }
  27348. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27349. userJSONBytes3, _ := json.Marshal(respJSON3)
  27350. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  27351. // utils.ErrorLog("解析失败:%v", err)
  27352. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27353. // return
  27354. //}
  27355. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  27356. utils.ErrorLog("解析失败:%v", err)
  27357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27358. return
  27359. }
  27360. res.InfRefmsgid = ahres.InfRefmsgid
  27361. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27362. // 创建对应的Time类型
  27363. t := time.UnixMilli(timestamp)
  27364. // 格式化成指定的日期字符串
  27365. str := t.Format("2006-01-02 15:04:05")
  27366. res.Output.Setlinfo.SetlTime = str
  27367. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27368. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27369. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27370. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27371. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27372. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27373. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27374. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27375. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27376. //
  27377. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  27378. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27379. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27380. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27381. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27382. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27383. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27384. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27385. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27386. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27387. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27388. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27389. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27390. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27391. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27392. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27393. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27394. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27395. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27396. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27397. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27398. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27399. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27400. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27401. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27402. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27403. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27404. //res.Output.Setldetail = ahres.Output.Setldetail
  27405. res.ErrMsg = ahres.ErrMsg
  27406. res.Cainfo = ahres.Cainfo
  27407. res.WarnMsg = ahres.WarnMsg
  27408. res.Infcode = ahres.Infcode
  27409. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27410. 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, "")
  27411. var dat map[string]interface{}
  27412. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27413. fmt.Println(dat)
  27414. } else {
  27415. fmt.Println(err)
  27416. }
  27417. saveLog(result, src_resquest, "2208", "退费")
  27418. userJSONBytes, _ := json.Marshal(dat)
  27419. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27420. utils.ErrorLog("解析失败:%v", err)
  27421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27422. return
  27423. }
  27424. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27425. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  27426. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  27427. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27428. resp3, requestErr3 := http.Get(api3)
  27429. if requestErr3 != nil {
  27430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27431. return
  27432. }
  27433. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  27434. if ioErr3 != nil {
  27435. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  27436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27437. return
  27438. }
  27439. var respJSON3 map[string]interface{}
  27440. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  27441. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27443. return
  27444. }
  27445. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27446. userJSONBytes3, _ := json.Marshal(respJSON3)
  27447. fmt.Println("log")
  27448. fmt.Println(string(userJSONBytes3))
  27449. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  27450. utils.ErrorLog("解析失败:%v", err)
  27451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27452. return
  27453. }
  27454. } else {
  27455. if miConfig.Code == "H15049901371" {
  27456. 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)
  27457. var dat map[string]interface{}
  27458. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27459. fmt.Println(dat)
  27460. } else {
  27461. fmt.Println(err)
  27462. }
  27463. saveLog(result, src_resquest, "2208", "退费")
  27464. if strings.Contains(result, "Post") {
  27465. res.Infcode = -1
  27466. res.ErrMsg = result
  27467. }
  27468. userJSONBytes, _ := json.Marshal(dat)
  27469. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  27470. utils.ErrorLog("解析失败:%v", err)
  27471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27472. return
  27473. }
  27474. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  27475. res.Output = resSixteen10265.Output
  27476. res.ErrMsg = resSixteen10265.ErrMsg
  27477. res.Cainfo = resSixteen10265.Cainfo
  27478. res.WarnMsg = resSixteen10265.WarnMsg
  27479. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  27480. res.Infcode = infocode
  27481. } else {
  27482. 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)
  27483. var dat map[string]interface{}
  27484. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27485. fmt.Println(dat)
  27486. } else {
  27487. fmt.Println(err)
  27488. }
  27489. saveLog(result, src_resquest, "2208", "退费")
  27490. userJSONBytes, _ := json.Marshal(dat)
  27491. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27492. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  27493. utils.ErrorLog("解析失败:%v", err)
  27494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27495. return
  27496. }
  27497. res.Infcode = gz.Infcode
  27498. } else {
  27499. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27500. utils.ErrorLog("解析失败:%v", err)
  27501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27502. return
  27503. }
  27504. }
  27505. if strings.Contains(result, "Post") {
  27506. res.Infcode = -1
  27507. res.ErrMsg = result
  27508. }
  27509. }
  27510. }
  27511. if res.Infcode == -1{
  27512. c.ServeSuccessJSON(map[string]interface{}{
  27513. "failed_code": -10,
  27514. "msg": res.ErrMsg,
  27515. })
  27516. return
  27517. }
  27518. if res.Infcode != -1 {
  27519. var res2 ResultSix
  27520. var resSix10265 ResultSix10265
  27521. if miConfig.MdtrtareaAdmvs == "421300" {
  27522. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  27523. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  27524. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27525. resp3, requestErr3 := http.Get(api3)
  27526. if requestErr3 != nil {
  27527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27528. return
  27529. }
  27530. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  27531. if ioErr3 != nil {
  27532. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  27533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27534. return
  27535. }
  27536. var respJSON3 map[string]interface{}
  27537. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  27538. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27540. return
  27541. }
  27542. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27543. userJSONBytes3, _ := json.Marshal(respJSON3)
  27544. fmt.Println("log")
  27545. fmt.Println(string(userJSONBytes3))
  27546. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  27547. utils.ErrorLog("解析失败:%v", err)
  27548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27549. return
  27550. }
  27551. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27552. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  27553. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  27554. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27555. resp3, requestErr3 := http.Get(api3)
  27556. if requestErr3 != nil {
  27557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27558. return
  27559. }
  27560. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  27561. if ioErr3 != nil {
  27562. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  27563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27564. return
  27565. }
  27566. var respJSON3 map[string]interface{}
  27567. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  27568. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27570. return
  27571. }
  27572. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27573. userJSONBytes3, _ := json.Marshal(respJSON3)
  27574. fmt.Println("log")
  27575. fmt.Println(string(userJSONBytes3))
  27576. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  27577. utils.ErrorLog("解析失败:%v", err)
  27578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27579. return
  27580. }
  27581. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27582. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  27583. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  27584. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27585. resp3, requestErr3 := http.Get(api3)
  27586. if requestErr3 != nil {
  27587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27588. return
  27589. }
  27590. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  27591. if ioErr3 != nil {
  27592. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  27593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27594. return
  27595. }
  27596. var respJSON3 map[string]interface{}
  27597. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  27598. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27600. return
  27601. }
  27602. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27603. userJSONBytes3, _ := json.Marshal(respJSON3)
  27604. fmt.Println("log")
  27605. fmt.Println(string(userJSONBytes3))
  27606. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  27607. utils.ErrorLog("解析失败:%v", err)
  27608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27609. return
  27610. }
  27611. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27612. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  27613. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  27614. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27615. resp3, requestErr3 := http.Get(api3)
  27616. if requestErr3 != nil {
  27617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27618. return
  27619. }
  27620. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  27621. if ioErr3 != nil {
  27622. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  27623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27624. return
  27625. }
  27626. var respJSON3 map[string]interface{}
  27627. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  27628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27630. return
  27631. }
  27632. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27633. userJSONBytes3, _ := json.Marshal(respJSON3)
  27634. fmt.Println("log")
  27635. fmt.Println(string(userJSONBytes3))
  27636. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  27637. utils.ErrorLog("解析失败:%v", err)
  27638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27639. return
  27640. }
  27641. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27642. var api3 string
  27643. if miConfig.MdtrtareaAdmvs == "320921" {
  27644. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  27645. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  27646. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27647. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27648. } else {
  27649. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27650. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  27651. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  27652. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27653. }
  27654. resp3, requestErr3 := http.Get(api3)
  27655. if requestErr3 != nil {
  27656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27657. return
  27658. }
  27659. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  27660. if ioErr3 != nil {
  27661. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  27662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27663. return
  27664. }
  27665. var respJSON3 map[string]interface{}
  27666. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  27667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27669. return
  27670. }
  27671. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27672. userJSONBytes3, _ := json.Marshal(respJSON3)
  27673. fmt.Println("log")
  27674. fmt.Println(string(userJSONBytes3))
  27675. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  27676. utils.ErrorLog("解析失败:%v", err)
  27677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27678. return
  27679. }
  27680. res2.InfRefmsgid = resSix10265.InfRefmsgid
  27681. res2.Output = resSix10265.Output
  27682. res2.ErrMsg = resSix10265.ErrMsg
  27683. res2.Cainfo = resSix10265.Cainfo
  27684. res2.WarnMsg = resSix10265.WarnMsg
  27685. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  27686. res2.Infcode = infocode
  27687. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27688. var api3 string
  27689. new_chrg_bchno := order.Number
  27690. if adminUser.CurrentOrgId == 10265 {
  27691. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27692. new_chrg_bchno = "0000"
  27693. }
  27694. }
  27695. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  27696. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  27697. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27698. resp3, requestErr3 := http.Get(api3)
  27699. if requestErr3 != nil {
  27700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27701. return
  27702. }
  27703. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  27704. if ioErr3 != nil {
  27705. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  27706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27707. return
  27708. }
  27709. var respJSON3 map[string]interface{}
  27710. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  27711. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27713. return
  27714. }
  27715. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27716. userJSONBytes3, _ := json.Marshal(respJSON3)
  27717. fmt.Println("log")
  27718. fmt.Println(string(userJSONBytes3))
  27719. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  27720. utils.ErrorLog("解析失败:%v", err)
  27721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27722. return
  27723. }
  27724. res2.InfRefmsgid = resSix10265.InfRefmsgid
  27725. res2.Output = resSix10265.Output
  27726. res2.ErrMsg = resSix10265.ErrMsg
  27727. res2.Cainfo = resSix10265.Cainfo
  27728. res2.WarnMsg = resSix10265.WarnMsg
  27729. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  27730. res2.Infcode = infocode
  27731. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27732. 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)
  27733. var dat map[string]interface{}
  27734. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27735. fmt.Println(dat)
  27736. } else {
  27737. fmt.Println(err)
  27738. }
  27739. saveLog(result2, src_request, "2205", "撤销明细")
  27740. userJSONBytes, _ := json.Marshal(dat)
  27741. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27742. utils.ErrorLog("解析失败:%v", err)
  27743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27744. return
  27745. }
  27746. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27747. 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, "")
  27748. var dat map[string]interface{}
  27749. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27750. fmt.Println(dat)
  27751. } else {
  27752. fmt.Println(err)
  27753. }
  27754. saveLog(result2, src_request, "2205", "撤销明细")
  27755. userJSONBytes, _ := json.Marshal(dat)
  27756. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27757. utils.ErrorLog("解析失败:%v", err)
  27758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27759. return
  27760. }
  27761. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27762. var api3 string
  27763. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  27764. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  27765. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27766. resp3, requestErr3 := http.Get(api3)
  27767. if requestErr3 != nil {
  27768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27769. return
  27770. }
  27771. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  27772. if ioErr3 != nil {
  27773. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  27774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27775. return
  27776. }
  27777. var respJSON3 map[string]interface{}
  27778. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  27779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27781. return
  27782. }
  27783. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  27784. if status == "0" {
  27785. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  27786. c.ServeSuccessJSON(map[string]interface{}{
  27787. "failed_code": -10,
  27788. "msg": err_msg,
  27789. })
  27790. return
  27791. }
  27792. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27793. userJSONBytes3, _ := json.Marshal(respJSON3)
  27794. fmt.Println("log")
  27795. fmt.Println(string(userJSONBytes3))
  27796. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  27797. utils.ErrorLog("解析失败:%v", err)
  27798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27799. return
  27800. }
  27801. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27802. 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, "")
  27803. var dat map[string]interface{}
  27804. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27805. fmt.Println(dat)
  27806. } else {
  27807. fmt.Println(err)
  27808. }
  27809. saveLog(result2, src_request, "2205", "撤销明细")
  27810. userJSONBytes, _ := json.Marshal(dat)
  27811. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27812. utils.ErrorLog("解析失败:%v", err)
  27813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27814. return
  27815. }
  27816. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27817. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  27818. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  27819. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27820. resp3, requestErr3 := http.Get(api3)
  27821. if requestErr3 != nil {
  27822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27823. return
  27824. }
  27825. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  27826. if ioErr3 != nil {
  27827. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  27828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27829. return
  27830. }
  27831. var respJSON3 map[string]interface{}
  27832. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  27833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27835. return
  27836. }
  27837. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27838. userJSONBytes3, _ := json.Marshal(respJSON3)
  27839. fmt.Println("log")
  27840. fmt.Println(string(userJSONBytes3))
  27841. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  27842. utils.ErrorLog("解析失败:%v", err)
  27843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27844. return
  27845. }
  27846. } else {
  27847. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27848. res2.Infcode = 0
  27849. } else {
  27850. 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)
  27851. var dat map[string]interface{}
  27852. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27853. fmt.Println(dat)
  27854. } else {
  27855. fmt.Println(err)
  27856. }
  27857. saveLog(result2, src_request, "2205", "撤销明细")
  27858. userJSONBytes, _ := json.Marshal(dat)
  27859. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27860. utils.ErrorLog("解析失败:%v", err)
  27861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27862. return
  27863. }
  27864. }
  27865. }
  27866. if res2.Infcode == -1 {
  27867. c.ServeSuccessJSON(map[string]interface{}{
  27868. "failed_code": -10,
  27869. "msg": res2.ErrMsg,
  27870. })
  27871. return
  27872. }
  27873. if res2.Infcode == 0 {
  27874. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  27875. if err == nil {
  27876. //当押金不为零时产生退费记录
  27877. if order.Decimal != 0 {
  27878. tmp := strconv.FormatInt(order.ID, 10)
  27879. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  27880. if err != nil {
  27881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27882. return
  27883. }
  27884. }
  27885. c.ServeSuccessJSON(map[string]interface{}{
  27886. "msg": "退费成功",
  27887. })
  27888. } else {
  27889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27890. return
  27891. }
  27892. } else {
  27893. c.ServeSuccessJSON(map[string]interface{}{
  27894. "failed_code": -10,
  27895. "msg": res2.ErrMsg,
  27896. })
  27897. }
  27898. } else {
  27899. c.ServeSuccessJSON(map[string]interface{}{
  27900. "failed_code": -10,
  27901. "msg": res.ErrMsg,
  27902. })
  27903. }
  27904. }
  27905. }
  27906. func (c *HisApiController) RefundNumber() {
  27907. record_time := c.GetString("record_time")
  27908. //patient_id, _ := c.GetInt64("patient_id")
  27909. admin_user_id, _ := c.GetInt64("admin_user_id")
  27910. his_patient_id, _ := c.GetInt64("id")
  27911. timeLayout := "2006-01-02"
  27912. loc, _ := time.LoadLocation("Local")
  27913. adminUser := c.GetAdminUserInfo()
  27914. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27915. fmt.Println(err)
  27916. if err != nil {
  27917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27918. return
  27919. }
  27920. recordDateTime := theTime.Unix()
  27921. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  27922. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  27923. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  27924. //order, _ := service.GetHisOrderByID(order_id)
  27925. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27926. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27927. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27928. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  27929. if count > 0 {
  27930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  27931. return
  27932. }
  27933. if config.IsOpen == 1 { //对接了医保,走医保流程
  27934. var res2 ResultSix
  27935. var res3 GZResultSix
  27936. var resSix10265 ResultSix10265
  27937. if miConfig.MdtrtareaAdmvs == "421300" {
  27938. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  27939. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  27940. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27941. resp3, requestErr3 := http.Get(api3)
  27942. if requestErr3 != nil {
  27943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27944. return
  27945. }
  27946. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  27947. if ioErr3 != nil {
  27948. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  27949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27950. return
  27951. }
  27952. var respJSON3 map[string]interface{}
  27953. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  27954. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27956. return
  27957. }
  27958. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27959. userJSONBytes3, _ := json.Marshal(respJSON3)
  27960. fmt.Println("log")
  27961. fmt.Println(string(userJSONBytes3))
  27962. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  27963. utils.ErrorLog("解析失败:%v", err)
  27964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27965. return
  27966. }
  27967. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27968. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  27969. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  27970. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27971. resp3, requestErr3 := http.Get(api3)
  27972. if requestErr3 != nil {
  27973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27974. return
  27975. }
  27976. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  27977. if ioErr3 != nil {
  27978. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  27979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27980. return
  27981. }
  27982. var respJSON3 map[string]interface{}
  27983. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  27984. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27986. return
  27987. }
  27988. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27989. userJSONBytes3, _ := json.Marshal(respJSON3)
  27990. fmt.Println("log")
  27991. fmt.Println(string(userJSONBytes3))
  27992. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  27993. utils.ErrorLog("解析失败:%v", err)
  27994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27995. return
  27996. }
  27997. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27998. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  27999. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28000. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28001. resp3, requestErr3 := http.Get(api3)
  28002. if requestErr3 != nil {
  28003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28004. return
  28005. }
  28006. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28007. if ioErr3 != nil {
  28008. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28010. return
  28011. }
  28012. var respJSON3 map[string]interface{}
  28013. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28014. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28016. return
  28017. }
  28018. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28019. userJSONBytes3, _ := json.Marshal(respJSON3)
  28020. fmt.Println("log")
  28021. fmt.Println(string(userJSONBytes3))
  28022. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28023. utils.ErrorLog("解析失败:%v", err)
  28024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28025. return
  28026. }
  28027. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28028. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  28029. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28030. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28031. resp3, requestErr3 := http.Get(api3)
  28032. if requestErr3 != nil {
  28033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28034. return
  28035. }
  28036. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28037. if ioErr3 != nil {
  28038. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28040. return
  28041. }
  28042. var respJSON3 map[string]interface{}
  28043. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28046. return
  28047. }
  28048. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28049. userJSONBytes3, _ := json.Marshal(respJSON3)
  28050. fmt.Println("log")
  28051. fmt.Println(string(userJSONBytes3))
  28052. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28053. utils.ErrorLog("解析失败:%v", err)
  28054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28055. return
  28056. }
  28057. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28058. var api3 string
  28059. if miConfig.MdtrtareaAdmvs == "320921" {
  28060. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  28061. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28062. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28063. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28064. } else {
  28065. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28066. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  28067. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28068. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28069. }
  28070. resp3, requestErr3 := http.Get(api3)
  28071. if requestErr3 != nil {
  28072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28073. return
  28074. }
  28075. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28076. if ioErr3 != nil {
  28077. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28079. return
  28080. }
  28081. var respJSON3 map[string]interface{}
  28082. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28083. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28085. return
  28086. }
  28087. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28088. userJSONBytes3, _ := json.Marshal(respJSON3)
  28089. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  28090. utils.ErrorLog("解析失败:%v", err)
  28091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28092. return
  28093. }
  28094. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28095. res2.Output = resSix10265.Output
  28096. res2.ErrMsg = resSix10265.ErrMsg
  28097. res2.Cainfo = resSix10265.Cainfo
  28098. res2.WarnMsg = resSix10265.WarnMsg
  28099. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28100. res2.Infcode = infocode
  28101. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28102. var api3 string
  28103. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  28104. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28105. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28106. resp3, requestErr3 := http.Get(api3)
  28107. if requestErr3 != nil {
  28108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28109. return
  28110. }
  28111. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28112. if ioErr3 != nil {
  28113. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28115. return
  28116. }
  28117. var respJSON3 map[string]interface{}
  28118. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28119. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28121. return
  28122. }
  28123. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28124. userJSONBytes3, _ := json.Marshal(respJSON3)
  28125. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  28126. utils.ErrorLog("解析失败:%v", err)
  28127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28128. return
  28129. }
  28130. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28131. res2.Output = resSix10265.Output
  28132. res2.ErrMsg = resSix10265.ErrMsg
  28133. res2.Cainfo = resSix10265.Cainfo
  28134. res2.WarnMsg = resSix10265.WarnMsg
  28135. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28136. res2.Infcode = infocode
  28137. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28138. 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)
  28139. var dat map[string]interface{}
  28140. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28141. fmt.Println(dat)
  28142. } else {
  28143. fmt.Println(err)
  28144. }
  28145. saveLog(result, request, "2202", "退号")
  28146. userJSONBytes, _ := json.Marshal(dat)
  28147. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28148. utils.ErrorLog("解析失败:%v", err)
  28149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28150. return
  28151. }
  28152. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28153. 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, "")
  28154. var dat map[string]interface{}
  28155. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28156. fmt.Println(dat)
  28157. } else {
  28158. fmt.Println(err)
  28159. }
  28160. saveLog(result, request, "2202", "退号")
  28161. userJSONBytes, _ := json.Marshal(dat)
  28162. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28163. utils.ErrorLog("解析失败:%v", err)
  28164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28165. return
  28166. }
  28167. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28168. var api3 string
  28169. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  28170. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28171. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28172. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28173. resp3, requestErr3 := http.Get(api3)
  28174. if requestErr3 != nil {
  28175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28176. return
  28177. }
  28178. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28179. if ioErr3 != nil {
  28180. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28182. return
  28183. }
  28184. var respJSON3 map[string]interface{}
  28185. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28186. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28188. return
  28189. }
  28190. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  28191. if status == "0" {
  28192. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  28193. c.ServeSuccessJSON(map[string]interface{}{
  28194. "failed_code": -10,
  28195. "msg": err_msg,
  28196. })
  28197. return
  28198. }
  28199. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28200. userJSONBytes3, _ := json.Marshal(respJSON3)
  28201. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28202. utils.ErrorLog("解析失败:%v", err)
  28203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28204. return
  28205. }
  28206. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  28207. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28208. 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, "")
  28209. var dat map[string]interface{}
  28210. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28211. fmt.Println(dat)
  28212. } else {
  28213. fmt.Println(err)
  28214. }
  28215. saveLog(result, request, "2202", "退号")
  28216. userJSONBytes, _ := json.Marshal(dat)
  28217. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28218. utils.ErrorLog("解析失败:%v", err)
  28219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28220. return
  28221. }
  28222. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28223. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  28224. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28225. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  28226. resp3, requestErr3 := http.Get(api3)
  28227. if requestErr3 != nil {
  28228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28229. return
  28230. }
  28231. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28232. if ioErr3 != nil {
  28233. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28235. return
  28236. }
  28237. var respJSON3 map[string]interface{}
  28238. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28239. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28241. return
  28242. }
  28243. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28244. userJSONBytes3, _ := json.Marshal(respJSON3)
  28245. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28246. utils.ErrorLog("解析失败:%v", err)
  28247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28248. return
  28249. }
  28250. } else {
  28251. var api3 string
  28252. if miConfig.Code == "H15049901371" {
  28253. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  28254. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28255. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28256. } else {
  28257. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  28258. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28259. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  28260. }
  28261. resp3, requestErr3 := http.Get(api3)
  28262. if requestErr3 != nil {
  28263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28264. return
  28265. }
  28266. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28267. if ioErr3 != nil {
  28268. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28270. return
  28271. }
  28272. var respJSON3 map[string]interface{}
  28273. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28274. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28276. return
  28277. }
  28278. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28279. userJSONBytes3, _ := json.Marshal(respJSON3)
  28280. if miConfig.Code == "H15049901371" {
  28281. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  28282. utils.ErrorLog("解析失败:%v", err)
  28283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28284. return
  28285. }
  28286. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28287. res2.Output = resSix10265.Output
  28288. res2.ErrMsg = resSix10265.ErrMsg
  28289. res2.Cainfo = resSix10265.Cainfo
  28290. res2.WarnMsg = resSix10265.WarnMsg
  28291. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28292. res2.Infcode = infocode
  28293. } else {
  28294. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28295. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  28296. utils.ErrorLog("解析失败:%v", err)
  28297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28298. return
  28299. }
  28300. res2.Infcode = res3.Infcode
  28301. } else {
  28302. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28303. utils.ErrorLog("解析失败:%v", err)
  28304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28305. return
  28306. }
  28307. }
  28308. }
  28309. }
  28310. if res2.Infcode == -1 {
  28311. c.ServeSuccessJSON(map[string]interface{}{
  28312. "failed_code": -10,
  28313. "msg": res2.ErrMsg,
  28314. })
  28315. return
  28316. }
  28317. if res2.Infcode == 0 {
  28318. if err == nil {
  28319. c.ServeSuccessJSON(map[string]interface{}{
  28320. "msg": "退号成功",
  28321. })
  28322. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  28323. } else {
  28324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28325. return
  28326. }
  28327. }
  28328. } else {
  28329. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  28330. //if err == nil {
  28331. // c.ServeSuccessJSON(map[string]interface{}{
  28332. // "msg": "退费成功",
  28333. // })
  28334. //} else {
  28335. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28336. // return
  28337. //}
  28338. }
  28339. }
  28340. func (c *HisApiController) RefundDetail() {
  28341. order_id, _ := c.GetInt64("order_id")
  28342. admin_user_id, _ := c.GetInt64("admin_user_id")
  28343. //his_patient_id, _ := c.GetInt64("his_patient_id")
  28344. number := c.GetString("number")
  28345. record_time := c.GetString("record_time")
  28346. patient_id, _ := c.GetInt64("patient_id")
  28347. //med_type, _ := c.GetInt64("med_type")
  28348. timeLayout := "2006-01-02"
  28349. loc, _ := time.LoadLocation("Local")
  28350. adminUser := c.GetAdminUserInfo()
  28351. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28352. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  28353. fmt.Println(err)
  28354. if err != nil {
  28355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28356. return
  28357. }
  28358. recordDateTime := theTime.Unix()
  28359. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  28360. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  28361. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28362. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28363. var order models.HisOrder
  28364. order, _ = service.GetHisOrderByID(order_id)
  28365. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  28366. if config.IsOpen == 1 { //对接了医保,走医保流程
  28367. var res2 ResultSix
  28368. if miConfig.MdtrtareaAdmvs == "421300" {
  28369. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  28370. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28371. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28372. resp3, requestErr3 := http.Get(api3)
  28373. if requestErr3 != nil {
  28374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28375. return
  28376. }
  28377. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28378. if ioErr3 != nil {
  28379. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28381. return
  28382. }
  28383. var respJSON3 map[string]interface{}
  28384. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28385. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28387. return
  28388. }
  28389. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28390. userJSONBytes3, _ := json.Marshal(respJSON3)
  28391. fmt.Println("log")
  28392. fmt.Println(string(userJSONBytes3))
  28393. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28394. utils.ErrorLog("解析失败:%v", err)
  28395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28396. return
  28397. }
  28398. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  28399. if err == nil {
  28400. c.ServeSuccessJSON(map[string]interface{}{
  28401. "msg": "撤销明细成功",
  28402. })
  28403. return
  28404. } else {
  28405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28406. return
  28407. }
  28408. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28409. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  28410. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28411. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28412. resp3, requestErr3 := http.Get(api3)
  28413. if requestErr3 != nil {
  28414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28415. return
  28416. }
  28417. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28418. if ioErr3 != nil {
  28419. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28421. return
  28422. }
  28423. var respJSON3 map[string]interface{}
  28424. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28425. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28427. return
  28428. }
  28429. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28430. userJSONBytes3, _ := json.Marshal(respJSON3)
  28431. fmt.Println("log")
  28432. fmt.Println(string(userJSONBytes3))
  28433. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28434. utils.ErrorLog("解析失败:%v", err)
  28435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28436. return
  28437. }
  28438. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  28439. if err == nil {
  28440. c.ServeSuccessJSON(map[string]interface{}{
  28441. "msg": "撤销明细成功",
  28442. })
  28443. return
  28444. } else {
  28445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28446. return
  28447. }
  28448. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28449. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  28450. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28451. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28452. resp3, requestErr3 := http.Get(api3)
  28453. if requestErr3 != nil {
  28454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28455. return
  28456. }
  28457. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28458. if ioErr3 != nil {
  28459. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28461. return
  28462. }
  28463. var respJSON3 map[string]interface{}
  28464. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28465. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28467. return
  28468. }
  28469. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28470. userJSONBytes3, _ := json.Marshal(respJSON3)
  28471. fmt.Println("log")
  28472. fmt.Println(string(userJSONBytes3))
  28473. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28474. utils.ErrorLog("解析失败:%v", err)
  28475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28476. return
  28477. }
  28478. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  28479. if err == nil {
  28480. c.ServeSuccessJSON(map[string]interface{}{
  28481. "msg": "撤销明细成功",
  28482. })
  28483. return
  28484. } else {
  28485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28486. return
  28487. }
  28488. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28489. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  28490. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28491. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28492. resp3, requestErr3 := http.Get(api3)
  28493. if requestErr3 != nil {
  28494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28495. return
  28496. }
  28497. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28498. if ioErr3 != nil {
  28499. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28501. return
  28502. }
  28503. var respJSON3 map[string]interface{}
  28504. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28507. return
  28508. }
  28509. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28510. userJSONBytes3, _ := json.Marshal(respJSON3)
  28511. fmt.Println("log")
  28512. fmt.Println(string(userJSONBytes3))
  28513. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28514. utils.ErrorLog("解析失败:%v", err)
  28515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28516. return
  28517. }
  28518. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  28519. if err == nil {
  28520. c.ServeSuccessJSON(map[string]interface{}{
  28521. "msg": "撤销明细成功",
  28522. })
  28523. return
  28524. } else {
  28525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28526. return
  28527. }
  28528. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28529. var resSix10265 ResultSix10265
  28530. var api3 string
  28531. if miConfig.MdtrtareaAdmvs == "320921" {
  28532. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  28533. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28534. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28535. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28536. } else {
  28537. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28538. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  28539. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28540. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28541. }
  28542. resp3, requestErr3 := http.Get(api3)
  28543. utils.ErrorLog("接口: %v", requestErr3)
  28544. if requestErr3 != nil {
  28545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28546. return
  28547. }
  28548. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28549. if ioErr3 != nil {
  28550. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28552. return
  28553. }
  28554. var respJSON3 map[string]interface{}
  28555. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28556. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28558. return
  28559. }
  28560. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28561. userJSONBytes3, _ := json.Marshal(respJSON3)
  28562. fmt.Println("log")
  28563. fmt.Println(string(userJSONBytes3))
  28564. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  28565. utils.ErrorLog("解析失败:%v", err)
  28566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28567. return
  28568. }
  28569. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28570. res2.Output = resSix10265.Output
  28571. res2.ErrMsg = resSix10265.ErrMsg
  28572. res2.Cainfo = resSix10265.Cainfo
  28573. res2.WarnMsg = resSix10265.WarnMsg
  28574. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28575. res2.Infcode = infocode
  28576. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  28577. if err == nil {
  28578. c.ServeSuccessJSON(map[string]interface{}{
  28579. "msg": "撤销明细成功",
  28580. })
  28581. return
  28582. } else {
  28583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28584. return
  28585. }
  28586. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28587. var api3 string
  28588. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  28589. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28590. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28591. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28592. resp3, requestErr3 := http.Get(api3)
  28593. utils.ErrorLog("接口: %v", requestErr3)
  28594. if requestErr3 != nil {
  28595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28596. return
  28597. }
  28598. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28599. if ioErr3 != nil {
  28600. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28602. return
  28603. }
  28604. var respJSON3 map[string]interface{}
  28605. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28606. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28608. return
  28609. }
  28610. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  28611. if status == "0" {
  28612. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  28613. c.ServeSuccessJSON(map[string]interface{}{
  28614. "failed_code": -10,
  28615. "msg": err_msg,
  28616. })
  28617. return
  28618. }
  28619. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28620. userJSONBytes3, _ := json.Marshal(respJSON3)
  28621. fmt.Println("log")
  28622. fmt.Println(string(userJSONBytes3))
  28623. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28624. utils.ErrorLog("解析失败:%v", err)
  28625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28626. return
  28627. }
  28628. fmt.Println(res2.Infcode)
  28629. if res2.Infcode == -1 {
  28630. c.ServeSuccessJSON(map[string]interface{}{
  28631. "failed_code": -10,
  28632. "msg": res2.ErrMsg,
  28633. })
  28634. return
  28635. }
  28636. if res2.Infcode == 0 {
  28637. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  28638. if err == nil {
  28639. c.ServeSuccessJSON(map[string]interface{}{
  28640. "msg": "撤销明细成功",
  28641. })
  28642. return
  28643. } else {
  28644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28645. return
  28646. }
  28647. } else {
  28648. c.ServeSuccessJSON(map[string]interface{}{
  28649. "failed_code": -10,
  28650. "msg": res2.ErrMsg,
  28651. })
  28652. }
  28653. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  28654. if err == nil {
  28655. c.ServeSuccessJSON(map[string]interface{}{
  28656. "msg": "撤销明细成功",
  28657. })
  28658. return
  28659. } else {
  28660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28661. return
  28662. }
  28663. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28664. var resSix10265 ResultSix10265
  28665. new_chrg_bchno := order.Number
  28666. if adminUser.CurrentOrgId == 10265 {
  28667. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  28668. new_chrg_bchno = "0000"
  28669. }
  28670. }
  28671. var api3 string
  28672. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  28673. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28674. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28675. resp3, requestErr3 := http.Get(api3)
  28676. if requestErr3 != nil {
  28677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28678. return
  28679. }
  28680. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28681. if ioErr3 != nil {
  28682. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28684. return
  28685. }
  28686. var respJSON3 map[string]interface{}
  28687. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28688. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28690. return
  28691. }
  28692. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28693. userJSONBytes3, _ := json.Marshal(respJSON3)
  28694. fmt.Println("log")
  28695. fmt.Println(string(userJSONBytes3))
  28696. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  28697. utils.ErrorLog("解析失败:%v", err)
  28698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28699. return
  28700. }
  28701. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28702. res2.Output = resSix10265.Output
  28703. res2.ErrMsg = resSix10265.ErrMsg
  28704. res2.Cainfo = resSix10265.Cainfo
  28705. res2.WarnMsg = resSix10265.WarnMsg
  28706. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28707. res2.Infcode = infocode
  28708. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  28709. if err == nil {
  28710. c.ServeSuccessJSON(map[string]interface{}{
  28711. "msg": "撤销明细成功",
  28712. })
  28713. return
  28714. } else {
  28715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28716. return
  28717. }
  28718. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28719. 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)
  28720. var dat map[string]interface{}
  28721. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28722. fmt.Println(dat)
  28723. } else {
  28724. fmt.Println(err)
  28725. }
  28726. saveLog(result2, src_request, "2205", "撤销明细")
  28727. userJSONBytes, _ := json.Marshal(dat)
  28728. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28729. utils.ErrorLog("解析失败:%v", err)
  28730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28731. return
  28732. }
  28733. if res2.Infcode == 0 {
  28734. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  28735. if err == nil {
  28736. c.ServeSuccessJSON(map[string]interface{}{
  28737. "msg": "撤销明细成功",
  28738. })
  28739. return
  28740. } else {
  28741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28742. return
  28743. }
  28744. } else {
  28745. c.ServeSuccessJSON(map[string]interface{}{
  28746. "failed_code": -10,
  28747. "msg": res2.ErrMsg,
  28748. })
  28749. }
  28750. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28751. 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, "")
  28752. var dat map[string]interface{}
  28753. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28754. fmt.Println(dat)
  28755. } else {
  28756. fmt.Println(err)
  28757. }
  28758. saveLog(result2, src_request, "2205", "撤销明细")
  28759. userJSONBytes, _ := json.Marshal(dat)
  28760. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28761. utils.ErrorLog("解析失败:%v", err)
  28762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28763. return
  28764. }
  28765. if res2.Infcode == 0 {
  28766. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  28767. if err == nil {
  28768. c.ServeSuccessJSON(map[string]interface{}{
  28769. "msg": "撤销明细成功",
  28770. })
  28771. return
  28772. } else {
  28773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28774. return
  28775. }
  28776. } else {
  28777. c.ServeSuccessJSON(map[string]interface{}{
  28778. "failed_code": -10,
  28779. "msg": res2.ErrMsg,
  28780. })
  28781. }
  28782. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28783. 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, "")
  28784. var dat map[string]interface{}
  28785. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28786. fmt.Println(dat)
  28787. } else {
  28788. fmt.Println(err)
  28789. }
  28790. saveLog(result2, src_request, "2205", "撤销明细")
  28791. userJSONBytes, _ := json.Marshal(dat)
  28792. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28793. utils.ErrorLog("解析失败:%v", err)
  28794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28795. return
  28796. }
  28797. if res2.Infcode == 0 {
  28798. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  28799. if err == nil {
  28800. c.ServeSuccessJSON(map[string]interface{}{
  28801. "msg": "撤销明细成功",
  28802. })
  28803. return
  28804. } else {
  28805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28806. return
  28807. }
  28808. } else {
  28809. c.ServeSuccessJSON(map[string]interface{}{
  28810. "failed_code": -10,
  28811. "msg": res2.ErrMsg,
  28812. })
  28813. }
  28814. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28815. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  28816. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28817. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28818. resp2, requestErr2 := http.Get(api2)
  28819. if requestErr2 != nil {
  28820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28821. return
  28822. }
  28823. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  28824. if ioErr2 != nil {
  28825. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  28826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28827. return
  28828. }
  28829. var respJSON2 map[string]interface{}
  28830. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  28831. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28833. return
  28834. }
  28835. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28836. userJSONBytes3, _ := json.Marshal(respJSON2)
  28837. fmt.Println("log")
  28838. fmt.Println(string(userJSONBytes3))
  28839. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28840. utils.ErrorLog("解析失败:%v", err)
  28841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28842. return
  28843. }
  28844. if res2.Infcode == 0 {
  28845. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  28846. if err == nil {
  28847. c.ServeSuccessJSON(map[string]interface{}{
  28848. "msg": "撤销明细成功",
  28849. })
  28850. return
  28851. } else {
  28852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28853. return
  28854. }
  28855. } else {
  28856. c.ServeSuccessJSON(map[string]interface{}{
  28857. "failed_code": -10,
  28858. "msg": res2.ErrMsg,
  28859. })
  28860. }
  28861. } else {
  28862. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  28863. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28864. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  28865. resp2, requestErr2 := http.Get(api2)
  28866. if requestErr2 != nil {
  28867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28868. return
  28869. }
  28870. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  28871. if ioErr2 != nil {
  28872. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  28873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28874. return
  28875. }
  28876. var respJSON2 map[string]interface{}
  28877. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  28878. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28880. return
  28881. }
  28882. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28883. userJSONBytes3, _ := json.Marshal(respJSON2)
  28884. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28885. utils.ErrorLog("解析失败:%v", err)
  28886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28887. return
  28888. }
  28889. if res2.Infcode == -1{
  28890. c.ServeSuccessJSON(map[string]interface{}{
  28891. "failed_code": -10,
  28892. "msg": res2.ErrMsg,
  28893. })
  28894. return
  28895. }else{
  28896. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  28897. if err == nil {
  28898. c.ServeSuccessJSON(map[string]interface{}{
  28899. "msg": "撤销明细成功",
  28900. })
  28901. return
  28902. } else {
  28903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28904. return
  28905. }
  28906. }
  28907. }
  28908. } else {
  28909. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  28910. if err == nil {
  28911. c.ServeSuccessJSON(map[string]interface{}{
  28912. "msg": "退费成功",
  28913. })
  28914. } else {
  28915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28916. return
  28917. }
  28918. }
  28919. }
  28920. // 对账
  28921. func (c *HisApiController) GetCheckAccount() {
  28922. start_time := c.GetString("start_time")
  28923. end_time := c.GetString("end_time")
  28924. insutype := c.GetString("insutype")
  28925. clr_type := c.GetString("clr_type")
  28926. clr_org := c.GetString("clr_optins")
  28927. admin_user_id, _ := c.GetInt64("admin_user_id")
  28928. adminUser := c.GetAdminUserInfo()
  28929. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28930. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28931. if len(clr_org) == 0 {
  28932. clr_org = miConfig.InsuplcAdmdvs
  28933. }
  28934. timeLayout := "2006-01-02"
  28935. loc, _ := time.LoadLocation("Local")
  28936. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  28937. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  28938. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  28939. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  28940. fixmedins_setl_cnt := int64(len(orders))
  28941. var medfee_sumamt float64
  28942. var acct_pay float64
  28943. var fund_pay_sumamt float64
  28944. for _, item := range orders {
  28945. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  28946. acct_pay = acct_pay + item.AcctPay
  28947. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  28948. }
  28949. var user_name string
  28950. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28951. if role.ID == 0 {
  28952. user_name = "xxx"
  28953. } else {
  28954. user_name = role.UserName
  28955. }
  28956. var res ResultEight
  28957. var res10188 ResultEightFor10188
  28958. if config.IsOpen == 1 {
  28959. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28960. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  28961. "insutype=" + insutype +
  28962. "&clr_type=" + clr_type +
  28963. "&setl_optins=" + clr_org +
  28964. "&stmt_begndate=" + start_time +
  28965. "&stm_enddate=" + end_time +
  28966. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  28967. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  28968. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  28969. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  28970. "&fixmedins_code=" + miConfig.Code +
  28971. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  28972. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28973. "&secret_key=" + miConfig.SecretKey +
  28974. "&org_name=" + miConfig.OrgName +
  28975. "&doctor=" + user_name +
  28976. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28977. fmt.Println(api)
  28978. resp, requestErr := http.Get(api)
  28979. if requestErr != nil {
  28980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28981. return
  28982. }
  28983. body, ioErr := ioutil.ReadAll(resp.Body)
  28984. fmt.Println(body)
  28985. if ioErr != nil {
  28986. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28988. return
  28989. }
  28990. var respJSON map[string]interface{}
  28991. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28992. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28994. return
  28995. }
  28996. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28997. userJSONBytes, _ := json.Marshal(respJSON)
  28998. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28999. utils.ErrorLog("解析失败:%v", err)
  29000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29001. return
  29002. }
  29003. res.InfRefmsgid = res10188.InfRefmsgid
  29004. res.Output = res10188.Output
  29005. res.ErrMsg = res10188.ErrMsg
  29006. res.Cainfo = res10188.Cainfo
  29007. res.WarnMsg = res10188.WarnMsg
  29008. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  29009. res.Infcode = infocode
  29010. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29011. if clr_type != "9903" {
  29012. clr_type = "99" // 就诊 ID(来自2201接口返回)
  29013. }
  29014. if clr_type == "9903" {
  29015. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  29016. }
  29017. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  29018. "insutype=" + insutype +
  29019. "&clr_type=" + clr_type +
  29020. "&setl_optins=" + clr_org +
  29021. "&stmt_begndate=" + start_time +
  29022. "&stm_enddate=" + end_time +
  29023. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  29024. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  29025. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  29026. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  29027. "&fixmedins_code=" + miConfig.Code +
  29028. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  29029. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29030. "&secret_key=" + miConfig.SecretKey +
  29031. "&org_name=" + miConfig.OrgName +
  29032. "&doctor=" + user_name
  29033. resp, requestErr := http.Get(api)
  29034. if requestErr != nil {
  29035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29036. return
  29037. }
  29038. body, ioErr := ioutil.ReadAll(resp.Body)
  29039. if ioErr != nil {
  29040. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29042. return
  29043. }
  29044. var respJSON map[string]interface{}
  29045. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29048. return
  29049. }
  29050. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29051. result, _ := json.Marshal(respJSON)
  29052. fmt.Println("log")
  29053. fmt.Println(string(result))
  29054. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  29055. utils.ErrorLog("解析失败:%v", err)
  29056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29057. return
  29058. }
  29059. res.InfRefmsgid = res10188.InfRefmsgid
  29060. res.Output = res10188.Output
  29061. res.ErrMsg = res10188.ErrMsg
  29062. res.Cainfo = res10188.Cainfo
  29063. res.WarnMsg = res10188.WarnMsg
  29064. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  29065. res.Infcode = infocode
  29066. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29067. var baseParams models.BaseParams
  29068. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  29069. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  29070. baseParams.SecretKey = miConfig.SecretKey
  29071. baseParams.OrgName = miConfig.OrgName
  29072. baseParams.FixmedinsCode = miConfig.Code
  29073. baseParams.EncKey = miConfig.EncKey
  29074. baseParams.AppSecret = miConfig.AppSecret
  29075. baseParams.SignKey = miConfig.SignKey
  29076. baseParams.AppID = miConfig.Code
  29077. baseParams.Doctor = role.UserName
  29078. baseParams.RequestUrl = miConfig.Url
  29079. businessParams := models.BusinessParams{
  29080. Insutype: insutype,
  29081. ClrType: clr_type,
  29082. SetlOptins: clr_org,
  29083. StmtBegndate: start_time,
  29084. StmtEnddate: end_time,
  29085. MedfeeSumamt: medfee_sumamt,
  29086. FundPaySumamt: fund_pay_sumamt,
  29087. AcctPay: acct_pay,
  29088. FixmedinsSetlCnt: fixmedins_setl_cnt,
  29089. }
  29090. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  29091. fmt.Println(requestLog)
  29092. fmt.Println(result)
  29093. fmt.Println(err_msg)
  29094. var dat map[string]interface{}
  29095. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29096. fmt.Println(dat)
  29097. } else {
  29098. fmt.Println(err)
  29099. }
  29100. userJSONBytes, _ := json.Marshal(dat)
  29101. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29102. utils.ErrorLog("解析失败:%v", err)
  29103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29104. return
  29105. }
  29106. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29107. var baseParams models.BaseParams
  29108. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  29109. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  29110. baseParams.SecretKey = miConfig.SecretKey
  29111. baseParams.OrgName = miConfig.OrgName
  29112. baseParams.FixmedinsCode = miConfig.Code
  29113. baseParams.EncKey = miConfig.EncKey
  29114. baseParams.AppSecret = miConfig.AppSecret
  29115. baseParams.SignKey = miConfig.SignKey
  29116. baseParams.AppID = miConfig.Code
  29117. baseParams.Doctor = role.UserName
  29118. baseParams.RequestUrl = miConfig.Url
  29119. baseParams.AccessKey = miConfig.AccessKey
  29120. businessParams := models.BusinessParams{
  29121. Insutype: insutype,
  29122. ClrType: clr_type,
  29123. SetlOptins: "430822",
  29124. StmtBegndate: start_time,
  29125. StmtEnddate: end_time,
  29126. MedfeeSumamt: medfee_sumamt,
  29127. FundPaySumamt: fund_pay_sumamt,
  29128. AcctPay: acct_pay,
  29129. FixmedinsSetlCnt: fixmedins_setl_cnt,
  29130. }
  29131. 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)
  29132. fmt.Println(requestLog)
  29133. fmt.Println(result)
  29134. var dat map[string]interface{}
  29135. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29136. fmt.Println(dat)
  29137. } else {
  29138. fmt.Println(err)
  29139. }
  29140. userJSONBytes, _ := json.Marshal(dat)
  29141. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29142. utils.ErrorLog("解析失败:%v", err)
  29143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29144. return
  29145. }
  29146. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29147. var baseParams models.BaseParams
  29148. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  29149. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  29150. baseParams.SecretKey = miConfig.SecretKey
  29151. baseParams.OrgName = miConfig.OrgName
  29152. baseParams.FixmedinsCode = miConfig.Code
  29153. baseParams.EncKey = miConfig.EncKey
  29154. baseParams.AppSecret = miConfig.AppSecret
  29155. baseParams.SignKey = miConfig.SignKey
  29156. baseParams.AppID = miConfig.Code
  29157. baseParams.Doctor = role.UserName
  29158. baseParams.RequestUrl = miConfig.Url
  29159. businessParams := models.BusinessParams{
  29160. Insutype: insutype,
  29161. ClrType: clr_type,
  29162. SetlOptins: clr_org,
  29163. StmtBegndate: start_time,
  29164. StmtEnddate: end_time,
  29165. MedfeeSumamt: medfee_sumamt,
  29166. FundPaySumamt: fund_pay_sumamt,
  29167. AcctPay: acct_pay,
  29168. FixmedinsSetlCnt: fixmedins_setl_cnt,
  29169. }
  29170. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  29171. fmt.Println(requestLog)
  29172. fmt.Println(result)
  29173. fmt.Println(err_msg)
  29174. var dat map[string]interface{}
  29175. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29176. fmt.Println(dat)
  29177. } else {
  29178. fmt.Println(err)
  29179. }
  29180. userJSONBytes, _ := json.Marshal(dat)
  29181. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29182. utils.ErrorLog("解析失败:%v", err)
  29183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29184. return
  29185. }
  29186. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29187. if len(clr_type) == 0 {
  29188. clr_type = "11"
  29189. }
  29190. api := miConfig.Url + "gdyb/ten?" +
  29191. "insutype=" + insutype +
  29192. "&clr_type=" + clr_type +
  29193. "&setl_optins=" + clr_org +
  29194. "&stmt_begndate=" + start_time +
  29195. "&stm_enddate=" + end_time +
  29196. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  29197. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  29198. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  29199. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  29200. "&fixmedins_code=" + miConfig.Code +
  29201. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  29202. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29203. "&secret_key=" + miConfig.SecretKey +
  29204. "&org_name=" + miConfig.OrgName +
  29205. "&doctor=" + user_name
  29206. fmt.Println(api)
  29207. resp, requestErr := http.Get(api)
  29208. if requestErr != nil {
  29209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29210. return
  29211. }
  29212. body, ioErr := ioutil.ReadAll(resp.Body)
  29213. fmt.Println(body)
  29214. if ioErr != nil {
  29215. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29217. return
  29218. }
  29219. var respJSON map[string]interface{}
  29220. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29221. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29223. return
  29224. }
  29225. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29226. userJSONBytes, _ := json.Marshal(respJSON)
  29227. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29228. utils.ErrorLog("解析失败:%v", err)
  29229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29230. return
  29231. }
  29232. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29233. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  29234. fixmedins_setl_cnt := int64(len(orders_two))
  29235. var medfee_sumamt float64
  29236. var acct_pay float64
  29237. var fund_pay_sumamt float64
  29238. for _, item := range orders_two {
  29239. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  29240. acct_pay = acct_pay + item.AcctPay
  29241. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  29242. }
  29243. var baseParams models.BaseParams
  29244. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  29245. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  29246. baseParams.SecretKey = miConfig.SecretKey
  29247. baseParams.OrgName = miConfig.OrgName
  29248. baseParams.FixmedinsCode = miConfig.Code
  29249. baseParams.EncKey = miConfig.EncKey
  29250. baseParams.AppSecret = miConfig.AppSecret
  29251. baseParams.SignKey = miConfig.SignKey
  29252. baseParams.AppID = miConfig.Code
  29253. baseParams.Doctor = role.UserName
  29254. baseParams.RequestUrl = miConfig.Url
  29255. if clr_type == "9903" {
  29256. clr_type = "9994"
  29257. }
  29258. businessParams := models.BusinessParams{
  29259. Insutype: insutype,
  29260. ClrType: clr_type,
  29261. SetlOptins: "360302",
  29262. StmtBegndate: start_time,
  29263. StmtEnddate: end_time,
  29264. MedfeeSumamt: 0,
  29265. FundPaySumamt: 0,
  29266. AcctPay: 0,
  29267. FixmedinsSetlCnt: fixmedins_setl_cnt,
  29268. }
  29269. 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))
  29270. fmt.Println(requestLog)
  29271. fmt.Println(result)
  29272. var dat map[string]interface{}
  29273. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29274. fmt.Println(dat)
  29275. } else {
  29276. fmt.Println(err)
  29277. }
  29278. userJSONBytes, _ := json.Marshal(dat)
  29279. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29280. utils.ErrorLog("解析失败:%v", err)
  29281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29282. return
  29283. }
  29284. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29285. var api string
  29286. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  29287. "&clr_type=" + clr_type +
  29288. "&setl_optins=" + clr_org +
  29289. "&stmt_begndate=" + start_time +
  29290. "&stm_enddate=" + end_time +
  29291. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  29292. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  29293. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  29294. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  29295. "&fixmedins_code=" + miConfig.Code +
  29296. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  29297. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29298. "&secret_key=" + miConfig.SecretKey +
  29299. "&org_name=" + miConfig.OrgName +
  29300. "&doctor=" + user_name + "&url=" + miConfig.Url
  29301. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29302. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29303. resp, requestErr := http.Get(api)
  29304. if requestErr != nil {
  29305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29306. return
  29307. }
  29308. body, ioErr := ioutil.ReadAll(resp.Body)
  29309. if ioErr != nil {
  29310. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29312. return
  29313. }
  29314. var respJSON map[string]interface{}
  29315. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29318. return
  29319. }
  29320. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29321. if status == "0" {
  29322. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29323. c.ServeSuccessJSON(map[string]interface{}{
  29324. "failed_code": -10,
  29325. "msg": err_msg,
  29326. })
  29327. return
  29328. }
  29329. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29330. userJSONBytes, _ := json.Marshal(respJSON)
  29331. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29332. utils.ErrorLog("解析失败:%v", err)
  29333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29334. return
  29335. }
  29336. } else {
  29337. if len(clr_type) == 0 {
  29338. clr_type = "11"
  29339. }
  29340. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  29341. "insutype=" + insutype +
  29342. "&clr_type=" + clr_type +
  29343. "&setl_optins=" + clr_org +
  29344. "&stmt_begndate=" + start_time +
  29345. "&stm_enddate=" + end_time +
  29346. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  29347. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  29348. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  29349. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  29350. "&fixmedins_code=" + miConfig.Code +
  29351. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  29352. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29353. "&secret_key=" + miConfig.SecretKey +
  29354. "&org_name=" + miConfig.OrgName +
  29355. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  29356. fmt.Println(api)
  29357. resp, requestErr := http.Get(api)
  29358. if requestErr != nil {
  29359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29360. return
  29361. }
  29362. body, ioErr := ioutil.ReadAll(resp.Body)
  29363. fmt.Println(body)
  29364. if ioErr != nil {
  29365. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29367. return
  29368. }
  29369. var respJSON map[string]interface{}
  29370. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29371. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29373. return
  29374. }
  29375. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29376. userJSONBytes, _ := json.Marshal(respJSON)
  29377. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29378. utils.ErrorLog("解析失败:%v", err)
  29379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29380. return
  29381. }
  29382. }
  29383. if res.Infcode == 0 {
  29384. if res.Output.Stmtinfo.StmtRslt == "0" {
  29385. micc := &models.MedicalInsuranceCostCompare{
  29386. StartTime: startime.Unix(),
  29387. EndTime: endtime.Unix(),
  29388. Insutype: insutype,
  29389. CheckType: 1,
  29390. Num: fixmedins_setl_cnt,
  29391. Mtime: time.Now().Unix(),
  29392. Status: 1,
  29393. UserOrgId: adminUser.CurrentOrgId,
  29394. CostTotal: medfee_sumamt,
  29395. FuncTotal: fund_pay_sumamt,
  29396. PsnPay: acct_pay,
  29397. Creator: admin_user_id,
  29398. Ctime: time.Now().Unix(),
  29399. ClrType: clr_type,
  29400. }
  29401. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  29402. if err == nil {
  29403. c.ServeSuccessJSON(map[string]interface{}{
  29404. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  29405. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  29406. })
  29407. } else {
  29408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29409. }
  29410. } else {
  29411. c.ServeSuccessJSON(map[string]interface{}{
  29412. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  29413. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  29414. })
  29415. }
  29416. } else {
  29417. c.ServeSuccessJSON(map[string]interface{}{
  29418. "failed_code": -10,
  29419. "msg": res.ErrMsg,
  29420. })
  29421. }
  29422. }
  29423. }
  29424. func (c *HisApiController) Check310() {
  29425. adminUser := c.GetAdminUserInfo()
  29426. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29427. var user_name string
  29428. user_name = "高慧裕"
  29429. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  29430. "insutype=" + "310" +
  29431. "&clr_type=" + "" +
  29432. "&setl_optins=" + "441202" +
  29433. "&stmt_begndate=" + "2022-03-01" +
  29434. "&stm_enddate=" + "2022-03-31" +
  29435. "&medfee_sumamt=" + "194930.12" +
  29436. "&fund_pay_sumamt=" + "188741.46" +
  29437. "&acct_pay=" + "0" +
  29438. "&fixmedins_setl_cnt=" + "452" +
  29439. "&fixmedins_code=" + miConfig.Code +
  29440. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  29441. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29442. "&secret_key=" + miConfig.SecretKey +
  29443. "&org_name=" + miConfig.OrgName +
  29444. "&doctor=" + user_name
  29445. fmt.Println(api)
  29446. resp, requestErr := http.Get(api)
  29447. if requestErr != nil {
  29448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29449. return
  29450. }
  29451. body, ioErr := ioutil.ReadAll(resp.Body)
  29452. fmt.Println(body)
  29453. if ioErr != nil {
  29454. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29456. return
  29457. }
  29458. var respJSON map[string]interface{}
  29459. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29460. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29462. return
  29463. }
  29464. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29465. userJSONBytes, _ := json.Marshal(respJSON)
  29466. var res ResultEight
  29467. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29468. utils.ErrorLog("解析失败:%v", err)
  29469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29470. return
  29471. }
  29472. }
  29473. func (c *HisApiController) Check390() {
  29474. adminUser := c.GetAdminUserInfo()
  29475. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29476. var user_name string
  29477. user_name = "高慧裕"
  29478. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  29479. "insutype=" + "390" +
  29480. "&clr_type=" + "" +
  29481. "&setl_optins=" + "441202" +
  29482. "&stmt_begndate=" + "2022-03-01" +
  29483. "&stm_enddate=" + "2022-03-31" +
  29484. "&medfee_sumamt=" + "1068448.89" +
  29485. "&fund_pay_sumamt=" + "1014677.62" +
  29486. "&acct_pay=" + "0" +
  29487. "&fixmedins_setl_cnt=" + "1950" +
  29488. "&fixmedins_code=" + miConfig.Code +
  29489. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  29490. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29491. "&secret_key=" + miConfig.SecretKey +
  29492. "&org_name=" + miConfig.OrgName +
  29493. "&doctor=" + user_name
  29494. fmt.Println(api)
  29495. resp, requestErr := http.Get(api)
  29496. if requestErr != nil {
  29497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29498. return
  29499. }
  29500. body, ioErr := ioutil.ReadAll(resp.Body)
  29501. fmt.Println(body)
  29502. if ioErr != nil {
  29503. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29505. return
  29506. }
  29507. var respJSON map[string]interface{}
  29508. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29509. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29511. return
  29512. }
  29513. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29514. userJSONBytes, _ := json.Marshal(respJSON)
  29515. var res ResultEight
  29516. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29517. utils.ErrorLog("解析失败:%v", err)
  29518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29519. return
  29520. }
  29521. }
  29522. // 对账明细
  29523. func (c *HisApiController) GetCheckDetailAccount() {
  29524. start_time := c.GetString("start_time")
  29525. end_time := c.GetString("end_time")
  29526. admin_user_id, _ := c.GetInt64("admin_user_id")
  29527. adminUser := c.GetAdminUserInfo()
  29528. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29529. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29530. timeLayout := "2006-01-02"
  29531. loc, _ := time.LoadLocation("Local")
  29532. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  29533. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  29534. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  29535. rand.Seed(time.Now().UnixNano())
  29536. num := rand.Intn(30000)
  29537. Mkdir(miConfig.OrgName)
  29538. file := strconv.FormatInt(int64(num), 10)
  29539. file_name := file + ".txt"
  29540. zip_name := file + ".zip"
  29541. zip_path := miConfig.OrgName + "/" + zip_name
  29542. file_path := miConfig.OrgName + "/" + file_name
  29543. decimal.DivisionPrecision = 2
  29544. var medfee_sumamt float64
  29545. var psn_cash_pay float64
  29546. var fund_pay_sumamt float64
  29547. fixmedins_setl_cnt := int64(len(orders))
  29548. for _, item := range orders {
  29549. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  29550. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  29551. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  29552. }
  29553. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  29554. defer f.Close()
  29555. if err != nil {
  29556. fmt.Println(err.Error())
  29557. } else {
  29558. for _, item := range orders {
  29559. var refd_setl_flag string
  29560. if item.OrderStatus == 2 {
  29561. refd_setl_flag = "0"
  29562. var str string
  29563. str = item.SetlId + " " +
  29564. item.MdtrtId + " " +
  29565. item.PsnNo + " " +
  29566. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  29567. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  29568. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  29569. _, err = f.Write([]byte(str))
  29570. }
  29571. if item.OrderStatus == 3 {
  29572. var str string
  29573. str = item.SetlId + " " +
  29574. item.MdtrtId + " " +
  29575. item.PsnNo + " " +
  29576. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  29577. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  29578. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  29579. _, err = f.Write([]byte(str))
  29580. var str2 string
  29581. str2 = item.SetlId + " " +
  29582. item.MdtrtId + " " +
  29583. item.PsnNo + " " +
  29584. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  29585. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  29586. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  29587. _, err = f.Write([]byte(str2))
  29588. }
  29589. }
  29590. }
  29591. Zip(file_path, zip_path)
  29592. fmt.Println(ReadFile(zip_path))
  29593. fmt.Println(string(ReadFile(zip_path)))
  29594. if config.IsOpen == 1 {
  29595. var user_name string
  29596. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29597. if role.ID == 0 {
  29598. user_name = "管理员"
  29599. } else {
  29600. user_name = role.UserName
  29601. }
  29602. baseParams := models.BaseParams{
  29603. SecretKey: miConfig.SecretKey,
  29604. FixmedinsCode: miConfig.Code,
  29605. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  29606. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  29607. OrgName: miConfig.OrgName,
  29608. Doctor: user_name,
  29609. }
  29610. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  29611. var dat map[string]interface{}
  29612. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29613. fmt.Println(dat)
  29614. } else {
  29615. fmt.Println(err)
  29616. }
  29617. userJSONBytes, _ := json.Marshal(dat)
  29618. var res ResultNine
  29619. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29620. utils.ErrorLog("解析失败:%v", err)
  29621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29622. return
  29623. }
  29624. if res.Infcode == 0 {
  29625. fileNo := res.Output.FileQuryNo
  29626. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  29627. "file_qury_no=" + fileNo +
  29628. "&setl_optins=" + "定点医保中心" +
  29629. "&stmt_begndate=" + start_time +
  29630. "&stm_enddate=" + end_time +
  29631. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  29632. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  29633. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  29634. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  29635. "&fixmedins_code=" + miConfig.Code +
  29636. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  29637. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29638. "&secret_key=" + miConfig.SecretKey +
  29639. "&org_name=" + miConfig.OrgName +
  29640. "&doctor=" + user_name
  29641. resp, requestErr := http.Get(api)
  29642. if requestErr != nil {
  29643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29644. return
  29645. }
  29646. body, ioErr := ioutil.ReadAll(resp.Body)
  29647. if ioErr != nil {
  29648. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29650. return
  29651. }
  29652. var respJSON map[string]interface{}
  29653. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29654. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29656. return
  29657. }
  29658. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29659. userJSONBytes, _ := json.Marshal(respJSON)
  29660. var res ResultTen
  29661. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29662. utils.ErrorLog("解析失败:%v", err)
  29663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29664. return
  29665. }
  29666. if res.Infcode == 0 {
  29667. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  29668. micc := &models.MedicalInsuranceCostCompare{
  29669. StartTime: startime.Unix(),
  29670. EndTime: endtime.Unix(),
  29671. Insutype: "0",
  29672. CheckType: 2,
  29673. Num: fixmedins_setl_cnt,
  29674. Mtime: time.Now().Unix(),
  29675. Status: 1,
  29676. UserOrgId: adminUser.CurrentOrgId,
  29677. CostTotal: medfee_sumamt,
  29678. FuncTotal: fund_pay_sumamt,
  29679. PsnPay: psn_cash_pay,
  29680. Creator: admin_user_id,
  29681. Ctime: time.Now().Unix(),
  29682. }
  29683. service.CreateMedicalInsuranceCostCompareRecord(micc)
  29684. c.ServeSuccessJSON(map[string]interface{}{
  29685. "msg": "明细对账成功",
  29686. })
  29687. }
  29688. } else {
  29689. }
  29690. }
  29691. }
  29692. type CustomOrderInfo struct {
  29693. Name string
  29694. Spec string
  29695. Unit string
  29696. Count float64
  29697. Price float64
  29698. Total float64
  29699. }
  29700. func (c *HisApiController) GetBatchSettleAccounts() {
  29701. admin_user_id, _ := c.GetInt64("admin_user_id")
  29702. order_ids := c.GetString("order_ids")
  29703. order_ids_arr := strings.Split(order_ids, ",")
  29704. data3 := []map[string]interface{}{}
  29705. for _, item := range order_ids_arr {
  29706. id, _ := strconv.ParseInt(item, 10, 64)
  29707. order_id := id
  29708. adminUser := c.GetAdminUserInfo()
  29709. order, _ := service.GetHisOrderByID(order_id)
  29710. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  29711. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  29712. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  29713. orderInfos = append(orderInfos, orderInfos_two...)
  29714. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  29715. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  29716. var diagnosis_ids []string
  29717. if his.ID > 0 {
  29718. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  29719. } else {
  29720. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  29721. }
  29722. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  29723. var dia_config []*models.HisXtDiagnoseConfig
  29724. var name string
  29725. for _, item := range diagnosis_ids {
  29726. id, _ := strconv.ParseInt(item, 10, 64)
  29727. diagnosisConfig, _ := service.FindDiagnoseById(id)
  29728. dia_config = append(dia_config, &diagnosisConfig)
  29729. if len(name) == 0 {
  29730. name = diagnosisConfig.ClassName
  29731. }
  29732. //} else {
  29733. // name = name + "," + diagnosisConfig.ClassName
  29734. //}
  29735. }
  29736. var bedCostTotal float64 = 0 //床位总费
  29737. var bedCostSelfTotal float64 = 0 //床位自费
  29738. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  29739. var bedSelfTotal float64 = 0 //床位部分项目自费
  29740. var bedInscpTotal float64 = 0 //床位部分项目自费
  29741. var operationCostTotal float64 = 0 //手术费
  29742. var operationCostSelfTotal float64 = 0 //手术费
  29743. var operationCostPartSelfTotal float64 = 0 //手术费
  29744. var operationSelfTotal float64 = 0 //床位部分项目自费
  29745. var operationInscpTotal float64 = 0 //床位部分项目自费
  29746. var otherCostTotal float64 = 0 //其他费用
  29747. var otherCostSelfTotal float64 = 0 //其他费用
  29748. var otherCostPartSelfTotal float64 = 0 //其他费用
  29749. var otherSelfTotal float64 = 0 //床位部分项目自费
  29750. var otherInscpTotal float64 = 0 //床位部分项目自费
  29751. var materialCostTotal float64 = 0 //材料费
  29752. var materialCostSelfTotal float64 = 0 //材料费
  29753. var materialCostPartSelfTotal float64 = 0 //材料费
  29754. var materialSelfTotal float64 = 0 //床位部分项目自费
  29755. var materialInscpTotal float64 = 0 //床位部分项目自费
  29756. var westernMedicineCostTotal float64 = 0 //西药费
  29757. var westernMedicineCostSelfTotal float64 = 0 //西药费
  29758. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  29759. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  29760. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  29761. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  29762. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  29763. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  29764. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  29765. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  29766. var checkCostTotal float64 = 0 //检查费
  29767. var checkCostSelfTotal float64 = 0 //检查费
  29768. var checkCostPartSelfTotal float64 = 0 //检查费
  29769. var checkSelfTotal float64 = 0 //床位部分项目自费
  29770. var checkInscpTotal float64 = 0 //床位部分项目自费
  29771. var laboratoryCostTotal float64 = 0 //化验费
  29772. var laboratoryCostSelfTotal float64 = 0 //化验费
  29773. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  29774. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  29775. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  29776. var treatCostTotal float64 = 0 //治疗费用
  29777. var treatCostSelfTotal float64 = 0 //治疗费用
  29778. var treatCostPartSelfTotal float64 = 0 //治疗费用
  29779. var treatSelfTotal float64 = 0 //床位部分项目自费
  29780. var treatInscpTotal float64 = 0 //床位部分项目自费
  29781. decimal.DivisionPrecision = 2
  29782. for _, item := range orderInfos {
  29783. if item.MedChrgitmType == "01" { //床位费
  29784. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  29785. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  29786. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  29787. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  29788. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  29789. }
  29790. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  29791. if item.MedChrgitmType == "03" { //检查费
  29792. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  29793. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  29794. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  29795. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  29796. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  29797. }
  29798. } else {
  29799. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  29800. fmt.Println("------------")
  29801. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  29802. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  29803. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  29804. }
  29805. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  29806. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  29807. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  29808. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  29809. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  29810. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  29811. }
  29812. }
  29813. if item.MedChrgitmType == "04" { //化验费
  29814. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  29815. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  29816. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  29817. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  29818. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  29819. }
  29820. if item.MedChrgitmType == "05" { //治疗费
  29821. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  29822. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  29823. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  29824. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  29825. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  29826. }
  29827. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  29828. fmt.Println("------------")
  29829. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  29830. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  29831. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  29832. }
  29833. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  29834. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  29835. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  29836. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  29837. }
  29838. //if item.MedChrgitmType == "06" { //手术费
  29839. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  29840. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  29841. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  29842. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  29843. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  29844. //
  29845. //}
  29846. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  29847. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  29848. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  29849. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  29850. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  29851. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  29852. }
  29853. if item.MedChrgitmType == "09" { //西药费
  29854. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  29855. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  29856. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  29857. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  29858. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  29859. }
  29860. if item.MedChrgitmType == "11" { //中成费
  29861. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  29862. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  29863. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  29864. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  29865. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  29866. }
  29867. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  29868. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  29869. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  29870. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  29871. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  29872. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  29873. }
  29874. }
  29875. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29876. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29877. var user_name string
  29878. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29879. if role.ID == 0 {
  29880. user_name = "管理员"
  29881. } else {
  29882. user_name = role.UserName
  29883. }
  29884. baseParams := models.BaseParams{
  29885. SecretKey: miConfig.SecretKey,
  29886. FixmedinsCode: miConfig.Code,
  29887. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  29888. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  29889. OrgName: miConfig.OrgName,
  29890. Doctor: user_name,
  29891. RequestUrl: miConfig.Url,
  29892. AccessKey: miConfig.AccessKey,
  29893. }
  29894. businessParams := models.BusinessParams{
  29895. PsnNo: order.PsnNo,
  29896. MdtrtId: order.MdtrtId,
  29897. SetlId: order.SetlId,
  29898. }
  29899. var res ResultEleven
  29900. var resEleven10265 ResultEleven10265
  29901. if config.IsOpen == 1 {
  29902. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  29903. result := service.Gdyb5203(baseParams, businessParams)
  29904. service.Gdyb5204(baseParams, businessParams)
  29905. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  29906. var dat map[string]interface{}
  29907. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29908. fmt.Println(dat)
  29909. } else {
  29910. fmt.Println(err)
  29911. }
  29912. userJSONBytes, _ := json.Marshal(dat)
  29913. if miConfig.Code == "H15049901371" {
  29914. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  29915. utils.ErrorLog("解析失败:%v", err)
  29916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29917. return
  29918. }
  29919. res.InfRefmsgid = resEleven10265.InfRefmsgid
  29920. res.Output = resEleven10265.Output
  29921. res.ErrMsg = resEleven10265.ErrMsg
  29922. res.Cainfo = resEleven10265.Cainfo
  29923. res.WarnMsg = resEleven10265.WarnMsg
  29924. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  29925. res.Infcode = infocode
  29926. } else {
  29927. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29928. utils.ErrorLog("解析失败:%v", err)
  29929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29930. return
  29931. }
  29932. }
  29933. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29934. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  29935. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  29936. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  29937. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  29938. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29939. var doctor_name string
  29940. if roles.ID == 0 {
  29941. doctor_name = "管理员"
  29942. } else {
  29943. doctor_name = roles.UserName
  29944. }
  29945. yiliao_leibie := ""
  29946. switch order.MedType {
  29947. case "11":
  29948. yiliao_leibie = "普通门诊"
  29949. break
  29950. case "12":
  29951. yiliao_leibie = "门诊挂号"
  29952. break
  29953. case "13":
  29954. yiliao_leibie = "急诊"
  29955. break
  29956. case "14":
  29957. yiliao_leibie = "门诊特殊病"
  29958. break
  29959. case "15":
  29960. yiliao_leibie = "门诊统筹"
  29961. break
  29962. case "16":
  29963. yiliao_leibie = "门诊慢性病"
  29964. break
  29965. case "21":
  29966. yiliao_leibie = "普通住院"
  29967. break
  29968. }
  29969. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  29970. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  29971. if res.Infcode == 0 {
  29972. data2 := map[string]interface{}{
  29973. "diagnosis": name,
  29974. "order_infos": orderInfos,
  29975. "number": order.MdtrtId,
  29976. "date": order.SettleAccountsDate,
  29977. "charge_admin": charge_admin,
  29978. "printor_admin": printor_admin,
  29979. "info": res.Output.Setlinfo,
  29980. "order": order,
  29981. "bedCostTotal": bedCostTotal,
  29982. "bedCostSelfTotal": bedCostSelfTotal,
  29983. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  29984. "bedSelfTotal": bedSelfTotal,
  29985. "bedInscpTotal": bedInscpTotal,
  29986. "operationCostTotal": operationCostTotal,
  29987. "operationCostSelfTotal": operationCostSelfTotal,
  29988. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  29989. "operationSelfTotal": operationSelfTotal,
  29990. "operationInscpTotal": operationInscpTotal,
  29991. "otherCostTotal": otherCostTotal,
  29992. "otherCostSelfTotal": otherCostSelfTotal,
  29993. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  29994. "otherSelfTotal": otherSelfTotal,
  29995. "otherInscpTotal": otherInscpTotal,
  29996. "materialCostTotal": materialCostTotal,
  29997. "materialCostSelfTotal": materialCostSelfTotal,
  29998. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  29999. "materialSelfTotal": materialSelfTotal,
  30000. "materialInscpTotal": materialInscpTotal,
  30001. "westernMedicineCostTotal": westernMedicineCostTotal,
  30002. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  30003. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  30004. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  30005. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  30006. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  30007. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  30008. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  30009. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  30010. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  30011. "checkCostTotal": checkCostTotal,
  30012. "checkCostSelfTotal": checkCostSelfTotal,
  30013. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  30014. "checkSelfTotal": checkSelfTotal,
  30015. "checkInscpTotal": checkInscpTotal,
  30016. "laboratoryCostTotal": laboratoryCostTotal,
  30017. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  30018. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  30019. "laboratorySelfTotal": laboratorySelfTotal,
  30020. "laboratoryInscpTotal": laboratoryInscpTotal,
  30021. "treatCostTotal": treatCostTotal,
  30022. "treatCostSelfTotal": treatCostSelfTotal,
  30023. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  30024. "treatSelfTotal": treatSelfTotal,
  30025. "treatInscpTotal": treatInscpTotal,
  30026. "doctor_info": doctor_info,
  30027. "doctor_code": adminRole_two.DoctorCode,
  30028. "doctor_name": doctor_name,
  30029. "health_card_no": order.PsnNo,
  30030. "department": departments.Name,
  30031. "yiliao_leibie": yiliao_leibie,
  30032. "after_money": order.AccountPrice,
  30033. "patient": patient,
  30034. "org_name": miConfig.OrgName,
  30035. "org_code": miConfig.Code,
  30036. "order_number": order.Number,
  30037. "his_hospital": his_hospital,
  30038. "his": his,
  30039. "dia_config": dia_config,
  30040. "psn_cash_pay": order.PsnCashPay,
  30041. //"check_order_info": cus_slice,
  30042. }
  30043. data3 = append(data3, data2)
  30044. }
  30045. }
  30046. }
  30047. c.ServeSuccessJSON(map[string]interface{}{
  30048. "infos": data3,
  30049. })
  30050. }
  30051. func (c *HisApiController) GetSettleAccounts() {
  30052. //id, _ := c.GetInt64("id")
  30053. //record_time := c.GetString("record_time")
  30054. order_id, _ := c.GetInt64("order_id")
  30055. admin_user_id, _ := c.GetInt64("admin_user_id")
  30056. //timeLayout := "2006-01-02"
  30057. //loc, _ := time.LoadLocation("Local")
  30058. //
  30059. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  30060. //if err != nil {
  30061. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30062. // return
  30063. //}Hbyb5203
  30064. //recordDateTime := theTime.Unix()
  30065. adminUser := c.GetAdminUserInfo()
  30066. order, _ := service.GetHisOrderByID(order_id)
  30067. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  30068. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  30069. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  30070. orderInfos = append(orderInfos, orderInfos_two...)
  30071. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  30072. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  30073. var diagnosis_ids []string
  30074. if his.ID > 0 {
  30075. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  30076. } else {
  30077. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  30078. }
  30079. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  30080. var dia_config []*models.HisXtDiagnoseConfig
  30081. var name string
  30082. for _, item := range diagnosis_ids {
  30083. id, _ := strconv.ParseInt(item, 10, 64)
  30084. diagnosisConfig, _ := service.FindDiagnoseById(id)
  30085. dia_config = append(dia_config, &diagnosisConfig)
  30086. if len(name) == 0 {
  30087. name = diagnosisConfig.ClassName
  30088. } else {
  30089. name = name + "," + diagnosisConfig.ClassName
  30090. }
  30091. }
  30092. if patient.UserOrgId == 10215 {
  30093. name = "慢性肾功能不全(血透治疗)"
  30094. }
  30095. var bedCostTotal float64 = 0 //床位总费
  30096. var bedCostSelfTotal float64 = 0 //床位自费
  30097. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  30098. var bedSelfTotal float64 = 0 //床位部分项目自费
  30099. var bedInscpTotal float64 = 0 //床位部分项目自费
  30100. var operationCostTotal float64 = 0 //手术费
  30101. var operationCostSelfTotal float64 = 0 //手术费
  30102. var operationCostPartSelfTotal float64 = 0 //手术费
  30103. var operationSelfTotal float64 = 0 //床位部分项目自费
  30104. var operationInscpTotal float64 = 0 //床位部分项目自费
  30105. var otherCostTotal float64 = 0 //其他费用
  30106. var otherCostSelfTotal float64 = 0 //其他费用
  30107. var otherCostPartSelfTotal float64 = 0 //其他费用
  30108. var otherSelfTotal float64 = 0 //床位部分项目自费
  30109. var otherInscpTotal float64 = 0 //床位部分项目自费
  30110. var materialCostTotal float64 = 0 //材料费
  30111. var materialCostSelfTotal float64 = 0 //材料费
  30112. var materialCostPartSelfTotal float64 = 0 //材料费
  30113. var materialSelfTotal float64 = 0 //床位部分项目自费
  30114. var materialInscpTotal float64 = 0 //床位部分项目自费
  30115. var westernMedicineCostTotal float64 = 0 //西药费
  30116. var westernMedicineCostSelfTotal float64 = 0 //西药费
  30117. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  30118. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  30119. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  30120. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  30121. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  30122. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  30123. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  30124. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  30125. var checkCostTotal float64 = 0 //检查费
  30126. var checkCostSelfTotal float64 = 0 //检查费
  30127. var checkCostPartSelfTotal float64 = 0 //检查费
  30128. var checkSelfTotal float64 = 0 //床位部分项目自费
  30129. var checkInscpTotal float64 = 0 //床位部分项目自费
  30130. var laboratoryCostTotal float64 = 0 //化验费
  30131. var laboratoryCostSelfTotal float64 = 0 //化验费
  30132. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  30133. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  30134. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  30135. var treatCostTotal float64 = 0 //治疗费用
  30136. var treatCostSelfTotal float64 = 0 //治疗费用
  30137. var treatCostPartSelfTotal float64 = 0 //治疗费用
  30138. var treatSelfTotal float64 = 0 //床位部分项目自费
  30139. var treatInscpTotal float64 = 0 //床位部分项目自费
  30140. var zcCostTotal float64 = 0 //治疗费用
  30141. var zcCostSelfTotal float64 = 0 //治疗费用
  30142. var zcCostPartSelfTotal float64 = 0 //治疗费用
  30143. var zcSelfTotal float64 = 0 //床位部分项目自费
  30144. var zcInscpTotal float64 = 0 //床位部分项目自费
  30145. var huliCostTotal float64 = 0 //治疗费用
  30146. var huliCostSelfTotal float64 = 0 //治疗费用
  30147. var huliCostPartSelfTotal float64 = 0 //治疗费用
  30148. var huliSelfTotal float64 = 0 //床位部分项目自费
  30149. var huliInscpTotal float64 = 0 //床位部分项目自费
  30150. decimal.DivisionPrecision = 2
  30151. for _, item := range orderInfos {
  30152. if item.MedChrgitmType == "01" { //床位费
  30153. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30154. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30155. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30156. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30157. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30158. }
  30159. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  30160. if item.MedChrgitmType == "03" { //检查费
  30161. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30162. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30163. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30164. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30165. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30166. }
  30167. } else {
  30168. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  30169. fmt.Println("------------")
  30170. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30171. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30172. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30173. }
  30174. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  30175. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30176. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30177. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30178. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30179. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30180. }
  30181. }
  30182. if item.MedChrgitmType == "04" { //化验费
  30183. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30184. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30185. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30186. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30187. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30188. }
  30189. if item.MedChrgitmType == "05" { //治疗费
  30190. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30191. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30192. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30193. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30194. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30195. }
  30196. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  30197. fmt.Println("------------")
  30198. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30199. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30200. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30201. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30202. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30203. }
  30204. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  30205. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30206. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30207. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30208. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30209. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30210. }
  30211. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  30212. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30213. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30214. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30215. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30216. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30217. }
  30218. if item.MedChrgitmType == "09" { //西药费
  30219. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30220. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30221. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30222. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30223. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30224. }
  30225. if item.MedChrgitmType == "11" { //中成费
  30226. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30227. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30228. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30229. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30230. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30231. }
  30232. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  30233. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30234. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30235. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30236. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30237. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30238. }
  30239. if item.MedChrgitmType == "02" { //其他费
  30240. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30241. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30242. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30243. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30244. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30245. }
  30246. if item.MedChrgitmType == "07" { //其他费
  30247. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30248. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30249. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30250. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30251. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30252. }
  30253. }
  30254. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30255. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30256. var user_name string
  30257. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30258. if role.ID == 0 {
  30259. user_name = "管理员"
  30260. } else {
  30261. user_name = role.UserName
  30262. }
  30263. baseParams := models.BaseParams{
  30264. SecretKey: miConfig.SecretKey,
  30265. FixmedinsCode: miConfig.Code,
  30266. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  30267. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  30268. OrgName: miConfig.OrgName,
  30269. Doctor: user_name,
  30270. RequestUrl: miConfig.Url,
  30271. AccessKey: miConfig.AccessKey,
  30272. }
  30273. businessParams := models.BusinessParams{
  30274. PsnNo: order.PsnNo,
  30275. MdtrtId: order.MdtrtId,
  30276. SetlId: order.SetlId,
  30277. }
  30278. var res ResultEleven
  30279. var resah ResultElevenah
  30280. var resEleven10265 ResultEleven10265
  30281. if config.IsOpen == 1 {
  30282. if miConfig.MdtrtareaAdmvs == "421300" {
  30283. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  30284. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  30285. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30286. resp, requestErr := http.Get(api)
  30287. if requestErr != nil {
  30288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30289. return
  30290. }
  30291. body, ioErr := ioutil.ReadAll(resp.Body)
  30292. if ioErr != nil {
  30293. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30295. return
  30296. }
  30297. var respJSON map[string]interface{}
  30298. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30301. return
  30302. }
  30303. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30304. result, _ := json.Marshal(respJSON)
  30305. fmt.Println("log")
  30306. fmt.Println(string(result))
  30307. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30308. utils.ErrorLog("解析失败:%v", err)
  30309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30310. return
  30311. }
  30312. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30313. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  30314. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  30315. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30316. resp, requestErr := http.Get(api)
  30317. if requestErr != nil {
  30318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30319. return
  30320. }
  30321. body, ioErr := ioutil.ReadAll(resp.Body)
  30322. if ioErr != nil {
  30323. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30325. return
  30326. }
  30327. var respJSON map[string]interface{}
  30328. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30329. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30331. return
  30332. }
  30333. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30334. result, _ := json.Marshal(respJSON)
  30335. fmt.Println("log")
  30336. fmt.Println(string(result))
  30337. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30338. utils.ErrorLog("解析失败:%v", err)
  30339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30340. return
  30341. }
  30342. } else if miConfig.MdtrtareaAdmvs == "420902" {
  30343. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  30344. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  30345. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30346. resp, requestErr := http.Get(api)
  30347. if requestErr != nil {
  30348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30349. return
  30350. }
  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(string(body)), &respJSON); err != nil {
  30359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30361. return
  30362. }
  30363. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30364. result, _ := json.Marshal(respJSON)
  30365. fmt.Println("log")
  30366. fmt.Println(string(result))
  30367. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30368. utils.ErrorLog("解析失败:%v", err)
  30369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30370. return
  30371. }
  30372. } else if miConfig.MdtrtareaAdmvs == "421182" {
  30373. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  30374. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  30375. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  30376. resp, requestErr := http.Get(api)
  30377. if requestErr != nil {
  30378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30379. return
  30380. }
  30381. body, ioErr := ioutil.ReadAll(resp.Body)
  30382. if ioErr != nil {
  30383. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30385. return
  30386. }
  30387. var respJSON map[string]interface{}
  30388. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30389. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30391. return
  30392. }
  30393. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30394. result, _ := json.Marshal(respJSON)
  30395. fmt.Println("log")
  30396. fmt.Println(string(result))
  30397. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30398. utils.ErrorLog("解析失败:%v", err)
  30399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30400. return
  30401. }
  30402. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  30403. var api string
  30404. if miConfig.MdtrtareaAdmvs == "320921" {
  30405. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  30406. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  30407. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30408. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30409. } else {
  30410. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30411. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  30412. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  30413. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30414. }
  30415. resp, requestErr := http.Get(api)
  30416. if requestErr != nil {
  30417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30418. return
  30419. }
  30420. body, ioErr := ioutil.ReadAll(resp.Body)
  30421. if ioErr != nil {
  30422. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30424. return
  30425. }
  30426. var respJSON map[string]interface{}
  30427. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30428. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30430. return
  30431. }
  30432. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30433. result, _ := json.Marshal(respJSON)
  30434. fmt.Println("log")
  30435. fmt.Println(string(result))
  30436. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  30437. utils.ErrorLog("解析失败:%v", err)
  30438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30439. return
  30440. }
  30441. res.InfRefmsgid = resEleven10265.InfRefmsgid
  30442. res.Output = resEleven10265.Output
  30443. res.ErrMsg = resEleven10265.ErrMsg
  30444. res.Cainfo = resEleven10265.Cainfo
  30445. res.WarnMsg = resEleven10265.WarnMsg
  30446. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  30447. res.Infcode = infocode
  30448. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30449. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  30450. saveLog(result, requestLog, "5203", "结算单")
  30451. var dat map[string]interface{}
  30452. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30453. fmt.Println(dat)
  30454. } else {
  30455. fmt.Println(err)
  30456. }
  30457. userJSONBytes, _ := json.Marshal(dat)
  30458. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30459. utils.ErrorLog("解析失败:%v", err)
  30460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30461. return
  30462. }
  30463. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30464. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  30465. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  30466. fmt.Println(result3)
  30467. fmt.Println(requestLog3)
  30468. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  30469. fmt.Println(result2)
  30470. fmt.Println(requestLog2)
  30471. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  30472. saveLog(result, requestLog, "5203", "结算单")
  30473. var dat map[string]interface{}
  30474. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30475. fmt.Println(dat)
  30476. } else {
  30477. fmt.Println(err)
  30478. }
  30479. userJSONBytes, _ := json.Marshal(dat)
  30480. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30481. utils.ErrorLog("解析失败:%v", err)
  30482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30483. return
  30484. }
  30485. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30486. var api string
  30487. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  30488. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  30489. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30490. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30491. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30492. resp, requestErr := http.Get(api)
  30493. if requestErr != nil {
  30494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30495. return
  30496. }
  30497. body, ioErr := ioutil.ReadAll(resp.Body)
  30498. if ioErr != nil {
  30499. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30501. return
  30502. }
  30503. var respJSON map[string]interface{}
  30504. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30507. return
  30508. }
  30509. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30510. if status == "0" {
  30511. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30512. c.ServeSuccessJSON(map[string]interface{}{
  30513. "failed_code": -10,
  30514. "msg": err_msg,
  30515. })
  30516. return
  30517. }
  30518. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30519. result, _ := json.Marshal(respJSON)
  30520. fmt.Println("log")
  30521. fmt.Println(string(result))
  30522. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  30523. utils.ErrorLog("解析失败:%v", err)
  30524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30525. return
  30526. }
  30527. res.InfRefmsgid = resah.InfRefmsgid
  30528. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30529. // 创建对应的Time类型
  30530. t := time.UnixMilli(timestamp)
  30531. // 格式化成指定的日期字符串
  30532. str := t.Format("2006-01-02 15:04:05")
  30533. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30534. // 创建对应的Time类型
  30535. t3 := time.UnixMilli(timestamp2)
  30536. // 格式化成指定的日期字符串
  30537. str2 := t3.Format("2006-01-02 15:04:05")
  30538. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  30539. // 创建对应的Time类型
  30540. t4 := time.UnixMilli(timestamp3)
  30541. // 格式化成指定的日期字符串
  30542. str3 := t4.Format("2006-01-02 15:04:05")
  30543. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  30544. // 创建对应的Time类型
  30545. t5 := time.UnixMilli(timestamp4)
  30546. // 格式化成指定的日期字符串
  30547. str5 := t5.Format("2006-01-02 15:04:05")
  30548. res.Output.Setlinfo.Brdy = str2
  30549. res.Output.Setlinfo.SetlTime = str
  30550. res.Output.Setlinfo.Begndate = str3
  30551. res.Output.Setlinfo.Enddate = str5
  30552. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  30553. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  30554. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  30555. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  30556. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  30557. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  30558. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  30559. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  30560. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  30561. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  30562. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  30563. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  30564. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30565. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  30566. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  30567. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  30568. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  30569. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  30570. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  30571. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  30572. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  30573. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  30574. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  30575. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  30576. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  30577. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30578. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  30579. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  30580. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  30581. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  30582. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30583. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  30584. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  30585. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  30586. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  30587. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  30588. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  30589. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  30590. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  30591. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  30592. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  30593. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  30594. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  30595. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  30596. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  30597. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30598. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  30599. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  30600. //res.Output.Setldetail = resah.Output.Setldetail
  30601. res.ErrMsg = resah.ErrMsg
  30602. res.Cainfo = resah.Cainfo
  30603. res.WarnMsg = resah.WarnMsg
  30604. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30605. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  30606. saveLog(result, requestLog, "5203", "结算单")
  30607. var dat map[string]interface{}
  30608. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30609. fmt.Println(dat)
  30610. } else {
  30611. fmt.Println(err)
  30612. }
  30613. userJSONBytes, _ := json.Marshal(dat)
  30614. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30615. utils.ErrorLog("解析失败:%v", err)
  30616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30617. return
  30618. }
  30619. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30620. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  30621. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  30622. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30623. resp, requestErr := http.Get(api)
  30624. if requestErr != nil {
  30625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30626. return
  30627. }
  30628. body, ioErr := ioutil.ReadAll(resp.Body)
  30629. if ioErr != nil {
  30630. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30632. return
  30633. }
  30634. var respJSON map[string]interface{}
  30635. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30636. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30638. return
  30639. }
  30640. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30641. result, _ := json.Marshal(respJSON)
  30642. fmt.Println("log")
  30643. fmt.Println(string(result))
  30644. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  30645. utils.ErrorLog("解析失败:%v", err)
  30646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30647. return
  30648. }
  30649. res.InfRefmsgid = resEleven10265.InfRefmsgid
  30650. res.Output = resEleven10265.Output
  30651. res.ErrMsg = resEleven10265.ErrMsg
  30652. res.Cainfo = resEleven10265.Cainfo
  30653. res.WarnMsg = resEleven10265.WarnMsg
  30654. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  30655. res.Infcode = infocode
  30656. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30657. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  30658. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  30659. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30660. resp, requestErr := http.Get(api)
  30661. if requestErr != nil {
  30662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30663. return
  30664. }
  30665. body, ioErr := ioutil.ReadAll(resp.Body)
  30666. if ioErr != nil {
  30667. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30669. return
  30670. }
  30671. var respJSON map[string]interface{}
  30672. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30675. return
  30676. }
  30677. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30678. result, _ := json.Marshal(respJSON)
  30679. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30680. utils.ErrorLog("解析失败:%v", err)
  30681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30682. return
  30683. }
  30684. } else if miConfig.MdtrtareaAdmvs == "450721" {
  30685. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  30686. //return
  30687. } else {
  30688. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  30689. if len(his.InsuplcAdmdvs) == 0 {
  30690. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  30691. } else {
  30692. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  30693. }
  30694. result := service.Gdyb5203(baseParams, businessParams)
  30695. //service.Gdyb5204(baseParams, businessParams)
  30696. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  30697. var dat map[string]interface{}
  30698. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30699. fmt.Println(dat)
  30700. } else {
  30701. fmt.Println(err)
  30702. }
  30703. userJSONBytes, _ := json.Marshal(dat)
  30704. if miConfig.Code == "H15049901371" {
  30705. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  30706. utils.ErrorLog("解析失败:%v", err)
  30707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30708. return
  30709. }
  30710. res.InfRefmsgid = resEleven10265.InfRefmsgid
  30711. res.Output = resEleven10265.Output
  30712. res.ErrMsg = resEleven10265.ErrMsg
  30713. res.Cainfo = resEleven10265.Cainfo
  30714. res.WarnMsg = resEleven10265.WarnMsg
  30715. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  30716. res.Infcode = infocode
  30717. } else {
  30718. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30719. utils.ErrorLog("解析失败:%v", err)
  30720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30721. return
  30722. }
  30723. }
  30724. }
  30725. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30726. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  30727. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  30728. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  30729. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  30730. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30731. var doctor_name string
  30732. if roles.ID == 0 {
  30733. doctor_name = "管理员"
  30734. } else {
  30735. doctor_name = roles.UserName
  30736. }
  30737. yiliao_leibie := ""
  30738. switch order.MedType {
  30739. case "11":
  30740. yiliao_leibie = "普通门诊"
  30741. break
  30742. case "12":
  30743. yiliao_leibie = "门诊挂号"
  30744. break
  30745. case "13":
  30746. yiliao_leibie = "急诊"
  30747. break
  30748. case "14":
  30749. yiliao_leibie = "门诊特殊病"
  30750. break
  30751. case "15":
  30752. yiliao_leibie = "门诊统筹"
  30753. break
  30754. case "16":
  30755. yiliao_leibie = "门诊慢性病"
  30756. break
  30757. case "21":
  30758. yiliao_leibie = "普通住院"
  30759. break
  30760. }
  30761. //var rf []CustomFundPay
  30762. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  30763. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  30764. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  30765. if res.Infcode == 0 {
  30766. 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 {
  30767. c.ServeSuccessJSON(map[string]interface{}{
  30768. "diagnosis": name,
  30769. "order_infos": orderInfos,
  30770. "number": order.MdtrtId,
  30771. "date": order.SettleAccountsDate,
  30772. "charge_admin": charge_admin,
  30773. "printor_admin": printor_admin,
  30774. "info": res.Output.Setlinfo,
  30775. "order": order,
  30776. "bedCostTotal": bedCostTotal,
  30777. "bedCostSelfTotal": bedCostSelfTotal,
  30778. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  30779. "bedSelfTotal": bedSelfTotal,
  30780. "bedInscpTotal": bedInscpTotal,
  30781. "operationCostTotal": operationCostTotal,
  30782. "operationCostSelfTotal": operationCostSelfTotal,
  30783. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  30784. "operationSelfTotal": operationSelfTotal,
  30785. "operationInscpTotal": operationInscpTotal,
  30786. "otherCostTotal": otherCostTotal,
  30787. "otherCostSelfTotal": otherCostSelfTotal,
  30788. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  30789. "otherSelfTotal": otherSelfTotal,
  30790. "otherInscpTotal": otherInscpTotal,
  30791. "materialCostTotal": materialCostTotal,
  30792. "materialCostSelfTotal": materialCostSelfTotal,
  30793. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  30794. "materialSelfTotal": materialSelfTotal,
  30795. "materialInscpTotal": materialInscpTotal,
  30796. "westernMedicineCostTotal": westernMedicineCostTotal,
  30797. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  30798. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  30799. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  30800. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  30801. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  30802. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  30803. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  30804. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  30805. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  30806. "checkCostTotal": checkCostTotal,
  30807. "checkCostSelfTotal": checkCostSelfTotal,
  30808. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  30809. "checkSelfTotal": checkSelfTotal,
  30810. "checkInscpTotal": checkInscpTotal,
  30811. "laboratoryCostTotal": laboratoryCostTotal,
  30812. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  30813. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  30814. "laboratorySelfTotal": laboratorySelfTotal,
  30815. "laboratoryInscpTotal": laboratoryInscpTotal,
  30816. "treatCostTotal": treatCostTotal,
  30817. "treatCostSelfTotal": treatCostSelfTotal,
  30818. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  30819. "treatSelfTotal": treatSelfTotal,
  30820. "treatInscpTotal": treatInscpTotal,
  30821. "doctor_info": doctor_info,
  30822. "doctor_code": adminRole_two.DoctorCode,
  30823. "doctor_name": doctor_name,
  30824. "health_card_no": order.PsnNo,
  30825. "department": departments.Name,
  30826. "yiliao_leibie": yiliao_leibie,
  30827. "after_money": order.AccountPrice,
  30828. "patient": patient,
  30829. "org_name": miConfig.OrgName,
  30830. "org_code": miConfig.Code,
  30831. "order_number": order.Number,
  30832. "his_hospital": his_hospital,
  30833. "his": his,
  30834. "dia_config": dia_config,
  30835. "psn_cash_pay": order.PsnCashPay,
  30836. "zcCostTotal": zcCostTotal,
  30837. "zcCostSelfTotal": zcCostSelfTotal,
  30838. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  30839. "zcSelfTotal": zcSelfTotal,
  30840. "zcInscpTotal": zcInscpTotal,
  30841. "huliCostTotal": huliCostTotal,
  30842. "huliCostSelfTotal": huliCostSelfTotal,
  30843. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  30844. "huliSelfTotal": huliSelfTotal,
  30845. "huliInscpTotal": huliInscpTotal,
  30846. //"funds": rf,
  30847. //"check_order_info": cus_slice,
  30848. })
  30849. } else {
  30850. c.ServeSuccessJSON(map[string]interface{}{
  30851. "diagnosis": name,
  30852. "order_infos": orderInfos,
  30853. "number": order.MdtrtId,
  30854. "date": order.SettleAccountsDate,
  30855. "charge_admin": charge_admin,
  30856. "printor_admin": printor_admin,
  30857. "info": order,
  30858. "order": order,
  30859. "bedCostTotal": bedCostTotal,
  30860. "bedCostSelfTotal": bedCostSelfTotal,
  30861. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  30862. "bedSelfTotal": bedSelfTotal,
  30863. "bedInscpTotal": bedInscpTotal,
  30864. "operationCostTotal": operationCostTotal,
  30865. "operationCostSelfTotal": operationCostSelfTotal,
  30866. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  30867. "operationSelfTotal": operationSelfTotal,
  30868. "operationInscpTotal": operationInscpTotal,
  30869. "otherCostTotal": otherCostTotal,
  30870. "otherCostSelfTotal": otherCostSelfTotal,
  30871. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  30872. "otherSelfTotal": otherSelfTotal,
  30873. "otherInscpTotal": otherInscpTotal,
  30874. "materialCostTotal": materialCostTotal,
  30875. "materialCostSelfTotal": materialCostSelfTotal,
  30876. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  30877. "materialSelfTotal": materialSelfTotal,
  30878. "materialInscpTotal": materialInscpTotal,
  30879. "westernMedicineCostTotal": westernMedicineCostTotal,
  30880. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  30881. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  30882. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  30883. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  30884. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  30885. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  30886. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  30887. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  30888. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  30889. "checkCostTotal": checkCostTotal,
  30890. "checkCostSelfTotal": checkCostSelfTotal,
  30891. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  30892. "checkSelfTotal": checkSelfTotal,
  30893. "checkInscpTotal": checkInscpTotal,
  30894. "laboratoryCostTotal": laboratoryCostTotal,
  30895. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  30896. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  30897. "laboratorySelfTotal": laboratorySelfTotal,
  30898. "laboratoryInscpTotal": laboratoryInscpTotal,
  30899. "treatCostTotal": treatCostTotal,
  30900. "treatCostSelfTotal": treatCostSelfTotal,
  30901. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  30902. "treatSelfTotal": treatSelfTotal,
  30903. "treatInscpTotal": treatInscpTotal,
  30904. "doctor_info": doctor_info,
  30905. "doctor_code": adminRole_two.DoctorCode,
  30906. "doctor_name": doctor_name,
  30907. "health_card_no": order.PsnNo,
  30908. "department": departments.Name,
  30909. "yiliao_leibie": yiliao_leibie,
  30910. "after_money": order.AccountPrice,
  30911. "patient": patient,
  30912. "org_name": miConfig.OrgName,
  30913. "org_code": miConfig.Code,
  30914. "order_number": order.Number,
  30915. "his_hospital": his_hospital,
  30916. "his": his,
  30917. "dia_config": dia_config,
  30918. "psn_cash_pay": order.PsnCashPay,
  30919. "zcCostTotal": zcCostTotal,
  30920. "zcCostSelfTotal": zcCostSelfTotal,
  30921. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  30922. "zcSelfTotal": zcSelfTotal,
  30923. "zcInscpTotal": zcInscpTotal,
  30924. "huliCostTotal": huliCostTotal,
  30925. "huliCostSelfTotal": huliCostSelfTotal,
  30926. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  30927. "huliSelfTotal": huliSelfTotal,
  30928. "huliInscpTotal": huliInscpTotal,
  30929. //"funds": rf,
  30930. //"check_order_info": cus_slice,
  30931. })
  30932. }
  30933. }
  30934. }
  30935. }
  30936. //func (c *HisApiController) CheckTreatment() {
  30937. // patient_id, _ := c.GetInt64("patient_id")
  30938. // id_card_no := c.GetString("id_card_no")
  30939. // insutype := c.GetString("insutype")
  30940. // med_type := c.GetString("med_type")
  30941. // admin_user_id, _ := c.GetInt64("admin_user_id")
  30942. //
  30943. // adminUser := c.GetAdminUserInfo()
  30944. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  30945. //
  30946. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30947. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30948. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30949. //
  30950. // if miConfig.MdtrtareaAdmvs == "421300" {
  30951. // var res ResultTwo
  30952. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  30953. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30954. // "&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)
  30955. // resp, requestErr := http.Get(api)
  30956. // if requestErr != nil {
  30957. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30958. // return
  30959. // }
  30960. //
  30961. // body, ioErr := ioutil.ReadAll(resp.Body)
  30962. // if ioErr != nil {
  30963. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30964. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30965. // return
  30966. // }
  30967. // var respJSON map[string]interface{}
  30968. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30969. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30970. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30971. // return
  30972. // }
  30973. //
  30974. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30975. // result, _ := json.Marshal(respJSON)
  30976. //
  30977. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  30978. // utils.ErrorLog("解析失败:%v", err)
  30979. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30980. // return
  30981. // }
  30982. //
  30983. // if res.Infcode == 0 {
  30984. //
  30985. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  30986. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30987. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  30988. // resp, requestErr := http.Get(api)
  30989. // if requestErr != nil {
  30990. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30991. // return
  30992. // }
  30993. //
  30994. // body, ioErr := ioutil.ReadAll(resp.Body)
  30995. // if ioErr != nil {
  30996. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30997. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30998. // return
  30999. // }
  31000. // var respJSON map[string]interface{}
  31001. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31002. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31003. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31004. // return
  31005. // }
  31006. // var res Result2001
  31007. //
  31008. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31009. // result2, _ := json.Marshal(respJSON)
  31010. //
  31011. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  31012. // utils.ErrorLog("解析失败:%v", err)
  31013. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31014. // return
  31015. // }
  31016. //
  31017. // if res.Infcode == 0 {
  31018. // c.ServeSuccessJSON(map[string]interface{}{
  31019. // "msg": res.Output.Trtinfo,
  31020. // })
  31021. // }
  31022. //
  31023. // } else {
  31024. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  31025. // return
  31026. // }
  31027. //
  31028. // } else {
  31029. //
  31030. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  31031. // var dat map[string]interface{}
  31032. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31033. // fmt.Println(dat)
  31034. // } else {
  31035. // fmt.Println(err)
  31036. // }
  31037. // userJSONBytes, _ := json.Marshal(dat)
  31038. // var res ResultTwo
  31039. // var res10265 ResultTwo10265
  31040. // if miConfig.Code == "H15049901371" {
  31041. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  31042. // utils.ErrorLog("解析失败:%v", err)
  31043. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31044. // return
  31045. // }
  31046. // res.ErrMsg = res10265.ErrMsg
  31047. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  31048. // res.Infcode = infocode
  31049. // res.Output = res10265.Output
  31050. // res.InfRefmsgid = res10265.InfRefmsgid
  31051. // } else {
  31052. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31053. // utils.ErrorLog("解析失败:%v", err)
  31054. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31055. // return
  31056. // }
  31057. // }
  31058. //
  31059. // var user_name string
  31060. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  31061. // if role.ID == 0 {
  31062. // user_name = "xxx"
  31063. // } else {
  31064. // user_name = role.UserName
  31065. // }
  31066. //
  31067. // baseParams := models.BaseParams{
  31068. // SecretKey: miConfig.SecretKey,
  31069. // FixmedinsCode: miConfig.Code,
  31070. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  31071. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  31072. // OrgName: miConfig.OrgName,
  31073. // Doctor: user_name,
  31074. // }
  31075. //
  31076. // if config.IsOpen == 1 {
  31077. // if miConfig.Code == "H15049901371" {
  31078. // if med_type == "14" {
  31079. // if insutype == "390" {
  31080. // med_type = "9933"
  31081. // } else if insutype == "310" {
  31082. // med_type = "990502"
  31083. // }
  31084. // } else if med_type == "11" {
  31085. // med_type = "11"
  31086. // }
  31087. // }
  31088. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  31089. // var dat map[string]interface{}
  31090. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31091. // fmt.Println(dat)
  31092. // } else {
  31093. // fmt.Println(err)
  31094. // }
  31095. // var res Result2001
  31096. // var res10265 Result2001Org10265
  31097. // if miConfig.Code == "H15049901371" {
  31098. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  31099. // utils.ErrorLog("解析失败:%v", err)
  31100. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31101. // return
  31102. // }
  31103. // res.ErrMsg = res10265.ErrMsg
  31104. // res.Output = res10265.Output
  31105. // res.InfRefmsgid = res10265.InfRefmsgid
  31106. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  31107. // res.Infcode = infocode
  31108. // } else {
  31109. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  31110. // utils.ErrorLog("解析失败:%v", err)
  31111. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31112. // return
  31113. // }
  31114. // }
  31115. // if res.Infcode == 0 {
  31116. // c.ServeSuccessJSON(map[string]interface{}{
  31117. // "msg": res.Output.Trtinfo,
  31118. // })
  31119. // }
  31120. // }
  31121. // }
  31122. //}
  31123. //func (c *HisApiController) PutRecord() {
  31124. // id, _ := c.GetInt64("id")
  31125. // record_time := c.GetString("record_time")
  31126. // timeLayout := "2006-01-02"
  31127. // loc, _ := time.LoadLocation("Local")
  31128. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  31129. // if err != nil {
  31130. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31131. // return
  31132. // }
  31133. // recordDateTime := theTime.Unix()
  31134. //
  31135. // adminInfo := c.GetAdminUserInfo()
  31136. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  31137. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  31138. //
  31139. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  31140. //
  31141. // fmt.Println(miConfig.SecretKey)
  31142. //
  31143. // if patient == nil {
  31144. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  31145. // return
  31146. // }
  31147. // if len(patient.IdCardNo) == 0 {
  31148. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  31149. // return
  31150. // }
  31151. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  31152. // if config.IsOpen == 1 {
  31153. // 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
  31154. // resp, requestErr := http.Get(api)
  31155. // if requestErr != nil {
  31156. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31157. // return
  31158. // }
  31159. // defer resp.Body.Close()
  31160. // body, ioErr := ioutil.ReadAll(resp.Body)
  31161. // if ioErr != nil {
  31162. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31163. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31164. // return
  31165. // }
  31166. // var respJSON map[string]interface{}
  31167. //
  31168. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31169. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31170. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31171. // return
  31172. // }
  31173. //
  31174. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31175. // userJSONBytes, _ := json.Marshal(userJSON)
  31176. // var res ResultTwo
  31177. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31178. // utils.ErrorLog("解析失败:%v", err)
  31179. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31180. // return
  31181. // }
  31182. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  31183. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  31184. // infoStr := string(Iinfos)
  31185. // idetinfoStr := string(Idetinfos)
  31186. //
  31187. // if res.Infcode == 0 {
  31188. // his := models.VMHisPatient{
  31189. // Status: 1,
  31190. // Ctime: time.Now().Unix(),
  31191. // Mtime: time.Now().Unix(),
  31192. // PsnNo: res.Output.Baseinfo.PsnNo,
  31193. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  31194. // Certno: res.Output.Baseinfo.Certno,
  31195. // PsnName: res.Output.Baseinfo.PsnName,
  31196. // Gend: res.Output.Baseinfo.Gend,
  31197. // Naty: res.Output.Baseinfo.Naty,
  31198. // Brdy: res.Output.Baseinfo.Brdy,
  31199. // Age: res.Output.Baseinfo.Age,
  31200. // Iinfo: infoStr,
  31201. // Idetinfo: idetinfoStr,
  31202. // PatientId: patient.ID,
  31203. // RecordDate: theTime.Unix(),
  31204. // UserOrgId: adminInfo.CurrentOrgId,
  31205. // AdminUserId: adminInfo.AdminUser.Id,
  31206. // IsReturn: 1,
  31207. // }
  31208. //
  31209. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  31210. // //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")
  31211. // //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")
  31212. //
  31213. // //var dat map[string]interface{}
  31214. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31215. // // fmt.Println(dat)
  31216. // //} else {
  31217. // // fmt.Println(err)
  31218. // //}
  31219. //
  31220. // var dat2 map[string]interface{}
  31221. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  31222. // fmt.Println(dat2)
  31223. // } else {
  31224. // fmt.Println(err)
  31225. // }
  31226. //
  31227. // } else {
  31228. // adminUser := c.GetAdminUserInfo()
  31229. // errlog := &models.HisOrderError{
  31230. // UserOrgId: adminUser.CurrentOrgId,
  31231. // Ctime: time.Now().Unix(),
  31232. // Mtime: time.Now().Unix(),
  31233. // ErrMsg: res.ErrMsg,
  31234. // Status: 1,
  31235. // PatientId: id,
  31236. // RecordTime: recordDateTime,
  31237. // Stage: 1,
  31238. // }
  31239. // service.CreateErrMsgLog(errlog)
  31240. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  31241. // return
  31242. // }
  31243. // }
  31244. //
  31245. //}
  31246. //func (c *HisApiController) GetUploadDiag() {
  31247. // id, _ := c.GetInt64("id")
  31248. // record_time := c.GetString("record_time")
  31249. //
  31250. // diagnosis_id, _ := c.GetInt64("diagnosis")
  31251. // sick_type, _ := c.GetInt64("sick_type")
  31252. // reg_type, _ := c.GetInt64("reg_type")
  31253. //
  31254. // timeLayout := "2006-01-02"
  31255. // loc, _ := time.LoadLocation("Local")
  31256. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  31257. // if err != nil {
  31258. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31259. // return
  31260. // }
  31261. //
  31262. // var patientPrescription models.HisPrescriptionInfo
  31263. // recordDateTime := theTime.Unix()
  31264. // adminInfo := c.GetAdminUserInfo()
  31265. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  31266. //
  31267. // if patientPrescription.ID == 0 {
  31268. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  31269. // }
  31270. //
  31271. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  31272. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  31273. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  31274. // sickConfig, _ := service.FindSickById(sick_type)
  31275. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  31276. //
  31277. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  31278. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  31279. // "&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 +
  31280. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  31281. // resp2, requestErr2 := http.Get(api2)
  31282. // if requestErr2 != nil {
  31283. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31284. // return
  31285. // }
  31286. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  31287. // if ioErr2 != nil {
  31288. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  31289. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31290. // return
  31291. // }
  31292. // var respJSON2 map[string]interface{}
  31293. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  31294. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31295. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31296. // return
  31297. // }
  31298. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31299. // userJSONBytes2, _ := json.Marshal(respJSON2)
  31300. //
  31301. // var res2 ResultSix
  31302. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  31303. // utils.ErrorLog("解析失败:%v", err)
  31304. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31305. // return
  31306. // }
  31307. // if res2.Infcode != 0 {
  31308. // adminUser := c.GetAdminUserInfo()
  31309. // errlog := &models.HisOrderError{
  31310. // UserOrgId: adminUser.CurrentOrgId,
  31311. // Ctime: time.Now().Unix(),
  31312. // Mtime: time.Now().Unix(),
  31313. // ErrMsg: res2.ErrMsg,
  31314. // Status: 1,
  31315. // PatientId: id,
  31316. // RecordTime: recordDateTime,
  31317. // Stage: 3,
  31318. // }
  31319. // service.CreateErrMsgLog(errlog)
  31320. //
  31321. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  31322. // return
  31323. // }
  31324. //
  31325. // c.ServeSuccessJSON(map[string]interface{}{
  31326. // "msg": "上传成功",
  31327. // })
  31328. //
  31329. //}
  31330. type QueryResult struct {
  31331. ID int64
  31332. Name string
  31333. Code string
  31334. List_type_code string
  31335. }
  31336. func (c *HisApiController) GetCheckCode() {
  31337. ids_str := c.GetString("ids")
  31338. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  31339. ids_arr := strings.Split(ids_str, ",")
  31340. var queryResult []QueryResult
  31341. ids := make([]int64, 0)
  31342. for _, item := range ids_arr {
  31343. id, _ := strconv.ParseInt(item, 10, 64)
  31344. ids = append(ids, id)
  31345. }
  31346. if record_type == 1 {
  31347. drugs, _ := service.GetBatchDrugList(ids)
  31348. for _, item := range drugs {
  31349. result := QueryResult{
  31350. ID: item.ID,
  31351. Name: item.DrugName,
  31352. Code: item.MedicalInsuranceNumber,
  31353. List_type_code: "101",
  31354. }
  31355. queryResult = append(queryResult, result)
  31356. }
  31357. } else if record_type == 2 {
  31358. goods, _ := service.GetBatchGoodInformationList(ids)
  31359. fmt.Println(goods)
  31360. for _, item := range goods {
  31361. result := QueryResult{
  31362. ID: item.ID,
  31363. Name: item.GoodName,
  31364. Code: item.SocialSecurityDirectoryCode,
  31365. List_type_code: "301",
  31366. }
  31367. queryResult = append(queryResult, result)
  31368. }
  31369. } else if record_type == 3 {
  31370. projects, _ := service.GetBathchMyPorjecgList(ids)
  31371. for _, item := range projects {
  31372. result := QueryResult{
  31373. ID: item.ID,
  31374. Name: item.ProjectName,
  31375. Code: item.MedicalCode,
  31376. List_type_code: "201",
  31377. }
  31378. queryResult = append(queryResult, result)
  31379. }
  31380. }
  31381. admin_user_id, _ := c.GetInt64("admin_user_id")
  31382. adminUser := c.GetAdminUserInfo()
  31383. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31384. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31385. var user_name string
  31386. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31387. if role.ID == 0 {
  31388. user_name = "管理员"
  31389. } else {
  31390. user_name = role.UserName
  31391. }
  31392. baseParams := models.BaseParams{
  31393. SecretKey: miConfig.SecretKey,
  31394. FixmedinsCode: miConfig.Code,
  31395. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  31396. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  31397. OrgName: miConfig.OrgName,
  31398. Doctor: user_name,
  31399. }
  31400. var result string
  31401. if miConfig.MdtrtareaAdmvs == "430800" {
  31402. for _, item := range queryResult {
  31403. if record_type == 1 {
  31404. 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)
  31405. } else if record_type == 2 {
  31406. fmt.Println(item.Code)
  31407. 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)
  31408. } else if record_type == 3 {
  31409. 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)
  31410. }
  31411. var dat map[string]interface{}
  31412. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31413. fmt.Println(dat)
  31414. } else {
  31415. fmt.Println(err)
  31416. }
  31417. userJSONBytes, _ := json.Marshal(dat)
  31418. var res ResultSix
  31419. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31420. utils.ErrorLog("解析失败:%v", err)
  31421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31422. return
  31423. }
  31424. if res.Infcode == 0 {
  31425. if record_type == 1 {
  31426. service.UpdateBaseDrugById(item.ID)
  31427. } else if record_type == 2 {
  31428. service.UpdateGoodInformaitonByDetail(item.ID)
  31429. } else if record_type == 3 {
  31430. service.UpdateProjectById(item.ID)
  31431. }
  31432. c.ServeSuccessJSON(map[string]interface{}{
  31433. "failed_code": 0,
  31434. "msg": "目录对照成功",
  31435. })
  31436. } else {
  31437. c.ServeSuccessJSON(map[string]interface{}{
  31438. "failed_code": -10,
  31439. "msg": res.ErrMsg,
  31440. })
  31441. }
  31442. }
  31443. } else {
  31444. for _, item := range queryResult {
  31445. var result string
  31446. if record_type == 1 {
  31447. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  31448. } else if record_type == 2 {
  31449. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  31450. } else if record_type == 3 {
  31451. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  31452. }
  31453. var dat map[string]interface{}
  31454. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31455. fmt.Println(dat)
  31456. } else {
  31457. fmt.Println(err)
  31458. }
  31459. userJSONBytes, _ := json.Marshal(dat)
  31460. var res ResultSix
  31461. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31462. utils.ErrorLog("解析失败:%v", err)
  31463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31464. return
  31465. }
  31466. if res.Infcode == 0 {
  31467. if record_type == 1 {
  31468. service.UpdateBaseDrugById(item.ID)
  31469. } else if record_type == 2 {
  31470. service.UpdateGoodInformaitonByDetail(item.ID)
  31471. } else if record_type == 3 {
  31472. service.UpdateProjectById(item.ID)
  31473. }
  31474. c.ServeSuccessJSON(map[string]interface{}{
  31475. "failed_code": 0,
  31476. "msg": "目录对照成功",
  31477. })
  31478. } else {
  31479. c.ServeSuccessJSON(map[string]interface{}{
  31480. "failed_code": -10,
  31481. "msg": res.ErrMsg,
  31482. })
  31483. }
  31484. }
  31485. }
  31486. }
  31487. func (c *HisApiController) UnCheckCode() {
  31488. ids_str := c.GetString("ids")
  31489. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  31490. admin_user_id, _ := c.GetInt64("admin_user_id")
  31491. ids_arr := strings.Split(ids_str, ",")
  31492. var queryResult []QueryResult
  31493. ids := make([]int64, 0)
  31494. for _, item := range ids_arr {
  31495. id, _ := strconv.ParseInt(item, 10, 64)
  31496. ids = append(ids, id)
  31497. }
  31498. if record_type == 1 {
  31499. drugs, _ := service.GetBatchDrugList(ids)
  31500. for _, item := range drugs {
  31501. result := QueryResult{
  31502. ID: item.ID,
  31503. Name: item.DrugName,
  31504. Code: item.MedicalInsuranceNumber,
  31505. List_type_code: "101",
  31506. }
  31507. queryResult = append(queryResult, result)
  31508. }
  31509. } else if record_type == 2 {
  31510. goods, _ := service.GetBatchGoodInformationList(ids)
  31511. for _, item := range goods {
  31512. result := QueryResult{
  31513. ID: item.ID,
  31514. Name: item.GoodName,
  31515. Code: item.SocialSecurityDirectoryCode,
  31516. List_type_code: "301",
  31517. }
  31518. queryResult = append(queryResult, result)
  31519. }
  31520. } else if record_type == 3 {
  31521. projects, _ := service.GetBathchMyPorjecgList(ids)
  31522. for _, item := range projects {
  31523. result := QueryResult{
  31524. ID: item.ID,
  31525. Name: item.ProjectName,
  31526. Code: item.MedicalCode,
  31527. List_type_code: "201",
  31528. }
  31529. queryResult = append(queryResult, result)
  31530. }
  31531. }
  31532. adminUser := c.GetAdminUserInfo()
  31533. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31534. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31535. var user_name string
  31536. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31537. if role.ID == 0 {
  31538. user_name = "xxx"
  31539. } else {
  31540. user_name = role.UserName
  31541. }
  31542. baseParams := &models.BaseParams{
  31543. SecretKey: miConfig.SecretKey,
  31544. FixmedinsCode: miConfig.Code,
  31545. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  31546. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  31547. OrgName: miConfig.OrgName,
  31548. Doctor: user_name,
  31549. }
  31550. if config.IsOpen == 1 {
  31551. if miConfig.MdtrtareaAdmvs == "430800" {
  31552. for _, item := range queryResult {
  31553. var result string
  31554. if record_type == 1 {
  31555. 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)
  31556. } else if record_type == 2 {
  31557. fmt.Println(item.Code)
  31558. 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)
  31559. } else if record_type == 3 {
  31560. 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)
  31561. }
  31562. var dat map[string]interface{}
  31563. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31564. fmt.Println(dat)
  31565. } else {
  31566. fmt.Println(err)
  31567. }
  31568. userJSONBytes, _ := json.Marshal(dat)
  31569. var res ResultSix
  31570. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31571. utils.ErrorLog("解析失败:%v", err)
  31572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31573. return
  31574. }
  31575. if res.Infcode == 0 {
  31576. if record_type == 1 {
  31577. service.UpdateBaseDrugById(item.ID)
  31578. } else if record_type == 2 {
  31579. service.UpdateGoodInformaitonByDetail(item.ID)
  31580. } else if record_type == 3 {
  31581. service.UpdateProjectById(item.ID)
  31582. }
  31583. c.ServeSuccessJSON(map[string]interface{}{
  31584. "failed_code": 0,
  31585. "msg": "目录对照成功",
  31586. })
  31587. } else {
  31588. c.ServeSuccessJSON(map[string]interface{}{
  31589. "failed_code": -10,
  31590. "msg": res.ErrMsg,
  31591. })
  31592. }
  31593. }
  31594. } else {
  31595. for _, item := range queryResult {
  31596. var result string
  31597. if record_type == 1 {
  31598. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  31599. } else if record_type == 2 {
  31600. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  31601. } else if record_type == 3 {
  31602. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  31603. }
  31604. var dat2 map[string]interface{}
  31605. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  31606. fmt.Println(dat2)
  31607. } else {
  31608. fmt.Println(err)
  31609. }
  31610. userJSONBytes, _ := json.Marshal(dat2)
  31611. var res ResultSix
  31612. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31613. utils.ErrorLog("解析失败:%v", err)
  31614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31615. return
  31616. }
  31617. if res.Infcode == 0 {
  31618. if record_type == 1 {
  31619. service.UpdateDrugByIdDetail(item.ID)
  31620. } else if record_type == 2 {
  31621. service.UpdateGoodInfoById(item.ID)
  31622. } else if record_type == 3 {
  31623. service.UpdateMyProjectById(item.ID)
  31624. }
  31625. c.ServeSuccessJSON(map[string]interface{}{
  31626. "failed_code": 0,
  31627. "msg": "撤销目录对照成功",
  31628. })
  31629. } else {
  31630. c.ServeSuccessJSON(map[string]interface{}{
  31631. "failed_code": -10,
  31632. "msg": res.ErrMsg,
  31633. })
  31634. }
  31635. }
  31636. }
  31637. }
  31638. }
  31639. func (c *HisApiController) GetPatientInfo() {
  31640. id_card_no := c.GetString("id_card_no")
  31641. admin_user_id, _ := c.GetInt64("admin_user_id")
  31642. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  31643. if patient.ID == 0 {
  31644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  31645. return
  31646. }
  31647. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  31648. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  31649. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  31650. var res ResultTwo
  31651. var res10265 ResultTwo10265
  31652. if config.IsOpen == 1 {
  31653. if miConfig.MdtrtareaAdmvs == "150499" {
  31654. //请求内网数据
  31655. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  31656. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  31657. "&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
  31658. resp, requestErr := http.Get(api)
  31659. if requestErr != nil {
  31660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31661. return
  31662. }
  31663. body, ioErr := ioutil.ReadAll(resp.Body)
  31664. if ioErr != nil {
  31665. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31667. return
  31668. }
  31669. var respJSON map[string]interface{}
  31670. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31673. return
  31674. }
  31675. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31676. result_byte, _ := json.Marshal(respJSON)
  31677. result := string(result_byte)
  31678. var dat map[string]interface{}
  31679. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31680. fmt.Println(dat)
  31681. } else {
  31682. fmt.Println(err)
  31683. }
  31684. userJSONBytes, _ := json.Marshal(dat)
  31685. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  31686. utils.ErrorLog("解析失败:%v", err)
  31687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31688. return
  31689. }
  31690. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  31691. res.Infcode = Infcode
  31692. res.ErrMsg = res10265.ErrMsg
  31693. res.Output = res10265.Output
  31694. res.InfRefmsgid = res10265.InfRefmsgid
  31695. res.RespondTime = res10265.RespondTime
  31696. res.WarnInfo = res10265.WarnInfo
  31697. } else {
  31698. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  31699. var dat map[string]interface{}
  31700. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31701. fmt.Println(dat)
  31702. } else {
  31703. fmt.Println(err)
  31704. }
  31705. userJSONBytes, _ := json.Marshal(dat)
  31706. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31707. utils.ErrorLog("解析失败:%v", err)
  31708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31709. return
  31710. }
  31711. }
  31712. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31713. // utils.ErrorLog("解析失败:%v", err)
  31714. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31715. // return
  31716. //}
  31717. for index, item := range res.Output.Iinfo {
  31718. if item.PsnInsuStas == "2" {
  31719. fmt.Println("--------")
  31720. res.Output.Iinfo[index].Insutype = "300"
  31721. res.Output.Iinfo[index].PsnInsuStas = "1"
  31722. }
  31723. }
  31724. fmt.Println(res.Output.Iinfo)
  31725. if res.Infcode != 0 {
  31726. c.ServeSuccessJSON(map[string]interface{}{
  31727. "failed_code": -10,
  31728. "msg": res.ErrMsg,
  31729. })
  31730. } else {
  31731. c.ServeSuccessJSON(map[string]interface{}{
  31732. "failed_code": 0,
  31733. "info": res,
  31734. })
  31735. }
  31736. }
  31737. }
  31738. func (c *HisApiController) PsnPutOnRecord() {
  31739. record_type, _ := c.GetInt64("type")
  31740. patient_id, _ := c.GetInt64("patient_id")
  31741. admin_user_id, _ := c.GetInt64("admin_user_id")
  31742. start_time := c.GetString("start_time")
  31743. end_time := c.GetString("end_time")
  31744. adminUser := c.GetAdminUserInfo()
  31745. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31746. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31747. var patients []*models.Patients
  31748. if record_type == 1 { //全部备案
  31749. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  31750. patients = append(patients, patient...)
  31751. } else { //单个备案
  31752. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  31753. patients = append(patients, patient)
  31754. }
  31755. var user_name string
  31756. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31757. if role.ID == 0 {
  31758. user_name = "xxx"
  31759. } else {
  31760. user_name = role.UserName
  31761. }
  31762. if config.IsOpen == 1 {
  31763. for _, item := range patients {
  31764. 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
  31765. resp, requestErr := http.Get(api)
  31766. if requestErr != nil {
  31767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31768. return
  31769. }
  31770. defer resp.Body.Close()
  31771. body, ioErr := ioutil.ReadAll(resp.Body)
  31772. if ioErr != nil {
  31773. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31775. return
  31776. }
  31777. var respJSON map[string]interface{}
  31778. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31781. return
  31782. }
  31783. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31784. userJSONBytes, _ := json.Marshal(userJSON)
  31785. var res ResultTwo
  31786. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31787. utils.ErrorLog("解析失败:%v", err)
  31788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31789. return
  31790. }
  31791. if res.Infcode == 0 {
  31792. 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)
  31793. var dat map[string]interface{}
  31794. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31795. fmt.Println(dat)
  31796. } else {
  31797. fmt.Println(err)
  31798. }
  31799. userJSONBytes, _ := json.Marshal(dat)
  31800. var res2 ResultThirteen
  31801. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31802. utils.ErrorLog("解析失败:%v", err)
  31803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31804. return
  31805. }
  31806. if res2.Infcode == 0 {
  31807. psnResult := &models.GdybPsnRecord{
  31808. UserOrgId: adminUser.CurrentOrgId,
  31809. PatientId: item.ID,
  31810. PsnNo: res.Output.Baseinfo.PsnNo,
  31811. Ctime: time.Now().Unix(),
  31812. Mtime: time.Now().Unix(),
  31813. Status: 1,
  31814. IsCancel: 1,
  31815. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  31816. }
  31817. service.CreatePsnRecord(psnResult)
  31818. } else {
  31819. c.ServeSuccessJSON(map[string]interface{}{
  31820. "failed_code": -10,
  31821. "msg": res2.ErrMsg,
  31822. })
  31823. return
  31824. }
  31825. }
  31826. }
  31827. }
  31828. }
  31829. func (c *HisApiController) PsnUnPutOnRecord() {
  31830. id, _ := c.GetInt64("id")
  31831. //record_type, _ := c.GetInt64("type")
  31832. admin_user_id, _ := c.GetInt64("admin_user_id")
  31833. adminUser := c.GetAdminUserInfo()
  31834. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31835. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31836. var user_name string
  31837. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31838. if role.ID == 0 {
  31839. user_name = "xxx"
  31840. } else {
  31841. user_name = role.UserName
  31842. }
  31843. psn_record, _ := service.GetPsnRecordById(id)
  31844. if psn_record.ID == 0 {
  31845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  31846. return
  31847. }
  31848. if config.IsOpen == 1 {
  31849. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  31850. var dat map[string]interface{}
  31851. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31852. fmt.Println(dat)
  31853. } else {
  31854. fmt.Println(err)
  31855. }
  31856. userJSONBytes, _ := json.Marshal(dat)
  31857. var res ResultFourteen
  31858. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31859. utils.ErrorLog("解析失败:%v", err)
  31860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31861. return
  31862. }
  31863. if res.Infcode == 0 {
  31864. psn_record.IsCancel = 2
  31865. service.CreatePsnRecord(&psn_record)
  31866. } else {
  31867. c.ServeSuccessJSON(map[string]interface{}{
  31868. "failed_code": -10,
  31869. "msg": res.ErrMsg,
  31870. })
  31871. return
  31872. }
  31873. }
  31874. }
  31875. func (c *HisApiController) PsnPutNCDSOnRecord() {
  31876. patient_id, _ := c.GetInt64("patient_id")
  31877. insutype_two := c.GetString("insutype")
  31878. psn_no := c.GetString("psn_no")
  31879. doctor_id, _ := c.GetInt64("doctor_id")
  31880. sick_id, _ := c.GetInt64("sick_id")
  31881. department_id, _ := c.GetInt64("department_id")
  31882. start_time := c.GetString("start_time")
  31883. end_time := c.GetString("end_time")
  31884. check_time := c.GetString("check_time")
  31885. hospital_code := c.GetString("hospital_code")
  31886. hospital_name := c.GetString("hospital_name")
  31887. adminUser := c.GetAdminUserInfo()
  31888. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  31889. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31890. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31891. sick, _ := service.FindSickById(sick_id)
  31892. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  31893. if len(hospital_code) == 0 {
  31894. hospital_code = miConfig.Code
  31895. }
  31896. if len(hospital_name) == 0 {
  31897. hospital_name = miConfig.OrgName
  31898. }
  31899. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  31900. var res ResultTwo
  31901. var res10265 ResultTwo10265
  31902. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31903. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  31904. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  31905. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  31906. "&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
  31907. resp, requestErr := http.Get(api)
  31908. if requestErr != nil {
  31909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31910. return
  31911. }
  31912. body, ioErr := ioutil.ReadAll(resp.Body)
  31913. if ioErr != nil {
  31914. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31916. return
  31917. }
  31918. var respJSON map[string]interface{}
  31919. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31922. return
  31923. }
  31924. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31925. result, _ := json.Marshal(respJSON)
  31926. fmt.Println("log")
  31927. fmt.Println(string(result))
  31928. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  31929. utils.ErrorLog("解析失败:%v", err)
  31930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31931. return
  31932. }
  31933. res.ErrMsg = res10265.ErrMsg
  31934. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  31935. res.Infcode = infocode
  31936. res.Output = res10265.Output
  31937. res.InfRefmsgid = res10265.InfRefmsgid
  31938. } else {
  31939. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  31940. if miConfig.Code == "H15049901371" {
  31941. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  31942. utils.ErrorLog("解析失败:%v", err)
  31943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31944. return
  31945. }
  31946. res.ErrMsg = res10265.ErrMsg
  31947. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  31948. res.Infcode = infocode
  31949. res.Output = res10265.Output
  31950. res.InfRefmsgid = res10265.InfRefmsgid
  31951. } else {
  31952. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31953. utils.ErrorLog("解析失败:%v", err)
  31954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31955. return
  31956. }
  31957. }
  31958. }
  31959. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  31960. infoStr := string(Iinfos)
  31961. var rf []*ResultFive
  31962. json.Unmarshal([]byte(infoStr), &rf)
  31963. var insuplc_admdvs string
  31964. var insutype string
  31965. var is390 int = 0
  31966. var is310 int = 0
  31967. var insutypes []*ResultFive
  31968. for _, item := range rf {
  31969. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  31970. insutypes = append(insutypes, item)
  31971. }
  31972. }
  31973. if len(insutypes) == 1 {
  31974. insutype = insutypes[0].Insutype
  31975. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  31976. } else {
  31977. for _, i := range insutypes {
  31978. if i.Insutype == "390" {
  31979. is390 = 1
  31980. }
  31981. if i.Insutype == "310" {
  31982. is310 = 1
  31983. }
  31984. }
  31985. }
  31986. if is390 == 1 {
  31987. insutype = "390"
  31988. }
  31989. if is310 == 1 {
  31990. insutype = "310"
  31991. }
  31992. if len(insutypes) == 2 {
  31993. insutype = insutype_two
  31994. }
  31995. if len(insutypes) == 0 {
  31996. insutype = "310"
  31997. }
  31998. insutype = insutype_two
  31999. fmt.Println(insutype)
  32000. for _, item := range rf {
  32001. fmt.Println(item.Insutype)
  32002. fmt.Println(insutype)
  32003. if item.Insutype == insutype {
  32004. fmt.Println(item.Insutype)
  32005. fmt.Println(insutype)
  32006. insuplc_admdvs = item.InsuplcAdmdvs
  32007. }
  32008. }
  32009. fmt.Println(insuplc_admdvs)
  32010. var res2 ResultThirteen
  32011. var res10265_2 ResultThirteen10265
  32012. if config.IsOpen == 1 {
  32013. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32014. } else {
  32015. if miConfig.MdtrtareaAdmvs == "150499" {
  32016. //
  32017. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  32018. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  32019. // "&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
  32020. //resp, requestErr := http.Get(api)
  32021. //if requestErr != nil {
  32022. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32023. // return
  32024. //}
  32025. //
  32026. //body, ioErr := ioutil.ReadAll(resp.Body)
  32027. //if ioErr != nil {
  32028. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32029. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32030. // return
  32031. //}
  32032. //var respJSON map[string]interface{}
  32033. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32034. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32035. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32036. // return
  32037. //}
  32038. //
  32039. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32040. //result, _ := json.Marshal(respJSON)
  32041. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  32042. // utils.ErrorLog("解析失败:%v", err)
  32043. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32044. // return
  32045. //}
  32046. //infocode = resThree.Infcode
  32047. //result, _ := json.Marshal(respJSON)
  32048. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  32049. // utils.ErrorLog("解析失败:%v", err)
  32050. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32051. // return
  32052. //}
  32053. //
  32054. //resThree.ErrMsg = resThree10265.ErrMsg
  32055. //
  32056. //resThree.Output = resThree10265.Output
  32057. //
  32058. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  32059. //
  32060. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  32061. //
  32062. } else {
  32063. 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)
  32064. var dat map[string]interface{}
  32065. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32066. fmt.Println(dat)
  32067. } else {
  32068. fmt.Println(err)
  32069. }
  32070. userJSONBytes, _ := json.Marshal(dat)
  32071. if miConfig.Code == "H15049901371" {
  32072. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  32073. utils.ErrorLog("解析失败:%v", err)
  32074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32075. return
  32076. }
  32077. res2.ErrMsg = res10265_2.ErrMsg
  32078. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  32079. res2.Infcode = infocode
  32080. res2.Output = res10265_2.Output
  32081. res2.InfRefmsgid = res10265_2.InfRefmsgid
  32082. } else {
  32083. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32084. utils.ErrorLog("解析失败:%v", err)
  32085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32086. return
  32087. }
  32088. }
  32089. }
  32090. }
  32091. if res2.Infcode == 0 {
  32092. psnResult := &models.GdybPsnNcdsRecord{
  32093. UserOrgId: adminUser.CurrentOrgId,
  32094. PatientId: patient.ID,
  32095. PsnNo: psn_no,
  32096. DoctorId: doctor.AdminUserId,
  32097. DepartmentId: department_id,
  32098. SickType: sick_id,
  32099. Insutype: insutype,
  32100. Ctime: time.Now().Unix(),
  32101. Mtime: time.Now().Unix(),
  32102. Status: 1,
  32103. IsCancel: 1,
  32104. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  32105. }
  32106. service.CreatePsnNCDSRecord(psnResult)
  32107. c.ServeSuccessJSON(map[string]interface{}{
  32108. "failed_code": 0,
  32109. "msg": "备案成功",
  32110. "result": psnResult,
  32111. })
  32112. } else {
  32113. c.ServeSuccessJSON(map[string]interface{}{
  32114. "failed_code": -10,
  32115. "msg": res2.ErrMsg,
  32116. })
  32117. return
  32118. }
  32119. }
  32120. }
  32121. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  32122. id, _ := c.GetInt64("id")
  32123. admin_user_id, _ := c.GetInt64("admin_user_id")
  32124. adminUser := c.GetAdminUserInfo()
  32125. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32126. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32127. //config, _ := service.Ge(adminUser.CurrentOrgId)
  32128. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  32129. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32130. //var user_name string
  32131. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32132. //if role.ID == 0 {
  32133. // user_name = "xxx"
  32134. //} else {
  32135. // user_name = role.UserName
  32136. //}
  32137. psn_record, _ := service.GetPsnNCDSRecordById(id)
  32138. if psn_record.ID == 0 {
  32139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  32140. return
  32141. }
  32142. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  32143. var res ResultTwo
  32144. var res10265 ResultTwo10265
  32145. if miConfig.Code == "H15049901371" {
  32146. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  32147. utils.ErrorLog("解析失败:%v", err)
  32148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32149. return
  32150. }
  32151. res.ErrMsg = res10265.ErrMsg
  32152. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  32153. res.Infcode = infocode
  32154. res.Output = res10265.Output
  32155. res.InfRefmsgid = res10265.InfRefmsgid
  32156. } else {
  32157. if err := json.Unmarshal([]byte(result), &res); err != nil {
  32158. utils.ErrorLog("解析失败:%v", err)
  32159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32160. return
  32161. }
  32162. }
  32163. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  32164. infoStr := string(Iinfos)
  32165. var rf []*ResultFive
  32166. json.Unmarshal([]byte(infoStr), &rf)
  32167. var insuplc_admdvs string
  32168. var insutype string
  32169. var is390 int = 0
  32170. var is310 int = 0
  32171. var insutypes []*ResultFive
  32172. for _, item := range rf {
  32173. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  32174. insutypes = append(insutypes, item)
  32175. }
  32176. }
  32177. if len(insutypes) == 1 {
  32178. insutype = insutypes[0].Insutype
  32179. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  32180. } else {
  32181. for _, i := range insutypes {
  32182. if i.Insutype == "390" {
  32183. is390 = 1
  32184. }
  32185. if i.Insutype == "310" {
  32186. is310 = 1
  32187. }
  32188. }
  32189. }
  32190. if is390 == 1 {
  32191. insutype = "390"
  32192. }
  32193. if is310 == 1 {
  32194. insutype = "310"
  32195. }
  32196. if len(insutypes) == 0 {
  32197. insutype = "310"
  32198. }
  32199. insutype = psn_record.Insutype
  32200. for _, item := range rf {
  32201. if item.Insutype == insutype {
  32202. insuplc_admdvs = item.InsuplcAdmdvs
  32203. }
  32204. }
  32205. if config.IsOpen == 1 {
  32206. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  32207. var dat map[string]interface{}
  32208. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32209. fmt.Println(dat)
  32210. } else {
  32211. fmt.Println(err)
  32212. }
  32213. userJSONBytes, _ := json.Marshal(dat)
  32214. var res ResultFourteen
  32215. var res10265 ResultFourteen10265
  32216. if miConfig.Code == "H15049901371" {
  32217. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  32218. utils.ErrorLog("解析失败:%v", err)
  32219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32220. return
  32221. }
  32222. res.ErrMsg = res10265.ErrMsg
  32223. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  32224. res.Infcode = infocode
  32225. res.Output = res10265.Output
  32226. res.InfRefmsgid = res10265.InfRefmsgid
  32227. } else {
  32228. if err := json.Unmarshal([]byte(result), &res); err != nil {
  32229. utils.ErrorLog("解析失败:%v", err)
  32230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32231. return
  32232. }
  32233. }
  32234. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32235. // utils.ErrorLog("解析失败:%v", err)
  32236. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32237. // return
  32238. //}
  32239. if res.Infcode == 0 {
  32240. psn_record.IsCancel = 2
  32241. service.CreatePsnNCDSRecord(&psn_record)
  32242. c.ServeSuccessJSON(map[string]interface{}{
  32243. "failed_code": 0,
  32244. "msg": "撤销备案成功",
  32245. })
  32246. } else {
  32247. c.ServeSuccessJSON(map[string]interface{}{
  32248. "failed_code": -10,
  32249. "msg": res.ErrMsg,
  32250. })
  32251. return
  32252. }
  32253. }
  32254. }
  32255. func (c *HisApiController) TestTest() {
  32256. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  32257. fmt.Println(patient.Iinfo)
  32258. }
  32259. type CustomData struct {
  32260. MsgId string
  32261. PsnNo string
  32262. Info string
  32263. }
  32264. func (c *HisApiController) ReversalData() {
  32265. var customData []*CustomData
  32266. custom := &CustomData{
  32267. MsgId: "H44022900158202103301714472004",
  32268. PsnNo: "44020000001101329945",
  32269. Info: "2207",
  32270. }
  32271. customData = append(customData, custom)
  32272. custom1 := &CustomData{
  32273. MsgId: "H4402290015820210330172057803",
  32274. PsnNo: "44020000001101161813",
  32275. Info: "2207",
  32276. }
  32277. customData = append(customData, custom1)
  32278. custom2 := &CustomData{
  32279. MsgId: "H44022900158202103301705198813",
  32280. PsnNo: "44190000133097375417",
  32281. Info: "2207",
  32282. }
  32283. customData = append(customData, custom2)
  32284. custom3 := &CustomData{
  32285. MsgId: "H44022900158202103301715524756",
  32286. PsnNo: "44020000001100187221",
  32287. Info: "2207",
  32288. }
  32289. customData = append(customData, custom3)
  32290. custom4 := &CustomData{
  32291. MsgId: "H44022900158202103301730376224",
  32292. PsnNo: "44020000001101959155",
  32293. Info: "2207",
  32294. }
  32295. customData = append(customData, custom4)
  32296. custom5 := &CustomData{
  32297. MsgId: "H44022900158202103301748008725",
  32298. PsnNo: "44020000001104246641",
  32299. Info: "2207",
  32300. }
  32301. customData = append(customData, custom5)
  32302. custom6 := &CustomData{
  32303. MsgId: "H44022900158202103301718096755",
  32304. PsnNo: "44020000001102211860",
  32305. Info: "2207",
  32306. }
  32307. customData = append(customData, custom6)
  32308. custom7 := &CustomData{
  32309. MsgId: "H44022900158202103301736551640",
  32310. PsnNo: "44020000001102687718",
  32311. Info: "2207",
  32312. }
  32313. customData = append(customData, custom7)
  32314. custom8 := &CustomData{
  32315. MsgId: "H44022900158202103301743097676",
  32316. PsnNo: "44020000001102127785",
  32317. Info: "2207",
  32318. }
  32319. customData = append(customData, custom8)
  32320. custom9 := &CustomData{
  32321. MsgId: "H44022900158202103301712304203",
  32322. PsnNo: "44020000001101518097",
  32323. Info: "2207",
  32324. }
  32325. customData = append(customData, custom9)
  32326. custom10 := &CustomData{
  32327. MsgId: "H44022900158202103301738448785",
  32328. PsnNo: "44020000001100500813",
  32329. Info: "2207",
  32330. }
  32331. customData = append(customData, custom10)
  32332. custom11 := &CustomData{
  32333. MsgId: "H44022900158202103301732455843",
  32334. PsnNo: "44020000001102690557",
  32335. Info: "2207",
  32336. }
  32337. customData = append(customData, custom11)
  32338. custom12 := &CustomData{
  32339. MsgId: "H44022900158202103301745421708",
  32340. PsnNo: "44020000001102211928",
  32341. Info: "2207",
  32342. }
  32343. customData = append(customData, custom12)
  32344. custom1212 := &CustomData{
  32345. MsgId: "H440229001582021033017351627",
  32346. PsnNo: "44020000001102481733",
  32347. Info: "2207",
  32348. }
  32349. customData = append(customData, custom1212)
  32350. custom13 := &CustomData{
  32351. MsgId: "H44022900158202103301740327951",
  32352. PsnNo: "44020000001103174866",
  32353. Info: "2207",
  32354. }
  32355. customData = append(customData, custom13)
  32356. custom14 := &CustomData{
  32357. MsgId: "H4402290015820210330174922668",
  32358. PsnNo: "44020000001102927272",
  32359. Info: "2207",
  32360. }
  32361. customData = append(customData, custom14)
  32362. custom15 := &CustomData{
  32363. MsgId: "H44022900158202103301752362273",
  32364. PsnNo: "44020000001102942890",
  32365. Info: "2207",
  32366. }
  32367. customData = append(customData, custom15)
  32368. custom16 := &CustomData{
  32369. MsgId: "H44022900158202103301751082917",
  32370. PsnNo: "44020000001101662162",
  32371. Info: "2207",
  32372. }
  32373. customData = append(customData, custom16)
  32374. custom17 := &CustomData{
  32375. MsgId: "H44022900158202103301754147728",
  32376. PsnNo: "44020000000229014511",
  32377. Info: "2207",
  32378. }
  32379. customData = append(customData, custom17)
  32380. adminUser := c.GetAdminUserInfo()
  32381. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32382. for _, item := range customData {
  32383. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  32384. fmt.Println(result)
  32385. }
  32386. }
  32387. func (c *HisApiController) GetAllopatry() {
  32388. year := c.GetString("year")
  32389. month := c.GetString("month")
  32390. admin_user_id, _ := c.GetInt64("admin_user_id")
  32391. adminUser := c.GetAdminUserInfo()
  32392. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32393. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32394. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  32395. var dat map[string]interface{}
  32396. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32397. fmt.Println(dat)
  32398. } else {
  32399. fmt.Println(err)
  32400. }
  32401. userJSONBytes, _ := json.Marshal(dat)
  32402. var res models.Result9001
  32403. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32404. utils.ErrorLog("解析失败:%v", err)
  32405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32406. return
  32407. }
  32408. fmt.Println(res.Output.Signinoutb)
  32409. fmt.Println(res.Output.Signinoutb.SignNo)
  32410. fmt.Println(string(userJSONBytes))
  32411. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  32412. var dat3 map[string]interface{}
  32413. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  32414. fmt.Println(dat3)
  32415. } else {
  32416. fmt.Println(err)
  32417. }
  32418. userJSONBytes3, _ := json.Marshal(dat3)
  32419. var res3 models.Result3260
  32420. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  32421. utils.ErrorLog("解析失败:%v", err)
  32422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32423. return
  32424. }
  32425. var curpage int
  32426. var pagesize int = 100
  32427. var start int = 1
  32428. //var stop int
  32429. //pagecount := 10
  32430. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  32431. var res22 []models.Result3260
  32432. for curpage = 1; curpage <= pagecount; curpage++ {
  32433. if curpage == 1 {
  32434. start = 0
  32435. } else {
  32436. start = (curpage-1)*pagesize + 1
  32437. }
  32438. fmt.Println(start)
  32439. //stop = curpage * pagesize
  32440. //if stop > int(res3.Output.Totalrow) {
  32441. // stop =int(res3.Output.Totalrow)
  32442. //}
  32443. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  32444. var dat2 map[string]interface{}
  32445. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  32446. fmt.Println(dat)
  32447. } else {
  32448. fmt.Println(err)
  32449. }
  32450. userJSONBytes2, _ := json.Marshal(dat2)
  32451. var res2 models.Result3260
  32452. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  32453. utils.ErrorLog("解析失败:%v", err)
  32454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32455. return
  32456. }
  32457. if res2.Infcode == 0 {
  32458. res22 = append(res22, res2)
  32459. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  32460. //var dat2 map[string]interface{}
  32461. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  32462. // fmt.Println(dat)
  32463. //} else {
  32464. // fmt.Println(err)
  32465. //}
  32466. //c.ServeSuccessJSON(map[string]interface{}{
  32467. // "list": res2.Output.Data,
  32468. //})
  32469. //continue
  32470. }
  32471. }
  32472. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  32473. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  32474. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  32475. //var dat2 map[string]interface{}
  32476. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  32477. // fmt.Println(dat)
  32478. //} else {
  32479. // fmt.Println(err)
  32480. //}
  32481. //userJSONBytes2, _ := json.Marshal(dat2)
  32482. //var res2 models.Result3260
  32483. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  32484. // utils.ErrorLog("解析失败:%v", err)
  32485. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32486. // return
  32487. //}
  32488. //if res2.Infcode == 0 {
  32489. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  32490. // var dat2 map[string]interface{}
  32491. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  32492. // fmt.Println(dat)
  32493. // } else {
  32494. // fmt.Println(err)
  32495. // }
  32496. // c.ServeSuccessJSON(map[string]interface{}{
  32497. // "list": res2.Output.Data,
  32498. // })
  32499. //}
  32500. }
  32501. func (c *HisApiController) ComfirmAllopatry() {
  32502. year := c.GetString("year")
  32503. month := c.GetString("month")
  32504. admin_user_id, _ := c.GetInt64("admin_user_id")
  32505. adminUser := c.GetAdminUserInfo()
  32506. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32507. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32508. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  32509. var dat map[string]interface{}
  32510. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32511. fmt.Println(dat)
  32512. } else {
  32513. fmt.Println(err)
  32514. }
  32515. userJSONBytes, _ := json.Marshal(dat)
  32516. var res models.Result9001
  32517. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32518. utils.ErrorLog("解析失败:%v", err)
  32519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32520. return
  32521. }
  32522. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  32523. var dat2 map[string]interface{}
  32524. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  32525. fmt.Println(dat)
  32526. } else {
  32527. fmt.Println(err)
  32528. }
  32529. userJSONBytes2, _ := json.Marshal(dat2)
  32530. var res2 models.Result3260
  32531. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  32532. utils.ErrorLog("解析失败:%v", err)
  32533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32534. return
  32535. }
  32536. //if res2.Infcode == 0 {
  32537. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  32538. // var dat map[string]interface{}
  32539. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32540. // fmt.Println(dat)
  32541. // } else {
  32542. // fmt.Println(err)
  32543. // }
  32544. // userJSONBytes, _ := json.Marshal(dat)
  32545. // var res3 models.Result3261
  32546. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  32547. // utils.ErrorLog("解析失败:%v", err)
  32548. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32549. // return
  32550. // }
  32551. //
  32552. // if res3.Infcode == 0 {
  32553. // record := &models.HisYidiClearRecord{
  32554. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  32555. // Ctime: time.Now().Unix(),
  32556. // Mtime: time.Now().Unix(),
  32557. // Status: 1,
  32558. // MsgId: msgId,
  32559. // }
  32560. // service.SaveClearRecord(record)
  32561. // c.ServeSuccessJSON(map[string]interface{}{
  32562. // "msg": "提取成功",
  32563. // })
  32564. // }
  32565. //}
  32566. }
  32567. func (c *HisApiController) RefundAllopatry() {
  32568. year := c.GetString("year")
  32569. month := c.GetString("month")
  32570. //id, _ := c.GetInt64("id")
  32571. admin_user_id, _ := c.GetInt64("admin_user_id")
  32572. adminUser := c.GetAdminUserInfo()
  32573. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32574. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32575. //record, _ := service.GetClearRecordById(id)
  32576. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  32577. var dat map[string]interface{}
  32578. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32579. fmt.Println(dat)
  32580. } else {
  32581. fmt.Println(err)
  32582. }
  32583. userJSONBytes, _ := json.Marshal(dat)
  32584. var res models.Result9001
  32585. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32586. utils.ErrorLog("解析失败:%v", err)
  32587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32588. return
  32589. }
  32590. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  32591. var dat2 map[string]interface{}
  32592. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  32593. fmt.Println(dat)
  32594. } else {
  32595. fmt.Println(err)
  32596. }
  32597. userJSONBytes2, _ := json.Marshal(dat2)
  32598. var empty ResultFourteen
  32599. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  32600. utils.ErrorLog("解析失败:%v", err)
  32601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32602. return
  32603. }
  32604. if empty.Infcode == 0 {
  32605. c.ServeSuccessJSON(map[string]interface{}{
  32606. "msg": "撤销成功",
  32607. })
  32608. return
  32609. }
  32610. }
  32611. func (c *HisApiController) ReversalOtherData() {
  32612. var customData []*CustomData
  32613. custom := &CustomData{
  32614. MsgId: "H44022900158202103301714472004",
  32615. PsnNo: "44020000001101329945",
  32616. Info: "2208",
  32617. }
  32618. customData = append(customData, custom)
  32619. custom1 := &CustomData{
  32620. MsgId: "H4402290015820210330172057803",
  32621. PsnNo: "44020000001101161813",
  32622. Info: "2208",
  32623. }
  32624. customData = append(customData, custom1)
  32625. custom2 := &CustomData{
  32626. MsgId: "H44022900158202103301705198813",
  32627. PsnNo: "44190000133097375417",
  32628. Info: "2208",
  32629. }
  32630. customData = append(customData, custom2)
  32631. custom3 := &CustomData{
  32632. MsgId: "H44022900158202103301715524756",
  32633. PsnNo: "44020000001100187221",
  32634. Info: "2208",
  32635. }
  32636. customData = append(customData, custom3)
  32637. custom4 := &CustomData{
  32638. MsgId: "H44022900158202103301730376224",
  32639. PsnNo: "44020000001101959155",
  32640. Info: "2208",
  32641. }
  32642. customData = append(customData, custom4)
  32643. custom5 := &CustomData{
  32644. MsgId: "H44022900158202103301748008725",
  32645. PsnNo: "44020000001104246641",
  32646. Info: "2208",
  32647. }
  32648. customData = append(customData, custom5)
  32649. custom6 := &CustomData{
  32650. MsgId: "H44022900158202103301718096755",
  32651. PsnNo: "44020000001102211860",
  32652. Info: "2208",
  32653. }
  32654. customData = append(customData, custom6)
  32655. custom7 := &CustomData{
  32656. MsgId: "H44022900158202103301736551640",
  32657. PsnNo: "44020000001102687718",
  32658. Info: "2208",
  32659. }
  32660. customData = append(customData, custom7)
  32661. custom8 := &CustomData{
  32662. MsgId: "H44022900158202103301743097676",
  32663. PsnNo: "44020000001102127785",
  32664. Info: "2208",
  32665. }
  32666. customData = append(customData, custom8)
  32667. custom9 := &CustomData{
  32668. MsgId: "H44022900158202103301712304203",
  32669. PsnNo: "44020000001101518097",
  32670. Info: "2208",
  32671. }
  32672. customData = append(customData, custom9)
  32673. custom10 := &CustomData{
  32674. MsgId: "H44022900158202103301738448785",
  32675. PsnNo: "44020000001100500813",
  32676. Info: "2208",
  32677. }
  32678. customData = append(customData, custom10)
  32679. custom11 := &CustomData{
  32680. MsgId: "H44022900158202103301732455843",
  32681. PsnNo: "44020000001102690557",
  32682. Info: "2208",
  32683. }
  32684. customData = append(customData, custom11)
  32685. custom12 := &CustomData{
  32686. MsgId: "H44022900158202103301745421708",
  32687. PsnNo: "44020000001102211928",
  32688. Info: "2208",
  32689. }
  32690. customData = append(customData, custom12)
  32691. custom1212 := &CustomData{
  32692. MsgId: "H440229001582021033017351627",
  32693. PsnNo: "44020000001102481733",
  32694. Info: "2208",
  32695. }
  32696. customData = append(customData, custom1212)
  32697. custom13 := &CustomData{
  32698. MsgId: "H44022900158202103301740327951",
  32699. PsnNo: "44020000001103174866",
  32700. Info: "2208",
  32701. }
  32702. customData = append(customData, custom13)
  32703. custom14 := &CustomData{
  32704. MsgId: "H4402290015820210330174922668",
  32705. PsnNo: "44020000001102927272",
  32706. Info: "2208",
  32707. }
  32708. customData = append(customData, custom14)
  32709. custom15 := &CustomData{
  32710. MsgId: "H44022900158202103301752362273",
  32711. PsnNo: "44020000001102942890",
  32712. Info: "2208",
  32713. }
  32714. customData = append(customData, custom15)
  32715. custom16 := &CustomData{
  32716. MsgId: "H44022900158202103301751082917",
  32717. PsnNo: "44020000001101662162",
  32718. Info: "2208",
  32719. }
  32720. customData = append(customData, custom16)
  32721. custom17 := &CustomData{
  32722. MsgId: "H44022900158202103301754147728",
  32723. PsnNo: "44020000000229014511",
  32724. Info: "2208",
  32725. }
  32726. customData = append(customData, custom17)
  32727. adminUser := c.GetAdminUserInfo()
  32728. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32729. for _, item := range customData {
  32730. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  32731. fmt.Println(result)
  32732. }
  32733. }
  32734. func PathExists(path string) (bool, error) {
  32735. _, err := os.Stat(path)
  32736. if err == nil {
  32737. return true, nil
  32738. }
  32739. if os.IsNotExist(err) {
  32740. return false, nil
  32741. }
  32742. return false, err
  32743. }
  32744. // 创建文件夹
  32745. func Mkdir(dir string) {
  32746. // 创建文件夹
  32747. exist, err := PathExists(dir)
  32748. if err != nil {
  32749. fmt.Println(err.Error())
  32750. } else {
  32751. if exist {
  32752. fmt.Println(dir + "文件夹已存在!")
  32753. } else {
  32754. // 文件夹名称,权限
  32755. err := os.Mkdir(dir, os.ModePerm)
  32756. if err != nil {
  32757. fmt.Println(dir+"文件夹创建失败:", err.Error())
  32758. } else {
  32759. fmt.Println(dir + "文件夹创建成功!")
  32760. }
  32761. }
  32762. }
  32763. }
  32764. // 压缩文件
  32765. func Zip(srcFile string, destZip string) error {
  32766. zipfile, err := os.Create(destZip)
  32767. if err != nil {
  32768. return err
  32769. }
  32770. defer zipfile.Close()
  32771. archive := zip.NewWriter(zipfile)
  32772. defer archive.Close()
  32773. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  32774. if err != nil {
  32775. return err
  32776. }
  32777. header, err := zip.FileInfoHeader(info)
  32778. if err != nil {
  32779. return err
  32780. }
  32781. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  32782. // header.Name = path
  32783. if info.IsDir() {
  32784. header.Name += "/"
  32785. } else {
  32786. header.Method = zip.Deflate
  32787. }
  32788. writer, err := archive.CreateHeader(header)
  32789. if err != nil {
  32790. return err
  32791. }
  32792. if !info.IsDir() {
  32793. file, err := os.Open(path)
  32794. if err != nil {
  32795. return err
  32796. }
  32797. defer file.Close()
  32798. _, err = io.Copy(writer, file)
  32799. }
  32800. return err
  32801. })
  32802. return err
  32803. }
  32804. func ReadFile(filePath string) []byte {
  32805. f, err := os.Open(filePath)
  32806. if err != nil {
  32807. fmt.Println("read file fail", err)
  32808. return nil
  32809. }
  32810. defer f.Close()
  32811. fd, err := ioutil.ReadAll(f)
  32812. if err != nil {
  32813. fmt.Println("read to fd fail", err)
  32814. return nil
  32815. }
  32816. return fd
  32817. }
  32818. func saveLogq(result string, request string, infno string, desc string) {
  32819. dir := "日志"
  32820. utils.Mkdir(dir)
  32821. month := time.Unix(1557042972, 0).Format("1")
  32822. year := time.Now().Format("2006")
  32823. month = time.Now().Format("01")
  32824. day := time.Now().Format("02")
  32825. hour := time.Now().Format("15")
  32826. min := time.Now().Format("04")
  32827. sec := time.Now().Format("05")
  32828. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  32829. file := year + month + day + "_log"
  32830. file_name := file + ".txt"
  32831. file_path := "日志" + "/" + file_name
  32832. exist, _ := utils.PathExists(file_path)
  32833. if exist { //存在
  32834. fmt.Println("存在")
  32835. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  32836. if err != nil {
  32837. fmt.Println("read fail")
  32838. }
  32839. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  32840. n, _ := f.Seek(0, 2)
  32841. _, err = f.WriteAt([]byte(content), n)
  32842. } else { //不存在
  32843. fmt.Println("文件不存在,创建文件")
  32844. f, err := os.Create("日志" + "/" + file_name)
  32845. defer f.Close()
  32846. if err != nil {
  32847. } else {
  32848. _, err = f.Write([]byte("记录日志"))
  32849. }
  32850. }
  32851. }
  32852. func saveLog(result string, request string, infno string, desc string) {
  32853. org_id, _ := beego.AppConfig.Int64("org_id")
  32854. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  32855. dir := miConfig.OrgName + "日志"
  32856. utils.Mkdir(dir)
  32857. month := time.Unix(1557042972, 0).Format("1")
  32858. year := time.Now().Format("2006")
  32859. month = time.Now().Format("01")
  32860. day := time.Now().Format("02")
  32861. hour := time.Now().Format("15")
  32862. min := time.Now().Format("04")
  32863. sec := time.Now().Format("05")
  32864. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  32865. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  32866. file_name := file + ".txt"
  32867. file_path := miConfig.OrgName + "日志" + "/" + file_name
  32868. exist, _ := utils.PathExists(file_path)
  32869. if exist { //存在
  32870. fmt.Println("存在")
  32871. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  32872. if err != nil {
  32873. fmt.Println("read fail")
  32874. }
  32875. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  32876. n, _ := f.Seek(0, 2)
  32877. _, err = f.WriteAt([]byte(content), n)
  32878. } else { //不存在
  32879. fmt.Println("文件不存在,创建文件")
  32880. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  32881. defer f.Close()
  32882. if err != nil {
  32883. } else {
  32884. _, err = f.Write([]byte("记录日志"))
  32885. }
  32886. }
  32887. }
  32888. type Charset string
  32889. const (
  32890. UTF8 = Charset("UTF-8")
  32891. GB18030 = Charset("GB18030")
  32892. )
  32893. func ConvertToString(src string, srcCode string, tagCode string) string {
  32894. srcCoder := mahonia.NewDecoder(srcCode)
  32895. srcResult := srcCoder.ConvertString(src)
  32896. tagCoder := mahonia.NewDecoder(tagCode)
  32897. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  32898. result := string(cdata)
  32899. return result
  32900. }
  32901. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  32902. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  32903. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  32904. var token string
  32905. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32906. var api string
  32907. if miConfig.MdtrtareaAdmvs == "320921" {
  32908. 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 +
  32909. "&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
  32910. fmt.Println(api)
  32911. } else {
  32912. 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 +
  32913. "&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
  32914. }
  32915. resp, requestErr := http.Get(api)
  32916. if requestErr != nil {
  32917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32918. return ""
  32919. }
  32920. body, ioErr := ioutil.ReadAll(resp.Body)
  32921. if ioErr != nil {
  32922. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32924. return ""
  32925. }
  32926. var respJSON map[string]interface{}
  32927. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32928. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32930. return ""
  32931. }
  32932. var status string
  32933. status = respJSON["data"].(map[string]interface{})["status"].(string)
  32934. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  32935. var res ResultTwo //1101结果
  32936. var res10265 ResultTwo10265 //1101结果
  32937. if status == "0" { //读卡成功
  32938. var card_info string //卡信息
  32939. var busi_card_info string
  32940. token = respJSON["data"].(map[string]interface{})["token"].(string)
  32941. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  32942. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  32943. fmt.Println(card_info)
  32944. fmt.Println(busi_card_info)
  32945. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  32946. result, _ := json.Marshal(respJSON)
  32947. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  32948. utils.ErrorLog("解析失败:%v", err)
  32949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32950. return ""
  32951. }
  32952. res.ErrMsg = res10265.ErrMsg
  32953. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  32954. res.Infcode = infocode
  32955. res.Output = res10265.Output
  32956. res.InfRefmsgid = res10265.InfRefmsgid
  32957. if res.Infcode == 0 {
  32958. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  32959. if err == gorm.ErrRecordNotFound {
  32960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  32961. return ""
  32962. } else if err != nil {
  32963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  32964. return ""
  32965. } else {
  32966. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  32967. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  32968. infoStr := string(Iinfos)
  32969. idetinfoStr := string(Idetinfos)
  32970. psn := &models.HisPsn{
  32971. PsnNo: res.Output.Baseinfo.PsnNo,
  32972. PatientId: patient.ID,
  32973. Certno: res.Output.Baseinfo.Certno,
  32974. Gend: res.Output.Baseinfo.Gend,
  32975. Naty: res.Output.Baseinfo.Naty,
  32976. PsnCertType: res.Output.Baseinfo.PsnCertType,
  32977. PsnName: res.Output.Baseinfo.PsnName,
  32978. Idetinfo: idetinfoStr,
  32979. Insuinfo: infoStr,
  32980. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  32981. CardInfo: card_info,
  32982. VerifyNumber: token,
  32983. }
  32984. service.CreateHisPsn(psn)
  32985. return token
  32986. }
  32987. }
  32988. } else {
  32989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  32990. return ""
  32991. }
  32992. } else { //读卡失败
  32993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  32994. return ""
  32995. }
  32996. return token
  32997. }
  32998. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  32999. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  33000. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  33001. var token string
  33002. var api string
  33003. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  33004. "&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
  33005. fmt.Println(api)
  33006. resp, requestErr := http.Get(api)
  33007. if requestErr != nil {
  33008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33009. return ""
  33010. }
  33011. body, ioErr := ioutil.ReadAll(resp.Body)
  33012. if ioErr != nil {
  33013. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33015. return ""
  33016. }
  33017. var respJSON map[string]interface{}
  33018. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33019. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33021. return ""
  33022. }
  33023. var status string
  33024. status = respJSON["data"].(map[string]interface{})["status"].(string)
  33025. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  33026. var res ResultTwo //1101结果
  33027. if status == "1" { //读卡成功
  33028. var card_info string //卡信息
  33029. var busi_card_info string
  33030. token = respJSON["data"].(map[string]interface{})["token"].(string)
  33031. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  33032. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  33033. fmt.Println(card_info)
  33034. fmt.Println(busi_card_info)
  33035. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  33036. result, _ := json.Marshal(respJSON)
  33037. if err := json.Unmarshal([]byte(result), &res); err != nil {
  33038. utils.ErrorLog("解析失败:%v", err)
  33039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33040. return ""
  33041. }
  33042. if res.Infcode == 0 {
  33043. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  33044. if err == gorm.ErrRecordNotFound {
  33045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  33046. return ""
  33047. } else if err != nil {
  33048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  33049. return ""
  33050. } else {
  33051. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  33052. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  33053. infoStr := string(Iinfos)
  33054. idetinfoStr := string(Idetinfos)
  33055. psn := &models.HisPsn{
  33056. PsnNo: res.Output.Baseinfo.PsnNo,
  33057. PatientId: patient.ID,
  33058. Certno: res.Output.Baseinfo.Certno,
  33059. Gend: res.Output.Baseinfo.Gend,
  33060. Naty: res.Output.Baseinfo.Naty,
  33061. PsnCertType: res.Output.Baseinfo.PsnCertType,
  33062. PsnName: res.Output.Baseinfo.PsnName,
  33063. Idetinfo: idetinfoStr,
  33064. Insuinfo: infoStr,
  33065. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  33066. CardInfo: card_info,
  33067. VerifyNumber: token,
  33068. }
  33069. service.CreateHisPsn(psn)
  33070. return token
  33071. }
  33072. }
  33073. } else {
  33074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  33075. return ""
  33076. }
  33077. return token
  33078. }
  33079. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  33080. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  33081. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  33082. var token string
  33083. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33084. var api string
  33085. if miConfig.MdtrtareaAdmvs == "320921" {
  33086. 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 +
  33087. "&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
  33088. fmt.Println(api)
  33089. } else {
  33090. 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 +
  33091. "&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
  33092. }
  33093. resp, requestErr := http.Get(api)
  33094. if requestErr != nil {
  33095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33096. return ""
  33097. }
  33098. body, ioErr := ioutil.ReadAll(resp.Body)
  33099. if ioErr != nil {
  33100. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33102. return ""
  33103. }
  33104. var respJSON map[string]interface{}
  33105. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33106. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33108. return ""
  33109. }
  33110. var status string
  33111. status = respJSON["data"].(map[string]interface{})["status"].(string)
  33112. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  33113. var res ResultTwo //1101结果
  33114. var res10265 ResultTwo10265 //1101结果
  33115. if status == "0" { //读卡成功
  33116. var card_info string //卡信息
  33117. var busi_card_info string
  33118. token = respJSON["data"].(map[string]interface{})["token"].(string)
  33119. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  33120. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  33121. fmt.Println(card_info)
  33122. fmt.Println(busi_card_info)
  33123. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  33124. result, _ := json.Marshal(respJSON)
  33125. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  33126. utils.ErrorLog("解析失败:%v", err)
  33127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33128. return ""
  33129. }
  33130. res.ErrMsg = res10265.ErrMsg
  33131. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  33132. res.Infcode = infocode
  33133. res.Output = res10265.Output
  33134. res.InfRefmsgid = res10265.InfRefmsgid
  33135. if res.Infcode == 0 {
  33136. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  33137. if err == gorm.ErrRecordNotFound {
  33138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  33139. return ""
  33140. } else if err != nil {
  33141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  33142. return ""
  33143. } else {
  33144. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  33145. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  33146. infoStr := string(Iinfos)
  33147. idetinfoStr := string(Idetinfos)
  33148. psn := &models.HisPsn{
  33149. PsnNo: res.Output.Baseinfo.PsnNo,
  33150. PatientId: patient.ID,
  33151. Certno: res.Output.Baseinfo.Certno,
  33152. Gend: res.Output.Baseinfo.Gend,
  33153. Naty: res.Output.Baseinfo.Naty,
  33154. PsnCertType: res.Output.Baseinfo.PsnCertType,
  33155. PsnName: res.Output.Baseinfo.PsnName,
  33156. Idetinfo: idetinfoStr,
  33157. Insuinfo: infoStr,
  33158. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  33159. CardInfo: card_info,
  33160. VerifyNumber: token,
  33161. }
  33162. service.CreateHisPsn(psn)
  33163. return token
  33164. }
  33165. }
  33166. } else {
  33167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  33168. return ""
  33169. }
  33170. } else { //读卡失败
  33171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  33172. return ""
  33173. }
  33174. return token
  33175. }
  33176. func DeleteExtraSpaceTwo(s string) string {
  33177. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  33178. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  33179. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  33180. reg, _ := regexp.Compile(regstr) //编译正则表达式
  33181. s2 := make([]byte, len(s1)) //定义字符数组切片
  33182. copy(s2, s1) //将字符串复制到切片
  33183. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  33184. for len(spc_index) > 0 { //找到适配项
  33185. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  33186. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  33187. }
  33188. return string(s2)
  33189. }
  33190. func Remove0000(s string) string {
  33191. str := make([]rune, 0, len(s))
  33192. for _, v := range []rune(s) {
  33193. if v == 0 {
  33194. continue
  33195. }
  33196. str = append(str, v)
  33197. }
  33198. return string(str)
  33199. }
  33200. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  33201. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  33202. readCard := DllDef.MustFindProc("EcQuery")
  33203. pCardInfo := make([]byte, 8192)
  33204. pBusiCardInfo := make([]byte, 8192)
  33205. data := make(map[string]interface{})
  33206. //pData := make(map[string]interface{})
  33207. inputData := make(map[string]interface{})
  33208. inputData["orgId"] = code
  33209. inputData["businessType"] = "01101"
  33210. inputData["operatorId"] = operator_id
  33211. inputData["operatorName"] = operator_name
  33212. inputData["officeId"] = "001"
  33213. inputData["officeName"] = "血透室"
  33214. //
  33215. data["data"] = inputData
  33216. data["transType"] = "ec.query"
  33217. data["orgId"] = code
  33218. bytesData, _ := json.Marshal(data)
  33219. pCardInfo = bytesData
  33220. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  33221. fmt.Println(ret2)
  33222. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  33223. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  33224. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  33225. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  33226. if ret2 != 0 {
  33227. return "", ""
  33228. }
  33229. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  33230. }
  33231. func DeleteExtraSpace(s string) string {
  33232. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  33233. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  33234. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  33235. reg, _ := regexp.Compile(regstr) //编译正则表达式
  33236. s2 := make([]byte, len(s1)) //定义字符数组切片
  33237. copy(s2, s1) //将字符串复制到切片
  33238. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  33239. for len(spc_index) > 0 { //找到适配项
  33240. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  33241. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  33242. }
  33243. return string(s2)
  33244. }
  33245. // 对账
  33246. func (c *HisApiController) Post3202() {
  33247. start_time := c.GetString("start_time")
  33248. end_time := c.GetString("end_time")
  33249. //insutype := c.GetString("insutype")
  33250. clr_type := c.GetString("clr_type")
  33251. clr_org := c.GetString("clr_optins")
  33252. admin_user_id, _ := c.GetInt64("admin_user_id")
  33253. adminUser := c.GetAdminUserInfo()
  33254. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33255. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33256. if len(clr_org) == 0 {
  33257. clr_org = miConfig.MdtrtareaAdmvs
  33258. }
  33259. timeLayout := "2006-01-02"
  33260. loc, _ := time.LoadLocation("Local")
  33261. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33262. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33263. var orders []*models.HisOrder
  33264. if clr_org == "421300" {
  33265. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  33266. } else if clr_org == "420902" {
  33267. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  33268. }else {
  33269. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  33270. }
  33271. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  33272. //fixmedins_setl_cnt := int64(len(orders))
  33273. var medfee_sumamt float64
  33274. var acct_pay float64
  33275. var fund_pay_sumamt float64
  33276. for _, item := range orders {
  33277. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33278. acct_pay = acct_pay + item.AcctPay
  33279. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33280. }
  33281. //var medfee_sumamt_two float64
  33282. //var acct_pay_two float64
  33283. //var fund_pay_sumamt_two float64
  33284. //for _, item := range orders_two {
  33285. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  33286. // acct_pay_two = acct_pay_two + item.AcctPay
  33287. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  33288. //}
  33289. //var user_name string
  33290. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33291. //if role.ID == 0 {
  33292. // user_name = "xxx"
  33293. //} else {
  33294. // user_name = role.UserName
  33295. //}
  33296. var res ResultSix
  33297. if config.IsOpen == 1 {
  33298. var bps []*models.BusinessParamsTwo
  33299. var bp models.BusinessParamsTwo
  33300. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  33301. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  33302. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  33303. bp.MedfeeSumamt = medfee_sumamt_str
  33304. bp.AcctPay = acct_pay_str
  33305. bp.FundPaySumamt = fund_pay_sumamt_str
  33306. bp.Insutype = ""
  33307. bp.StmtBegndate = start_time
  33308. bp.ClrType = clr_type
  33309. bp.SetlOptins = clr_org
  33310. bp.StmtEnddate = end_time
  33311. bps = append(bps, &bp)
  33312. data := make(map[string]interface{})
  33313. data["bps"] = bps
  33314. data["org_name"] = miConfig.OrgName
  33315. data["doctor"] = role.UserName
  33316. data["fixmedins_code"] = miConfig.Code
  33317. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  33318. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  33319. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  33320. if miConfig.MdtrtareaAdmvs == "421300" {
  33321. client := &http.Client{}
  33322. bytesData, _ := json.Marshal(data)
  33323. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  33324. resp, _ := client.Do(req)
  33325. defer resp.Body.Close()
  33326. body, ioErr := ioutil.ReadAll(resp.Body)
  33327. if ioErr != nil {
  33328. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33330. return
  33331. }
  33332. var respJSON map[string]interface{}
  33333. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  33334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33336. return
  33337. }
  33338. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33339. userJSONBytes, _ := json.Marshal(respJSON)
  33340. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33341. utils.ErrorLog("解析失败:%v", err)
  33342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33343. return
  33344. }
  33345. }
  33346. if miConfig.MdtrtareaAdmvs == "420200" {
  33347. client := &http.Client{}
  33348. bytesData, _ := json.Marshal(data)
  33349. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  33350. resp, _ := client.Do(req)
  33351. defer resp.Body.Close()
  33352. body, ioErr := ioutil.ReadAll(resp.Body)
  33353. if ioErr != nil {
  33354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33356. return
  33357. }
  33358. var respJSON map[string]interface{}
  33359. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  33360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33362. return
  33363. }
  33364. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33365. userJSONBytes, _ := json.Marshal(respJSON)
  33366. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33367. utils.ErrorLog("解析失败:%v", err)
  33368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33369. return
  33370. }
  33371. }
  33372. if miConfig.MdtrtareaAdmvs == "421182" {
  33373. client := &http.Client{}
  33374. bytesData, _ := json.Marshal(data)
  33375. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  33376. resp, _ := client.Do(req)
  33377. defer resp.Body.Close()
  33378. body, ioErr := ioutil.ReadAll(resp.Body)
  33379. if ioErr != nil {
  33380. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33382. return
  33383. }
  33384. var respJSON map[string]interface{}
  33385. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  33386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33388. return
  33389. }
  33390. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33391. userJSONBytes, _ := json.Marshal(respJSON)
  33392. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33393. utils.ErrorLog("解析失败:%v", err)
  33394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33395. return
  33396. }
  33397. }
  33398. if miConfig.MdtrtareaAdmvs == "420902" {
  33399. client := &http.Client{}
  33400. bytesData, _ := json.Marshal(data)
  33401. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  33402. resp, _ := client.Do(req)
  33403. defer resp.Body.Close()
  33404. body, ioErr := ioutil.ReadAll(resp.Body)
  33405. if ioErr != nil {
  33406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33408. return
  33409. }
  33410. var respJSON map[string]interface{}
  33411. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  33412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33414. return
  33415. }
  33416. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33417. userJSONBytes, _ := json.Marshal(respJSON)
  33418. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33419. utils.ErrorLog("解析失败:%v", err)
  33420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33421. return
  33422. }
  33423. }
  33424. if res.Infcode == 0 {
  33425. c.ServeSuccessJSON(map[string]interface{}{
  33426. "msg": "发起成功",
  33427. })
  33428. } else {
  33429. c.ServeSuccessJSON(map[string]interface{}{
  33430. "failed_code": -10,
  33431. "msg": res.ErrMsg,
  33432. })
  33433. }
  33434. }
  33435. }
  33436. func (c *HisApiController) Post3204a() {
  33437. start_time := c.GetString("start_time")
  33438. end_time := c.GetString("end_time")
  33439. //insutype := c.GetString("insutype")
  33440. clr_type := c.GetString("clr_type")
  33441. clr_org := c.GetString("clr_optins")
  33442. admin_user_id, _ := c.GetInt64("admin_user_id")
  33443. adminUser := c.GetAdminUserInfo()
  33444. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33445. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33446. if len(clr_org) == 0 {
  33447. clr_org = miConfig.MdtrtareaAdmvs
  33448. }
  33449. timeLayout := "2006-01-02"
  33450. loc, _ := time.LoadLocation("Local")
  33451. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33452. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33453. var orders []*models.HisOrder
  33454. if clr_org == "421300" {
  33455. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  33456. } else if clr_org == "420902" {
  33457. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  33458. }else {
  33459. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  33460. }
  33461. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  33462. //fixmedins_setl_cnt := int64(len(orders))
  33463. var medfee_sumamt float64
  33464. var acct_pay float64
  33465. var fund_pay_sumamt float64
  33466. for _, item := range orders {
  33467. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33468. acct_pay = acct_pay + item.AcctPay
  33469. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33470. }
  33471. //var medfee_sumamt_two float64
  33472. //var acct_pay_two float64
  33473. //var fund_pay_sumamt_two float64
  33474. //for _, item := range orders_two {
  33475. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  33476. // acct_pay_two = acct_pay_two + item.AcctPay
  33477. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  33478. //}
  33479. //var user_name string
  33480. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33481. //if role.ID == 0 {
  33482. // user_name = "xxx"
  33483. //} else {
  33484. // user_name = role.UserName
  33485. //}
  33486. var res ResultSix
  33487. if config.IsOpen == 1 {
  33488. var bps []*models.BusinessParamsTwo
  33489. var bp models.BusinessParamsTwo
  33490. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  33491. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  33492. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  33493. bp.MedfeeSumamt = medfee_sumamt_str
  33494. bp.AcctPay = acct_pay_str
  33495. bp.FundPaySumamt = fund_pay_sumamt_str
  33496. bp.Insutype = ""
  33497. bp.StmtBegndate = start_time
  33498. bp.ClrType = clr_type
  33499. bp.SetlOptins = clr_org
  33500. bp.StmtEnddate = end_time
  33501. bps = append(bps, &bp)
  33502. data := make(map[string]interface{})
  33503. data["bps"] = bps
  33504. data["org_name"] = miConfig.OrgName
  33505. data["doctor"] = role.UserName
  33506. data["fixmedins_code"] = miConfig.Code
  33507. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  33508. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  33509. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  33510. if miConfig.MdtrtareaAdmvs == "421300" {
  33511. client := &http.Client{}
  33512. bytesData, _ := json.Marshal(data)
  33513. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  33514. resp, _ := client.Do(req)
  33515. defer resp.Body.Close()
  33516. body, ioErr := ioutil.ReadAll(resp.Body)
  33517. if ioErr != nil {
  33518. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33520. return
  33521. }
  33522. var respJSON map[string]interface{}
  33523. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  33524. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33526. return
  33527. }
  33528. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33529. userJSONBytes, _ := json.Marshal(respJSON)
  33530. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33531. utils.ErrorLog("解析失败:%v", err)
  33532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33533. return
  33534. }
  33535. }
  33536. if miConfig.MdtrtareaAdmvs == "420200" {
  33537. client := &http.Client{}
  33538. bytesData, _ := json.Marshal(data)
  33539. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  33540. resp, _ := client.Do(req)
  33541. defer resp.Body.Close()
  33542. body, ioErr := ioutil.ReadAll(resp.Body)
  33543. if ioErr != nil {
  33544. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33546. return
  33547. }
  33548. var respJSON map[string]interface{}
  33549. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  33550. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33552. return
  33553. }
  33554. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33555. userJSONBytes, _ := json.Marshal(respJSON)
  33556. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33557. utils.ErrorLog("解析失败:%v", err)
  33558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33559. return
  33560. }
  33561. }
  33562. if miConfig.MdtrtareaAdmvs == "421182" {
  33563. client := &http.Client{}
  33564. bytesData, _ := json.Marshal(data)
  33565. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  33566. resp, _ := client.Do(req)
  33567. defer resp.Body.Close()
  33568. body, ioErr := ioutil.ReadAll(resp.Body)
  33569. if ioErr != nil {
  33570. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33572. return
  33573. }
  33574. var respJSON map[string]interface{}
  33575. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  33576. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33578. return
  33579. }
  33580. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33581. userJSONBytes, _ := json.Marshal(respJSON)
  33582. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33583. utils.ErrorLog("解析失败:%v", err)
  33584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33585. return
  33586. }
  33587. }
  33588. if miConfig.MdtrtareaAdmvs == "420902" {
  33589. client := &http.Client{}
  33590. bytesData, _ := json.Marshal(data)
  33591. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  33592. resp, _ := client.Do(req)
  33593. defer resp.Body.Close()
  33594. body, ioErr := ioutil.ReadAll(resp.Body)
  33595. if ioErr != nil {
  33596. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33598. return
  33599. }
  33600. var respJSON map[string]interface{}
  33601. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  33602. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33604. return
  33605. }
  33606. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33607. userJSONBytes, _ := json.Marshal(respJSON)
  33608. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33609. utils.ErrorLog("解析失败:%v", err)
  33610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33611. return
  33612. }
  33613. }
  33614. if res.Infcode == 0 {
  33615. c.ServeSuccessJSON(map[string]interface{}{
  33616. "msg": "撤销成功",
  33617. })
  33618. } else {
  33619. c.ServeSuccessJSON(map[string]interface{}{
  33620. "failed_code": -10,
  33621. "msg": res.ErrMsg,
  33622. })
  33623. }
  33624. }
  33625. }
  33626. func (c *HisApiController) Post3204() {
  33627. admin_user_id, _ := c.GetInt64("admin_user_id")
  33628. id := c.GetString("id")
  33629. adminUser := c.GetAdminUserInfo()
  33630. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33631. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33632. //clr_org := miConfig.MdtrtareaAdmvs
  33633. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33634. var res ResultSix
  33635. if config.IsOpen == 1 {
  33636. data := make(map[string]interface{})
  33637. data["id"] = id
  33638. data["org_name"] = miConfig.OrgName
  33639. data["doctor"] = role.UserName
  33640. data["fixmedins_code"] = miConfig.Code
  33641. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  33642. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  33643. client := &http.Client{}
  33644. bytesData, _ := json.Marshal(data)
  33645. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  33646. resp, _ := client.Do(req)
  33647. defer resp.Body.Close()
  33648. body, ioErr := ioutil.ReadAll(resp.Body)
  33649. if ioErr != nil {
  33650. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33652. return
  33653. }
  33654. var respJSON map[string]interface{}
  33655. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  33656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33658. return
  33659. }
  33660. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33661. userJSONBytes, _ := json.Marshal(respJSON)
  33662. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33663. utils.ErrorLog("解析失败:%v", err)
  33664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33665. return
  33666. }
  33667. if res.Infcode == 0 {
  33668. c.ServeSuccessJSON(map[string]interface{}{
  33669. "msg": "发起成功",
  33670. })
  33671. } else {
  33672. c.ServeSuccessJSON(map[string]interface{}{
  33673. "failed_code": -10,
  33674. "msg": res.ErrMsg,
  33675. })
  33676. }
  33677. }
  33678. }
  33679. func (c *HisApiController) Post8404() {
  33680. admin_user_id, _ := c.GetInt64("admin_user_id")
  33681. month := c.GetString("month")
  33682. adminUser := c.GetAdminUserInfo()
  33683. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33684. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33685. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33686. var res ResultSix
  33687. if config.IsOpen == 1 {
  33688. data := make(map[string]interface{})
  33689. data["month"] = month
  33690. data["org_name"] = miConfig.OrgName
  33691. data["doctor"] = role.UserName
  33692. data["fixmedins_code"] = miConfig.Code
  33693. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  33694. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  33695. client := &http.Client{}
  33696. bytesData, _ := json.Marshal(data)
  33697. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  33698. resp, _ := client.Do(req)
  33699. defer resp.Body.Close()
  33700. body, ioErr := ioutil.ReadAll(resp.Body)
  33701. if ioErr != nil {
  33702. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33704. return
  33705. }
  33706. var respJSON map[string]interface{}
  33707. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  33708. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33710. return
  33711. }
  33712. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33713. userJSONBytes, _ := json.Marshal(respJSON)
  33714. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33715. utils.ErrorLog("解析失败:%v", err)
  33716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33717. return
  33718. }
  33719. if res.Infcode == 0 {
  33720. c.ServeSuccessJSON(map[string]interface{}{
  33721. "msg": "查询成功",
  33722. })
  33723. } else {
  33724. c.ServeSuccessJSON(map[string]interface{}{
  33725. "failed_code": -10,
  33726. "msg": res.ErrMsg,
  33727. })
  33728. }
  33729. }
  33730. }
  33731. func (c *HisApiController) Post3202b() {
  33732. start_time := c.GetString("start_time")
  33733. end_time := c.GetString("end_time")
  33734. //insutype := c.GetString("insutype")
  33735. clr_type := c.GetString("clr_type")
  33736. clr_org := c.GetString("clr_optins")
  33737. admin_user_id, _ := c.GetInt64("admin_user_id")
  33738. adminUser := c.GetAdminUserInfo()
  33739. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33740. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33741. if len(clr_org) == 0 {
  33742. clr_org = miConfig.MdtrtareaAdmvs
  33743. }
  33744. timeLayout := "2006-01-02"
  33745. loc, _ := time.LoadLocation("Local")
  33746. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33747. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33748. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  33749. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  33750. //fixmedins_setl_cnt := int64(len(orders))
  33751. var medfee_sumamt float64
  33752. var acct_pay float64
  33753. var fund_pay_sumamt float64
  33754. for _, item := range orders {
  33755. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33756. acct_pay = acct_pay + item.AcctPay
  33757. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33758. }
  33759. //var medfee_sumamt_two float64
  33760. //var acct_pay_two float64
  33761. //var fund_pay_sumamt_two float64
  33762. //for _, item := range orders_two {
  33763. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  33764. // acct_pay_two = acct_pay_two + item.AcctPay
  33765. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  33766. //}
  33767. //var user_name string
  33768. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33769. //if role.ID == 0 {
  33770. // user_name = "xxx"
  33771. //} else {
  33772. // user_name = role.UserName
  33773. //}
  33774. var res ResultSix
  33775. if config.IsOpen == 1 {
  33776. var bps []*models.BusinessParamsTwo
  33777. var bp models.BusinessParamsTwo
  33778. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  33779. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  33780. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  33781. bp.MedfeeSumamt = medfee_sumamt_str
  33782. bp.AcctPay = acct_pay_str
  33783. bp.FundPaySumamt = fund_pay_sumamt_str
  33784. bp.Insutype = "390"
  33785. bp.StmtBegndate = start_time
  33786. bp.ClrType = clr_type
  33787. bp.SetlOptins = clr_org
  33788. bp.StmtEnddate = end_time
  33789. bps = append(bps, &bp)
  33790. data := make(map[string]interface{})
  33791. data["bps"] = bps
  33792. data["org_name"] = miConfig.OrgName
  33793. data["doctor"] = role.UserName
  33794. data["fixmedins_code"] = miConfig.Code
  33795. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  33796. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  33797. if miConfig.MdtrtareaAdmvs == "421300" {
  33798. client := &http.Client{}
  33799. bytesData, _ := json.Marshal(data)
  33800. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  33801. resp, _ := client.Do(req)
  33802. defer resp.Body.Close()
  33803. body, ioErr := ioutil.ReadAll(resp.Body)
  33804. if ioErr != nil {
  33805. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33807. return
  33808. }
  33809. var respJSON map[string]interface{}
  33810. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  33811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33813. return
  33814. }
  33815. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33816. userJSONBytes, _ := json.Marshal(respJSON)
  33817. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33818. utils.ErrorLog("解析失败:%v", err)
  33819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33820. return
  33821. }
  33822. }
  33823. if miConfig.MdtrtareaAdmvs == "420200" {
  33824. client := &http.Client{}
  33825. bytesData, _ := json.Marshal(data)
  33826. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  33827. resp, _ := client.Do(req)
  33828. defer resp.Body.Close()
  33829. body, ioErr := ioutil.ReadAll(resp.Body)
  33830. if ioErr != nil {
  33831. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33833. return
  33834. }
  33835. var respJSON map[string]interface{}
  33836. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  33837. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33839. return
  33840. }
  33841. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33842. userJSONBytes, _ := json.Marshal(respJSON)
  33843. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33844. utils.ErrorLog("解析失败:%v", err)
  33845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33846. return
  33847. }
  33848. }
  33849. if miConfig.MdtrtareaAdmvs == "421182" {
  33850. client := &http.Client{}
  33851. bytesData, _ := json.Marshal(data)
  33852. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  33853. resp, _ := client.Do(req)
  33854. defer resp.Body.Close()
  33855. body, ioErr := ioutil.ReadAll(resp.Body)
  33856. if ioErr != nil {
  33857. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33859. return
  33860. }
  33861. var respJSON map[string]interface{}
  33862. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  33863. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33865. return
  33866. }
  33867. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33868. userJSONBytes, _ := json.Marshal(respJSON)
  33869. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33870. utils.ErrorLog("解析失败:%v", err)
  33871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33872. return
  33873. }
  33874. }
  33875. if res.Infcode == 0 {
  33876. c.ServeSuccessJSON(map[string]interface{}{
  33877. "msg": "发起成功",
  33878. })
  33879. } else {
  33880. c.ServeSuccessJSON(map[string]interface{}{
  33881. "failed_code": -10,
  33882. "msg": res.ErrMsg,
  33883. })
  33884. }
  33885. }
  33886. }
  33887. func (c *HisApiController) Post1608() {
  33888. start_time := c.GetString("start_time")
  33889. end_time := c.GetString("end_time")
  33890. admin_user_id, _ := c.GetInt64("admin_user_id")
  33891. adminUser := c.GetAdminUserInfo()
  33892. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33893. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33894. timeLayout := "2006-01-02"
  33895. loc, _ := time.LoadLocation("Local")
  33896. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33897. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33898. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  33899. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  33900. fixmedins_setl_cnt := int64(len(orders))
  33901. var medfee_sumamt float64
  33902. var func_smamt float64
  33903. for _, item := range orders {
  33904. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33905. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  33906. }
  33907. times := strings.Split(start_time, "-")
  33908. time_tows := strings.Split(end_time, "-")
  33909. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33910. var res ResultSix
  33911. if config.IsOpen == 1 {
  33912. //var bps []*models.BusinessParamsTwo
  33913. //var bp models.BusinessParamsTwo
  33914. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  33915. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  33916. data := make(map[string]interface{})
  33917. data["org_name"] = miConfig.OrgName
  33918. data["doctor"] = role.UserName
  33919. data["func_smamt"] = func_smamt_str
  33920. data["fixmedins_code"] = miConfig.Code
  33921. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  33922. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  33923. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  33924. data["medfee_sumamt"] = medfee_sumamt_str
  33925. data["start_time"] = times[0] + times[1] + times[2]
  33926. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  33927. if miConfig.MdtrtareaAdmvs == "421300" {
  33928. client := &http.Client{}
  33929. bytesData, _ := json.Marshal(data)
  33930. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  33931. resp, _ := client.Do(req)
  33932. defer resp.Body.Close()
  33933. body, ioErr := ioutil.ReadAll(resp.Body)
  33934. if ioErr != nil {
  33935. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33937. return
  33938. }
  33939. var respJSON map[string]interface{}
  33940. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  33941. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33943. return
  33944. }
  33945. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33946. userJSONBytes, _ := json.Marshal(respJSON)
  33947. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33948. utils.ErrorLog("解析失败:%v", err)
  33949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33950. return
  33951. }
  33952. }
  33953. if miConfig.MdtrtareaAdmvs == "420200" {
  33954. client := &http.Client{}
  33955. bytesData, _ := json.Marshal(data)
  33956. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  33957. resp, _ := client.Do(req)
  33958. defer resp.Body.Close()
  33959. body, ioErr := ioutil.ReadAll(resp.Body)
  33960. if ioErr != nil {
  33961. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33963. return
  33964. }
  33965. var respJSON map[string]interface{}
  33966. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  33967. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33969. return
  33970. }
  33971. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33972. userJSONBytes, _ := json.Marshal(respJSON)
  33973. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33974. utils.ErrorLog("解析失败:%v", err)
  33975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33976. return
  33977. }
  33978. }
  33979. if miConfig.MdtrtareaAdmvs == "421182" {
  33980. client := &http.Client{}
  33981. bytesData, _ := json.Marshal(data)
  33982. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  33983. resp, _ := client.Do(req)
  33984. defer resp.Body.Close()
  33985. body, ioErr := ioutil.ReadAll(resp.Body)
  33986. if ioErr != nil {
  33987. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33989. return
  33990. }
  33991. var respJSON map[string]interface{}
  33992. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  33993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33995. return
  33996. }
  33997. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33998. userJSONBytes, _ := json.Marshal(respJSON)
  33999. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34000. utils.ErrorLog("解析失败:%v", err)
  34001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34002. return
  34003. }
  34004. }
  34005. if res.Infcode == 0 {
  34006. c.ServeSuccessJSON(map[string]interface{}{
  34007. "msg": "发起成功",
  34008. })
  34009. } else {
  34010. c.ServeSuccessJSON(map[string]interface{}{
  34011. "failed_code": -10,
  34012. "msg": res.ErrMsg,
  34013. })
  34014. }
  34015. }
  34016. }
  34017. // 5.11.1.1【5262】结算信息按时间段查询
  34018. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  34019. admin_user_id, _ := c.GetInt64("admin_user_id")
  34020. adminUser := c.GetAdminUserInfo()
  34021. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34022. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34023. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34024. var res Result5262
  34025. if config.IsOpen == 1 {
  34026. if miConfig.MdtrtareaAdmvs == "421300" {
  34027. data := make(map[string]interface{})
  34028. data["bps"] = bp
  34029. data["org_name"] = miConfig.OrgName
  34030. data["doctor"] = role.UserName
  34031. data["fixmedins_code"] = miConfig.Code
  34032. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34033. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  34034. data["page"] = strconv.FormatInt(page, 10)
  34035. data["limit"] = strconv.FormatInt(limit, 10)
  34036. fmt.Println(data)
  34037. client := &http.Client{}
  34038. bytesData, _ := json.Marshal(data)
  34039. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  34040. resp, _ := client.Do(req)
  34041. defer resp.Body.Close()
  34042. body, ioErr := ioutil.ReadAll(resp.Body)
  34043. if ioErr != nil {
  34044. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34046. return
  34047. }
  34048. var respJSON map[string]interface{}
  34049. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34050. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34052. return
  34053. }
  34054. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34055. userJSONBytes, _ := json.Marshal(respJSON)
  34056. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34057. utils.ErrorLog("解析失败:%v", err)
  34058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34059. return
  34060. }
  34061. }
  34062. if miConfig.MdtrtareaAdmvs == "420200" {
  34063. data := make(map[string]interface{})
  34064. data["bps"] = bp
  34065. data["org_name"] = miConfig.OrgName
  34066. data["doctor"] = role.UserName
  34067. data["fixmedins_code"] = miConfig.Code
  34068. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34069. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  34070. data["page"] = strconv.FormatInt(page, 10)
  34071. data["limit"] = strconv.FormatInt(limit, 10)
  34072. fmt.Println(data)
  34073. client := &http.Client{}
  34074. bytesData, _ := json.Marshal(data)
  34075. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  34076. resp, _ := client.Do(req)
  34077. defer resp.Body.Close()
  34078. body, ioErr := ioutil.ReadAll(resp.Body)
  34079. if ioErr != nil {
  34080. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34082. return
  34083. }
  34084. var respJSON map[string]interface{}
  34085. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34086. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34088. return
  34089. }
  34090. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34091. userJSONBytes, _ := json.Marshal(respJSON)
  34092. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34093. utils.ErrorLog("解析失败:%v", err)
  34094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34095. return
  34096. }
  34097. }
  34098. if miConfig.MdtrtareaAdmvs == "421182" {
  34099. data := make(map[string]interface{})
  34100. data["bps"] = bp
  34101. data["org_name"] = miConfig.OrgName
  34102. data["doctor"] = role.UserName
  34103. data["fixmedins_code"] = miConfig.Code
  34104. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34105. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  34106. data["page"] = strconv.FormatInt(page, 10)
  34107. data["limit"] = strconv.FormatInt(limit, 10)
  34108. fmt.Println(data)
  34109. client := &http.Client{}
  34110. bytesData, _ := json.Marshal(data)
  34111. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  34112. resp, _ := client.Do(req)
  34113. defer resp.Body.Close()
  34114. body, ioErr := ioutil.ReadAll(resp.Body)
  34115. if ioErr != nil {
  34116. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34118. return
  34119. }
  34120. var respJSON map[string]interface{}
  34121. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34122. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34124. return
  34125. }
  34126. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34127. userJSONBytes, _ := json.Marshal(respJSON)
  34128. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34129. utils.ErrorLog("解析失败:%v", err)
  34130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34131. return
  34132. }
  34133. }
  34134. if miConfig.MdtrtareaAdmvs == "420902" {
  34135. data := make(map[string]interface{})
  34136. data["bps"] = bp
  34137. data["org_name"] = miConfig.OrgName
  34138. data["doctor"] = role.UserName
  34139. data["fixmedins_code"] = miConfig.Code
  34140. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34141. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  34142. data["page"] = strconv.FormatInt(page, 10)
  34143. data["limit"] = strconv.FormatInt(limit, 10)
  34144. fmt.Println(data)
  34145. client := &http.Client{}
  34146. bytesData, _ := json.Marshal(data)
  34147. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  34148. resp, _ := client.Do(req)
  34149. defer resp.Body.Close()
  34150. body, ioErr := ioutil.ReadAll(resp.Body)
  34151. if ioErr != nil {
  34152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34154. return
  34155. }
  34156. var respJSON map[string]interface{}
  34157. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34160. return
  34161. }
  34162. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34163. userJSONBytes, _ := json.Marshal(respJSON)
  34164. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34165. utils.ErrorLog("解析失败:%v", err)
  34166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34167. return
  34168. }
  34169. }
  34170. if res.Infcode == 0 {
  34171. c.ServeSuccessJSON(map[string]interface{}{
  34172. "order": res.Output.Result,
  34173. "total": res.Output.PageInfo.RecordCounts,
  34174. })
  34175. } else {
  34176. c.ServeSuccessJSON(map[string]interface{}{
  34177. "failed_code": -10,
  34178. "msg": res.ErrMsg,
  34179. })
  34180. }
  34181. }
  34182. }
  34183. // 5.11.1.2【5267】异地结算信息时间段查询
  34184. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  34185. admin_user_id, _ := c.GetInt64("admin_user_id")
  34186. adminUser := c.GetAdminUserInfo()
  34187. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34188. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34189. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34190. var res Result5267
  34191. if config.IsOpen == 1 {
  34192. if miConfig.MdtrtareaAdmvs == "421300" {
  34193. data := make(map[string]interface{})
  34194. data["bps"] = bp
  34195. data["org_name"] = miConfig.OrgName
  34196. data["doctor"] = role.UserName
  34197. data["fixmedins_code"] = miConfig.Code
  34198. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34199. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  34200. data["page"] = page
  34201. data["limit"] = limit
  34202. fmt.Println(data)
  34203. client := &http.Client{}
  34204. bytesData, _ := json.Marshal(data)
  34205. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  34206. resp, _ := client.Do(req)
  34207. defer resp.Body.Close()
  34208. body, ioErr := ioutil.ReadAll(resp.Body)
  34209. if ioErr != nil {
  34210. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34212. return
  34213. }
  34214. var respJSON map[string]interface{}
  34215. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34218. return
  34219. }
  34220. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34221. userJSONBytes, _ := json.Marshal(respJSON)
  34222. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34223. utils.ErrorLog("解析失败:%v", err)
  34224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34225. return
  34226. }
  34227. }
  34228. if miConfig.MdtrtareaAdmvs == "420200" {
  34229. data := make(map[string]interface{})
  34230. data["bps"] = bp
  34231. data["org_name"] = miConfig.OrgName
  34232. data["doctor"] = role.UserName
  34233. data["fixmedins_code"] = miConfig.Code
  34234. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34235. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  34236. data["page"] = page
  34237. data["limit"] = limit
  34238. fmt.Println(data)
  34239. client := &http.Client{}
  34240. bytesData, _ := json.Marshal(data)
  34241. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  34242. resp, _ := client.Do(req)
  34243. defer resp.Body.Close()
  34244. body, ioErr := ioutil.ReadAll(resp.Body)
  34245. if ioErr != nil {
  34246. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34248. return
  34249. }
  34250. var respJSON map[string]interface{}
  34251. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34254. return
  34255. }
  34256. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34257. userJSONBytes, _ := json.Marshal(respJSON)
  34258. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34259. utils.ErrorLog("解析失败:%v", err)
  34260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34261. return
  34262. }
  34263. }
  34264. if miConfig.MdtrtareaAdmvs == "421182" {
  34265. data := make(map[string]interface{})
  34266. data["bps"] = bp
  34267. data["org_name"] = miConfig.OrgName
  34268. data["doctor"] = role.UserName
  34269. data["fixmedins_code"] = miConfig.Code
  34270. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34271. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  34272. data["page"] = page
  34273. data["limit"] = limit
  34274. fmt.Println(data)
  34275. client := &http.Client{}
  34276. bytesData, _ := json.Marshal(data)
  34277. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  34278. resp, _ := client.Do(req)
  34279. defer resp.Body.Close()
  34280. body, ioErr := ioutil.ReadAll(resp.Body)
  34281. if ioErr != nil {
  34282. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34284. return
  34285. }
  34286. var respJSON map[string]interface{}
  34287. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34290. return
  34291. }
  34292. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34293. userJSONBytes, _ := json.Marshal(respJSON)
  34294. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34295. utils.ErrorLog("解析失败:%v", err)
  34296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34297. return
  34298. }
  34299. }
  34300. if res.Infcode == 0 {
  34301. c.ServeSuccessJSON(map[string]interface{}{
  34302. "order": res.Output.Result,
  34303. "total": res.Output.PageInfo.RecordCounts,
  34304. })
  34305. } else {
  34306. c.ServeSuccessJSON(map[string]interface{}{
  34307. "failed_code": -10,
  34308. "msg": res.ErrMsg,
  34309. })
  34310. }
  34311. }
  34312. }
  34313. func (c *HisApiController) Post3501() {
  34314. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  34315. data := make(map[string]interface{})
  34316. var struct3501s []models.Struct3501
  34317. var struct3501 models.Struct3501
  34318. struct3501.OrgName = miConfig.OrgName
  34319. struct3501.AccessKey = miConfig.AccessKey
  34320. struct3501.RequestUrl = miConfig.Url
  34321. struct3501.SecretKey = miConfig.SecretKey
  34322. struct3501.ManuDate = "2022-08-17"
  34323. struct3501.FixmedinsBchno = ""
  34324. struct3501.ManuLotnum = ""
  34325. struct3501.RxFlag = "0"
  34326. struct3501.ExpyEnd = "2022-08-17"
  34327. struct3501.Invdate = "2022-08-17"
  34328. struct3501.InvCnt = "20.25"
  34329. struct3501.Memo = ""
  34330. struct3501.MedListCodg = "XB01ABD056B002020200517"
  34331. struct3501.FixmedinsHilistId = miConfig.Code
  34332. struct3501.FixmedinsHilistName = miConfig.OrgName
  34333. struct3501s = append(struct3501s, struct3501)
  34334. data["struct_3501s"] = struct3501s
  34335. client := &http.Client{}
  34336. bytesData, _ := json.Marshal(data)
  34337. var req *http.Request
  34338. if miConfig.MdtrtareaAdmvs == "320921" {
  34339. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  34340. } else {
  34341. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  34342. }
  34343. resp, _ := client.Do(req)
  34344. defer resp.Body.Close()
  34345. body, ioErr := ioutil.ReadAll(resp.Body)
  34346. if ioErr != nil {
  34347. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34349. return
  34350. }
  34351. var respJSON map[string]interface{}
  34352. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34353. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34355. return
  34356. }
  34357. var res ResultSix
  34358. var resSix10265 ResultSix10265 //1101结果
  34359. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  34360. result, _ := json.Marshal(respJSON)
  34361. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  34362. utils.ErrorLog("解析失败:%v", err)
  34363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34364. return
  34365. }
  34366. res.InfRefmsgid = resSix10265.InfRefmsgid
  34367. res.Output = resSix10265.Output
  34368. res.ErrMsg = resSix10265.ErrMsg
  34369. res.Cainfo = resSix10265.Cainfo
  34370. res.WarnMsg = resSix10265.WarnMsg
  34371. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34372. res.Infcode = infocode
  34373. if infocode == 0 {
  34374. c.ServeSuccessJSON(map[string]interface{}{
  34375. "msg": "上传成功",
  34376. })
  34377. return
  34378. } else {
  34379. c.ServeSuccessJSON(map[string]interface{}{
  34380. "failed_code": -10,
  34381. "msg": res.ErrMsg,
  34382. })
  34383. return
  34384. }
  34385. }
  34386. func (c *HisApiController) Post3502() {
  34387. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  34388. data := make(map[string]interface{})
  34389. var struct3502s []models.Struct3502
  34390. var struct3502 models.Struct3502
  34391. struct3502.OrgName = miConfig.OrgName
  34392. struct3502.AccessKey = miConfig.AccessKey
  34393. struct3502.RequestUrl = miConfig.Url
  34394. struct3502.SecretKey = miConfig.SecretKey
  34395. struct3502.ManuDate = "2022-08-15"
  34396. struct3502.FixmedinsBchno = ""
  34397. struct3502.ManuLotnum = ""
  34398. struct3502.RxFlag = "0"
  34399. struct3502.ExpyEnd = "2022-08-15"
  34400. struct3502.Invdate = "2022-08-15"
  34401. struct3502.InvCnt = "20.25"
  34402. struct3502.Memo = ""
  34403. struct3502.MedListCodg = "XB01ABD056B002020200517"
  34404. struct3502.FixmedinsHilistId = miConfig.Code
  34405. struct3502.FixmedinsHilistName = miConfig.OrgName
  34406. struct3502s = append(struct3502s, struct3502)
  34407. data["struct_3502s"] = struct3502s
  34408. client := &http.Client{}
  34409. bytesData, _ := json.Marshal(data)
  34410. var req *http.Request
  34411. if miConfig.MdtrtareaAdmvs == "320921" {
  34412. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  34413. } else {
  34414. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  34415. }
  34416. resp, _ := client.Do(req)
  34417. defer resp.Body.Close()
  34418. body, ioErr := ioutil.ReadAll(resp.Body)
  34419. if ioErr != nil {
  34420. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34422. return
  34423. }
  34424. var respJSON map[string]interface{}
  34425. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34426. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34428. return
  34429. }
  34430. var res ResultSix
  34431. var resSix10265 ResultSix10265 //1101结果
  34432. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  34433. result, _ := json.Marshal(respJSON)
  34434. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  34435. utils.ErrorLog("解析失败:%v", err)
  34436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34437. return
  34438. }
  34439. res.InfRefmsgid = resSix10265.InfRefmsgid
  34440. res.Output = resSix10265.Output
  34441. res.ErrMsg = resSix10265.ErrMsg
  34442. res.Cainfo = resSix10265.Cainfo
  34443. res.WarnMsg = resSix10265.WarnMsg
  34444. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34445. res.Infcode = infocode
  34446. if infocode == 0 {
  34447. c.ServeSuccessJSON(map[string]interface{}{
  34448. "msg": "上传成功",
  34449. })
  34450. return
  34451. } else {
  34452. c.ServeSuccessJSON(map[string]interface{}{
  34453. "failed_code": -10,
  34454. "msg": res.ErrMsg,
  34455. })
  34456. return
  34457. }
  34458. }
  34459. func (c *HisApiController) Post3503() {
  34460. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  34461. data := make(map[string]interface{})
  34462. var struct3501s []models.Struct3501
  34463. var struct3501 models.Struct3501
  34464. struct3501.OrgName = miConfig.OrgName
  34465. struct3501.AccessKey = miConfig.AccessKey
  34466. struct3501.RequestUrl = miConfig.Url
  34467. struct3501.SecretKey = miConfig.SecretKey
  34468. struct3501.ManuDate = "2022-08-15"
  34469. struct3501.FixmedinsBchno = ""
  34470. struct3501.ManuLotnum = ""
  34471. struct3501.RxFlag = "0"
  34472. struct3501.ExpyEnd = "2022-08-15"
  34473. struct3501.Invdate = "2022-08-15"
  34474. struct3501.InvCnt = "20.25"
  34475. struct3501.Memo = ""
  34476. struct3501.MedListCodg = "XB01ABD056B002020200517"
  34477. struct3501.FixmedinsHilistId = miConfig.Code
  34478. struct3501.FixmedinsHilistName = miConfig.OrgName
  34479. struct3501s = append(struct3501s, struct3501)
  34480. data["struct_3501s"] = struct3501s
  34481. client := &http.Client{}
  34482. bytesData, _ := json.Marshal(data)
  34483. var req *http.Request
  34484. if miConfig.MdtrtareaAdmvs == "320921" {
  34485. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  34486. } else {
  34487. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  34488. }
  34489. resp, _ := client.Do(req)
  34490. defer resp.Body.Close()
  34491. body, ioErr := ioutil.ReadAll(resp.Body)
  34492. if ioErr != nil {
  34493. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34495. return
  34496. }
  34497. var respJSON map[string]interface{}
  34498. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34499. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34501. return
  34502. }
  34503. var res ResultSix
  34504. var resSix10265 ResultSix10265 //1101结果
  34505. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  34506. result, _ := json.Marshal(respJSON)
  34507. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  34508. utils.ErrorLog("解析失败:%v", err)
  34509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34510. return
  34511. }
  34512. res.InfRefmsgid = resSix10265.InfRefmsgid
  34513. res.Output = resSix10265.Output
  34514. res.ErrMsg = resSix10265.ErrMsg
  34515. res.Cainfo = resSix10265.Cainfo
  34516. res.WarnMsg = resSix10265.WarnMsg
  34517. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34518. res.Infcode = infocode
  34519. if infocode == 0 {
  34520. c.ServeSuccessJSON(map[string]interface{}{
  34521. "msg": "上传成功",
  34522. })
  34523. return
  34524. } else {
  34525. c.ServeSuccessJSON(map[string]interface{}{
  34526. "failed_code": -10,
  34527. "msg": res.ErrMsg,
  34528. })
  34529. return
  34530. }
  34531. }
  34532. func (c *HisApiController) Post3504() {
  34533. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  34534. data := make(map[string]interface{})
  34535. var struct3501s []models.Struct3501
  34536. var struct3501 models.Struct3501
  34537. struct3501.OrgName = miConfig.OrgName
  34538. struct3501.AccessKey = miConfig.AccessKey
  34539. struct3501.RequestUrl = miConfig.Url
  34540. struct3501.SecretKey = miConfig.SecretKey
  34541. struct3501.ManuDate = "2022-08-15"
  34542. struct3501.FixmedinsBchno = ""
  34543. struct3501.ManuLotnum = ""
  34544. struct3501.RxFlag = "0"
  34545. struct3501.ExpyEnd = "2022-08-15"
  34546. struct3501.Invdate = "2022-08-15"
  34547. struct3501.InvCnt = "20.25"
  34548. struct3501.Memo = ""
  34549. struct3501.MedListCodg = "XB01ABD056B002020200517"
  34550. struct3501.FixmedinsHilistId = miConfig.Code
  34551. struct3501.FixmedinsHilistName = miConfig.OrgName
  34552. struct3501s = append(struct3501s, struct3501)
  34553. data["struct_3501s"] = struct3501s
  34554. client := &http.Client{}
  34555. bytesData, _ := json.Marshal(data)
  34556. var req *http.Request
  34557. if miConfig.MdtrtareaAdmvs == "320921" {
  34558. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  34559. } else {
  34560. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  34561. }
  34562. resp, _ := client.Do(req)
  34563. defer resp.Body.Close()
  34564. body, ioErr := ioutil.ReadAll(resp.Body)
  34565. if ioErr != nil {
  34566. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34568. return
  34569. }
  34570. var respJSON map[string]interface{}
  34571. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34572. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34574. return
  34575. }
  34576. var res ResultSix
  34577. var resSix10265 ResultSix10265 //1101结果
  34578. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  34579. result, _ := json.Marshal(respJSON)
  34580. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  34581. utils.ErrorLog("解析失败:%v", err)
  34582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34583. return
  34584. }
  34585. res.InfRefmsgid = resSix10265.InfRefmsgid
  34586. res.Output = resSix10265.Output
  34587. res.ErrMsg = resSix10265.ErrMsg
  34588. res.Cainfo = resSix10265.Cainfo
  34589. res.WarnMsg = resSix10265.WarnMsg
  34590. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34591. res.Infcode = infocode
  34592. if infocode == 0 {
  34593. c.ServeSuccessJSON(map[string]interface{}{
  34594. "msg": "上传成功",
  34595. })
  34596. return
  34597. } else {
  34598. c.ServeSuccessJSON(map[string]interface{}{
  34599. "failed_code": -10,
  34600. "msg": res.ErrMsg,
  34601. })
  34602. return
  34603. }
  34604. }
  34605. func (c *HisApiController) Post3505() {
  34606. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  34607. data := make(map[string]interface{})
  34608. var struct3501s []models.Struct3501
  34609. var struct3501 models.Struct3501
  34610. struct3501.OrgName = miConfig.OrgName
  34611. struct3501.AccessKey = miConfig.AccessKey
  34612. struct3501.RequestUrl = miConfig.Url
  34613. struct3501.SecretKey = miConfig.SecretKey
  34614. struct3501.ManuDate = "2022-08-15"
  34615. struct3501.FixmedinsBchno = ""
  34616. struct3501.ManuLotnum = ""
  34617. struct3501.RxFlag = "0"
  34618. struct3501.ExpyEnd = "2022-08-15"
  34619. struct3501.Invdate = "2022-08-15"
  34620. struct3501.InvCnt = "20.25"
  34621. struct3501.Memo = ""
  34622. struct3501.MedListCodg = "XB01ABD056B002020200517"
  34623. struct3501.FixmedinsHilistId = miConfig.Code
  34624. struct3501.FixmedinsHilistName = miConfig.OrgName
  34625. struct3501s = append(struct3501s, struct3501)
  34626. data["struct_3501s"] = struct3501s
  34627. client := &http.Client{}
  34628. bytesData, _ := json.Marshal(data)
  34629. var req *http.Request
  34630. if miConfig.MdtrtareaAdmvs == "320921" {
  34631. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  34632. } else {
  34633. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  34634. }
  34635. resp, _ := client.Do(req)
  34636. defer resp.Body.Close()
  34637. body, ioErr := ioutil.ReadAll(resp.Body)
  34638. if ioErr != nil {
  34639. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34641. return
  34642. }
  34643. var respJSON map[string]interface{}
  34644. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34645. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34647. return
  34648. }
  34649. var res ResultSix
  34650. var resSix10265 ResultSix10265 //1101结果
  34651. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  34652. result, _ := json.Marshal(respJSON)
  34653. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  34654. utils.ErrorLog("解析失败:%v", err)
  34655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34656. return
  34657. }
  34658. res.InfRefmsgid = resSix10265.InfRefmsgid
  34659. res.Output = resSix10265.Output
  34660. res.ErrMsg = resSix10265.ErrMsg
  34661. res.Cainfo = resSix10265.Cainfo
  34662. res.WarnMsg = resSix10265.WarnMsg
  34663. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34664. res.Infcode = infocode
  34665. if infocode == 0 {
  34666. c.ServeSuccessJSON(map[string]interface{}{
  34667. "msg": "上传成功",
  34668. })
  34669. return
  34670. } else {
  34671. c.ServeSuccessJSON(map[string]interface{}{
  34672. "failed_code": -10,
  34673. "msg": res.ErrMsg,
  34674. })
  34675. return
  34676. }
  34677. }
  34678. func (c *HisApiController) Post3506() {
  34679. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  34680. data := make(map[string]interface{})
  34681. var struct3501s []models.Struct3501
  34682. var struct3501 models.Struct3501
  34683. struct3501.OrgName = miConfig.OrgName
  34684. struct3501.AccessKey = miConfig.AccessKey
  34685. struct3501.RequestUrl = miConfig.Url
  34686. struct3501.SecretKey = miConfig.SecretKey
  34687. struct3501.ManuDate = "2022-08-15"
  34688. struct3501.FixmedinsBchno = ""
  34689. struct3501.ManuLotnum = ""
  34690. struct3501.RxFlag = "0"
  34691. struct3501.ExpyEnd = "2022-08-15"
  34692. struct3501.Invdate = "2022-08-15"
  34693. struct3501.InvCnt = "20.25"
  34694. struct3501.Memo = ""
  34695. struct3501.MedListCodg = "XB01ABD056B002020200517"
  34696. struct3501.FixmedinsHilistId = miConfig.Code
  34697. struct3501.FixmedinsHilistName = miConfig.OrgName
  34698. struct3501s = append(struct3501s, struct3501)
  34699. data["struct_3501s"] = struct3501s
  34700. client := &http.Client{}
  34701. bytesData, _ := json.Marshal(data)
  34702. var req *http.Request
  34703. if miConfig.MdtrtareaAdmvs == "320921" {
  34704. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  34705. } else {
  34706. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  34707. }
  34708. resp, _ := client.Do(req)
  34709. defer resp.Body.Close()
  34710. body, ioErr := ioutil.ReadAll(resp.Body)
  34711. if ioErr != nil {
  34712. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34714. return
  34715. }
  34716. var respJSON map[string]interface{}
  34717. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34718. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34720. return
  34721. }
  34722. var res ResultSix
  34723. var resSix10265 ResultSix10265 //1101结果
  34724. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  34725. result, _ := json.Marshal(respJSON)
  34726. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  34727. utils.ErrorLog("解析失败:%v", err)
  34728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34729. return
  34730. }
  34731. res.InfRefmsgid = resSix10265.InfRefmsgid
  34732. res.Output = resSix10265.Output
  34733. res.ErrMsg = resSix10265.ErrMsg
  34734. res.Cainfo = resSix10265.Cainfo
  34735. res.WarnMsg = resSix10265.WarnMsg
  34736. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34737. res.Infcode = infocode
  34738. if infocode == 0 {
  34739. c.ServeSuccessJSON(map[string]interface{}{
  34740. "msg": "上传成功",
  34741. })
  34742. return
  34743. } else {
  34744. c.ServeSuccessJSON(map[string]interface{}{
  34745. "failed_code": -10,
  34746. "msg": res.ErrMsg,
  34747. })
  34748. return
  34749. }
  34750. }
  34751. func (c *HisApiController) Post3507() {
  34752. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  34753. data := make(map[string]interface{})
  34754. var struct3501s []models.Struct3501
  34755. var struct3501 models.Struct3501
  34756. struct3501.OrgName = miConfig.OrgName
  34757. struct3501.AccessKey = miConfig.AccessKey
  34758. struct3501.RequestUrl = miConfig.Url
  34759. struct3501.SecretKey = miConfig.SecretKey
  34760. struct3501.ManuDate = "2022-08-15"
  34761. struct3501.FixmedinsBchno = ""
  34762. struct3501.ManuLotnum = ""
  34763. struct3501.RxFlag = "0"
  34764. struct3501.ExpyEnd = "2022-08-15"
  34765. struct3501.Invdate = "2022-08-15"
  34766. struct3501.InvCnt = "20.25"
  34767. struct3501.Memo = ""
  34768. struct3501.MedListCodg = "XB01ABD056B002020200517"
  34769. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  34770. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  34771. struct3501s = append(struct3501s, struct3501)
  34772. data["struct_3501s"] = struct3501s
  34773. client := &http.Client{}
  34774. bytesData, _ := json.Marshal(data)
  34775. var req *http.Request
  34776. if miConfig.MdtrtareaAdmvs == "320921" {
  34777. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  34778. } else {
  34779. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  34780. }
  34781. resp, _ := client.Do(req)
  34782. defer resp.Body.Close()
  34783. body, ioErr := ioutil.ReadAll(resp.Body)
  34784. if ioErr != nil {
  34785. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34787. return
  34788. }
  34789. var respJSON map[string]interface{}
  34790. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34791. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34793. return
  34794. }
  34795. var res ResultSix
  34796. var resSix10265 ResultSix10265 //1101结果
  34797. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  34798. result, _ := json.Marshal(respJSON)
  34799. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  34800. utils.ErrorLog("解析失败:%v", err)
  34801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34802. return
  34803. }
  34804. res.InfRefmsgid = resSix10265.InfRefmsgid
  34805. res.Output = resSix10265.Output
  34806. res.ErrMsg = resSix10265.ErrMsg
  34807. res.Cainfo = resSix10265.Cainfo
  34808. res.WarnMsg = resSix10265.WarnMsg
  34809. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34810. res.Infcode = infocode
  34811. if infocode == 0 {
  34812. c.ServeSuccessJSON(map[string]interface{}{
  34813. "msg": "上传成功",
  34814. })
  34815. return
  34816. } else {
  34817. c.ServeSuccessJSON(map[string]interface{}{
  34818. "failed_code": -10,
  34819. "msg": res.ErrMsg,
  34820. })
  34821. return
  34822. }
  34823. }
  34824. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  34825. // WebSocket服务器地址
  34826. serverURL := "ws://127.0.0.1:8899"
  34827. // 解析WebSocket服务器地址
  34828. u, err := url.Parse(serverURL)
  34829. if err != nil {
  34830. }
  34831. // 建立WebSocket连接
  34832. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  34833. if err != nil {
  34834. }
  34835. defer conn.Close()
  34836. input2 := make(map[string]interface{})
  34837. input := make(map[string]interface{})
  34838. inputData := make(map[string]interface{})
  34839. inputData["orgId"] = code
  34840. inputData["businessType"] = "01101"
  34841. inputData["operatorId"] = operator_id
  34842. inputData["operatorName"] = operator_name
  34843. inputData["officeId"] = "001"
  34844. inputData["officeName"] = "血透室"
  34845. inputData["deviceType"] = ""
  34846. input["data"] = inputData
  34847. input["orgId"] = code
  34848. input["transType"] = "ec.query"
  34849. //if md == ""
  34850. if md[:4] == "4403" {
  34851. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  34852. } else if md[:4] == "4401" {
  34853. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  34854. } else {
  34855. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  34856. }
  34857. input2["indata"] = input
  34858. fmt.Println(input2)
  34859. bytesData, _ := json.Marshal(input2)
  34860. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  34861. if err != nil {
  34862. fmt.Println(err)
  34863. }
  34864. // 接收消息
  34865. _, receivedMessage, err := conn.ReadMessage()
  34866. if err != nil {
  34867. fmt.Println(err)
  34868. }
  34869. return "", string(receivedMessage)
  34870. }
  34871. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  34872. // WebSocket服务器地址
  34873. serverURL := "ws://127.0.0.1:8899"
  34874. // 解析WebSocket服务器地址
  34875. u, err := url.Parse(serverURL)
  34876. if err != nil {
  34877. }
  34878. // 建立WebSocket连接
  34879. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  34880. if err != nil {
  34881. }
  34882. defer conn.Close()
  34883. input2 := make(map[string]interface{})
  34884. input := make(map[string]interface{})
  34885. inputData := make(map[string]interface{})
  34886. inputData["orgId"] = code
  34887. inputData["businessType"] = "01101"
  34888. inputData["operatorId"] = operator_id
  34889. inputData["operatorName"] = operator_name
  34890. inputData["officeId"] = "001"
  34891. inputData["officeName"] = "血透室"
  34892. inputData["deviceType"] = ""
  34893. input["data"] = inputData
  34894. input["orgId"] = code
  34895. input["transType"] = "ec.query"
  34896. //if md == ""
  34897. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  34898. input2["indata"] = input
  34899. fmt.Println(input2)
  34900. bytesData, _ := json.Marshal(input2)
  34901. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  34902. if err != nil {
  34903. fmt.Println(err)
  34904. }
  34905. // 接收消息
  34906. _, receivedMessage, err := conn.ReadMessage()
  34907. if err != nil {
  34908. fmt.Println(err)
  34909. }
  34910. return "", string(receivedMessage)
  34911. }
  34912. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  34913. // WebSocket服务器地址
  34914. serverURL := "ws://127.0.0.1:8899"
  34915. // 解析WebSocket服务器地址
  34916. u, err := url.Parse(serverURL)
  34917. if err != nil {
  34918. }
  34919. // 建立WebSocket连接
  34920. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  34921. if err != nil {
  34922. }
  34923. defer conn.Close()
  34924. input2 := make(map[string]interface{})
  34925. input := make(map[string]interface{})
  34926. inputData := make(map[string]interface{})
  34927. inputData["orgId"] = code
  34928. inputData["businessType"] = "01301"
  34929. inputData["operatorId"] = operator_id
  34930. inputData["operatorName"] = operator_name
  34931. inputData["officeId"] = "001"
  34932. inputData["officeName"] = "血透室"
  34933. inputData["deviceType"] = ""
  34934. input["data"] = inputData
  34935. input["orgId"] = code
  34936. input["transType"] = "ec.query"
  34937. //if md == ""
  34938. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  34939. input2["indata"] = input
  34940. fmt.Println(input2)
  34941. bytesData, _ := json.Marshal(input2)
  34942. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  34943. if err != nil {
  34944. fmt.Println(err)
  34945. }
  34946. // 接收消息
  34947. _, receivedMessage, err := conn.ReadMessage()
  34948. if err != nil {
  34949. fmt.Println(err)
  34950. }
  34951. return "", string(receivedMessage)
  34952. }
  34953. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  34954. // WebSocket服务器地址
  34955. serverURL := "ws://127.0.0.1:8899"
  34956. // 解析WebSocket服务器地址
  34957. u, err := url.Parse(serverURL)
  34958. if err != nil {
  34959. }
  34960. // 建立WebSocket连接
  34961. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  34962. if err != nil {
  34963. }
  34964. defer conn.Close()
  34965. input2 := make(map[string]interface{})
  34966. input := make(map[string]interface{})
  34967. inputData := make(map[string]interface{})
  34968. inputData["orgId"] = code
  34969. inputData["businessType"] = "01103"
  34970. inputData["operatorId"] = operator_id
  34971. inputData["operatorName"] = operator_name
  34972. inputData["officeId"] = "001"
  34973. inputData["officeName"] = "血透室"
  34974. inputData["deviceType"] = ""
  34975. input["data"] = inputData
  34976. input["orgId"] = code
  34977. input["transType"] = "ec.query"
  34978. //if md ==
  34979. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  34980. input2["indata"] = input
  34981. fmt.Println(input2)
  34982. bytesData, _ := json.Marshal(input2)
  34983. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  34984. if err != nil {
  34985. fmt.Println(err)
  34986. }
  34987. // 接收消息
  34988. _, receivedMessage, err := conn.ReadMessage()
  34989. if err != nil {
  34990. fmt.Println(err)
  34991. }
  34992. return "", string(receivedMessage)
  34993. }
  34994. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  34995. // WebSocket服务器地址
  34996. serverURL := "ws://127.0.0.1:8899"
  34997. // 解析WebSocket服务器地址
  34998. u, err := url.Parse(serverURL)
  34999. if err != nil {
  35000. }
  35001. // 建立WebSocket连接
  35002. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  35003. if err != nil {
  35004. }
  35005. defer conn.Close()
  35006. input2 := make(map[string]interface{})
  35007. input := make(map[string]interface{})
  35008. inputData := make(map[string]interface{})
  35009. inputData["orgId"] = code
  35010. inputData["businessType"] = "01101"
  35011. inputData["operatorId"] = operator_id
  35012. inputData["operatorName"] = operator_name
  35013. inputData["officeId"] = "001"
  35014. inputData["officeName"] = "血透室"
  35015. inputData["deviceType"] = ""
  35016. input["data"] = inputData
  35017. input["orgId"] = code
  35018. input["transType"] = "ec.query"
  35019. //if md == ""
  35020. if md[:4] == "4403" {
  35021. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  35022. } else if md[:4] == "4401" {
  35023. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  35024. } else {
  35025. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  35026. }
  35027. input2["indata"] = input
  35028. fmt.Println(input2)
  35029. bytesData, _ := json.Marshal(input2)
  35030. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  35031. if err != nil {
  35032. fmt.Println(err)
  35033. }
  35034. // 接收消息
  35035. _, receivedMessage, err := conn.ReadMessage()
  35036. if err != nil {
  35037. fmt.Println(err)
  35038. }
  35039. return "", string(receivedMessage)
  35040. }
  35041. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  35042. // WebSocket服务器地址
  35043. serverURL := "ws://127.0.0.1:8899"
  35044. // 解析WebSocket服务器地址
  35045. u, err := url.Parse(serverURL)
  35046. if err != nil {
  35047. }
  35048. // 建立WebSocket连接
  35049. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  35050. if err != nil {
  35051. }
  35052. defer conn.Close()
  35053. input2 := make(map[string]interface{})
  35054. input := make(map[string]interface{})
  35055. inputData := make(map[string]interface{})
  35056. inputData["orgId"] = code
  35057. inputData["businessType"] = "01301"
  35058. inputData["operatorId"] = operator_id
  35059. inputData["operatorName"] = operator_name
  35060. inputData["officeId"] = "001"
  35061. inputData["officeName"] = "血透室"
  35062. inputData["deviceType"] = ""
  35063. input["data"] = inputData
  35064. input["orgId"] = code
  35065. input["transType"] = "ec.query"
  35066. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  35067. input2["indata"] = input
  35068. bytesData, _ := json.Marshal(input2)
  35069. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  35070. if err != nil {
  35071. fmt.Println(err)
  35072. }
  35073. // 接收消息
  35074. _, receivedMessage, err := conn.ReadMessage()
  35075. if err != nil {
  35076. fmt.Println(err)
  35077. }
  35078. return "", string(receivedMessage)
  35079. }
  35080. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  35081. newArr = make([]string, 0)
  35082. for i := 0; i < len(arr); i++ {
  35083. repeat := false
  35084. for j := i + 1; j < len(arr); j++ {
  35085. if arr[i] == arr[j] {
  35086. repeat = true
  35087. break
  35088. }
  35089. }
  35090. if !repeat {
  35091. newArr = append(newArr, arr[i])
  35092. }
  35093. }
  35094. return
  35095. }
  35096. func getBirthdateAndAge(idNumber string) (string, int, error) {
  35097. if len(idNumber) != 18 {
  35098. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  35099. }
  35100. // 提取出生日期
  35101. year, err := strconv.Atoi(idNumber[6:10])
  35102. if err != nil {
  35103. return "", 0, err
  35104. }
  35105. month, err := strconv.Atoi(idNumber[10:12])
  35106. if err != nil {
  35107. return "", 0, err
  35108. }
  35109. day, err := strconv.Atoi(idNumber[12:14])
  35110. if err != nil {
  35111. return "", 0, err
  35112. }
  35113. // 格式化生日字符串
  35114. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  35115. birthdateFormatted := birthdate.Format("2006-01-02")
  35116. // 计算年龄
  35117. today := time.Now()
  35118. age := today.Year() - birthdate.Year()
  35119. if today.YearDay() < birthdate.YearDay() {
  35120. age--
  35121. }
  35122. return birthdateFormatted, age, nil
  35123. }
  35124. // 从身份证号码中提取出生年月日
  35125. func getBirthDateFromIDCard(idCard string) (string, error) {
  35126. // 身份证号码长度应为18位
  35127. if len(idCard) != 18 {
  35128. return "", fmt.Errorf("身份证号码长度应为18位")
  35129. }
  35130. // 提取出生日期部分 (YYYYMMDD)
  35131. birthDateStr := idCard[6:14]
  35132. // 解析出生日期
  35133. birthDate, err := time.Parse("20060102", birthDateStr)
  35134. if err != nil {
  35135. return "", fmt.Errorf("解析出生日期失败: %v", err)
  35136. }
  35137. // 格式化出生日期为 YYYY-MM-DD
  35138. formattedDate := birthDate.Format("2006-01-02")
  35139. return formattedDate, nil
  35140. }