his_api_controller.go 1.5MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113
  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. )
  38. type HisApiController struct {
  39. controllers.BaseAuthAPIController
  40. }
  41. func HisManagerApiRegistRouters() {
  42. //挂号
  43. beego.Router("/test/net", &HisApiController{}, "get:TestNet")
  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/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  161. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  162. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  163. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  164. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  165. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  166. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  167. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  168. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  169. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  170. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  171. }
  172. func (c *HisApiController) TestNet() {
  173. c.ServeSuccessJSON(map[string]interface{}{
  174. "msg": "成功",
  175. })
  176. }
  177. func (c *HisApiController) Get3508() {
  178. admin_user_id, _ := c.GetInt64("admin_user_id")
  179. drug_id, _ := c.GetInt64("id")
  180. start_time := c.GetString("start_time")
  181. end_time := c.GetString("end_time")
  182. adminUser := c.GetAdminUserInfo()
  183. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  184. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  185. drug, _ := service.GetDrugByID(drug_id)
  186. var struct3508 models.Struct3508
  187. struct3508.OrgName = miConfig.OrgName
  188. struct3508.FixmedinsCode = miConfig.Code
  189. struct3508.AccessKey = miConfig.AccessKey
  190. struct3508.Opter = curRoles.UserName
  191. struct3508.RequestUrl = miConfig.Url
  192. struct3508.Url = miConfig.Url
  193. struct3508.AppId = miConfig.Cainfo
  194. struct3508.AppSecret = miConfig.AppSecret
  195. struct3508.Enckey = miConfig.EncKey
  196. struct3508.SignKey = miConfig.SignKey
  197. struct3508.SecretKey = miConfig.SecretKey
  198. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  199. struct3508.Begndate = start_time
  200. struct3508.Enddate = end_time
  201. result1, result2, _ := service.FJyb3508(struct3508)
  202. saveLog(result1, result2, "3508", "3508")
  203. var res models.Result3508
  204. var respJSON2 map[string]interface{}
  205. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  206. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  208. return
  209. }
  210. userJSONBytes2, _ := json.Marshal(respJSON2)
  211. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  212. utils.ErrorLog("解析失败:%v", err)
  213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  214. return
  215. }
  216. if res.Infcode == -1 {
  217. c.ServeSuccessJSON(map[string]interface{}{
  218. "failed_code": -10,
  219. "msg": res.ErrMsg,
  220. })
  221. } else {
  222. c.ServeSuccessJSON(map[string]interface{}{
  223. "info": res.Output,
  224. })
  225. }
  226. }
  227. func (c *HisApiController) Get3509() {
  228. admin_user_id, _ := c.GetInt64("admin_user_id")
  229. drug_id, _ := c.GetInt64("id")
  230. start_time := c.GetString("start_time")
  231. end_time := c.GetString("end_time")
  232. adminUser := c.GetAdminUserInfo()
  233. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  234. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  235. drug, _ := service.GetDrugByID(drug_id)
  236. var struct3508 models.Struct3509
  237. struct3508.OrgName = miConfig.OrgName
  238. struct3508.FixmedinsCode = miConfig.Code
  239. struct3508.AccessKey = miConfig.AccessKey
  240. struct3508.Opter = curRoles.UserName
  241. struct3508.RequestUrl = miConfig.Url
  242. struct3508.Url = miConfig.Url
  243. struct3508.AppId = miConfig.Cainfo
  244. struct3508.AppSecret = miConfig.AppSecret
  245. struct3508.Enckey = miConfig.EncKey
  246. struct3508.SignKey = miConfig.SignKey
  247. struct3508.SecretKey = miConfig.SecretKey
  248. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  249. struct3508.Begndate = start_time
  250. struct3508.Enddate = end_time
  251. result1, result2, _ := service.FJyb3509(struct3508)
  252. saveLog(result1, result2, "3509", "3509")
  253. var res models.Result3509
  254. var respJSON2 map[string]interface{}
  255. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  256. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  258. return
  259. }
  260. userJSONBytes2, _ := json.Marshal(respJSON2)
  261. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  262. utils.ErrorLog("解析失败:%v", err)
  263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  264. return
  265. }
  266. if res.Infcode == -1 {
  267. c.ServeSuccessJSON(map[string]interface{}{
  268. "failed_code": -10,
  269. "msg": res.ErrMsg,
  270. })
  271. } else {
  272. c.ServeSuccessJSON(map[string]interface{}{
  273. "info": res.Output,
  274. })
  275. }
  276. }
  277. func (c *HisApiController) Get3510() {
  278. admin_user_id, _ := c.GetInt64("admin_user_id")
  279. drug_id, _ := c.GetInt64("id")
  280. start_time := c.GetString("start_time")
  281. end_time := c.GetString("end_time")
  282. adminUser := c.GetAdminUserInfo()
  283. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  284. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  285. drug, _ := service.GetDrugByID(drug_id)
  286. var struct3508 models.Struct3510
  287. struct3508.FixmedinsCode = miConfig.Code
  288. struct3508.OrgName = miConfig.OrgName
  289. struct3508.AccessKey = miConfig.AccessKey
  290. struct3508.Opter = curRoles.UserName
  291. struct3508.RequestUrl = miConfig.Url
  292. struct3508.Url = miConfig.Url
  293. struct3508.AppId = miConfig.Cainfo
  294. struct3508.AppSecret = miConfig.AppSecret
  295. struct3508.Enckey = miConfig.EncKey
  296. struct3508.SignKey = miConfig.SignKey
  297. struct3508.SecretKey = miConfig.SecretKey
  298. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  299. struct3508.Begndate = start_time
  300. struct3508.Enddate = end_time
  301. result1, result2, _ := service.FJyb3510(struct3508)
  302. saveLog(result1, result2, "3510", "3510")
  303. var res models.Result3510
  304. var respJSON2 map[string]interface{}
  305. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  306. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  308. return
  309. }
  310. userJSONBytes2, _ := json.Marshal(respJSON2)
  311. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  312. utils.ErrorLog("解析失败:%v", err)
  313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  314. return
  315. }
  316. if res.Infcode == -1 {
  317. c.ServeSuccessJSON(map[string]interface{}{
  318. "failed_code": -10,
  319. "msg": res.ErrMsg,
  320. })
  321. } else {
  322. c.ServeSuccessJSON(map[string]interface{}{
  323. "info": res.Output,
  324. })
  325. }
  326. }
  327. func (c *HisApiController) Get3511() {
  328. admin_user_id, _ := c.GetInt64("admin_user_id")
  329. drug_id, _ := c.GetInt64("id")
  330. start_time := c.GetString("start_time")
  331. end_time := c.GetString("end_time")
  332. adminUser := c.GetAdminUserInfo()
  333. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  334. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  335. drug, _ := service.GetDrugByID(drug_id)
  336. var struct3508 models.Struct3511
  337. struct3508.FixmedinsCode = miConfig.Code
  338. struct3508.OrgName = miConfig.OrgName
  339. struct3508.AccessKey = miConfig.AccessKey
  340. struct3508.Opter = curRoles.UserName
  341. struct3508.RequestUrl = miConfig.Url
  342. struct3508.Url = miConfig.Url
  343. struct3508.AppId = miConfig.Cainfo
  344. struct3508.AppSecret = miConfig.AppSecret
  345. struct3508.Enckey = miConfig.EncKey
  346. struct3508.SignKey = miConfig.SignKey
  347. struct3508.SecretKey = miConfig.SecretKey
  348. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  349. struct3508.Begndate = start_time
  350. struct3508.Enddate = end_time
  351. result1, result2, _ := service.FJyb3511(struct3508)
  352. saveLog(result1, result2, "3511", "3511")
  353. var res models.Result3511
  354. var respJSON2 map[string]interface{}
  355. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  356. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  358. return
  359. }
  360. userJSONBytes2, _ := json.Marshal(respJSON2)
  361. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  362. utils.ErrorLog("解析失败:%v", err)
  363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  364. return
  365. }
  366. if res.Infcode == -1 {
  367. c.ServeSuccessJSON(map[string]interface{}{
  368. "failed_code": -10,
  369. "msg": res.ErrMsg,
  370. })
  371. } else {
  372. c.ServeSuccessJSON(map[string]interface{}{
  373. "info": res.Output,
  374. })
  375. }
  376. }
  377. func (c *HisApiController) Get3512() {
  378. admin_user_id, _ := c.GetInt64("admin_user_id")
  379. drug_id, _ := c.GetInt64("id")
  380. start_time := c.GetString("start_time")
  381. end_time := c.GetString("end_time")
  382. adminUser := c.GetAdminUserInfo()
  383. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  384. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  385. drug, _ := service.GetDrugByID(drug_id)
  386. var struct3508 models.Struct3512
  387. struct3508.FixmedinsCode = miConfig.Code
  388. struct3508.OrgName = miConfig.OrgName
  389. struct3508.AccessKey = miConfig.AccessKey
  390. struct3508.Opter = curRoles.UserName
  391. struct3508.RequestUrl = miConfig.Url
  392. struct3508.Url = miConfig.Url
  393. struct3508.AppId = miConfig.Cainfo
  394. struct3508.AppSecret = miConfig.AppSecret
  395. struct3508.Enckey = miConfig.EncKey
  396. struct3508.SignKey = miConfig.SignKey
  397. struct3508.SecretKey = miConfig.SecretKey
  398. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  399. struct3508.Begndate = start_time
  400. struct3508.Enddate = end_time
  401. result1, result2, _ := service.FJyb3512(struct3508)
  402. saveLog(result1, result2, "3512", "3512")
  403. var res models.Result3512
  404. var respJSON2 map[string]interface{}
  405. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  406. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  408. return
  409. }
  410. userJSONBytes2, _ := json.Marshal(respJSON2)
  411. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  412. utils.ErrorLog("解析失败:%v", err)
  413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  414. return
  415. }
  416. if res.Infcode == -1 {
  417. c.ServeSuccessJSON(map[string]interface{}{
  418. "failed_code": -10,
  419. "msg": res.ErrMsg,
  420. })
  421. } else {
  422. c.ServeSuccessJSON(map[string]interface{}{
  423. "info": res.Output,
  424. })
  425. }
  426. }
  427. func (c *HisApiController) Get3513() {
  428. admin_user_id, _ := c.GetInt64("admin_user_id")
  429. drug_id, _ := c.GetInt64("id")
  430. start_time := c.GetString("start_time")
  431. end_time := c.GetString("end_time")
  432. adminUser := c.GetAdminUserInfo()
  433. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  434. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  435. drug, _ := service.GetDrugByID(drug_id)
  436. var struct3508 models.Struct3513
  437. struct3508.FixmedinsCode = miConfig.Code
  438. struct3508.OrgName = miConfig.OrgName
  439. struct3508.AccessKey = miConfig.AccessKey
  440. struct3508.Opter = curRoles.UserName
  441. struct3508.RequestUrl = miConfig.Url
  442. struct3508.Url = miConfig.Url
  443. struct3508.AppId = miConfig.Cainfo
  444. struct3508.AppSecret = miConfig.AppSecret
  445. struct3508.Enckey = miConfig.EncKey
  446. struct3508.SignKey = miConfig.SignKey
  447. struct3508.SecretKey = miConfig.SecretKey
  448. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  449. struct3508.Begndate = start_time
  450. struct3508.Enddate = end_time
  451. result1, result2, _ := service.FJyb3513(struct3508)
  452. saveLog(result1, result2, "3513", "3513")
  453. var res models.Result3513
  454. var respJSON2 map[string]interface{}
  455. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  456. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  458. return
  459. }
  460. userJSONBytes2, _ := json.Marshal(respJSON2)
  461. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  462. utils.ErrorLog("解析失败:%v", err)
  463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  464. return
  465. }
  466. if res.Infcode == -1 {
  467. c.ServeSuccessJSON(map[string]interface{}{
  468. "failed_code": -10,
  469. "msg": res.ErrMsg,
  470. })
  471. } else {
  472. c.ServeSuccessJSON(map[string]interface{}{
  473. "info": res.Output,
  474. })
  475. }
  476. }
  477. func (c *HisApiController) Get35081() {
  478. admin_user_id, _ := c.GetInt64("admin_user_id")
  479. drug_id, _ := c.GetInt64("id")
  480. //start_time := c.GetString("start_time")
  481. //end_time := c.GetString("end_time")
  482. page, _ := c.GetInt("page")
  483. adminUser := c.GetAdminUserInfo()
  484. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  485. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  486. drug, _ := service.GetDrugByID(drug_id)
  487. var struct3508 models.Struct35081
  488. struct3508.FixmedinsCode = miConfig.Code
  489. struct3508.OrgName = miConfig.OrgName
  490. struct3508.AccessKey = miConfig.AccessKey
  491. struct3508.Opter = curRoles.UserName
  492. struct3508.RequestUrl = miConfig.Url
  493. struct3508.Url = miConfig.Url
  494. struct3508.AppId = miConfig.Cainfo
  495. struct3508.AppSecret = miConfig.AppSecret
  496. struct3508.Enckey = miConfig.EncKey
  497. struct3508.SignKey = miConfig.SignKey
  498. struct3508.SecretKey = miConfig.SecretKey
  499. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  500. struct3508.PageNum = page
  501. struct3508.PageSize = 10
  502. result1, result2, _ := service.FJyb35081(struct3508)
  503. saveLog(result1, result2, "35081", "35081")
  504. var res models.Result35081
  505. var respJSON2 map[string]interface{}
  506. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  509. return
  510. }
  511. userJSONBytes2, _ := json.Marshal(respJSON2)
  512. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  513. utils.ErrorLog("解析失败:%v", err)
  514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  515. return
  516. }
  517. if res.Infcode == -1 {
  518. c.ServeSuccessJSON(map[string]interface{}{
  519. "failed_code": -10,
  520. "msg": res.ErrMsg,
  521. })
  522. } else {
  523. c.ServeSuccessJSON(map[string]interface{}{
  524. "info": res.Output,
  525. })
  526. }
  527. }
  528. func (c *HisApiController) Get35082() {
  529. admin_user_id, _ := c.GetInt64("admin_user_id")
  530. drug_id, _ := c.GetInt64("id")
  531. //start_time := c.GetString("start_time")
  532. //end_time := c.GetString("end_time")
  533. page, _ := c.GetInt("page")
  534. adminUser := c.GetAdminUserInfo()
  535. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  536. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  537. drug, _ := service.GetDrugByID(drug_id)
  538. var struct3508 models.Struct35082
  539. struct3508.FixmedinsCode = miConfig.Code
  540. struct3508.OrgName = miConfig.OrgName
  541. struct3508.AccessKey = miConfig.AccessKey
  542. struct3508.Opter = curRoles.UserName
  543. struct3508.RequestUrl = miConfig.Url
  544. struct3508.Url = miConfig.Url
  545. struct3508.AppId = miConfig.Cainfo
  546. struct3508.AppSecret = miConfig.AppSecret
  547. struct3508.Enckey = miConfig.EncKey
  548. struct3508.SignKey = miConfig.SignKey
  549. struct3508.SecretKey = miConfig.SecretKey
  550. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  551. struct3508.PageNum = page
  552. struct3508.PageSize = 10
  553. result1, result2, _ := service.FJyb35082(struct3508)
  554. saveLog(result1, result2, "35082", "35082")
  555. var res models.Result35082
  556. var respJSON2 map[string]interface{}
  557. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  558. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  560. return
  561. }
  562. userJSONBytes2, _ := json.Marshal(respJSON2)
  563. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  564. utils.ErrorLog("解析失败:%v", err)
  565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  566. return
  567. }
  568. if res.Infcode == -1 {
  569. c.ServeSuccessJSON(map[string]interface{}{
  570. "failed_code": -10,
  571. "msg": res.ErrMsg,
  572. })
  573. } else {
  574. c.ServeSuccessJSON(map[string]interface{}{
  575. "info": res.Output,
  576. })
  577. }
  578. }
  579. func (c *HisApiController) FJ3501AND3502() {
  580. ids := c.GetString("ids")
  581. admin_user_id, _ := c.GetInt64("admin_user_id")
  582. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  583. id_arr := strings.Split(ids, ",")
  584. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  585. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  586. //库盘
  587. var errs []string
  588. for _, drug := range drugs {
  589. if drug.IsPc == 0 && drug.IsBg == 0 {
  590. var res2 ResultSix
  591. var res3 ResultSix
  592. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  593. var struct3501 models.Struct3501
  594. struct3501.Code = miConfig.Code
  595. struct3501.OrgName = miConfig.OrgName
  596. struct3501.AccessKey = miConfig.AccessKey
  597. struct3501.Opter = roles.UserName
  598. struct3501.RequestUrl = miConfig.Url
  599. struct3501.Url = miConfig.Url
  600. struct3501.AppId = miConfig.Cainfo
  601. struct3501.AppSecret = miConfig.AppSecret
  602. struct3501.Enckey = miConfig.EncKey
  603. struct3501.SignKey = miConfig.SignKey
  604. struct3501.SecretKey = miConfig.SecretKey
  605. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  606. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  607. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  608. struct3501.RxFlag = "0"
  609. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  610. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  611. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  612. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  613. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  614. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  615. struct3501.FixmedinsBchno = number
  616. struct3501.DrugTracCodg = drug.DrugCode
  617. memo := make(map[string]interface{})
  618. memo["pric"] = drug.Price
  619. bytesData, _ := json.Marshal(memo)
  620. struct3501.Memo = string(bytesData)
  621. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  622. result1, result2, _ := service.FJyb3501(struct3501)
  623. saveLog(result1, result2, "3501", "3501")
  624. //saveLog(result, requestLog, "2201", "挂号")
  625. var respJSON2 map[string]interface{}
  626. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  627. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  629. return
  630. }
  631. userJSONBytes2, _ := json.Marshal(respJSON2)
  632. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  633. utils.ErrorLog("解析失败:%v", err)
  634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  635. return
  636. }
  637. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  638. data := make(map[string]interface{})
  639. data["struct_3501s"] = struct3501
  640. client := &http.Client{}
  641. bytesData, _ := json.Marshal(data)
  642. var req *http.Request
  643. if miConfig.MdtrtareaAdmvs == "320921" {
  644. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  645. } else {
  646. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  647. }
  648. resp, _ := client.Do(req)
  649. defer resp.Body.Close()
  650. body, ioErr := ioutil.ReadAll(resp.Body)
  651. if ioErr != nil {
  652. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  653. }
  654. var respJSON map[string]interface{}
  655. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  658. return
  659. }
  660. var resSix10265 ResultSix10265 //1101结果
  661. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  662. result, _ := json.Marshal(respJSON)
  663. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  664. utils.ErrorLog("解析失败:%v", err)
  665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  666. return
  667. }
  668. res2.InfRefmsgid = resSix10265.InfRefmsgid
  669. res2.Output = resSix10265.Output
  670. res2.ErrMsg = resSix10265.ErrMsg
  671. res2.Cainfo = resSix10265.Cainfo
  672. res2.WarnMsg = resSix10265.WarnMsg
  673. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  674. res2.Infcode = infocode
  675. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  676. data := make(map[string]interface{})
  677. data["struct_3501s"] = struct3501
  678. client := &http.Client{}
  679. bytesData, _ := json.Marshal(data)
  680. var req *http.Request
  681. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  682. resp, _ := client.Do(req)
  683. defer resp.Body.Close()
  684. body, ioErr := ioutil.ReadAll(resp.Body)
  685. if ioErr != nil {
  686. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  687. }
  688. var respJSON map[string]interface{}
  689. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  690. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  692. return
  693. }
  694. var resSix10265 ResultSix10265 //1101结果
  695. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  696. result, _ := json.Marshal(respJSON)
  697. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  698. utils.ErrorLog("解析失败:%v", err)
  699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  700. return
  701. }
  702. res2.InfRefmsgid = resSix10265.InfRefmsgid
  703. res2.Output = resSix10265.Output
  704. res2.ErrMsg = resSix10265.ErrMsg
  705. res2.Cainfo = resSix10265.Cainfo
  706. res2.WarnMsg = resSix10265.WarnMsg
  707. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  708. res2.Infcode = infocode
  709. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  710. data := make(map[string]interface{})
  711. data["struct_3501s"] = struct3501
  712. client := &http.Client{}
  713. bytesData, _ := json.Marshal(data)
  714. var req *http.Request
  715. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  716. resp, _ := client.Do(req)
  717. defer resp.Body.Close()
  718. body, ioErr := ioutil.ReadAll(resp.Body)
  719. if ioErr != nil {
  720. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  721. }
  722. var respJSON map[string]interface{}
  723. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  724. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  726. return
  727. }
  728. var resSix10265 ResultSix10265 //1101结果
  729. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  730. result, _ := json.Marshal(respJSON)
  731. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  732. utils.ErrorLog("解析失败:%v", err)
  733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  734. return
  735. }
  736. res2.InfRefmsgid = resSix10265.InfRefmsgid
  737. res2.Output = resSix10265.Output
  738. res2.ErrMsg = resSix10265.ErrMsg
  739. res2.Cainfo = resSix10265.Cainfo
  740. res2.WarnMsg = resSix10265.WarnMsg
  741. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  742. res2.Infcode = infocode
  743. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") { //广东
  744. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  745. saveLog(result1, result2, "3501", "3501")
  746. //saveLog(result, requestLog, "2201", "挂号")
  747. var respJSON2 map[string]interface{}
  748. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  749. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  751. return
  752. }
  753. userJSONBytes2, _ := json.Marshal(respJSON2)
  754. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  755. utils.ErrorLog("解析失败:%v", err)
  756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  757. return
  758. }
  759. }
  760. if res2.Infcode != -1 {
  761. drug.IsPc = 1
  762. drug.Bchno = number
  763. drug.PcDate = time.Now().Unix()
  764. err := service.SaveW(drug)
  765. if err == nil {
  766. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  767. var struct3502 models.Struct3502
  768. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  769. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  770. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  771. struct3502.FixmedinsCode = miConfig.Code
  772. struct3502.Code = miConfig.Code
  773. struct3502.RxFlag = "0"
  774. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  775. struct3502.OrgName = miConfig.OrgName
  776. struct3502.Opter = roles.UserName
  777. struct3502.AccessKey = miConfig.AccessKey
  778. struct3502.RequestUrl = miConfig.Url
  779. struct3502.SecretKey = miConfig.SecretKey
  780. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  781. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  782. struct3502.Url = miConfig.Url
  783. struct3502.AppId = miConfig.Cainfo
  784. struct3502.AppSecret = miConfig.AppSecret
  785. struct3502.Enckey = miConfig.EncKey
  786. struct3502.SignKey = miConfig.SignKey
  787. struct3502.SecretKey = miConfig.SecretKey
  788. struct3502.DrugTracCodg = drug.DrugCode
  789. struct3502.Memo = ""
  790. struct3502.InvChgType = "108"
  791. struct3502.FixmedinsBchno = bg_number
  792. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  793. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  794. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  795. result11, result22, _ := service.FJyb3502(struct3502)
  796. saveLog(result11, result22, "3502", "3502")
  797. var respJSON3 map[string]interface{}
  798. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  799. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  801. return
  802. }
  803. userJSONBytes3, _ := json.Marshal(respJSON3)
  804. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  805. utils.ErrorLog("解析失败:%v", err)
  806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  807. return
  808. }
  809. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  810. data := make(map[string]interface{})
  811. data["struct_3502s"] = struct3502
  812. client := &http.Client{}
  813. bytesData, _ := json.Marshal(data)
  814. var req *http.Request
  815. if miConfig.MdtrtareaAdmvs == "320921" {
  816. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  817. } else {
  818. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  819. }
  820. resp, _ := client.Do(req)
  821. defer resp.Body.Close()
  822. body, ioErr := ioutil.ReadAll(resp.Body)
  823. if ioErr != nil {
  824. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  825. }
  826. var respJSON map[string]interface{}
  827. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  828. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  830. return
  831. }
  832. var resSix10265 ResultSix10265 //1101结果
  833. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  834. result, _ := json.Marshal(respJSON)
  835. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  836. utils.ErrorLog("解析失败:%v", err)
  837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  838. return
  839. }
  840. res3.InfRefmsgid = resSix10265.InfRefmsgid
  841. res3.Output = resSix10265.Output
  842. res3.ErrMsg = resSix10265.ErrMsg
  843. res3.Cainfo = resSix10265.Cainfo
  844. res3.WarnMsg = resSix10265.WarnMsg
  845. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  846. res3.Infcode = infocode
  847. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  848. data := make(map[string]interface{})
  849. data["struct_3502s"] = struct3502
  850. client := &http.Client{}
  851. bytesData, _ := json.Marshal(data)
  852. var req *http.Request
  853. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  854. resp, _ := client.Do(req)
  855. defer resp.Body.Close()
  856. body, ioErr := ioutil.ReadAll(resp.Body)
  857. if ioErr != nil {
  858. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  859. }
  860. var respJSON map[string]interface{}
  861. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  862. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  864. return
  865. }
  866. var resSix10265 ResultSix10265 //1101结果
  867. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  868. result, _ := json.Marshal(respJSON)
  869. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  870. utils.ErrorLog("解析失败:%v", err)
  871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  872. return
  873. }
  874. res3.InfRefmsgid = resSix10265.InfRefmsgid
  875. res3.Output = resSix10265.Output
  876. res3.ErrMsg = resSix10265.ErrMsg
  877. res3.Cainfo = resSix10265.Cainfo
  878. res3.WarnMsg = resSix10265.WarnMsg
  879. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  880. res3.Infcode = infocode
  881. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  882. data := make(map[string]interface{})
  883. data["struct_3501s"] = struct3501
  884. client := &http.Client{}
  885. bytesData, _ := json.Marshal(data)
  886. var req *http.Request
  887. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  888. resp, _ := client.Do(req)
  889. defer resp.Body.Close()
  890. body, ioErr := ioutil.ReadAll(resp.Body)
  891. if ioErr != nil {
  892. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  893. }
  894. var respJSON map[string]interface{}
  895. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  896. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  898. return
  899. }
  900. var resSix10265 ResultSix10265 //1101结果
  901. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  902. result, _ := json.Marshal(respJSON)
  903. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  904. utils.ErrorLog("解析失败:%v", err)
  905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  906. return
  907. }
  908. res2.InfRefmsgid = resSix10265.InfRefmsgid
  909. res2.Output = resSix10265.Output
  910. res2.ErrMsg = resSix10265.ErrMsg
  911. res2.Cainfo = resSix10265.Cainfo
  912. res2.WarnMsg = resSix10265.WarnMsg
  913. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  914. res2.Infcode = infocode
  915. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  916. result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  917. saveLog(result11, result22, "3502", "3502")
  918. var respJSON3 map[string]interface{}
  919. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  922. return
  923. }
  924. userJSONBytes3, _ := json.Marshal(respJSON3)
  925. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  926. utils.ErrorLog("解析失败:%v", err)
  927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  928. return
  929. }
  930. }
  931. if res3.Infcode == -1 {
  932. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  933. c.ServeSuccessJSON(map[string]interface{}{
  934. "failed_code": -10,
  935. "msg": res3.ErrMsg,
  936. })
  937. } else {
  938. drug.IsBg = 1
  939. drug.BgBchno = bg_number
  940. service.SaveW(drug)
  941. }
  942. }
  943. } else {
  944. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  945. }
  946. }
  947. //变更
  948. if drug.IsPc == 1 && drug.IsBg == 0 {
  949. var res3 ResultSix
  950. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  951. var struct3502 models.Struct3502
  952. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  953. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  954. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  955. struct3502.FixmedinsCode = miConfig.Code
  956. struct3502.Code = miConfig.Code
  957. struct3502.Opter = roles.UserName
  958. struct3502.RxFlag = "0"
  959. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  960. struct3502.OrgName = miConfig.OrgName
  961. struct3502.AccessKey = miConfig.AccessKey
  962. struct3502.RequestUrl = miConfig.Url
  963. struct3502.SecretKey = miConfig.SecretKey
  964. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  965. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  966. struct3502.InvChgType = "108"
  967. struct3502.DrugTracCodg = drug.DrugCode
  968. struct3502.Url = miConfig.Url
  969. struct3502.AppId = miConfig.Cainfo
  970. struct3502.AppSecret = miConfig.AppSecret
  971. struct3502.Enckey = miConfig.EncKey
  972. struct3502.SignKey = miConfig.SignKey
  973. struct3502.SecretKey = miConfig.SecretKey
  974. struct3502.FixmedinsBchno = bg_number
  975. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  976. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  977. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  978. result1, result2, _ := service.FJyb3502(struct3502)
  979. saveLog(result1, result2, "3502", "3502")
  980. var respJSON3 map[string]interface{}
  981. if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  982. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  984. return
  985. }
  986. userJSONBytes3, _ := json.Marshal(respJSON3)
  987. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  988. utils.ErrorLog("解析失败:%v", err)
  989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  990. return
  991. }
  992. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  993. data := make(map[string]interface{})
  994. data["struct_3502s"] = struct3502
  995. client := &http.Client{}
  996. bytesData, _ := json.Marshal(data)
  997. var req *http.Request
  998. if miConfig.MdtrtareaAdmvs == "320921" {
  999. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1000. } else {
  1001. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1002. }
  1003. resp, _ := client.Do(req)
  1004. defer resp.Body.Close()
  1005. body, ioErr := ioutil.ReadAll(resp.Body)
  1006. if ioErr != nil {
  1007. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1008. }
  1009. var respJSON map[string]interface{}
  1010. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1011. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1013. return
  1014. }
  1015. var resSix10265 ResultSix10265 //1101结果
  1016. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1017. result, _ := json.Marshal(respJSON)
  1018. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1019. utils.ErrorLog("解析失败:%v", err)
  1020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1021. return
  1022. }
  1023. res3.InfRefmsgid = resSix10265.InfRefmsgid
  1024. res3.Output = resSix10265.Output
  1025. res3.ErrMsg = resSix10265.ErrMsg
  1026. res3.Cainfo = resSix10265.Cainfo
  1027. res3.WarnMsg = resSix10265.WarnMsg
  1028. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1029. res3.Infcode = infocode
  1030. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  1031. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  1032. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  1033. }
  1034. if res3.Infcode == -1 {
  1035. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  1036. } else {
  1037. drug.IsBg = 1
  1038. drug.BgBchno = bg_number
  1039. service.SaveW(drug)
  1040. }
  1041. }
  1042. }
  1043. if len(errs) == 0 {
  1044. c.ServeSuccessJSON(map[string]interface{}{
  1045. "msg": "盘存变更成功",
  1046. })
  1047. } else {
  1048. c.ServeSuccessJSON(map[string]interface{}{
  1049. "failed_code": -10,
  1050. "msg": errs,
  1051. })
  1052. }
  1053. }
  1054. func (c *HisApiController) DeletePCandBG() {
  1055. ids := c.GetString("ids")
  1056. id_arr := strings.Split(ids, ",")
  1057. admin_user_id, _ := c.GetInt64("admin_user_id")
  1058. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1059. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1060. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1061. var err []string
  1062. for _, item := range drugs {
  1063. if item.IsPc == 1 && item.IsBg == 1 {
  1064. var res FJ3507Result
  1065. var res2 FJ3507Result
  1066. var struct3507 models.Struct3507
  1067. struct3507.FixmedinsBchno = item.Bchno
  1068. struct3507.InvDataType = "1"
  1069. struct3507.Opter = roles.UserName
  1070. struct3507.OrgName = miConfig.OrgName
  1071. struct3507.AccessKey = miConfig.AccessKey
  1072. struct3507.RequestUrl = miConfig.Url
  1073. struct3507.FixmedinsCode = miConfig.Code
  1074. struct3507.Code = miConfig.Code
  1075. struct3507.SecretKey = miConfig.SecretKey
  1076. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1077. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1078. struct3507.Url = miConfig.Url
  1079. struct3507.AppId = miConfig.Cainfo
  1080. struct3507.AppSecret = miConfig.AppSecret
  1081. struct3507.Enckey = miConfig.EncKey
  1082. struct3507.SignKey = miConfig.SignKey
  1083. struct3507.SecretKey = miConfig.SecretKey
  1084. if miConfig.MdtrtareaAdmvs == "350500" {
  1085. result, result1, _ := service.FJyb3507(struct3507)
  1086. saveLog(result, result1, "3507", "3507")
  1087. var respJSON2 map[string]interface{}
  1088. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1089. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1091. return
  1092. }
  1093. userJSONBytes2, _ := json.Marshal(respJSON2)
  1094. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1095. utils.ErrorLog("解析失败:%v", err)
  1096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1097. return
  1098. }
  1099. } else {
  1100. data := make(map[string]interface{})
  1101. data["struct_3507s"] = struct3507
  1102. client := &http.Client{}
  1103. bytesData, _ := json.Marshal(data)
  1104. var req *http.Request
  1105. if miConfig.MdtrtareaAdmvs == "320921" {
  1106. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1107. } else {
  1108. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1109. }
  1110. resp, _ := client.Do(req)
  1111. defer resp.Body.Close()
  1112. body, ioErr := ioutil.ReadAll(resp.Body)
  1113. if ioErr != nil {
  1114. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1115. }
  1116. var respJSON map[string]interface{}
  1117. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1118. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1120. return
  1121. }
  1122. var resSix10265 ResultSix10265 //1101结果
  1123. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1124. result, _ := json.Marshal(respJSON)
  1125. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1126. utils.ErrorLog("解析失败:%v", err)
  1127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1128. return
  1129. }
  1130. res.InfRefmsgid = resSix10265.InfRefmsgid
  1131. //res.Output = resSix10265.Output
  1132. res.ErrMsg = resSix10265.ErrMsg
  1133. res.Cainfo = resSix10265.Cainfo
  1134. res.WarnMsg = resSix10265.WarnMsg
  1135. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1136. res.Infcode = infocode
  1137. }
  1138. if res.Infcode == 0 {
  1139. item.IsPc = 0
  1140. err2 := service.SaveW(item)
  1141. if err2 == nil {
  1142. var struct3507_2 models.Struct3507
  1143. struct3507_2.OrgName = miConfig.OrgName
  1144. struct3507_2.AccessKey = miConfig.AccessKey
  1145. struct3507_2.RequestUrl = miConfig.Url
  1146. struct3507_2.Opter = roles.UserName
  1147. struct3507_2.FixmedinsCode = miConfig.Code
  1148. struct3507_2.Code = miConfig.Code
  1149. struct3507_2.SecretKey = miConfig.SecretKey
  1150. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1151. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1152. struct3507_2.Url = miConfig.Url
  1153. struct3507_2.AppId = miConfig.Cainfo
  1154. struct3507_2.AppSecret = miConfig.AppSecret
  1155. struct3507_2.Enckey = miConfig.EncKey
  1156. struct3507_2.SignKey = miConfig.SignKey
  1157. struct3507_2.SecretKey = miConfig.SecretKey
  1158. struct3507_2.FixmedinsBchno = item.BgBchno
  1159. struct3507_2.InvDataType = "2"
  1160. if miConfig.MdtrtareaAdmvs == "350500" {
  1161. result11, result22, _ := service.FJyb3507(struct3507_2)
  1162. saveLog(result11, result22, "3507", "3507")
  1163. var respJSON3 map[string]interface{}
  1164. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1167. return
  1168. }
  1169. userJSONBytes3, _ := json.Marshal(respJSON3)
  1170. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1171. utils.ErrorLog("解析失败:%v", err)
  1172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1173. return
  1174. }
  1175. } else {
  1176. data := make(map[string]interface{})
  1177. data["struct_3507s"] = struct3507_2
  1178. client := &http.Client{}
  1179. bytesData, _ := json.Marshal(data)
  1180. var req *http.Request
  1181. if miConfig.MdtrtareaAdmvs == "320921" {
  1182. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1183. } else {
  1184. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1185. }
  1186. resp, _ := client.Do(req)
  1187. defer resp.Body.Close()
  1188. body, ioErr := ioutil.ReadAll(resp.Body)
  1189. if ioErr != nil {
  1190. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1191. }
  1192. var respJSON map[string]interface{}
  1193. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1194. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1196. return
  1197. }
  1198. var resSix10265 ResultSix10265 //1101结果
  1199. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1200. result, _ := json.Marshal(respJSON)
  1201. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1202. utils.ErrorLog("解析失败:%v", err)
  1203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1204. return
  1205. }
  1206. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1207. //res2.Output = resSix10265.Output
  1208. res2.ErrMsg = resSix10265.ErrMsg
  1209. res2.Cainfo = resSix10265.Cainfo
  1210. res2.WarnMsg = resSix10265.WarnMsg
  1211. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1212. res2.Infcode = infocode
  1213. }
  1214. if res2.Infcode != -1 {
  1215. item.IsBg = 0
  1216. item.Bchno = ""
  1217. item.BgBchno = ""
  1218. item.PcDate = 0
  1219. service.SaveW(item)
  1220. } else {
  1221. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1222. }
  1223. }
  1224. } else {
  1225. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1226. }
  1227. }
  1228. if item.IsPc == 1 && item.IsBg == 0 {
  1229. var res FJ3507Result
  1230. var struct3507 models.Struct3507
  1231. struct3507.FixmedinsBchno = item.Bchno
  1232. struct3507.InvDataType = "1"
  1233. struct3507.Opter = roles.UserName
  1234. struct3507.FixmedinsCode = miConfig.Code
  1235. struct3507.Code = miConfig.Code
  1236. struct3507.OrgName = miConfig.OrgName
  1237. struct3507.AccessKey = miConfig.AccessKey
  1238. struct3507.RequestUrl = miConfig.Url
  1239. struct3507.SecretKey = miConfig.SecretKey
  1240. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1241. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1242. struct3507.Url = miConfig.Url
  1243. struct3507.AppId = miConfig.Cainfo
  1244. struct3507.AppSecret = miConfig.AppSecret
  1245. struct3507.Enckey = miConfig.EncKey
  1246. struct3507.SignKey = miConfig.SignKey
  1247. struct3507.SecretKey = miConfig.SecretKey
  1248. //result, result1, _ := service.FJyb3507(struct3507)
  1249. //saveLog(result, result1, "3507", "3507")
  1250. if miConfig.MdtrtareaAdmvs == "350500" {
  1251. result, result1, _ := service.FJyb3507(struct3507)
  1252. saveLog(result, result1, "3507", "3507")
  1253. var respJSON2 map[string]interface{}
  1254. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1255. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1257. return
  1258. }
  1259. userJSONBytes2, _ := json.Marshal(respJSON2)
  1260. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1261. utils.ErrorLog("解析失败:%v", err)
  1262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1263. return
  1264. }
  1265. } else {
  1266. data := make(map[string]interface{})
  1267. data["struct_3507s"] = struct3507
  1268. client := &http.Client{}
  1269. bytesData, _ := json.Marshal(data)
  1270. var req *http.Request
  1271. if miConfig.MdtrtareaAdmvs == "320921" {
  1272. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1273. } else {
  1274. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1275. }
  1276. resp, _ := client.Do(req)
  1277. defer resp.Body.Close()
  1278. body, ioErr := ioutil.ReadAll(resp.Body)
  1279. if ioErr != nil {
  1280. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1281. }
  1282. var respJSON map[string]interface{}
  1283. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1284. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1286. return
  1287. }
  1288. var resSix10265 ResultSix10265 //1101结果
  1289. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1290. result, _ := json.Marshal(respJSON)
  1291. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1292. utils.ErrorLog("解析失败:%v", err)
  1293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1294. return
  1295. }
  1296. res.InfRefmsgid = resSix10265.InfRefmsgid
  1297. //res.Output = resSix10265.Output
  1298. res.ErrMsg = resSix10265.ErrMsg
  1299. res.Cainfo = resSix10265.Cainfo
  1300. res.WarnMsg = resSix10265.WarnMsg
  1301. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1302. res.Infcode = infocode
  1303. }
  1304. if res.Infcode == 0 {
  1305. item.IsPc = 0
  1306. item.Bchno = ""
  1307. item.BgBchno = ""
  1308. item.PcDate = 0
  1309. service.SaveW(item)
  1310. } else {
  1311. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1312. }
  1313. }
  1314. if item.IsPc == 0 && item.IsBg == 1 {
  1315. var res FJ3507Result
  1316. var struct3507 models.Struct3507
  1317. struct3507.FixmedinsBchno = item.BgBchno
  1318. struct3507.InvDataType = "2"
  1319. struct3507.Opter = roles.UserName
  1320. struct3507.FixmedinsCode = miConfig.Code
  1321. struct3507.OrgName = miConfig.OrgName
  1322. struct3507.AccessKey = miConfig.AccessKey
  1323. struct3507.RequestUrl = miConfig.Url
  1324. struct3507.SecretKey = miConfig.SecretKey
  1325. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1326. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1327. struct3507.Url = miConfig.Url
  1328. struct3507.AppId = miConfig.Cainfo
  1329. struct3507.AppSecret = miConfig.AppSecret
  1330. struct3507.Enckey = miConfig.EncKey
  1331. struct3507.SignKey = miConfig.SignKey
  1332. struct3507.SecretKey = miConfig.SecretKey
  1333. //result, result1, _ := service.FJyb3507(struct3507)
  1334. //saveLog(result, result1, "3507", "3507")
  1335. if miConfig.MdtrtareaAdmvs == "350500" {
  1336. result, result1, _ := service.FJyb3507(struct3507)
  1337. saveLog(result, result1, "3507", "3507")
  1338. var respJSON2 map[string]interface{}
  1339. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1340. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1342. return
  1343. }
  1344. userJSONBytes2, _ := json.Marshal(respJSON2)
  1345. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1346. utils.ErrorLog("解析失败:%v", err)
  1347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1348. return
  1349. }
  1350. } else {
  1351. data := make(map[string]interface{})
  1352. data["struct_3507s"] = struct3507
  1353. client := &http.Client{}
  1354. bytesData, _ := json.Marshal(data)
  1355. var req *http.Request
  1356. if miConfig.MdtrtareaAdmvs == "320921" {
  1357. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1358. } else {
  1359. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1360. }
  1361. resp, _ := client.Do(req)
  1362. defer resp.Body.Close()
  1363. body, ioErr := ioutil.ReadAll(resp.Body)
  1364. if ioErr != nil {
  1365. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1366. }
  1367. var respJSON map[string]interface{}
  1368. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1371. return
  1372. }
  1373. var resSix10265 ResultSix10265 //1101结果
  1374. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1375. result, _ := json.Marshal(respJSON)
  1376. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1377. utils.ErrorLog("解析失败:%v", err)
  1378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1379. return
  1380. }
  1381. res.InfRefmsgid = resSix10265.InfRefmsgid
  1382. //res.Output = resSix10265.Output
  1383. res.ErrMsg = resSix10265.ErrMsg
  1384. res.Cainfo = resSix10265.Cainfo
  1385. res.WarnMsg = resSix10265.WarnMsg
  1386. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1387. res.Infcode = infocode
  1388. }
  1389. if res.Infcode == 0 {
  1390. item.IsBg = 0
  1391. item.Bchno = ""
  1392. item.BgBchno = ""
  1393. item.PcDate = 0
  1394. service.SaveW(item)
  1395. } else {
  1396. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1397. }
  1398. }
  1399. }
  1400. if len(err) == 0 {
  1401. c.ServeSuccessJSON(map[string]interface{}{
  1402. "msg": "删除盘存变更成功",
  1403. })
  1404. } else {
  1405. c.ServeSuccessJSON(map[string]interface{}{
  1406. "failed_code": -10,
  1407. "msg": err,
  1408. })
  1409. }
  1410. }
  1411. func (c *HisApiController) DeleteXSandBG() {
  1412. ids := c.GetString("ids")
  1413. id_arr := strings.Split(ids, ",")
  1414. admin_user_id, _ := c.GetInt64("admin_user_id")
  1415. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1416. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1417. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1418. var err []string
  1419. for _, item := range flows {
  1420. if item.IsSale == 1 && item.IsChange == 1 {
  1421. var res FJ3507Result
  1422. var res2 FJ3507Result
  1423. var struct3507 models.Struct3507
  1424. struct3507.FixmedinsBchno = item.Bchno
  1425. struct3507.InvDataType = "4"
  1426. struct3507.Opter = roles.UserName
  1427. struct3507.OrgName = miConfig.OrgName
  1428. struct3507.AccessKey = miConfig.AccessKey
  1429. struct3507.RequestUrl = miConfig.Url
  1430. struct3507.FixmedinsCode = miConfig.Code
  1431. struct3507.SecretKey = miConfig.SecretKey
  1432. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1433. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1434. struct3507.Url = miConfig.Url
  1435. struct3507.AppId = miConfig.Cainfo
  1436. struct3507.AppSecret = miConfig.AppSecret
  1437. struct3507.Enckey = miConfig.EncKey
  1438. struct3507.SignKey = miConfig.SignKey
  1439. struct3507.SecretKey = miConfig.SecretKey
  1440. //result, result1, _ := service.FJyb3507(struct3507)
  1441. //saveLog(result, result1, "3507", "3507")
  1442. if miConfig.MdtrtareaAdmvs == "350500" {
  1443. result, result1, _ := service.FJyb3507(struct3507)
  1444. saveLog(result, result1, "3507", "3507")
  1445. var respJSON2 map[string]interface{}
  1446. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1447. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1449. return
  1450. }
  1451. userJSONBytes2, _ := json.Marshal(respJSON2)
  1452. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1453. utils.ErrorLog("解析失败:%v", err)
  1454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1455. return
  1456. }
  1457. } else {
  1458. data := make(map[string]interface{})
  1459. data["struct_3507s"] = struct3507
  1460. client := &http.Client{}
  1461. bytesData, _ := json.Marshal(data)
  1462. var req *http.Request
  1463. if miConfig.MdtrtareaAdmvs == "320921" {
  1464. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1465. } else {
  1466. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1467. }
  1468. resp, _ := client.Do(req)
  1469. defer resp.Body.Close()
  1470. body, ioErr := ioutil.ReadAll(resp.Body)
  1471. if ioErr != nil {
  1472. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1473. }
  1474. var respJSON map[string]interface{}
  1475. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1476. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1478. return
  1479. }
  1480. var resSix10265 ResultSix10265 //1101结果
  1481. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1482. result, _ := json.Marshal(respJSON)
  1483. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1484. utils.ErrorLog("解析失败:%v", err)
  1485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1486. return
  1487. }
  1488. res.InfRefmsgid = resSix10265.InfRefmsgid
  1489. //res.Output = resSix10265.Output
  1490. res.ErrMsg = resSix10265.ErrMsg
  1491. res.Cainfo = resSix10265.Cainfo
  1492. res.WarnMsg = resSix10265.WarnMsg
  1493. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1494. res.Infcode = infocode
  1495. }
  1496. if res.Infcode == 0 {
  1497. item.IsSale = 0
  1498. item.SaleDate = ""
  1499. item.Bchno = ""
  1500. err2 := service.SaveDF(item)
  1501. if err2 == nil {
  1502. var struct3507_2 models.Struct3507
  1503. struct3507_2.OrgName = miConfig.OrgName
  1504. struct3507_2.AccessKey = miConfig.AccessKey
  1505. struct3507_2.RequestUrl = miConfig.Url
  1506. struct3507_2.Opter = roles.UserName
  1507. struct3507_2.FixmedinsCode = miConfig.Code
  1508. struct3507_2.Code = miConfig.Code
  1509. struct3507_2.SecretKey = miConfig.SecretKey
  1510. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1511. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1512. struct3507_2.Url = miConfig.Url
  1513. struct3507_2.AppId = miConfig.Cainfo
  1514. struct3507_2.AppSecret = miConfig.AppSecret
  1515. struct3507_2.Enckey = miConfig.EncKey
  1516. struct3507_2.SignKey = miConfig.SignKey
  1517. struct3507_2.SecretKey = miConfig.SecretKey
  1518. struct3507_2.FixmedinsBchno = item.BgBchno
  1519. struct3507_2.InvDataType = "2"
  1520. if miConfig.MdtrtareaAdmvs == "350500" {
  1521. result11, result22, _ := service.FJyb3507(struct3507_2)
  1522. saveLog(result11, result22, "3507", "3507")
  1523. var respJSON3 map[string]interface{}
  1524. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1525. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1527. return
  1528. }
  1529. userJSONBytes3, _ := json.Marshal(respJSON3)
  1530. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1531. utils.ErrorLog("解析失败:%v", err)
  1532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1533. return
  1534. }
  1535. } else {
  1536. data := make(map[string]interface{})
  1537. data["struct_3507s"] = struct3507_2
  1538. client := &http.Client{}
  1539. bytesData, _ := json.Marshal(data)
  1540. var req *http.Request
  1541. if miConfig.MdtrtareaAdmvs == "320921" {
  1542. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1543. } else {
  1544. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1545. }
  1546. resp, _ := client.Do(req)
  1547. defer resp.Body.Close()
  1548. body, ioErr := ioutil.ReadAll(resp.Body)
  1549. if ioErr != nil {
  1550. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1551. }
  1552. var respJSON map[string]interface{}
  1553. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1554. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1556. return
  1557. }
  1558. var resSix10265 ResultSix10265 //1101结果
  1559. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1560. result, _ := json.Marshal(respJSON)
  1561. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1562. utils.ErrorLog("解析失败:%v", err)
  1563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1564. return
  1565. }
  1566. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1567. //res.Output = resSix10265.Output
  1568. res2.ErrMsg = resSix10265.ErrMsg
  1569. res2.Cainfo = resSix10265.Cainfo
  1570. res2.WarnMsg = resSix10265.WarnMsg
  1571. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1572. res2.Infcode = infocode
  1573. }
  1574. if res2.Infcode == 0 {
  1575. item.IsChange = 0
  1576. item.BgBchno = ""
  1577. service.SaveDF2(item)
  1578. } else {
  1579. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1580. }
  1581. }
  1582. } else {
  1583. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1584. }
  1585. }
  1586. if item.IsSale == 2 && item.IsChange == 1 {
  1587. var res FJ3507Result
  1588. var res2 FJ3507Result
  1589. var struct3507 models.Struct3507
  1590. struct3507.FixmedinsBchno = item.Bchno
  1591. struct3507.InvDataType = "4"
  1592. struct3507.Opter = roles.UserName
  1593. struct3507.OrgName = miConfig.OrgName
  1594. struct3507.AccessKey = miConfig.AccessKey
  1595. struct3507.RequestUrl = miConfig.Url
  1596. struct3507.FixmedinsCode = miConfig.Code
  1597. struct3507.Code = miConfig.Code
  1598. struct3507.SecretKey = miConfig.SecretKey
  1599. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1600. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1601. struct3507.Url = miConfig.Url
  1602. struct3507.AppId = miConfig.Cainfo
  1603. struct3507.AppSecret = miConfig.AppSecret
  1604. struct3507.Enckey = miConfig.EncKey
  1605. struct3507.SignKey = miConfig.SignKey
  1606. struct3507.SecretKey = miConfig.SecretKey
  1607. //result, result1, _ := service.FJyb3507(struct3507)
  1608. //saveLog(result, result1, "3507", "3507")
  1609. //
  1610. //var respJSON2 map[string]interface{}
  1611. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1612. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1613. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1614. // return
  1615. //}
  1616. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1617. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1618. // utils.ErrorLog("解析失败:%v", err)
  1619. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1620. // return
  1621. //}
  1622. if miConfig.MdtrtareaAdmvs == "350500" {
  1623. result, result1, _ := service.FJyb3507(struct3507)
  1624. saveLog(result, result1, "3507", "3507")
  1625. var respJSON2 map[string]interface{}
  1626. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1627. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1629. return
  1630. }
  1631. userJSONBytes2, _ := json.Marshal(respJSON2)
  1632. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1633. utils.ErrorLog("解析失败:%v", err)
  1634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1635. return
  1636. }
  1637. } else {
  1638. data := make(map[string]interface{})
  1639. data["struct_3507s"] = struct3507
  1640. client := &http.Client{}
  1641. bytesData, _ := json.Marshal(data)
  1642. var req *http.Request
  1643. if miConfig.MdtrtareaAdmvs == "320921" {
  1644. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1645. } else {
  1646. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1647. }
  1648. resp, _ := client.Do(req)
  1649. defer resp.Body.Close()
  1650. body, ioErr := ioutil.ReadAll(resp.Body)
  1651. if ioErr != nil {
  1652. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1653. }
  1654. var respJSON map[string]interface{}
  1655. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1658. return
  1659. }
  1660. var resSix10265 ResultSix10265 //1101结果
  1661. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1662. result, _ := json.Marshal(respJSON)
  1663. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1664. utils.ErrorLog("解析失败:%v", err)
  1665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1666. return
  1667. }
  1668. res.InfRefmsgid = resSix10265.InfRefmsgid
  1669. //res.Output = resSix10265.Output
  1670. res.ErrMsg = resSix10265.ErrMsg
  1671. res.Cainfo = resSix10265.Cainfo
  1672. res.WarnMsg = resSix10265.WarnMsg
  1673. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1674. res.Infcode = infocode
  1675. }
  1676. if res.Infcode == 0 {
  1677. item.IsSale = 0
  1678. item.SaleDate = ""
  1679. item.Bchno = ""
  1680. err2 := service.SaveDF(item)
  1681. if err2 == nil {
  1682. var struct3507_2 models.Struct3507
  1683. struct3507_2.OrgName = miConfig.OrgName
  1684. struct3507_2.AccessKey = miConfig.AccessKey
  1685. struct3507_2.RequestUrl = miConfig.Url
  1686. struct3507_2.Opter = roles.UserName
  1687. struct3507_2.FixmedinsCode = miConfig.Code
  1688. struct3507_2.Code = miConfig.Code
  1689. struct3507_2.SecretKey = miConfig.SecretKey
  1690. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1691. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1692. struct3507_2.Url = miConfig.Url
  1693. struct3507_2.AppId = miConfig.Cainfo
  1694. struct3507_2.AppSecret = miConfig.AppSecret
  1695. struct3507_2.Enckey = miConfig.EncKey
  1696. struct3507_2.SignKey = miConfig.SignKey
  1697. struct3507_2.SecretKey = miConfig.SecretKey
  1698. struct3507_2.FixmedinsBchno = item.BgBchno
  1699. struct3507_2.InvDataType = "2"
  1700. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1701. //saveLog(result11, result22, "3507", "3507")
  1702. //var respJSON3 map[string]interface{}
  1703. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1704. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1705. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1706. // return
  1707. //}
  1708. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1709. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1710. // utils.ErrorLog("解析失败:%v", err)
  1711. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1712. // return
  1713. //}
  1714. if miConfig.MdtrtareaAdmvs == "350500" {
  1715. result11, result22, _ := service.FJyb3507(struct3507_2)
  1716. saveLog(result11, result22, "3507", "3507")
  1717. var respJSON3 map[string]interface{}
  1718. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1719. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1721. return
  1722. }
  1723. userJSONBytes3, _ := json.Marshal(respJSON3)
  1724. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1725. utils.ErrorLog("解析失败:%v", err)
  1726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1727. return
  1728. }
  1729. } else {
  1730. data := make(map[string]interface{})
  1731. data["struct_3507s"] = struct3507_2
  1732. client := &http.Client{}
  1733. bytesData, _ := json.Marshal(data)
  1734. var req *http.Request
  1735. if miConfig.MdtrtareaAdmvs == "320921" {
  1736. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1737. } else {
  1738. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1739. }
  1740. resp, _ := client.Do(req)
  1741. defer resp.Body.Close()
  1742. body, ioErr := ioutil.ReadAll(resp.Body)
  1743. if ioErr != nil {
  1744. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1745. }
  1746. var respJSON map[string]interface{}
  1747. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1748. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1750. return
  1751. }
  1752. var resSix10265 ResultSix10265 //1101结果
  1753. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1754. result, _ := json.Marshal(respJSON)
  1755. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1756. utils.ErrorLog("解析失败:%v", err)
  1757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1758. return
  1759. }
  1760. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1761. //res.Output = resSix10265.Output
  1762. res2.ErrMsg = resSix10265.ErrMsg
  1763. res2.Cainfo = resSix10265.Cainfo
  1764. res2.WarnMsg = resSix10265.WarnMsg
  1765. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1766. res2.Infcode = infocode
  1767. }
  1768. if res2.Infcode == 0 {
  1769. item.IsChange = 0
  1770. item.BgBchno = ""
  1771. service.SaveDF2(item)
  1772. } else {
  1773. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1774. }
  1775. }
  1776. } else {
  1777. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1778. }
  1779. }
  1780. if item.IsSale == 1 && item.IsChange == 0 {
  1781. var res FJ3507Result
  1782. var struct3507 models.Struct3507
  1783. struct3507.FixmedinsBchno = item.Bchno
  1784. struct3507.InvDataType = "4"
  1785. struct3507.Opter = roles.UserName
  1786. struct3507.FixmedinsCode = miConfig.Code
  1787. struct3507.Code = miConfig.Code
  1788. struct3507.OrgName = miConfig.OrgName
  1789. struct3507.AccessKey = miConfig.AccessKey
  1790. struct3507.RequestUrl = miConfig.Url
  1791. struct3507.SecretKey = miConfig.SecretKey
  1792. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1793. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1794. struct3507.Url = miConfig.Url
  1795. struct3507.AppId = miConfig.Cainfo
  1796. struct3507.AppSecret = miConfig.AppSecret
  1797. struct3507.Enckey = miConfig.EncKey
  1798. struct3507.SignKey = miConfig.SignKey
  1799. struct3507.SecretKey = miConfig.SecretKey
  1800. //result, result1, _ := service.FJyb3507(struct3507)
  1801. //saveLog(result, result1, "3507", "3507")
  1802. //
  1803. //var respJSON3 map[string]interface{}
  1804. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1805. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1806. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1807. // return
  1808. //}
  1809. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1810. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1811. // utils.ErrorLog("解析失败:%v", err)
  1812. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1813. // return
  1814. //}
  1815. if miConfig.MdtrtareaAdmvs == "350500" {
  1816. result, result1, _ := service.FJyb3507(struct3507)
  1817. saveLog(result, result1, "3507", "3507")
  1818. var respJSON2 map[string]interface{}
  1819. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1822. return
  1823. }
  1824. userJSONBytes2, _ := json.Marshal(respJSON2)
  1825. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1826. utils.ErrorLog("解析失败:%v", err)
  1827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1828. return
  1829. }
  1830. } else {
  1831. data := make(map[string]interface{})
  1832. data["struct_3507s"] = struct3507
  1833. client := &http.Client{}
  1834. bytesData, _ := json.Marshal(data)
  1835. var req *http.Request
  1836. if miConfig.MdtrtareaAdmvs == "320921" {
  1837. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1838. } else {
  1839. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1840. }
  1841. resp, _ := client.Do(req)
  1842. defer resp.Body.Close()
  1843. body, ioErr := ioutil.ReadAll(resp.Body)
  1844. if ioErr != nil {
  1845. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1846. }
  1847. var respJSON map[string]interface{}
  1848. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1849. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1851. return
  1852. }
  1853. var resSix10265 ResultSix10265 //1101结果
  1854. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1855. result, _ := json.Marshal(respJSON)
  1856. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1857. utils.ErrorLog("解析失败:%v", err)
  1858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1859. return
  1860. }
  1861. res.InfRefmsgid = resSix10265.InfRefmsgid
  1862. //res.Output = resSix10265.Output
  1863. res.ErrMsg = resSix10265.ErrMsg
  1864. res.Cainfo = resSix10265.Cainfo
  1865. res.WarnMsg = resSix10265.WarnMsg
  1866. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1867. res.Infcode = infocode
  1868. }
  1869. if res.Infcode == 0 {
  1870. item.IsSale = 0
  1871. item.SaleDate = ""
  1872. service.SaveDF(item)
  1873. } else {
  1874. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1875. }
  1876. }
  1877. if item.IsSale == 2 && item.IsChange == 0 {
  1878. var res FJ3507Result
  1879. var struct3507 models.Struct3507
  1880. struct3507.FixmedinsBchno = item.Bchno
  1881. struct3507.InvDataType = "4"
  1882. struct3507.Opter = roles.UserName
  1883. struct3507.FixmedinsCode = miConfig.Code
  1884. struct3507.Code = miConfig.Code
  1885. struct3507.OrgName = miConfig.OrgName
  1886. struct3507.AccessKey = miConfig.AccessKey
  1887. struct3507.RequestUrl = miConfig.Url
  1888. struct3507.SecretKey = miConfig.SecretKey
  1889. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1890. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1891. struct3507.Url = miConfig.Url
  1892. struct3507.AppId = miConfig.Cainfo
  1893. struct3507.AppSecret = miConfig.AppSecret
  1894. struct3507.Enckey = miConfig.EncKey
  1895. struct3507.SignKey = miConfig.SignKey
  1896. struct3507.SecretKey = miConfig.SecretKey
  1897. //result, result1, _ := service.FJyb3507(struct3507)
  1898. //saveLog(result, result1, "3507", "3507")
  1899. //
  1900. //var respJSON3 map[string]interface{}
  1901. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1902. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1903. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1904. // return
  1905. //}
  1906. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1907. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1908. // utils.ErrorLog("解析失败:%v", err)
  1909. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1910. // return
  1911. //}
  1912. if miConfig.MdtrtareaAdmvs == "350500" {
  1913. result, result1, _ := service.FJyb3507(struct3507)
  1914. saveLog(result, result1, "3507", "3507")
  1915. var respJSON2 map[string]interface{}
  1916. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1917. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1919. return
  1920. }
  1921. userJSONBytes2, _ := json.Marshal(respJSON2)
  1922. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1923. utils.ErrorLog("解析失败:%v", err)
  1924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1925. return
  1926. }
  1927. } else {
  1928. data := make(map[string]interface{})
  1929. data["struct_3507s"] = struct3507
  1930. client := &http.Client{}
  1931. bytesData, _ := json.Marshal(data)
  1932. var req *http.Request
  1933. if miConfig.MdtrtareaAdmvs == "320921" {
  1934. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1935. } else {
  1936. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1937. }
  1938. resp, _ := client.Do(req)
  1939. defer resp.Body.Close()
  1940. body, ioErr := ioutil.ReadAll(resp.Body)
  1941. if ioErr != nil {
  1942. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1943. }
  1944. var respJSON map[string]interface{}
  1945. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1946. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1948. return
  1949. }
  1950. var resSix10265 ResultSix10265 //1101结果
  1951. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1952. result, _ := json.Marshal(respJSON)
  1953. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1954. utils.ErrorLog("解析失败:%v", err)
  1955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1956. return
  1957. }
  1958. res.InfRefmsgid = resSix10265.InfRefmsgid
  1959. //res.Output = resSix10265.Output
  1960. res.ErrMsg = resSix10265.ErrMsg
  1961. res.Cainfo = resSix10265.Cainfo
  1962. res.WarnMsg = resSix10265.WarnMsg
  1963. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1964. res.Infcode = infocode
  1965. }
  1966. if res.Infcode == 0 {
  1967. item.IsSale = 0
  1968. item.SaleDate = ""
  1969. item.Bchno = ""
  1970. service.SaveDF(item)
  1971. } else {
  1972. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1973. }
  1974. }
  1975. if item.IsSale == 0 && item.IsChange == 1 {
  1976. var res FJ3507Result
  1977. var struct3507 models.Struct3507
  1978. struct3507.FixmedinsBchno = item.BgBchno
  1979. struct3507.InvDataType = "2"
  1980. struct3507.Opter = roles.UserName
  1981. struct3507.FixmedinsCode = miConfig.Code
  1982. struct3507.Code = miConfig.Code
  1983. struct3507.OrgName = miConfig.OrgName
  1984. struct3507.AccessKey = miConfig.AccessKey
  1985. struct3507.RequestUrl = miConfig.Url
  1986. struct3507.SecretKey = miConfig.SecretKey
  1987. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1988. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1989. struct3507.Url = miConfig.Url
  1990. struct3507.AppId = miConfig.Cainfo
  1991. struct3507.AppSecret = miConfig.AppSecret
  1992. struct3507.Enckey = miConfig.EncKey
  1993. struct3507.SignKey = miConfig.SignKey
  1994. struct3507.SecretKey = miConfig.SecretKey
  1995. //result, result1, _ := service.FJyb3507(struct3507)
  1996. //saveLog(result, result1, "3507", "3507")
  1997. //
  1998. //var respJSON3 map[string]interface{}
  1999. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2000. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2001. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2002. // return
  2003. //}
  2004. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2005. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2006. // utils.ErrorLog("解析失败:%v", err)
  2007. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2008. // return
  2009. //}
  2010. if miConfig.MdtrtareaAdmvs == "350500" {
  2011. result, result1, _ := service.FJyb3507(struct3507)
  2012. saveLog(result, result1, "3507", "3507")
  2013. var respJSON2 map[string]interface{}
  2014. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2017. return
  2018. }
  2019. userJSONBytes2, _ := json.Marshal(respJSON2)
  2020. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2021. utils.ErrorLog("解析失败:%v", err)
  2022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2023. return
  2024. }
  2025. } else {
  2026. data := make(map[string]interface{})
  2027. data["struct_3507s"] = struct3507
  2028. client := &http.Client{}
  2029. bytesData, _ := json.Marshal(data)
  2030. var req *http.Request
  2031. if miConfig.MdtrtareaAdmvs == "320921" {
  2032. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2033. } else {
  2034. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2035. }
  2036. resp, _ := client.Do(req)
  2037. defer resp.Body.Close()
  2038. body, ioErr := ioutil.ReadAll(resp.Body)
  2039. if ioErr != nil {
  2040. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2041. }
  2042. var respJSON map[string]interface{}
  2043. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2046. return
  2047. }
  2048. var resSix10265 ResultSix10265 //1101结果
  2049. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2050. result, _ := json.Marshal(respJSON)
  2051. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2052. utils.ErrorLog("解析失败:%v", err)
  2053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2054. return
  2055. }
  2056. res.InfRefmsgid = resSix10265.InfRefmsgid
  2057. //res.Output = resSix10265.Output
  2058. res.ErrMsg = resSix10265.ErrMsg
  2059. res.Cainfo = resSix10265.Cainfo
  2060. res.WarnMsg = resSix10265.WarnMsg
  2061. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2062. res.Infcode = infocode
  2063. }
  2064. if res.Infcode == 0 {
  2065. item.IsChange = 0
  2066. item.BgBchno = ""
  2067. service.SaveDF2(item)
  2068. } else {
  2069. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2070. }
  2071. }
  2072. }
  2073. if len(err) == 0 {
  2074. c.ServeSuccessJSON(map[string]interface{}{
  2075. "msg": "删除销售变更成功",
  2076. })
  2077. } else {
  2078. c.ServeSuccessJSON(map[string]interface{}{
  2079. "failed_code": -10,
  2080. "msg": err,
  2081. })
  2082. }
  2083. }
  2084. func (c *HisApiController) DeleteXSandBGTwo() {
  2085. patient_id, _ := c.GetInt64("patient_id")
  2086. admin_user_id, _ := c.GetInt64("admin_user_id")
  2087. //id_arr := strings.Split(ids, ",")
  2088. times := c.GetString("time", "")
  2089. timeLayout := "2006-01-02"
  2090. loc, _ := time.LoadLocation("Local")
  2091. var stime, etime int64
  2092. if times == "" {
  2093. stime, etime = GetNowTime()
  2094. } else {
  2095. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2096. stime = stmp.Unix()
  2097. etime = stime + 86399
  2098. }
  2099. advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2100. var flows []*models.DrugFlow
  2101. for _, item := range advicelist {
  2102. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.ID, times, c.GetAdminUserInfo().CurrentOrgId)
  2103. flows = append(flows, flow...)
  2104. }
  2105. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2106. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2107. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2108. var err []string
  2109. for _, item := range flows {
  2110. if item.IsSale == 1 && item.IsChange == 1 {
  2111. var res FJ3507Result
  2112. var res2 FJ3507Result
  2113. var struct3507 models.Struct3507
  2114. struct3507.FixmedinsBchno = item.Bchno
  2115. struct3507.InvDataType = "4"
  2116. struct3507.Opter = roles.UserName
  2117. struct3507.OrgName = miConfig.OrgName
  2118. struct3507.AccessKey = miConfig.AccessKey
  2119. struct3507.RequestUrl = miConfig.Url
  2120. struct3507.FixmedinsCode = miConfig.Code
  2121. struct3507.SecretKey = miConfig.SecretKey
  2122. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2123. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2124. struct3507.Url = miConfig.Url
  2125. struct3507.AppId = miConfig.Cainfo
  2126. struct3507.AppSecret = miConfig.AppSecret
  2127. struct3507.Enckey = miConfig.EncKey
  2128. struct3507.SignKey = miConfig.SignKey
  2129. struct3507.SecretKey = miConfig.SecretKey
  2130. //result, result1, _ := service.FJyb3507(struct3507)
  2131. //saveLog(result, result1, "3507", "3507")
  2132. if miConfig.MdtrtareaAdmvs == "350500" {
  2133. result, result1, _ := service.FJyb3507(struct3507)
  2134. saveLog(result, result1, "3507", "3507")
  2135. var respJSON2 map[string]interface{}
  2136. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2139. return
  2140. }
  2141. userJSONBytes2, _ := json.Marshal(respJSON2)
  2142. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2143. utils.ErrorLog("解析失败:%v", err)
  2144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2145. return
  2146. }
  2147. } else {
  2148. data := make(map[string]interface{})
  2149. data["struct_3507s"] = struct3507
  2150. client := &http.Client{}
  2151. bytesData, _ := json.Marshal(data)
  2152. var req *http.Request
  2153. if miConfig.MdtrtareaAdmvs == "320921" {
  2154. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2155. } else {
  2156. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2157. }
  2158. resp, _ := client.Do(req)
  2159. defer resp.Body.Close()
  2160. body, ioErr := ioutil.ReadAll(resp.Body)
  2161. if ioErr != nil {
  2162. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2163. }
  2164. var respJSON map[string]interface{}
  2165. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2168. return
  2169. }
  2170. var resSix10265 ResultSix10265 //1101结果
  2171. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2172. result, _ := json.Marshal(respJSON)
  2173. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2174. utils.ErrorLog("解析失败:%v", err)
  2175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2176. return
  2177. }
  2178. res.InfRefmsgid = resSix10265.InfRefmsgid
  2179. //res.Output = resSix10265.Output
  2180. res.ErrMsg = resSix10265.ErrMsg
  2181. res.Cainfo = resSix10265.Cainfo
  2182. res.WarnMsg = resSix10265.WarnMsg
  2183. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2184. res.Infcode = infocode
  2185. }
  2186. if res.Infcode == 0 {
  2187. item.IsSale = 0
  2188. item.SaleDate = ""
  2189. item.Bchno = ""
  2190. err2 := service.SaveDF(item)
  2191. if err2 == nil {
  2192. var struct3507_2 models.Struct3507
  2193. struct3507_2.OrgName = miConfig.OrgName
  2194. struct3507_2.AccessKey = miConfig.AccessKey
  2195. struct3507_2.RequestUrl = miConfig.Url
  2196. struct3507_2.Opter = roles.UserName
  2197. struct3507_2.FixmedinsCode = miConfig.Code
  2198. struct3507_2.Code = miConfig.Code
  2199. struct3507_2.SecretKey = miConfig.SecretKey
  2200. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2201. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2202. struct3507_2.Url = miConfig.Url
  2203. struct3507_2.AppId = miConfig.Cainfo
  2204. struct3507_2.AppSecret = miConfig.AppSecret
  2205. struct3507_2.Enckey = miConfig.EncKey
  2206. struct3507_2.SignKey = miConfig.SignKey
  2207. struct3507_2.SecretKey = miConfig.SecretKey
  2208. struct3507_2.FixmedinsBchno = item.BgBchno
  2209. struct3507_2.InvDataType = "2"
  2210. if miConfig.MdtrtareaAdmvs == "350500" {
  2211. result11, result22, _ := service.FJyb3507(struct3507_2)
  2212. saveLog(result11, result22, "3507", "3507")
  2213. var respJSON3 map[string]interface{}
  2214. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2215. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2217. return
  2218. }
  2219. userJSONBytes3, _ := json.Marshal(respJSON3)
  2220. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2221. utils.ErrorLog("解析失败:%v", err)
  2222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2223. return
  2224. }
  2225. } else {
  2226. data := make(map[string]interface{})
  2227. data["struct_3507s"] = struct3507_2
  2228. client := &http.Client{}
  2229. bytesData, _ := json.Marshal(data)
  2230. var req *http.Request
  2231. if miConfig.MdtrtareaAdmvs == "320921" {
  2232. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2233. } else {
  2234. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2235. }
  2236. resp, _ := client.Do(req)
  2237. defer resp.Body.Close()
  2238. body, ioErr := ioutil.ReadAll(resp.Body)
  2239. if ioErr != nil {
  2240. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2241. }
  2242. var respJSON map[string]interface{}
  2243. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2244. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2246. return
  2247. }
  2248. var resSix10265 ResultSix10265 //1101结果
  2249. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2250. result, _ := json.Marshal(respJSON)
  2251. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2252. utils.ErrorLog("解析失败:%v", err)
  2253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2254. return
  2255. }
  2256. res2.InfRefmsgid = resSix10265.InfRefmsgid
  2257. //res.Output = resSix10265.Output
  2258. res2.ErrMsg = resSix10265.ErrMsg
  2259. res2.Cainfo = resSix10265.Cainfo
  2260. res2.WarnMsg = resSix10265.WarnMsg
  2261. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2262. res2.Infcode = infocode
  2263. }
  2264. if res2.Infcode == 0 {
  2265. item.IsChange = 0
  2266. item.BgBchno = ""
  2267. service.SaveDF2(item)
  2268. } else {
  2269. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2270. }
  2271. }
  2272. } else {
  2273. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2274. }
  2275. }
  2276. if item.IsSale == 2 && item.IsChange == 1 {
  2277. var res FJ3507Result
  2278. var res2 FJ3507Result
  2279. var struct3507 models.Struct3507
  2280. struct3507.FixmedinsBchno = item.Bchno
  2281. struct3507.InvDataType = "4"
  2282. struct3507.Opter = roles.UserName
  2283. struct3507.OrgName = miConfig.OrgName
  2284. struct3507.AccessKey = miConfig.AccessKey
  2285. struct3507.RequestUrl = miConfig.Url
  2286. struct3507.FixmedinsCode = miConfig.Code
  2287. struct3507.Code = miConfig.Code
  2288. struct3507.SecretKey = miConfig.SecretKey
  2289. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2290. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2291. struct3507.Url = miConfig.Url
  2292. struct3507.AppId = miConfig.Cainfo
  2293. struct3507.AppSecret = miConfig.AppSecret
  2294. struct3507.Enckey = miConfig.EncKey
  2295. struct3507.SignKey = miConfig.SignKey
  2296. struct3507.SecretKey = miConfig.SecretKey
  2297. //result, result1, _ := service.FJyb3507(struct3507)
  2298. //saveLog(result, result1, "3507", "3507")
  2299. //
  2300. //var respJSON2 map[string]interface{}
  2301. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2302. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2303. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2304. // return
  2305. //}
  2306. //userJSONBytes2, _ := json.Marshal(respJSON2)
  2307. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2308. // utils.ErrorLog("解析失败:%v", err)
  2309. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2310. // return
  2311. //}
  2312. if miConfig.MdtrtareaAdmvs == "350500" {
  2313. result, result1, _ := service.FJyb3507(struct3507)
  2314. saveLog(result, result1, "3507", "3507")
  2315. var respJSON2 map[string]interface{}
  2316. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2317. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2319. return
  2320. }
  2321. userJSONBytes2, _ := json.Marshal(respJSON2)
  2322. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2323. utils.ErrorLog("解析失败:%v", err)
  2324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2325. return
  2326. }
  2327. } else {
  2328. data := make(map[string]interface{})
  2329. data["struct_3507s"] = struct3507
  2330. client := &http.Client{}
  2331. bytesData, _ := json.Marshal(data)
  2332. var req *http.Request
  2333. if miConfig.MdtrtareaAdmvs == "320921" {
  2334. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2335. } else {
  2336. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2337. }
  2338. resp, _ := client.Do(req)
  2339. defer resp.Body.Close()
  2340. body, ioErr := ioutil.ReadAll(resp.Body)
  2341. if ioErr != nil {
  2342. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2343. }
  2344. var respJSON map[string]interface{}
  2345. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2346. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2348. return
  2349. }
  2350. var resSix10265 ResultSix10265 //1101结果
  2351. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2352. result, _ := json.Marshal(respJSON)
  2353. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2354. utils.ErrorLog("解析失败:%v", err)
  2355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2356. return
  2357. }
  2358. res.InfRefmsgid = resSix10265.InfRefmsgid
  2359. //res.Output = resSix10265.Output
  2360. res.ErrMsg = resSix10265.ErrMsg
  2361. res.Cainfo = resSix10265.Cainfo
  2362. res.WarnMsg = resSix10265.WarnMsg
  2363. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2364. res.Infcode = infocode
  2365. }
  2366. if res.Infcode == 0 {
  2367. item.IsSale = 0
  2368. item.SaleDate = ""
  2369. item.Bchno = ""
  2370. err2 := service.SaveDF(item)
  2371. if err2 == nil {
  2372. var struct3507_2 models.Struct3507
  2373. struct3507_2.OrgName = miConfig.OrgName
  2374. struct3507_2.AccessKey = miConfig.AccessKey
  2375. struct3507_2.RequestUrl = miConfig.Url
  2376. struct3507_2.Opter = roles.UserName
  2377. struct3507_2.FixmedinsCode = miConfig.Code
  2378. struct3507_2.Code = miConfig.Code
  2379. struct3507_2.SecretKey = miConfig.SecretKey
  2380. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2381. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2382. struct3507_2.Url = miConfig.Url
  2383. struct3507_2.AppId = miConfig.Cainfo
  2384. struct3507_2.AppSecret = miConfig.AppSecret
  2385. struct3507_2.Enckey = miConfig.EncKey
  2386. struct3507_2.SignKey = miConfig.SignKey
  2387. struct3507_2.SecretKey = miConfig.SecretKey
  2388. struct3507_2.FixmedinsBchno = item.BgBchno
  2389. struct3507_2.InvDataType = "2"
  2390. //result11, result22, _ := service.FJyb3507(struct3507_2)
  2391. //saveLog(result11, result22, "3507", "3507")
  2392. //var respJSON3 map[string]interface{}
  2393. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2394. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2395. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2396. // return
  2397. //}
  2398. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2399. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2400. // utils.ErrorLog("解析失败:%v", err)
  2401. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2402. // return
  2403. //}
  2404. if miConfig.MdtrtareaAdmvs == "350500" {
  2405. result11, result22, _ := service.FJyb3507(struct3507_2)
  2406. saveLog(result11, result22, "3507", "3507")
  2407. var respJSON3 map[string]interface{}
  2408. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2409. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2411. return
  2412. }
  2413. userJSONBytes3, _ := json.Marshal(respJSON3)
  2414. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2415. utils.ErrorLog("解析失败:%v", err)
  2416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2417. return
  2418. }
  2419. } else {
  2420. data := make(map[string]interface{})
  2421. data["struct_3507s"] = struct3507_2
  2422. client := &http.Client{}
  2423. bytesData, _ := json.Marshal(data)
  2424. var req *http.Request
  2425. if miConfig.MdtrtareaAdmvs == "320921" {
  2426. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2427. } else {
  2428. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2429. }
  2430. resp, _ := client.Do(req)
  2431. defer resp.Body.Close()
  2432. body, ioErr := ioutil.ReadAll(resp.Body)
  2433. if ioErr != nil {
  2434. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2435. }
  2436. var respJSON map[string]interface{}
  2437. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2438. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2440. return
  2441. }
  2442. var resSix10265 ResultSix10265 //1101结果
  2443. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2444. result, _ := json.Marshal(respJSON)
  2445. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2446. utils.ErrorLog("解析失败:%v", err)
  2447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2448. return
  2449. }
  2450. res2.InfRefmsgid = resSix10265.InfRefmsgid
  2451. //res.Output = resSix10265.Output
  2452. res2.ErrMsg = resSix10265.ErrMsg
  2453. res2.Cainfo = resSix10265.Cainfo
  2454. res2.WarnMsg = resSix10265.WarnMsg
  2455. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2456. res2.Infcode = infocode
  2457. }
  2458. if res2.Infcode == 0 {
  2459. item.IsChange = 0
  2460. item.BgBchno = ""
  2461. service.SaveDF2(item)
  2462. } else {
  2463. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2464. }
  2465. }
  2466. } else {
  2467. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2468. }
  2469. }
  2470. if item.IsSale == 1 && item.IsChange == 0 {
  2471. var res FJ3507Result
  2472. var struct3507 models.Struct3507
  2473. struct3507.FixmedinsBchno = item.Bchno
  2474. struct3507.InvDataType = "4"
  2475. struct3507.Opter = roles.UserName
  2476. struct3507.FixmedinsCode = miConfig.Code
  2477. struct3507.Code = miConfig.Code
  2478. struct3507.OrgName = miConfig.OrgName
  2479. struct3507.AccessKey = miConfig.AccessKey
  2480. struct3507.RequestUrl = miConfig.Url
  2481. struct3507.SecretKey = miConfig.SecretKey
  2482. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2483. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2484. struct3507.Url = miConfig.Url
  2485. struct3507.AppId = miConfig.Cainfo
  2486. struct3507.AppSecret = miConfig.AppSecret
  2487. struct3507.Enckey = miConfig.EncKey
  2488. struct3507.SignKey = miConfig.SignKey
  2489. struct3507.SecretKey = miConfig.SecretKey
  2490. //result, result1, _ := service.FJyb3507(struct3507)
  2491. //saveLog(result, result1, "3507", "3507")
  2492. //
  2493. //var respJSON3 map[string]interface{}
  2494. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2495. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2496. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2497. // return
  2498. //}
  2499. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2500. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2501. // utils.ErrorLog("解析失败:%v", err)
  2502. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2503. // return
  2504. //}
  2505. if miConfig.MdtrtareaAdmvs == "350500" {
  2506. result, result1, _ := service.FJyb3507(struct3507)
  2507. saveLog(result, result1, "3507", "3507")
  2508. var respJSON2 map[string]interface{}
  2509. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2510. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2512. return
  2513. }
  2514. userJSONBytes2, _ := json.Marshal(respJSON2)
  2515. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2516. utils.ErrorLog("解析失败:%v", err)
  2517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2518. return
  2519. }
  2520. } else {
  2521. data := make(map[string]interface{})
  2522. data["struct_3507s"] = struct3507
  2523. client := &http.Client{}
  2524. bytesData, _ := json.Marshal(data)
  2525. var req *http.Request
  2526. if miConfig.MdtrtareaAdmvs == "320921" {
  2527. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2528. } else {
  2529. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2530. }
  2531. resp, _ := client.Do(req)
  2532. defer resp.Body.Close()
  2533. body, ioErr := ioutil.ReadAll(resp.Body)
  2534. if ioErr != nil {
  2535. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2536. }
  2537. var respJSON map[string]interface{}
  2538. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2539. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2541. return
  2542. }
  2543. var resSix10265 ResultSix10265 //1101结果
  2544. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2545. result, _ := json.Marshal(respJSON)
  2546. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2547. utils.ErrorLog("解析失败:%v", err)
  2548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2549. return
  2550. }
  2551. res.InfRefmsgid = resSix10265.InfRefmsgid
  2552. //res.Output = resSix10265.Output
  2553. res.ErrMsg = resSix10265.ErrMsg
  2554. res.Cainfo = resSix10265.Cainfo
  2555. res.WarnMsg = resSix10265.WarnMsg
  2556. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2557. res.Infcode = infocode
  2558. }
  2559. if res.Infcode == 0 {
  2560. item.IsSale = 0
  2561. item.SaleDate = ""
  2562. service.SaveDF(item)
  2563. } else {
  2564. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2565. }
  2566. }
  2567. if item.IsSale == 2 && item.IsChange == 0 {
  2568. var res FJ3507Result
  2569. var struct3507 models.Struct3507
  2570. struct3507.FixmedinsBchno = item.Bchno
  2571. struct3507.InvDataType = "4"
  2572. struct3507.Opter = roles.UserName
  2573. struct3507.FixmedinsCode = miConfig.Code
  2574. struct3507.Code = miConfig.Code
  2575. struct3507.OrgName = miConfig.OrgName
  2576. struct3507.AccessKey = miConfig.AccessKey
  2577. struct3507.RequestUrl = miConfig.Url
  2578. struct3507.SecretKey = miConfig.SecretKey
  2579. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2580. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2581. struct3507.Url = miConfig.Url
  2582. struct3507.AppId = miConfig.Cainfo
  2583. struct3507.AppSecret = miConfig.AppSecret
  2584. struct3507.Enckey = miConfig.EncKey
  2585. struct3507.SignKey = miConfig.SignKey
  2586. struct3507.SecretKey = miConfig.SecretKey
  2587. //result, result1, _ := service.FJyb3507(struct3507)
  2588. //saveLog(result, result1, "3507", "3507")
  2589. //
  2590. //var respJSON3 map[string]interface{}
  2591. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2592. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2593. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2594. // return
  2595. //}
  2596. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2597. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2598. // utils.ErrorLog("解析失败:%v", err)
  2599. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2600. // return
  2601. //}
  2602. if miConfig.MdtrtareaAdmvs == "350500" {
  2603. result, result1, _ := service.FJyb3507(struct3507)
  2604. saveLog(result, result1, "3507", "3507")
  2605. var respJSON2 map[string]interface{}
  2606. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2607. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2609. return
  2610. }
  2611. userJSONBytes2, _ := json.Marshal(respJSON2)
  2612. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2613. utils.ErrorLog("解析失败:%v", err)
  2614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2615. return
  2616. }
  2617. } else {
  2618. data := make(map[string]interface{})
  2619. data["struct_3507s"] = struct3507
  2620. client := &http.Client{}
  2621. bytesData, _ := json.Marshal(data)
  2622. var req *http.Request
  2623. if miConfig.MdtrtareaAdmvs == "320921" {
  2624. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2625. } else {
  2626. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2627. }
  2628. resp, _ := client.Do(req)
  2629. defer resp.Body.Close()
  2630. body, ioErr := ioutil.ReadAll(resp.Body)
  2631. if ioErr != nil {
  2632. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2633. }
  2634. var respJSON map[string]interface{}
  2635. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2636. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2638. return
  2639. }
  2640. var resSix10265 ResultSix10265 //1101结果
  2641. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2642. result, _ := json.Marshal(respJSON)
  2643. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2644. utils.ErrorLog("解析失败:%v", err)
  2645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2646. return
  2647. }
  2648. res.InfRefmsgid = resSix10265.InfRefmsgid
  2649. //res.Output = resSix10265.Output
  2650. res.ErrMsg = resSix10265.ErrMsg
  2651. res.Cainfo = resSix10265.Cainfo
  2652. res.WarnMsg = resSix10265.WarnMsg
  2653. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2654. res.Infcode = infocode
  2655. }
  2656. if res.Infcode == 0 {
  2657. item.IsSale = 0
  2658. item.SaleDate = ""
  2659. item.Bchno = ""
  2660. service.SaveDF(item)
  2661. } else {
  2662. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2663. }
  2664. }
  2665. if item.IsSale == 0 && item.IsChange == 1 {
  2666. var res FJ3507Result
  2667. var struct3507 models.Struct3507
  2668. struct3507.FixmedinsBchno = item.BgBchno
  2669. struct3507.InvDataType = "2"
  2670. struct3507.Opter = roles.UserName
  2671. struct3507.FixmedinsCode = miConfig.Code
  2672. struct3507.Code = miConfig.Code
  2673. struct3507.OrgName = miConfig.OrgName
  2674. struct3507.AccessKey = miConfig.AccessKey
  2675. struct3507.RequestUrl = miConfig.Url
  2676. struct3507.SecretKey = miConfig.SecretKey
  2677. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2678. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2679. struct3507.Url = miConfig.Url
  2680. struct3507.AppId = miConfig.Cainfo
  2681. struct3507.AppSecret = miConfig.AppSecret
  2682. struct3507.Enckey = miConfig.EncKey
  2683. struct3507.SignKey = miConfig.SignKey
  2684. struct3507.SecretKey = miConfig.SecretKey
  2685. //result, result1, _ := service.FJyb3507(struct3507)
  2686. //saveLog(result, result1, "3507", "3507")
  2687. //
  2688. //var respJSON3 map[string]interface{}
  2689. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2690. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2691. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2692. // return
  2693. //}
  2694. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2695. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2696. // utils.ErrorLog("解析失败:%v", err)
  2697. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2698. // return
  2699. //}
  2700. if miConfig.MdtrtareaAdmvs == "350500" {
  2701. result, result1, _ := service.FJyb3507(struct3507)
  2702. saveLog(result, result1, "3507", "3507")
  2703. var respJSON2 map[string]interface{}
  2704. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2705. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2707. return
  2708. }
  2709. userJSONBytes2, _ := json.Marshal(respJSON2)
  2710. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2711. utils.ErrorLog("解析失败:%v", err)
  2712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2713. return
  2714. }
  2715. } else {
  2716. data := make(map[string]interface{})
  2717. data["struct_3507s"] = struct3507
  2718. client := &http.Client{}
  2719. bytesData, _ := json.Marshal(data)
  2720. var req *http.Request
  2721. if miConfig.MdtrtareaAdmvs == "320921" {
  2722. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2723. } else {
  2724. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2725. }
  2726. resp, _ := client.Do(req)
  2727. defer resp.Body.Close()
  2728. body, ioErr := ioutil.ReadAll(resp.Body)
  2729. if ioErr != nil {
  2730. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2731. }
  2732. var respJSON map[string]interface{}
  2733. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2734. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2736. return
  2737. }
  2738. var resSix10265 ResultSix10265 //1101结果
  2739. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2740. result, _ := json.Marshal(respJSON)
  2741. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2742. utils.ErrorLog("解析失败:%v", err)
  2743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2744. return
  2745. }
  2746. res.InfRefmsgid = resSix10265.InfRefmsgid
  2747. //res.Output = resSix10265.Output
  2748. res.ErrMsg = resSix10265.ErrMsg
  2749. res.Cainfo = resSix10265.Cainfo
  2750. res.WarnMsg = resSix10265.WarnMsg
  2751. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2752. res.Infcode = infocode
  2753. }
  2754. if res.Infcode == 0 {
  2755. item.IsChange = 0
  2756. item.BgBchno = ""
  2757. service.SaveDF2(item)
  2758. } else {
  2759. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2760. }
  2761. }
  2762. }
  2763. if len(err) == 0 {
  2764. c.ServeSuccessJSON(map[string]interface{}{
  2765. "msg": "删除销售变更成功",
  2766. })
  2767. } else {
  2768. c.ServeSuccessJSON(map[string]interface{}{
  2769. "failed_code": -10,
  2770. "msg": err,
  2771. })
  2772. }
  2773. }
  2774. // 获取当天起止时间戳
  2775. func GetNowTime() (int64, int64) {
  2776. t := time.Now()
  2777. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  2778. timesamp := addTime.Unix()
  2779. return timesamp, timesamp + 86399
  2780. }
  2781. func (c *HisApiController) ChangeDrugfour() {
  2782. patient_id, _ := c.GetInt64("patient_id")
  2783. admin_user_id, _ := c.GetInt64("admin_user_id")
  2784. //id_arr := strings.Split(ids, ",")
  2785. times := c.GetString("time", "")
  2786. timeLayout := "2006-01-02"
  2787. loc, _ := time.LoadLocation("Local")
  2788. var stime, etime int64
  2789. if times == "" {
  2790. stime, etime = GetNowTime()
  2791. } else {
  2792. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2793. stime = stmp.Unix()
  2794. etime = stime + 86399
  2795. }
  2796. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2797. var flows []*models.DrugFlow
  2798. for _, item := range advicelist {
  2799. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.ID, times, c.GetAdminUserInfo().CurrentOrgId)
  2800. flows = append(flows, flow...)
  2801. }
  2802. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2803. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2804. var err []string
  2805. for _, item := range flows {
  2806. var res3 ResultSix
  2807. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  2808. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2809. if prescription.OrderStatus == 2 {
  2810. //已经结算
  2811. //判断是否已经销售
  2812. if item.IsSale == 1 { //是否已经销售,1是 0否
  2813. //是否已经变更 1是 0否
  2814. if item.IsChange == 0 { //没变更,进行变更操作
  2815. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2816. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  2817. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  2818. var respJSON3 map[string]interface{}
  2819. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2822. return
  2823. }
  2824. userJSONBytes3, _ := json.Marshal(respJSON3)
  2825. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2826. utils.ErrorLog("解析失败:%v", err)
  2827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2828. return
  2829. }
  2830. if res3.Infcode == 0 {
  2831. item.IsChange = 1
  2832. item.BgBchno = bg_number
  2833. service.SaveDF2(item)
  2834. } else {
  2835. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2836. }
  2837. }
  2838. } else { //没销售,
  2839. var res FJ3507Result
  2840. var res3507for10188 FJ3507ResultFor10188
  2841. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  2842. //进行商品销售接口
  2843. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2844. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  2845. var respJSON3 map[string]interface{}
  2846. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  2847. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2849. return
  2850. }
  2851. userJSONBytes3, _ := json.Marshal(respJSON3)
  2852. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2853. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2854. utils.ErrorLog("解析失败:%v", err)
  2855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2856. return
  2857. }
  2858. //if res3507for10188.Infcode
  2859. res.InfRefmsgid = res3507for10188.InfRefmsgid
  2860. //res.Output = resSix10265.Output
  2861. res.ErrMsg = res3507for10188.ErrMsg
  2862. res.Cainfo = res3507for10188.Cainfo
  2863. res.WarnMsg = res3507for10188.WarnMsg
  2864. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2865. res.Infcode = infocode
  2866. } else {
  2867. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2868. utils.ErrorLog("解析失败:%v", err)
  2869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2870. return
  2871. }
  2872. }
  2873. if res.Infcode == 0 {
  2874. item.IsSale = 1
  2875. item.Bchno = number
  2876. item.SaleDate = time.Now().Format("2006-01-02")
  2877. err5 := service.SaveDF(item)
  2878. if err5 == nil {
  2879. if item.IsChange == 0 { //没变更,进行变更操作
  2880. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2881. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  2882. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  2883. var respJSON3 map[string]interface{}
  2884. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2885. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2887. return
  2888. }
  2889. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2890. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2891. utils.ErrorLog("解析失败:%v", err)
  2892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2893. return
  2894. }
  2895. //if res3507for10188.Infcode
  2896. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  2897. //res.Output = resSix10265.Output
  2898. res3.ErrMsg = res3507for10188.ErrMsg
  2899. res3.Cainfo = res3507for10188.Cainfo
  2900. res3.WarnMsg = res3507for10188.WarnMsg
  2901. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2902. res3.Infcode = infocode
  2903. } else {
  2904. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2905. utils.ErrorLog("解析失败:%v", err)
  2906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2907. return
  2908. }
  2909. }
  2910. if res3.Infcode == 0 {
  2911. item.IsChange = 1
  2912. item.BgBchno = bg_number
  2913. service.SaveDF2(item)
  2914. } else {
  2915. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2916. }
  2917. }
  2918. }
  2919. } else {
  2920. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  2921. }
  2922. }
  2923. } else { //还没结,提示用户去结算,并药品追溯上传
  2924. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  2925. }
  2926. }
  2927. }
  2928. if len(err) == 0 {
  2929. c.ServeSuccessJSON(map[string]interface{}{
  2930. "msg": "销售变更成功",
  2931. })
  2932. } else {
  2933. c.ServeSuccessJSON(map[string]interface{}{
  2934. "failed_code": -10,
  2935. "msg": err,
  2936. })
  2937. }
  2938. }
  2939. func (c *HisApiController) ChangeDrug() {
  2940. ids := c.GetString("ids")
  2941. id_arr := strings.Split(ids, ",")
  2942. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2943. admin_user_id, _ := c.GetInt64("admin_user_id")
  2944. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2945. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2946. var err []string
  2947. for _, item := range flows {
  2948. var res3 ResultSix
  2949. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  2950. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2951. if prescription.OrderStatus == 2 {
  2952. //已经结算
  2953. //判断是否已经销售
  2954. if item.IsSale == 1 { //是否已经销售,1是 0否
  2955. //是否已经变更 1是 0否
  2956. if item.IsChange == 0 { //没变更,进行变更操作
  2957. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2958. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  2959. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  2960. var respJSON3 map[string]interface{}
  2961. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2962. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2964. return
  2965. }
  2966. userJSONBytes3, _ := json.Marshal(respJSON3)
  2967. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2968. utils.ErrorLog("解析失败:%v", err)
  2969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2970. return
  2971. }
  2972. if res3.Infcode == 0 {
  2973. item.IsChange = 1
  2974. item.BgBchno = bg_number
  2975. service.SaveDF2(item)
  2976. } else {
  2977. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2978. }
  2979. }
  2980. } else { //没销售,
  2981. var res FJ3507Result
  2982. var res3507for10188 FJ3507ResultFor10188
  2983. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  2984. //进行商品销售接口
  2985. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2986. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  2987. var respJSON3 map[string]interface{}
  2988. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  2989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2991. return
  2992. }
  2993. userJSONBytes3, _ := json.Marshal(respJSON3)
  2994. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2995. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2996. utils.ErrorLog("解析失败:%v", err)
  2997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2998. return
  2999. }
  3000. //if res3507for10188.Infcode
  3001. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3002. //res.Output = resSix10265.Output
  3003. res.ErrMsg = res3507for10188.ErrMsg
  3004. res.Cainfo = res3507for10188.Cainfo
  3005. res.WarnMsg = res3507for10188.WarnMsg
  3006. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3007. res.Infcode = infocode
  3008. } else {
  3009. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3010. utils.ErrorLog("解析失败:%v", err)
  3011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3012. return
  3013. }
  3014. }
  3015. if res.Infcode == 0 {
  3016. item.IsSale = 1
  3017. item.Bchno = number
  3018. item.SaleDate = time.Now().Format("2006-01-02")
  3019. err5 := service.SaveDF(item)
  3020. if err5 == nil {
  3021. if item.IsChange == 0 { //没变更,进行变更操作
  3022. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3023. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3024. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3025. var respJSON3 map[string]interface{}
  3026. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3029. return
  3030. }
  3031. userJSONBytes3, _ := json.Marshal(respJSON3)
  3032. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3033. utils.ErrorLog("解析失败:%v", err)
  3034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3035. return
  3036. }
  3037. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3038. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3039. utils.ErrorLog("解析失败:%v", err)
  3040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3041. return
  3042. }
  3043. //if res3507for10188.Infcode
  3044. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3045. //res.Output = resSix10265.Output
  3046. res3.ErrMsg = res3507for10188.ErrMsg
  3047. res3.Cainfo = res3507for10188.Cainfo
  3048. res3.WarnMsg = res3507for10188.WarnMsg
  3049. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3050. res3.Infcode = infocode
  3051. } else {
  3052. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3053. utils.ErrorLog("解析失败:%v", err)
  3054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3055. return
  3056. }
  3057. }
  3058. if res3.Infcode == 0 {
  3059. item.IsChange = 1
  3060. item.BgBchno = bg_number
  3061. service.SaveDF2(item)
  3062. } else {
  3063. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3064. }
  3065. }
  3066. }
  3067. } else {
  3068. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3069. }
  3070. }
  3071. } else { //还没结算
  3072. var res3507for10188 FJ3507ResultFor10188
  3073. if item.IsChange == 0 { //没变更,进行变更操作
  3074. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3075. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3076. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3077. var respJSON3 map[string]interface{}
  3078. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3079. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3081. return
  3082. }
  3083. userJSONBytes3, _ := json.Marshal(respJSON3)
  3084. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3085. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3086. utils.ErrorLog("解析失败:%v", err)
  3087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3088. return
  3089. }
  3090. //if res3507for10188.Infcode
  3091. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3092. //res.Output = resSix10265.Output
  3093. res3.ErrMsg = res3507for10188.ErrMsg
  3094. res3.Cainfo = res3507for10188.Cainfo
  3095. res3.WarnMsg = res3507for10188.WarnMsg
  3096. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3097. res3.Infcode = infocode
  3098. } else {
  3099. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3100. utils.ErrorLog("解析失败:%v", err)
  3101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3102. return
  3103. }
  3104. }
  3105. if res3.Infcode == 0 {
  3106. item.IsChange = 1
  3107. item.BgBchno = bg_number
  3108. service.SaveDF2(item)
  3109. } else {
  3110. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3111. }
  3112. }
  3113. }
  3114. } else if item.ConsumableType == 7 {
  3115. var res3507for10188 FJ3507ResultFor10188
  3116. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3117. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3118. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3119. //判断是否已经销售
  3120. if item.IsSale == 2 { //是否已经销售,1是 0否
  3121. //是否已经变更 1是 0否
  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, "101", 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. userJSONBytes3, _ := json.Marshal(respJSON3)
  3133. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3134. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3135. utils.ErrorLog("解析失败:%v", err)
  3136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3137. return
  3138. }
  3139. //if res3507for10188.Infcode
  3140. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3141. //res.Output = resSix10265.Output
  3142. res3.ErrMsg = res3507for10188.ErrMsg
  3143. res3.Cainfo = res3507for10188.Cainfo
  3144. res3.WarnMsg = res3507for10188.WarnMsg
  3145. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3146. res3.Infcode = infocode
  3147. } else {
  3148. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3149. utils.ErrorLog("解析失败:%v", err)
  3150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3151. return
  3152. }
  3153. }
  3154. if res3.Infcode == 0 {
  3155. item.IsChange = 1
  3156. item.BgBchno = bg_number
  3157. service.SaveDF2(item)
  3158. } else {
  3159. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3160. }
  3161. }
  3162. } else { //没销售,
  3163. //进行商品销售退货接口
  3164. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3165. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3166. saveLog(result111, result222, "3506", "销售退货")
  3167. var res7 FJ3507Result
  3168. //进行商品销售接口
  3169. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3170. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3171. var respJSON3 map[string]interface{}
  3172. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3173. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3175. return
  3176. }
  3177. userJSONBytes3, _ := json.Marshal(respJSON3)
  3178. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3179. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3180. utils.ErrorLog("解析失败:%v", err)
  3181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3182. return
  3183. }
  3184. //if res3507for10188.Infcode
  3185. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3186. //res.Output = resSix10265.Output
  3187. res7.ErrMsg = res3507for10188.ErrMsg
  3188. res7.Cainfo = res3507for10188.Cainfo
  3189. res7.WarnMsg = res3507for10188.WarnMsg
  3190. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3191. res7.Infcode = infocode
  3192. } else {
  3193. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3194. utils.ErrorLog("解析失败:%v", err)
  3195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3196. return
  3197. }
  3198. }
  3199. if res7.Infcode == 0 {
  3200. item.IsSale = 2
  3201. item.SaleDate = item.SaleDate
  3202. item.Bchno = number
  3203. service.SaveDF(item)
  3204. if item.IsChange == 0 { //没变更,进行变更操作
  3205. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3206. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3207. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3208. var respJSON3 map[string]interface{}
  3209. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3210. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3212. return
  3213. }
  3214. userJSONBytes3, _ := json.Marshal(respJSON3)
  3215. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3216. // utils.ErrorLog("解析失败:%v", err)
  3217. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3218. // return
  3219. //}
  3220. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3221. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3222. utils.ErrorLog("解析失败:%v", err)
  3223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3224. return
  3225. }
  3226. //if res3507for10188.Infcode
  3227. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3228. //res.Output = resSix10265.Output
  3229. res3.ErrMsg = res3507for10188.ErrMsg
  3230. res3.Cainfo = res3507for10188.Cainfo
  3231. res3.WarnMsg = res3507for10188.WarnMsg
  3232. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3233. res3.Infcode = infocode
  3234. } else {
  3235. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3236. utils.ErrorLog("解析失败:%v", err)
  3237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3238. return
  3239. }
  3240. }
  3241. if res3.Infcode == 0 {
  3242. item.IsChange = 1
  3243. item.BgBchno = bg_number
  3244. service.SaveDF2(item)
  3245. } else {
  3246. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3247. }
  3248. }
  3249. } else {
  3250. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3251. }
  3252. }
  3253. } else { //还没结算
  3254. if item.IsChange == 0 { //没变更,进行变更操作
  3255. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3256. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3257. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3258. var respJSON3 map[string]interface{}
  3259. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3260. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3262. return
  3263. }
  3264. userJSONBytes3, _ := json.Marshal(respJSON3)
  3265. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3266. // utils.ErrorLog("解析失败:%v", err)
  3267. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3268. // return
  3269. //}
  3270. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3271. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3272. utils.ErrorLog("解析失败:%v", err)
  3273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3274. return
  3275. }
  3276. //if res3507for10188.Infcode
  3277. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3278. //res.Output = resSix10265.Output
  3279. res3.ErrMsg = res3507for10188.ErrMsg
  3280. res3.Cainfo = res3507for10188.Cainfo
  3281. res3.WarnMsg = res3507for10188.WarnMsg
  3282. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3283. res3.Infcode = infocode
  3284. } else {
  3285. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3286. utils.ErrorLog("解析失败:%v", err)
  3287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3288. return
  3289. }
  3290. }
  3291. if res3.Infcode == 0 {
  3292. item.IsChange = 1
  3293. item.BgBchno = bg_number
  3294. service.SaveDF2(item)
  3295. } else {
  3296. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3297. }
  3298. }
  3299. }
  3300. }
  3301. }
  3302. if len(err) == 0 {
  3303. c.ServeSuccessJSON(map[string]interface{}{
  3304. "msg": "销售变更成功",
  3305. })
  3306. } else {
  3307. c.ServeSuccessJSON(map[string]interface{}{
  3308. "failed_code": -10,
  3309. "msg": err,
  3310. })
  3311. }
  3312. }
  3313. func (c *HisApiController) ChangeDrugtwo() {
  3314. //ids := c.GetString("ids")
  3315. //id_arr := strings.Split(ids, ",")
  3316. flows, _ := service.GetNewDrugFlowInfotwo()
  3317. admin_user_id, _ := c.GetInt64("admin_user_id")
  3318. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3319. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3320. var err []string
  3321. for _, item := range flows {
  3322. var res3 ResultSix
  3323. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3324. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3325. if prescription.OrderStatus == 2 {
  3326. //已经结算
  3327. //判断是否已经销售
  3328. if item.IsSale == 1 { //是否已经销售,1是 0否
  3329. //是否已经变更 1是 0否
  3330. if item.IsChange == 0 { //没变更,进行变更操作
  3331. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3332. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3333. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3334. var respJSON3 map[string]interface{}
  3335. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3336. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3338. return
  3339. }
  3340. userJSONBytes3, _ := json.Marshal(respJSON3)
  3341. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3342. utils.ErrorLog("解析失败:%v", err)
  3343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3344. return
  3345. }
  3346. if res3.Infcode == 0 {
  3347. item.IsChange = 1
  3348. item.BgBchno = bg_number
  3349. service.SaveDF2(item)
  3350. } else {
  3351. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3352. }
  3353. }
  3354. } else { //没销售,
  3355. var res FJ3507Result
  3356. var res3507for10188 FJ3507ResultFor10188
  3357. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3358. //进行商品销售接口
  3359. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3360. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3361. var respJSON3 map[string]interface{}
  3362. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3363. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3365. return
  3366. }
  3367. userJSONBytes3, _ := json.Marshal(respJSON3)
  3368. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3369. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3370. utils.ErrorLog("解析失败:%v", err)
  3371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3372. return
  3373. }
  3374. //if res3507for10188.Infcode
  3375. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3376. //res.Output = resSix10265.Output
  3377. res.ErrMsg = res3507for10188.ErrMsg
  3378. res.Cainfo = res3507for10188.Cainfo
  3379. res.WarnMsg = res3507for10188.WarnMsg
  3380. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3381. res.Infcode = infocode
  3382. } else {
  3383. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3384. utils.ErrorLog("解析失败:%v", err)
  3385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3386. return
  3387. }
  3388. }
  3389. if res.Infcode == 0 {
  3390. item.IsSale = 1
  3391. item.Bchno = number
  3392. item.SaleDate = time.Now().Format("2006-01-02")
  3393. err5 := service.SaveDF(item)
  3394. if err5 == nil {
  3395. if item.IsChange == 0 { //没变更,进行变更操作
  3396. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3397. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3398. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3399. var respJSON3 map[string]interface{}
  3400. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3401. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3403. return
  3404. }
  3405. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3406. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3407. utils.ErrorLog("解析失败:%v", err)
  3408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3409. return
  3410. }
  3411. //if res3507for10188.Infcode
  3412. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3413. //res.Output = resSix10265.Output
  3414. res3.ErrMsg = res3507for10188.ErrMsg
  3415. res3.Cainfo = res3507for10188.Cainfo
  3416. res3.WarnMsg = res3507for10188.WarnMsg
  3417. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3418. res3.Infcode = infocode
  3419. } else {
  3420. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3421. utils.ErrorLog("解析失败:%v", err)
  3422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3423. return
  3424. }
  3425. }
  3426. if res3.Infcode == 0 {
  3427. item.IsChange = 1
  3428. item.BgBchno = bg_number
  3429. service.SaveDF2(item)
  3430. } else {
  3431. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3432. }
  3433. }
  3434. }
  3435. } else {
  3436. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3437. }
  3438. }
  3439. } else { //还没结算
  3440. var res3507for10188 FJ3507ResultFor10188
  3441. if item.IsChange == 0 { //没变更,进行变更操作
  3442. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3443. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3444. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3445. var respJSON3 map[string]interface{}
  3446. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3447. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3449. return
  3450. }
  3451. userJSONBytes3, _ := json.Marshal(respJSON3)
  3452. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3453. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3454. utils.ErrorLog("解析失败:%v", err)
  3455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3456. return
  3457. }
  3458. //if res3507for10188.Infcode
  3459. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3460. //res.Output = resSix10265.Output
  3461. res3.ErrMsg = res3507for10188.ErrMsg
  3462. res3.Cainfo = res3507for10188.Cainfo
  3463. res3.WarnMsg = res3507for10188.WarnMsg
  3464. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3465. res3.Infcode = infocode
  3466. } else {
  3467. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3468. utils.ErrorLog("解析失败:%v", err)
  3469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3470. return
  3471. }
  3472. }
  3473. if res3.Infcode == 0 {
  3474. item.IsChange = 1
  3475. item.BgBchno = bg_number
  3476. service.SaveDF2(item)
  3477. } else {
  3478. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3479. }
  3480. }
  3481. }
  3482. } else if item.ConsumableType == 7 {
  3483. var res3507for10188 FJ3507ResultFor10188
  3484. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3485. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3486. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3487. //判断是否已经销售
  3488. if item.IsSale == 2 { //是否已经销售,1是 0否
  3489. //是否已经变更 1是 0否
  3490. if item.IsChange == 0 { //没变更,进行变更操作
  3491. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3492. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3493. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3494. var respJSON3 map[string]interface{}
  3495. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3496. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3498. return
  3499. }
  3500. userJSONBytes3, _ := json.Marshal(respJSON3)
  3501. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3502. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3503. utils.ErrorLog("解析失败:%v", err)
  3504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3505. return
  3506. }
  3507. //if res3507for10188.Infcode
  3508. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3509. //res.Output = resSix10265.Output
  3510. res3.ErrMsg = res3507for10188.ErrMsg
  3511. res3.Cainfo = res3507for10188.Cainfo
  3512. res3.WarnMsg = res3507for10188.WarnMsg
  3513. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3514. res3.Infcode = infocode
  3515. } else {
  3516. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3517. utils.ErrorLog("解析失败:%v", err)
  3518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3519. return
  3520. }
  3521. }
  3522. if res3.Infcode == 0 {
  3523. item.IsChange = 1
  3524. item.BgBchno = bg_number
  3525. service.SaveDF2(item)
  3526. } else {
  3527. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3528. }
  3529. }
  3530. } else { //没销售,
  3531. //进行商品销售退货接口
  3532. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3533. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3534. saveLog(result111, result222, "3506", "销售退货")
  3535. var res7 FJ3507Result
  3536. //进行商品销售接口
  3537. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3538. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3539. var respJSON3 map[string]interface{}
  3540. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3541. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3543. return
  3544. }
  3545. userJSONBytes3, _ := json.Marshal(respJSON3)
  3546. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3547. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3548. utils.ErrorLog("解析失败:%v", err)
  3549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3550. return
  3551. }
  3552. //if res3507for10188.Infcode
  3553. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3554. //res.Output = resSix10265.Output
  3555. res7.ErrMsg = res3507for10188.ErrMsg
  3556. res7.Cainfo = res3507for10188.Cainfo
  3557. res7.WarnMsg = res3507for10188.WarnMsg
  3558. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3559. res7.Infcode = infocode
  3560. } else {
  3561. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3562. utils.ErrorLog("解析失败:%v", err)
  3563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3564. return
  3565. }
  3566. }
  3567. if res7.Infcode == 0 {
  3568. item.IsSale = 2
  3569. item.SaleDate = item.SaleDate
  3570. item.Bchno = number
  3571. service.SaveDF(item)
  3572. if item.IsChange == 0 { //没变更,进行变更操作
  3573. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3574. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3575. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3576. var respJSON3 map[string]interface{}
  3577. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3578. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3580. return
  3581. }
  3582. userJSONBytes3, _ := json.Marshal(respJSON3)
  3583. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3584. // utils.ErrorLog("解析失败:%v", err)
  3585. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3586. // return
  3587. //}
  3588. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3589. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3590. utils.ErrorLog("解析失败:%v", err)
  3591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3592. return
  3593. }
  3594. //if res3507for10188.Infcode
  3595. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3596. //res.Output = resSix10265.Output
  3597. res3.ErrMsg = res3507for10188.ErrMsg
  3598. res3.Cainfo = res3507for10188.Cainfo
  3599. res3.WarnMsg = res3507for10188.WarnMsg
  3600. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3601. res3.Infcode = infocode
  3602. } else {
  3603. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3604. utils.ErrorLog("解析失败:%v", err)
  3605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3606. return
  3607. }
  3608. }
  3609. if res3.Infcode == 0 {
  3610. item.IsChange = 1
  3611. item.BgBchno = bg_number
  3612. service.SaveDF2(item)
  3613. } else {
  3614. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3615. }
  3616. }
  3617. } else {
  3618. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3619. }
  3620. }
  3621. } else { //还没结算
  3622. if item.IsChange == 0 { //没变更,进行变更操作
  3623. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3624. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3625. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3626. var respJSON3 map[string]interface{}
  3627. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3630. return
  3631. }
  3632. userJSONBytes3, _ := json.Marshal(respJSON3)
  3633. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3634. // utils.ErrorLog("解析失败:%v", err)
  3635. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3636. // return
  3637. //}
  3638. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3639. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3640. utils.ErrorLog("解析失败:%v", err)
  3641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3642. return
  3643. }
  3644. //if res3507for10188.Infcode
  3645. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3646. //res.Output = resSix10265.Output
  3647. res3.ErrMsg = res3507for10188.ErrMsg
  3648. res3.Cainfo = res3507for10188.Cainfo
  3649. res3.WarnMsg = res3507for10188.WarnMsg
  3650. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3651. res3.Infcode = infocode
  3652. } else {
  3653. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3654. utils.ErrorLog("解析失败:%v", err)
  3655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3656. return
  3657. }
  3658. }
  3659. if res3.Infcode == 0 {
  3660. item.IsChange = 1
  3661. item.BgBchno = bg_number
  3662. service.SaveDF2(item)
  3663. } else {
  3664. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3665. }
  3666. }
  3667. }
  3668. }
  3669. }
  3670. if len(err) == 0 {
  3671. c.ServeSuccessJSON(map[string]interface{}{
  3672. "msg": "销售变更成功",
  3673. })
  3674. } else {
  3675. c.ServeSuccessJSON(map[string]interface{}{
  3676. "failed_code": -10,
  3677. "msg": err,
  3678. })
  3679. }
  3680. }
  3681. func (c *HisApiController) ChangeDrugthree() {
  3682. //ids := c.GetString("ids")
  3683. //id_arr := strings.Split(ids, ",")
  3684. flows, _ := service.GetNewDrugFlowInfothree()
  3685. admin_user_id, _ := c.GetInt64("admin_user_id")
  3686. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3687. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3688. var err []string
  3689. for _, item := range flows {
  3690. var res3 ResultSix
  3691. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3692. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3693. if prescription.OrderStatus == 2 {
  3694. //已经结算
  3695. //判断是否已经销售
  3696. if item.IsSale == 1 { //是否已经销售,1是 0否
  3697. //是否已经变更 1是 0否
  3698. if item.IsChange == 0 { //没变更,进行变更操作
  3699. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3700. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3701. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3702. var respJSON3 map[string]interface{}
  3703. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3706. return
  3707. }
  3708. userJSONBytes3, _ := json.Marshal(respJSON3)
  3709. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3710. utils.ErrorLog("解析失败:%v", err)
  3711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3712. return
  3713. }
  3714. if res3.Infcode == 0 {
  3715. item.IsChange = 1
  3716. item.BgBchno = bg_number
  3717. service.SaveDF2(item)
  3718. } else {
  3719. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3720. }
  3721. }
  3722. } else { //没销售,
  3723. var res FJ3507Result
  3724. var res3507for10188 FJ3507ResultFor10188
  3725. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3726. //进行商品销售接口
  3727. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3728. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3729. var respJSON3 map[string]interface{}
  3730. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3731. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3733. return
  3734. }
  3735. userJSONBytes3, _ := json.Marshal(respJSON3)
  3736. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3737. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3738. utils.ErrorLog("解析失败:%v", err)
  3739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3740. return
  3741. }
  3742. //if res3507for10188.Infcode
  3743. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3744. //res.Output = resSix10265.Output
  3745. res.ErrMsg = res3507for10188.ErrMsg
  3746. res.Cainfo = res3507for10188.Cainfo
  3747. res.WarnMsg = res3507for10188.WarnMsg
  3748. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3749. res.Infcode = infocode
  3750. } else {
  3751. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3752. utils.ErrorLog("解析失败:%v", err)
  3753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3754. return
  3755. }
  3756. }
  3757. if res.Infcode == 0 {
  3758. item.IsSale = 1
  3759. item.Bchno = number
  3760. item.SaleDate = time.Now().Format("2006-01-02")
  3761. err5 := service.SaveDF(item)
  3762. if err5 == nil {
  3763. if item.IsChange == 0 { //没变更,进行变更操作
  3764. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3765. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3766. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3767. var respJSON3 map[string]interface{}
  3768. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3769. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3771. return
  3772. }
  3773. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  3774. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3775. utils.ErrorLog("解析失败:%v", err)
  3776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3777. return
  3778. }
  3779. //if res3507for10188.Infcode
  3780. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3781. //res.Output = resSix10265.Output
  3782. res3.ErrMsg = res3507for10188.ErrMsg
  3783. res3.Cainfo = res3507for10188.Cainfo
  3784. res3.WarnMsg = res3507for10188.WarnMsg
  3785. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3786. res3.Infcode = infocode
  3787. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3788. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3789. utils.ErrorLog("解析失败:%v", err)
  3790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3791. return
  3792. }
  3793. //if res3507for10188.Infcode
  3794. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3795. //res.Output = resSix10265.Output
  3796. res3.ErrMsg = res3507for10188.ErrMsg
  3797. res3.Cainfo = res3507for10188.Cainfo
  3798. res3.WarnMsg = res3507for10188.WarnMsg
  3799. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3800. res3.Infcode = infocode
  3801. } else {
  3802. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3803. utils.ErrorLog("解析失败:%v", err)
  3804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3805. return
  3806. }
  3807. }
  3808. if res3.Infcode == 0 {
  3809. item.IsChange = 1
  3810. item.BgBchno = bg_number
  3811. service.SaveDF2(item)
  3812. } else {
  3813. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3814. }
  3815. }
  3816. }
  3817. } else {
  3818. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3819. }
  3820. }
  3821. } else { //还没结算
  3822. var res3507for10188 FJ3507ResultFor10188
  3823. if item.IsChange == 0 { //没变更,进行变更操作
  3824. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3825. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3826. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3827. var respJSON3 map[string]interface{}
  3828. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3829. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3831. return
  3832. }
  3833. userJSONBytes3, _ := json.Marshal(respJSON3)
  3834. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  3835. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3836. utils.ErrorLog("解析失败:%v", err)
  3837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3838. return
  3839. }
  3840. //if res3507for10188.Infcode
  3841. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3842. //res.Output = resSix10265.Output
  3843. res3.ErrMsg = res3507for10188.ErrMsg
  3844. res3.Cainfo = res3507for10188.Cainfo
  3845. res3.WarnMsg = res3507for10188.WarnMsg
  3846. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3847. res3.Infcode = infocode
  3848. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3849. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3850. utils.ErrorLog("解析失败:%v", err)
  3851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3852. return
  3853. }
  3854. //if res3507for10188.Infcode
  3855. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3856. //res.Output = resSix10265.Output
  3857. res3.ErrMsg = res3507for10188.ErrMsg
  3858. res3.Cainfo = res3507for10188.Cainfo
  3859. res3.WarnMsg = res3507for10188.WarnMsg
  3860. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3861. res3.Infcode = infocode
  3862. } else {
  3863. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3864. utils.ErrorLog("解析失败:%v", err)
  3865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3866. return
  3867. }
  3868. }
  3869. if res3.Infcode == 0 {
  3870. item.IsChange = 1
  3871. item.BgBchno = bg_number
  3872. service.SaveDF2(item)
  3873. } else {
  3874. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3875. }
  3876. }
  3877. }
  3878. } else if item.ConsumableType == 7 {
  3879. var res3507for10188 FJ3507ResultFor10188
  3880. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3881. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3882. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3883. //判断是否已经销售
  3884. if item.IsSale == 2 { //是否已经销售,1是 0否
  3885. //是否已经变更 1是 0否
  3886. if item.IsChange == 0 { //没变更,进行变更操作
  3887. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3888. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3889. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3890. var respJSON3 map[string]interface{}
  3891. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3892. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3894. return
  3895. }
  3896. userJSONBytes3, _ := json.Marshal(respJSON3)
  3897. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3898. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3899. utils.ErrorLog("解析失败:%v", err)
  3900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3901. return
  3902. }
  3903. //if res3507for10188.Infcode
  3904. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3905. //res.Output = resSix10265.Output
  3906. res3.ErrMsg = res3507for10188.ErrMsg
  3907. res3.Cainfo = res3507for10188.Cainfo
  3908. res3.WarnMsg = res3507for10188.WarnMsg
  3909. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3910. res3.Infcode = infocode
  3911. } else {
  3912. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3913. utils.ErrorLog("解析失败:%v", err)
  3914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3915. return
  3916. }
  3917. }
  3918. if res3.Infcode == 0 {
  3919. item.IsChange = 1
  3920. item.BgBchno = bg_number
  3921. service.SaveDF2(item)
  3922. } else {
  3923. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3924. }
  3925. }
  3926. } else { //没销售,
  3927. //进行商品销售退货接口
  3928. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3929. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3930. saveLog(result111, result222, "3506", "销售退货")
  3931. var res7 FJ3507Result
  3932. //进行商品销售接口
  3933. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3934. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3935. var respJSON3 map[string]interface{}
  3936. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3937. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3939. return
  3940. }
  3941. userJSONBytes3, _ := json.Marshal(respJSON3)
  3942. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3943. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3944. utils.ErrorLog("解析失败:%v", err)
  3945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3946. return
  3947. }
  3948. //if res3507for10188.Infcode
  3949. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3950. //res.Output = resSix10265.Output
  3951. res7.ErrMsg = res3507for10188.ErrMsg
  3952. res7.Cainfo = res3507for10188.Cainfo
  3953. res7.WarnMsg = res3507for10188.WarnMsg
  3954. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3955. res7.Infcode = infocode
  3956. } else {
  3957. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3958. utils.ErrorLog("解析失败:%v", err)
  3959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3960. return
  3961. }
  3962. }
  3963. if res7.Infcode == 0 {
  3964. item.IsSale = 2
  3965. item.SaleDate = item.SaleDate
  3966. item.Bchno = number
  3967. service.SaveDF(item)
  3968. if item.IsChange == 0 { //没变更,进行变更操作
  3969. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3970. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3971. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3972. var respJSON3 map[string]interface{}
  3973. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3974. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3976. return
  3977. }
  3978. userJSONBytes3, _ := json.Marshal(respJSON3)
  3979. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3980. // utils.ErrorLog("解析失败:%v", err)
  3981. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3982. // return
  3983. //}
  3984. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3985. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3986. utils.ErrorLog("解析失败:%v", err)
  3987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3988. return
  3989. }
  3990. //if res3507for10188.Infcode
  3991. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3992. //res.Output = resSix10265.Output
  3993. res3.ErrMsg = res3507for10188.ErrMsg
  3994. res3.Cainfo = res3507for10188.Cainfo
  3995. res3.WarnMsg = res3507for10188.WarnMsg
  3996. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3997. res3.Infcode = infocode
  3998. } else {
  3999. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4000. utils.ErrorLog("解析失败:%v", err)
  4001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4002. return
  4003. }
  4004. }
  4005. if res3.Infcode == 0 {
  4006. item.IsChange = 1
  4007. item.BgBchno = bg_number
  4008. service.SaveDF2(item)
  4009. } else {
  4010. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4011. }
  4012. }
  4013. } else {
  4014. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4015. }
  4016. }
  4017. } else { //还没结算
  4018. if item.IsChange == 0 { //没变更,进行变更操作
  4019. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4020. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4021. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4022. var respJSON3 map[string]interface{}
  4023. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4024. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4026. return
  4027. }
  4028. userJSONBytes3, _ := json.Marshal(respJSON3)
  4029. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4030. // utils.ErrorLog("解析失败:%v", err)
  4031. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4032. // return
  4033. //}
  4034. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4035. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4036. utils.ErrorLog("解析失败:%v", err)
  4037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4038. return
  4039. }
  4040. //if res3507for10188.Infcode
  4041. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4042. //res.Output = resSix10265.Output
  4043. res3.ErrMsg = res3507for10188.ErrMsg
  4044. res3.Cainfo = res3507for10188.Cainfo
  4045. res3.WarnMsg = res3507for10188.WarnMsg
  4046. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4047. res3.Infcode = infocode
  4048. } else {
  4049. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4050. utils.ErrorLog("解析失败:%v", err)
  4051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4052. return
  4053. }
  4054. }
  4055. if res3.Infcode == 0 {
  4056. item.IsChange = 1
  4057. item.BgBchno = bg_number
  4058. service.SaveDF2(item)
  4059. } else {
  4060. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4061. }
  4062. }
  4063. }
  4064. }
  4065. }
  4066. if len(err) == 0 {
  4067. c.ServeSuccessJSON(map[string]interface{}{
  4068. "msg": "销售变更成功",
  4069. })
  4070. } else {
  4071. c.ServeSuccessJSON(map[string]interface{}{
  4072. "failed_code": -10,
  4073. "msg": err,
  4074. })
  4075. }
  4076. }
  4077. func (c *HisApiController) ChangeDrugTen() {
  4078. //ids := c.GetString("ids")
  4079. //id_arr := strings.Split(ids, ",")
  4080. flows, _ := service.GetNewDrugFlowInforTen()
  4081. admin_user_id, _ := c.GetInt64("admin_user_id")
  4082. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4083. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4084. var err []string
  4085. for _, item := range flows {
  4086. var res3 ResultSix
  4087. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4088. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4089. if prescription.OrderStatus == 2 {
  4090. //已经结算
  4091. //判断是否已经销售
  4092. if item.IsSale == 1 { //是否已经销售,1是 0否
  4093. //是否已经变更 1是 0否
  4094. if item.IsChange == 0 { //没变更,进行变更操作
  4095. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4096. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4097. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4098. var respJSON3 map[string]interface{}
  4099. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4100. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4102. return
  4103. }
  4104. userJSONBytes3, _ := json.Marshal(respJSON3)
  4105. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4106. utils.ErrorLog("解析失败:%v", err)
  4107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4108. return
  4109. }
  4110. if res3.Infcode == 0 {
  4111. item.IsChange = 1
  4112. item.BgBchno = bg_number
  4113. service.SaveDF2(item)
  4114. } else {
  4115. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4116. }
  4117. }
  4118. } else { //没销售,
  4119. var res FJ3507Result
  4120. var res3507for10188 FJ3507ResultFor10188
  4121. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4122. //进行商品销售接口
  4123. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4124. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4125. var respJSON3 map[string]interface{}
  4126. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4127. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4129. return
  4130. }
  4131. userJSONBytes3, _ := json.Marshal(respJSON3)
  4132. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4133. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4134. utils.ErrorLog("解析失败:%v", err)
  4135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4136. return
  4137. }
  4138. //if res3507for10188.Infcode
  4139. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4140. //res.Output = resSix10265.Output
  4141. res.ErrMsg = res3507for10188.ErrMsg
  4142. res.Cainfo = res3507for10188.Cainfo
  4143. res.WarnMsg = res3507for10188.WarnMsg
  4144. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4145. res.Infcode = infocode
  4146. } else {
  4147. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4148. utils.ErrorLog("解析失败:%v", err)
  4149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4150. return
  4151. }
  4152. }
  4153. if res.Infcode == 0 {
  4154. item.IsSale = 1
  4155. item.Bchno = number
  4156. item.SaleDate = time.Now().Format("2006-01-02")
  4157. err5 := service.SaveDF(item)
  4158. if err5 == nil {
  4159. if item.IsChange == 0 { //没变更,进行变更操作
  4160. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4161. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4162. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4163. var respJSON3 map[string]interface{}
  4164. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4167. return
  4168. }
  4169. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4170. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4171. utils.ErrorLog("解析失败:%v", err)
  4172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4173. return
  4174. }
  4175. //if res3507for10188.Infcode
  4176. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4177. //res.Output = resSix10265.Output
  4178. res3.ErrMsg = res3507for10188.ErrMsg
  4179. res3.Cainfo = res3507for10188.Cainfo
  4180. res3.WarnMsg = res3507for10188.WarnMsg
  4181. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4182. res3.Infcode = infocode
  4183. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4184. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4185. utils.ErrorLog("解析失败:%v", err)
  4186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4187. return
  4188. }
  4189. //if res3507for10188.Infcode
  4190. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4191. //res.Output = resSix10265.Output
  4192. res3.ErrMsg = res3507for10188.ErrMsg
  4193. res3.Cainfo = res3507for10188.Cainfo
  4194. res3.WarnMsg = res3507for10188.WarnMsg
  4195. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4196. res3.Infcode = infocode
  4197. } else {
  4198. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4199. utils.ErrorLog("解析失败:%v", err)
  4200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4201. return
  4202. }
  4203. }
  4204. if res3.Infcode == 0 {
  4205. item.IsChange = 1
  4206. item.BgBchno = bg_number
  4207. service.SaveDF2(item)
  4208. } else {
  4209. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4210. }
  4211. }
  4212. }
  4213. } else {
  4214. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4215. }
  4216. }
  4217. } else { //还没结算
  4218. var res3507for10188 FJ3507ResultFor10188
  4219. if item.IsChange == 0 { //没变更,进行变更操作
  4220. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4221. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4222. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4223. var respJSON3 map[string]interface{}
  4224. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4225. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4227. return
  4228. }
  4229. userJSONBytes3, _ := json.Marshal(respJSON3)
  4230. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4231. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4232. utils.ErrorLog("解析失败:%v", err)
  4233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4234. return
  4235. }
  4236. //if res3507for10188.Infcode
  4237. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4238. //res.Output = resSix10265.Output
  4239. res3.ErrMsg = res3507for10188.ErrMsg
  4240. res3.Cainfo = res3507for10188.Cainfo
  4241. res3.WarnMsg = res3507for10188.WarnMsg
  4242. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4243. res3.Infcode = infocode
  4244. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4245. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4246. utils.ErrorLog("解析失败:%v", err)
  4247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4248. return
  4249. }
  4250. //if res3507for10188.Infcode
  4251. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4252. //res.Output = resSix10265.Output
  4253. res3.ErrMsg = res3507for10188.ErrMsg
  4254. res3.Cainfo = res3507for10188.Cainfo
  4255. res3.WarnMsg = res3507for10188.WarnMsg
  4256. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4257. res3.Infcode = infocode
  4258. } else {
  4259. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4260. utils.ErrorLog("解析失败:%v", err)
  4261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4262. return
  4263. }
  4264. }
  4265. if res3.Infcode == 0 {
  4266. item.IsChange = 1
  4267. item.BgBchno = bg_number
  4268. service.SaveDF2(item)
  4269. } else {
  4270. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4271. }
  4272. }
  4273. }
  4274. } else if item.ConsumableType == 7 {
  4275. var res3507for10188 FJ3507ResultFor10188
  4276. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4277. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4278. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4279. //判断是否已经销售
  4280. if item.IsSale == 2 { //是否已经销售,1是 0否
  4281. //是否已经变更 1是 0否
  4282. if item.IsChange == 0 { //没变更,进行变更操作
  4283. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4284. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4285. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4286. var respJSON3 map[string]interface{}
  4287. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4290. return
  4291. }
  4292. userJSONBytes3, _ := json.Marshal(respJSON3)
  4293. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4294. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4295. utils.ErrorLog("解析失败:%v", err)
  4296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4297. return
  4298. }
  4299. //if res3507for10188.Infcode
  4300. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4301. //res.Output = resSix10265.Output
  4302. res3.ErrMsg = res3507for10188.ErrMsg
  4303. res3.Cainfo = res3507for10188.Cainfo
  4304. res3.WarnMsg = res3507for10188.WarnMsg
  4305. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4306. res3.Infcode = infocode
  4307. } else {
  4308. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4309. utils.ErrorLog("解析失败:%v", err)
  4310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4311. return
  4312. }
  4313. }
  4314. if res3.Infcode == 0 {
  4315. item.IsChange = 1
  4316. item.BgBchno = bg_number
  4317. service.SaveDF2(item)
  4318. } else {
  4319. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4320. }
  4321. }
  4322. } else { //没销售,
  4323. //进行商品销售退货接口
  4324. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4325. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4326. saveLog(result111, result222, "3506", "销售退货")
  4327. var res7 FJ3507Result
  4328. //进行商品销售接口
  4329. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4330. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4331. var respJSON3 map[string]interface{}
  4332. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4333. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4335. return
  4336. }
  4337. userJSONBytes3, _ := json.Marshal(respJSON3)
  4338. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4339. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4340. utils.ErrorLog("解析失败:%v", err)
  4341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4342. return
  4343. }
  4344. //if res3507for10188.Infcode
  4345. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4346. //res.Output = resSix10265.Output
  4347. res7.ErrMsg = res3507for10188.ErrMsg
  4348. res7.Cainfo = res3507for10188.Cainfo
  4349. res7.WarnMsg = res3507for10188.WarnMsg
  4350. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4351. res7.Infcode = infocode
  4352. } else {
  4353. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4354. utils.ErrorLog("解析失败:%v", err)
  4355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4356. return
  4357. }
  4358. }
  4359. if res7.Infcode == 0 {
  4360. item.IsSale = 2
  4361. item.SaleDate = item.SaleDate
  4362. item.Bchno = number
  4363. service.SaveDF(item)
  4364. if item.IsChange == 0 { //没变更,进行变更操作
  4365. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4366. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4367. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4368. var respJSON3 map[string]interface{}
  4369. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4370. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4372. return
  4373. }
  4374. userJSONBytes3, _ := json.Marshal(respJSON3)
  4375. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4376. // utils.ErrorLog("解析失败:%v", err)
  4377. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4378. // return
  4379. //}
  4380. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4381. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4382. utils.ErrorLog("解析失败:%v", err)
  4383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4384. return
  4385. }
  4386. //if res3507for10188.Infcode
  4387. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4388. //res.Output = resSix10265.Output
  4389. res3.ErrMsg = res3507for10188.ErrMsg
  4390. res3.Cainfo = res3507for10188.Cainfo
  4391. res3.WarnMsg = res3507for10188.WarnMsg
  4392. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4393. res3.Infcode = infocode
  4394. } else {
  4395. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4396. utils.ErrorLog("解析失败:%v", err)
  4397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4398. return
  4399. }
  4400. }
  4401. if res3.Infcode == 0 {
  4402. item.IsChange = 1
  4403. item.BgBchno = bg_number
  4404. service.SaveDF2(item)
  4405. } else {
  4406. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4407. }
  4408. }
  4409. } else {
  4410. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4411. }
  4412. }
  4413. } else { //还没结算
  4414. if item.IsChange == 0 { //没变更,进行变更操作
  4415. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4416. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4417. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4418. var respJSON3 map[string]interface{}
  4419. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4420. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4422. return
  4423. }
  4424. userJSONBytes3, _ := json.Marshal(respJSON3)
  4425. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4426. // utils.ErrorLog("解析失败:%v", err)
  4427. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4428. // return
  4429. //}
  4430. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4431. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4432. utils.ErrorLog("解析失败:%v", err)
  4433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4434. return
  4435. }
  4436. //if res3507for10188.Infcode
  4437. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4438. //res.Output = resSix10265.Output
  4439. res3.ErrMsg = res3507for10188.ErrMsg
  4440. res3.Cainfo = res3507for10188.Cainfo
  4441. res3.WarnMsg = res3507for10188.WarnMsg
  4442. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4443. res3.Infcode = infocode
  4444. } else {
  4445. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4446. utils.ErrorLog("解析失败:%v", err)
  4447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4448. return
  4449. }
  4450. }
  4451. if res3.Infcode == 0 {
  4452. item.IsChange = 1
  4453. item.BgBchno = bg_number
  4454. service.SaveDF2(item)
  4455. } else {
  4456. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4457. }
  4458. }
  4459. }
  4460. }
  4461. }
  4462. if len(err) == 0 {
  4463. c.ServeSuccessJSON(map[string]interface{}{
  4464. "msg": "销售变更成功",
  4465. })
  4466. } else {
  4467. c.ServeSuccessJSON(map[string]interface{}{
  4468. "failed_code": -10,
  4469. "msg": err,
  4470. })
  4471. }
  4472. }
  4473. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4474. var struct3502 models.Struct3502
  4475. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4476. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4477. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4478. struct3502.FixmedinsCode = miConfig.Code
  4479. struct3502.Code = miConfig.Code
  4480. struct3502.Opter = role.UserName
  4481. struct3502.RxFlag = "0"
  4482. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  4483. struct3502.OrgName = miConfig.OrgName
  4484. struct3502.AccessKey = miConfig.AccessKey
  4485. struct3502.RequestUrl = miConfig.Url
  4486. struct3502.SecretKey = miConfig.SecretKey
  4487. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4488. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4489. struct3502.Url = miConfig.Url
  4490. struct3502.AppId = miConfig.Cainfo
  4491. struct3502.AppSecret = miConfig.AppSecret
  4492. struct3502.Enckey = miConfig.EncKey
  4493. struct3502.SignKey = miConfig.SignKey
  4494. struct3502.SecretKey = miConfig.SecretKey
  4495. struct3502.InvChgType = chgType
  4496. struct3502.FixmedinsBchno = number
  4497. struct3502.Cnt = strconv.FormatInt(count, 10)
  4498. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  4499. //result1, result2, _ := service.FJyb3502(struct3502)
  4500. if miConfig.MdtrtareaAdmvs == "350500" {
  4501. result1, result2, _ := service.FJyb3502(struct3502)
  4502. //saveLog(result1, result2, "3502", "3502")
  4503. return result1, result2
  4504. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4505. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  4506. return result1, result2
  4507. } else {
  4508. data := make(map[string]interface{})
  4509. data["struct_3502s"] = struct3502
  4510. client := &http.Client{}
  4511. bytesData, _ := json.Marshal(data)
  4512. var req *http.Request
  4513. if miConfig.MdtrtareaAdmvs == "320921" {
  4514. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4515. } else {
  4516. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4517. }
  4518. resp, _ := client.Do(req)
  4519. defer resp.Body.Close()
  4520. body, ioErr := ioutil.ReadAll(resp.Body)
  4521. if ioErr != nil {
  4522. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4523. }
  4524. var respJSON map[string]interface{}
  4525. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4526. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4527. }
  4528. //var resSix10265 ResultSix10265 //1101结果
  4529. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4530. result, _ := json.Marshal(respJSON)
  4531. return string(result), ""
  4532. }
  4533. }
  4534. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4535. var struct3505 models.Struct3505
  4536. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4537. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4538. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4539. struct3505.FixmedinsBchno = number
  4540. struct3505.Opter = role.UserName
  4541. struct3505.FixmedinsCode = miConfig.Code
  4542. struct3505.Code = miConfig.Code
  4543. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  4544. struct3505.PrscDrName = roles.UserName
  4545. if org_id == 10191 {
  4546. struct3505.PharName = "刘水山"
  4547. struct3505.PharPracCertNo = "2015026350260000002611351127"
  4548. }
  4549. if org_id == 10188 {
  4550. struct3505.PharName = "李汉清"
  4551. struct3505.PharPracCertNo = "30220200932022010034"
  4552. }
  4553. if org_id == 10217 {
  4554. struct3505.PharName = "张敏"
  4555. struct3505.PharPracCertNo = "30220230432090100108"
  4556. }
  4557. if org_id == 10318 {
  4558. struct3505.PharName = "张敏"
  4559. struct3505.PharPracCertNo = "30220230432090100108"
  4560. }
  4561. order := service.GetHisOrderByNumber(pre.BatchNumber)
  4562. struct3505.SetlId = order.SetlId
  4563. struct3505.MdtrtSn = order.MdtrtId
  4564. struct3505.ManuLotnum = drug.Number
  4565. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  4566. struct3505.ExpyEnd = ""
  4567. struct3505.RxFlag = "0"
  4568. struct3505.TrdnFlag = "1"
  4569. struct3505.RtalDocno = order.Number
  4570. struct3505.Url = miConfig.Url
  4571. struct3505.AppId = miConfig.Cainfo
  4572. struct3505.AppSecret = miConfig.AppSecret
  4573. struct3505.Enckey = miConfig.EncKey
  4574. struct3505.SignKey = miConfig.SignKey
  4575. struct3505.SecretKey = miConfig.SecretKey
  4576. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  4577. struct3505.SelRetnCnt = strValue
  4578. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4579. struct3505.SelRetnOpterName = role.UserName
  4580. if order.IsMedicineInsurance == 1 {
  4581. struct3505.MdtrtSetlType = "1"
  4582. } else {
  4583. struct3505.MdtrtSetlType = "2"
  4584. }
  4585. struct3505.OrgName = miConfig.OrgName
  4586. struct3505.AccessKey = miConfig.AccessKey
  4587. struct3505.RequestUrl = miConfig.Url
  4588. struct3505.SecretKey = miConfig.SecretKey
  4589. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4590. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4591. struct3505.DrugTracCodg = drug.DrugCode
  4592. if miConfig.MdtrtareaAdmvs == "350500" {
  4593. result1, result2, _ := service.FJyb3505(struct3505)
  4594. return result1, result2
  4595. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4596. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  4597. return result1, result2
  4598. } else {
  4599. data := make(map[string]interface{})
  4600. data["struct_3505s"] = struct3505
  4601. client := &http.Client{}
  4602. bytesData, _ := json.Marshal(data)
  4603. var req *http.Request
  4604. if miConfig.MdtrtareaAdmvs == "320921" {
  4605. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  4606. } else {
  4607. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  4608. }
  4609. resp, _ := client.Do(req)
  4610. defer resp.Body.Close()
  4611. body, ioErr := ioutil.ReadAll(resp.Body)
  4612. if ioErr != nil {
  4613. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4614. }
  4615. var respJSON map[string]interface{}
  4616. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4617. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4618. }
  4619. //var resSix10265 ResultSix10265 //1101结果
  4620. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4621. result, _ := json.Marshal(respJSON)
  4622. return string(result), ""
  4623. }
  4624. }
  4625. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4626. var struct3506 models.Struct3506
  4627. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4628. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4629. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4630. struct3506.FixmedinsCode = miConfig.Code
  4631. struct3506.Code = miConfig.Code
  4632. struct3506.FixmedinsBchno = number
  4633. struct3506.Opter = role.UserName
  4634. order := service.GetHisOrderByNumber(pre.BatchNumber)
  4635. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  4636. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  4637. struct3506.MdtrtSn = order.MdtrtId
  4638. struct3506.ExpyEnd = ""
  4639. struct3506.RxFlag = "0"
  4640. struct3506.TrdnFlag = "1"
  4641. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  4642. struct3506.SelRetnCnt = strValue
  4643. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4644. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  4645. struct3506.SelRetnOpterName = role.UserName
  4646. struct3506.OrgName = miConfig.OrgName
  4647. struct3506.AccessKey = miConfig.AccessKey
  4648. struct3506.RequestUrl = miConfig.Url
  4649. struct3506.SecretKey = miConfig.SecretKey
  4650. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4651. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4652. struct3506.Url = miConfig.Url
  4653. struct3506.AppId = miConfig.Cainfo
  4654. struct3506.AppSecret = miConfig.AppSecret
  4655. struct3506.Enckey = miConfig.EncKey
  4656. struct3506.SignKey = miConfig.SignKey
  4657. struct3506.SecretKey = miConfig.SecretKey
  4658. struct3506.DrugTracCodg = drug.DrugCode
  4659. if miConfig.MdtrtareaAdmvs == "350500" {
  4660. result1, result2, _ := service.FJyb3506(struct3506)
  4661. return result1, result2
  4662. } else {
  4663. data := make(map[string]interface{})
  4664. data["struct_3506s"] = struct3506
  4665. client := &http.Client{}
  4666. bytesData, _ := json.Marshal(data)
  4667. var req *http.Request
  4668. if miConfig.MdtrtareaAdmvs == "320921" {
  4669. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  4670. } else {
  4671. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  4672. }
  4673. resp, _ := client.Do(req)
  4674. defer resp.Body.Close()
  4675. body, ioErr := ioutil.ReadAll(resp.Body)
  4676. if ioErr != nil {
  4677. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4678. }
  4679. var respJSON map[string]interface{}
  4680. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4681. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4682. }
  4683. //var resSix10265 ResultSix10265 //1101结果
  4684. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4685. result, _ := json.Marshal(respJSON)
  4686. return string(result), ""
  4687. }
  4688. }
  4689. func (c *HisApiController) Get1318() {
  4690. adminUser := c.GetAdminUserInfo()
  4691. admin_user_id, _ := c.GetInt64("admin_user_id")
  4692. code := c.GetString("code")
  4693. code = ""
  4694. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4695. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4696. api := ""
  4697. if miConfig.MdtrtareaAdmvs == "320921" {
  4698. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  4699. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  4700. } else {
  4701. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  4702. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  4703. }
  4704. resp, requestErr := http.Get(api)
  4705. if requestErr != nil {
  4706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4707. return
  4708. }
  4709. body, ioErr := ioutil.ReadAll(resp.Body)
  4710. if ioErr != nil {
  4711. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4713. return
  4714. }
  4715. var respJSON map[string]interface{}
  4716. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4717. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4719. return
  4720. }
  4721. //var res Result2406
  4722. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4723. result, _ := json.Marshal(respJSON)
  4724. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4725. utils.ErrorLog("解析失败:%v", err)
  4726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4727. return
  4728. }
  4729. if res.Infcode == "0" {
  4730. c.ServeSuccessJSON(map[string]interface{}{
  4731. "result": "",
  4732. })
  4733. } else {
  4734. c.ServeSuccessJSON(map[string]interface{}{
  4735. "failed_code": -10,
  4736. "msg": res.ErrMsg,
  4737. })
  4738. */return
  4739. //}
  4740. }
  4741. func (c *HisApiController) Get2503() {
  4742. adminUser := c.GetAdminUserInfo()
  4743. admin_user_id, _ := c.GetInt64("admin_user_id")
  4744. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4745. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4746. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  4747. }
  4748. func (c *HisApiController) Get2406() {
  4749. id, _ := c.GetInt64("id")
  4750. record_time := c.GetString("record_time")
  4751. his_patient_id, _ := c.GetInt64("his_patient_id")
  4752. admin_user_id, _ := c.GetInt64("admin_user_id")
  4753. diagnosis_id := c.GetString("diagnosis")
  4754. timeLayout := "2006-01-02"
  4755. loc, _ := time.LoadLocation("Local")
  4756. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4757. if err != nil {
  4758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4759. return
  4760. }
  4761. recordDateTime := theTime.Unix()
  4762. adminUser := c.GetAdminUserInfo()
  4763. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4764. var config []*models.HisXtDiagnoseConfig
  4765. for _, item := range diagnosis_ids {
  4766. id, _ := strconv.ParseInt(item, 10, 64)
  4767. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4768. config = append(config, &diagnosisConfig)
  4769. }
  4770. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4771. fmt.Println(his_patient_id)
  4772. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4773. //timestamp := time.Now().Unix()
  4774. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4775. var patientPrescription models.HisPrescriptionInfo
  4776. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4777. if patientPrescription.ID == 0 {
  4778. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4779. }
  4780. var res2 Result2406
  4781. if miConfig.MdtrtareaAdmvs == "341203" {
  4782. data := make(map[string]interface{})
  4783. client := &http.Client{}
  4784. data["psn_no"] = his.PsnNo
  4785. data["mdtrt_id"] = his.Number
  4786. data["operator"] = roles.UserName
  4787. data["cert_no"] = his.IdCardNo
  4788. data["org_name"] = miConfig.OrgName
  4789. data["psn_name"] = his.Name
  4790. data["ipt_otp_no"] = his.IptOtpNo
  4791. data["ipt_psn_sp_flag_type"] = "0901"
  4792. data["ipt_psn_sp_flag"] = "1"
  4793. data["fixmedins_code"] = miConfig.Code
  4794. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4795. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4796. data["url"] = miConfig.Url
  4797. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  4798. bytesData, _ := json.Marshal(data)
  4799. var req *http.Request
  4800. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  4801. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  4802. resp, _ := client.Do(req)
  4803. defer resp.Body.Close()
  4804. body, ioErr := ioutil.ReadAll(resp.Body)
  4805. if ioErr != nil {
  4806. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4808. return
  4809. }
  4810. var respJSON map[string]interface{}
  4811. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4814. return
  4815. }
  4816. status := respJSON["data"].(map[string]interface{})["status"].(string)
  4817. if status == "0" {
  4818. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  4819. c.ServeSuccessJSON(map[string]interface{}{
  4820. "failed_code": -10,
  4821. "msg": err_msg,
  4822. })
  4823. return
  4824. }
  4825. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4826. userJSONBytes, _ := json.Marshal(respJSON)
  4827. fmt.Println("log")
  4828. fmt.Println(string(userJSONBytes))
  4829. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4830. utils.ErrorLog("解析失败:%v", err)
  4831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4832. return
  4833. }
  4834. }
  4835. if res2.Infcode != 0 {
  4836. adminUser := c.GetAdminUserInfo()
  4837. errlog := &models.HisOrderError{
  4838. UserOrgId: adminUser.CurrentOrgId,
  4839. Ctime: time.Now().Unix(),
  4840. Mtime: time.Now().Unix(),
  4841. ErrMsg: res2.ErrMsg,
  4842. Status: 1,
  4843. PatientId: id,
  4844. RecordTime: recordDateTime,
  4845. Stage: 3,
  4846. }
  4847. service.CreateErrMsgLog(errlog)
  4848. c.ServeSuccessJSON(map[string]interface{}{
  4849. "failed_code": -10,
  4850. "msg": res2.ErrMsg,
  4851. })
  4852. return
  4853. } else {
  4854. c.ServeSuccessJSON(map[string]interface{}{
  4855. "msg": "上传成功",
  4856. })
  4857. return
  4858. }
  4859. }
  4860. func (c *HisApiController) Get4105() {
  4861. }
  4862. func (c *HisApiController) Post5302() {
  4863. patient_id, _ := c.GetInt64("id")
  4864. admin_user_id, _ := c.GetInt64("admin_user_id")
  4865. p, _ := service.GetHisPatientById(patient_id)
  4866. adminUser := c.GetAdminUserInfo()
  4867. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4868. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4869. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  4870. }
  4871. func (c *HisApiController) Get4104() {
  4872. }
  4873. type Output struct {
  4874. CertNo string `json:"certno"`
  4875. PsnName string `json:"psn_name"`
  4876. CardNo string `json:"card_no"`
  4877. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4878. CardSN string `json:"card_sn"`
  4879. PsnCertType string `json:"psn_cert_type"`
  4880. MdtrtCertNo string `json:"mdtrt_cert_no"`
  4881. MdtrtCertType string `json:"mdtrt_cert_type"`
  4882. QRCode string `json:"qrCode"`
  4883. EcToken string `json:"ecToken"`
  4884. }
  4885. type AHResponse struct {
  4886. Body AHBody `json:"body"`
  4887. Code int `json:"code"`
  4888. CSBCode int `json:"csbCode"`
  4889. Message string `json:"message"`
  4890. RequestID string `json:"requestId"`
  4891. State struct{} `json:"state"`
  4892. }
  4893. type AHBody struct {
  4894. ErrMsg string `json:"err_msg"`
  4895. InfRefMsgID string `json:"inf_refmsgid"`
  4896. InfCode int `json:"infcode"`
  4897. Output struct {
  4898. Result []struct {
  4899. BasMednFlag string `json:"bas_medn_flag"`
  4900. ChldMedcFlag string `json:"chld_medc_flag"`
  4901. ChrgitmLv string `json:"chrgitm_lv"`
  4902. Cnt float64 `json:"cnt"`
  4903. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  4904. DrtReimFlag string `json:"drt_reim_flag"`
  4905. FeedetlSn string `json:"feedetl_sn"`
  4906. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4907. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  4908. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4909. ListSpItemFlag string `json:"list_sp_item_flag"`
  4910. LmtUsedFlag string `json:"lmt_used_flag"`
  4911. MedChrgitmType string `json:"med_chrgitm_type"`
  4912. Memo string `json:"memo"`
  4913. OverlmtAmt float64 `json:"overlmt_amt"`
  4914. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4915. Pric float64 `json:"pric"`
  4916. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  4917. SelfpayProp float64 `json:"selfpay_prop"`
  4918. } `json:"result"`
  4919. } `json:"output"`
  4920. }
  4921. type Response struct {
  4922. Output Output `json:"output"`
  4923. Infcode int `json:"infcode"`
  4924. InfRefMsgID string `json:"inf_refmsgid"`
  4925. RefMsgTime string `json:"refmsg_time"`
  4926. RespondTime string `json:"respond_time"`
  4927. ErrMsg string `json:"err_msg"`
  4928. WarnMsg string `json:"warn_msg"`
  4929. SignType string `json:"signtype"`
  4930. CAInfo string `json:"cainfo"`
  4931. }
  4932. func (c *HisApiController) Getquerydata() {
  4933. query_type, _ := c.GetInt64("type")
  4934. refd_setl_flag := c.GetString("refd_setl_flag")
  4935. med_type := c.GetString("med_type")
  4936. //admin_user_id,_ := c.GetInt64("admin_user_id")
  4937. cert_no := c.GetString("cert_no")
  4938. psn_no := c.GetString("psn_no")
  4939. start_time := c.GetString("start_time")
  4940. end_time := c.GetString("end_time")
  4941. page, _ := c.GetInt64("page")
  4942. limit, _ := c.GetInt64("limit")
  4943. var bp models.BusinessParams5262
  4944. bp.RefdSetlFlag = refd_setl_flag
  4945. bp.MedType = med_type
  4946. bp.Certno = cert_no
  4947. bp.Psnno = psn_no
  4948. bp.QBegntime = start_time
  4949. bp.QEndtime = end_time
  4950. if query_type == 1 { //本地
  4951. Post5262(c, bp, page, limit)
  4952. } else { //异地
  4953. Post5267(c, bp, page, limit)
  4954. }
  4955. }
  4956. func (c *HisApiController) Drugscheck() {
  4957. admin_user_id, _ := c.GetInt64("admin_user_id")
  4958. adminUser := c.GetAdminUserInfo()
  4959. var queryResult []QueryResult
  4960. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  4961. for _, item := range drugs {
  4962. result := QueryResult{
  4963. ID: item.ID,
  4964. Name: item.DrugName,
  4965. Code: item.MedicalInsuranceNumber,
  4966. List_type_code: "101",
  4967. }
  4968. queryResult = append(queryResult, result)
  4969. }
  4970. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4971. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4972. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4973. for _, item := range queryResult {
  4974. 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)
  4975. }
  4976. }
  4977. func (c *HisApiController) Goodcheck() {
  4978. admin_user_id, _ := c.GetInt64("admin_user_id")
  4979. adminUser := c.GetAdminUserInfo()
  4980. var queryResult []QueryResult
  4981. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  4982. for _, item := range goods {
  4983. result := QueryResult{
  4984. ID: item.ID,
  4985. Name: item.GoodName,
  4986. Code: item.SocialSecurityDirectoryCode,
  4987. List_type_code: "301",
  4988. }
  4989. queryResult = append(queryResult, result)
  4990. }
  4991. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4992. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4993. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4994. for _, item := range queryResult {
  4995. 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)
  4996. //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)
  4997. }
  4998. }
  4999. func (c *HisApiController) Projectcheck() {
  5000. admin_user_id, _ := c.GetInt64("admin_user_id")
  5001. adminUser := c.GetAdminUserInfo()
  5002. var queryResult []QueryResult
  5003. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  5004. for _, item := range projects {
  5005. result := QueryResult{
  5006. ID: item.ID,
  5007. Name: item.ProjectName,
  5008. Code: item.MedicalCode,
  5009. List_type_code: "201",
  5010. }
  5011. queryResult = append(queryResult, result)
  5012. }
  5013. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5014. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5015. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5016. for _, item := range queryResult {
  5017. 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)
  5018. }
  5019. }
  5020. //func (c *HisApiController)CancleDia(){
  5021. //
  5022. // id, _ := c.GetInt64("id")
  5023. // record_time := c.GetString("record_time")
  5024. // his_patient_id, _ := c.GetInt64("his_patient_id")
  5025. //
  5026. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5027. //
  5028. // diagnosis_id := c.GetString("diagnosis")
  5029. // sick_type, _ := c.GetInt64("sick_type")
  5030. // reg_type, _ := c.GetInt64("p_type")
  5031. // begin_time := c.GetString("begin_time")
  5032. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  5033. //
  5034. //
  5035. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  5036. //
  5037. // fmt.Println(acct_used_flag)
  5038. //
  5039. //
  5040. // timeLayout := "2006-01-02"
  5041. // loc, _ := time.LoadLocation("Local")
  5042. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5043. // if err != nil {
  5044. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5045. // return
  5046. // }
  5047. // recordDateTime := theTime.Unix()
  5048. // adminUser := c.GetAdminUserInfo()
  5049. //
  5050. //
  5051. //
  5052. //
  5053. //
  5054. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5055. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5056. // var patientPrescription models.HisPrescriptionInfo
  5057. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5058. // if patientPrescription.ID == 0 {
  5059. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5060. // }
  5061. // //if patientPrescription.Do
  5062. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5063. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5064. //
  5065. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5066. //
  5067. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  5068. //
  5069. // var config []*models.HisXtDiagnoseConfig
  5070. // for _, item := range diagnosis_ids {
  5071. // id, _ := strconv.ParseInt(item, 10, 64)
  5072. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  5073. // config = append(config, &diagnosisConfig)
  5074. // }
  5075. //
  5076. // sickConfig, _ := service.FindSickById(sick_type)
  5077. //
  5078. //
  5079. // data := make(map[string]interface{})
  5080. // client := &http.Client{}
  5081. // data["psn_no"] = his.PsnNo
  5082. // data["mdtrt_id"] = his.Number
  5083. // data["doctor"] = roles.UserName
  5084. // data["department"] = department.Name
  5085. // data["org_name"] = miConfig.OrgName
  5086. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  5087. // data["doctor_id"] = doctor_info.DoctorNumber
  5088. // data["new_doctor_name"] = doctor_info.UserName
  5089. // data["fixmedins_code"] = miConfig.Code
  5090. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5091. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5092. // data["secret_key"] = miConfig.SecretKey
  5093. // data["sick_code"] = sickConfig.CountryCode
  5094. // data["sick_name"] = sickConfig.ClassName
  5095. // data["url"] = miConfig.Url
  5096. // data["ak"] = miConfig.AccessKey
  5097. // data["begin_time"] = begin_time
  5098. // data["cainfo"] = miConfig.Cainfo
  5099. // data["is_vaild"] = "0"
  5100. //
  5101. // data["dept"] = strconv.FormatInt(department.ID, 10)
  5102. // data["config"] = config
  5103. // bytesData, _ := json.Marshal(data)
  5104. //
  5105. // var req *http.Request
  5106. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  5107. // resp, _ := client.Do(req)
  5108. // defer resp.Body.Close()
  5109. // body, ioErr := ioutil.ReadAll(resp.Body)
  5110. // if ioErr != nil {
  5111. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5112. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5113. // return
  5114. // }
  5115. // var respJSON map[string]interface{}
  5116. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5117. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5118. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5119. // return
  5120. // }
  5121. //
  5122. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5123. // userJSONBytes, _ := json.Marshal(respJSON)
  5124. // fmt.Println("log")
  5125. // fmt.Println(string(userJSONBytes))
  5126. //
  5127. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5128. // utils.ErrorLog("解析失败:%v", err)
  5129. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5130. // return
  5131. // }
  5132. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  5133. // res2.Output = ressix10265.Output
  5134. // res2.ErrMsg = ressix10265.ErrMsg
  5135. // res2.Cainfo = ressix10265.Cainfo
  5136. // res2.WarnMsg = ressix10265.WarnMsg
  5137. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5138. // res2.Infcode = infocode
  5139. //
  5140. //}
  5141. func (c *HisApiController) Get4102() {
  5142. order_id, _ := c.GetInt64("order_id")
  5143. admin_user_id, _ := c.GetInt64("admin_user_id")
  5144. stas_type := c.GetString("stas_type")
  5145. order, _ := service.GetHisOrderByIDTwo(order_id)
  5146. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5147. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5148. var pp models.PublicParams
  5149. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5150. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5151. pp.FixmedinsName = miConfig.OrgName
  5152. pp.FixmedinsCode = miConfig.Code
  5153. pp.RequestUrl = miConfig.Url
  5154. pp.Cainfo = miConfig.Cainfo
  5155. pp.SecretKey = miConfig.SecretKey
  5156. pp.AccessKey = miConfig.AccessKey
  5157. pp.OpterName = curRoles.UserName
  5158. if miConfig.MdtrtareaAdmvs == "350500" {
  5159. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5160. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  5161. saveLog(result, request, "4102", "清单确认")
  5162. var dat map[string]interface{}
  5163. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5164. fmt.Println(dat)
  5165. } else {
  5166. fmt.Println(err)
  5167. }
  5168. var empty ResultFourteen
  5169. userJSONBytes, _ := json.Marshal(dat)
  5170. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5171. utils.ErrorLog("解析失败:%v", err)
  5172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5173. return
  5174. }
  5175. if empty.Infcode == 0 {
  5176. c.ServeSuccessJSON(map[string]interface{}{
  5177. "msg": "确认成功",
  5178. })
  5179. return
  5180. }
  5181. } else {
  5182. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5183. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  5184. result3, request3 := service.Jxyb4105(pp)
  5185. saveLog(result, request, "4102", "清单确认")
  5186. saveLog(result2, request2, "4103", "清单确认")
  5187. saveLog(result3, request3, "4105", "清单统计")
  5188. var dat map[string]interface{}
  5189. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5190. fmt.Println(dat)
  5191. } else {
  5192. fmt.Println(err)
  5193. }
  5194. var empty ResultFourteen
  5195. userJSONBytes, _ := json.Marshal(dat)
  5196. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5197. utils.ErrorLog("解析失败:%v", err)
  5198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5199. return
  5200. }
  5201. if empty.Infcode == 0 {
  5202. c.ServeSuccessJSON(map[string]interface{}{
  5203. "msg": "确认成功",
  5204. })
  5205. return
  5206. }
  5207. }
  5208. }
  5209. // 对账权限查询
  5210. func (c *HisApiController) Get3260() {
  5211. admin_user_id, _ := c.GetInt64("admin_user_id")
  5212. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5213. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5214. var api string
  5215. var res models.JSResult3260
  5216. if miConfig.MdtrtareaAdmvs == "320921" {
  5217. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5218. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5219. } else {
  5220. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5221. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5222. }
  5223. resp, requestErr := http.Get(api)
  5224. if requestErr != nil {
  5225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5226. return
  5227. }
  5228. body, ioErr := ioutil.ReadAll(resp.Body)
  5229. if ioErr != nil {
  5230. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5232. return
  5233. }
  5234. var respJSON map[string]interface{}
  5235. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5236. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5238. return
  5239. }
  5240. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5241. result, _ := json.Marshal(respJSON)
  5242. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5243. utils.ErrorLog("解析失败:%v", err)
  5244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5245. return
  5246. }
  5247. if res.Infcode == "0" {
  5248. c.ServeSuccessJSON(map[string]interface{}{
  5249. "result": res.Output.Data,
  5250. })
  5251. } else {
  5252. c.ServeSuccessJSON(map[string]interface{}{
  5253. "failed_code": -10,
  5254. "msg": res.ErrMsg,
  5255. })
  5256. return
  5257. }
  5258. }
  5259. func (c *HisApiController) Get3261() {
  5260. admin_user_id, _ := c.GetInt64("admin_user_id")
  5261. //month := c.GetString("month")
  5262. startTime := c.GetString("start_time")
  5263. //endTime, _ := c.GetString("end_time")
  5264. times := strings.Split(startTime, "-")
  5265. stmt_mon := times[0] + times[1]
  5266. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5267. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5268. var api string
  5269. var res models.JSResult3261
  5270. //var res10265 Result5301For10265
  5271. if miConfig.MdtrtareaAdmvs == "320921" {
  5272. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5273. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  5274. } else {
  5275. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5276. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  5277. }
  5278. resp, requestErr := http.Get(api)
  5279. if requestErr != nil {
  5280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5281. return
  5282. }
  5283. body, ioErr := ioutil.ReadAll(resp.Body)
  5284. if ioErr != nil {
  5285. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5287. return
  5288. }
  5289. var respJSON map[string]interface{}
  5290. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5291. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5293. return
  5294. }
  5295. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5296. result, _ := json.Marshal(respJSON)
  5297. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5298. utils.ErrorLog("解析失败:%v", err)
  5299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5300. return
  5301. }
  5302. if res.Infcode == "0" {
  5303. c.ServeSuccessJSON(map[string]interface{}{
  5304. "result": res.Output,
  5305. })
  5306. } else {
  5307. c.ServeSuccessJSON(map[string]interface{}{
  5308. "failed_code": -10,
  5309. "msg": res.ErrMsg,
  5310. })
  5311. return
  5312. }
  5313. }
  5314. type TempFun struct {
  5315. FundKey string
  5316. FundCode string
  5317. }
  5318. func (c *HisApiController) Get3262() {
  5319. admin_user_id, _ := c.GetInt64("admin_user_id")
  5320. startTime := c.GetString("start_time")
  5321. endTime := c.GetString("end_time")
  5322. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5323. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5324. //timeLayout := "2006-01-02"
  5325. //loc, _ := time.LoadLocation("Local")
  5326. //var theStartTIme int64
  5327. //if len(startTime) > 0 {
  5328. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  5329. // if err != nil {
  5330. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5331. // return
  5332. // }
  5333. // theStartTIme = theTime.Unix()
  5334. //}
  5335. //var theEndtTIme int64
  5336. //if len(endTime) > 0 {
  5337. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  5338. // if err != nil {
  5339. // utils.ErrorLog(err.Error())
  5340. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5341. // return
  5342. // }
  5343. // theEndtTIme = theTime.Unix()
  5344. //}
  5345. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  5346. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  5347. for _, team := range datas {
  5348. fmt.Println(team.PsnTime)
  5349. for _, team_two := range datas_two {
  5350. fmt.Println(team_two.PsnTime)
  5351. if team.FundKey == team_two.FundKey {
  5352. fmt.Println(team_two.PsnTime)
  5353. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  5354. fmt.Println(team.PsnTime)
  5355. }
  5356. }
  5357. }
  5358. fmt.Println("1111")
  5359. fmt.Println(datas)
  5360. fmt.Println("1111")
  5361. var twos []models.FixMonRecDetailFileInTwo
  5362. for _, team := range datas {
  5363. var two models.FixMonRecDetailFileInTwo
  5364. two.MedType = team.MedType
  5365. two.Insutype = team.Insutype
  5366. two.PsnType = team.PsnType
  5367. two.MedType = team.MedType
  5368. two.FixBlngAdmdvs = "999999"
  5369. two.InsuAdmdvs = "555555"
  5370. two.PsnTime = team.PsnTime
  5371. two.PsnCnt = team.PsnCnt
  5372. two.FundKey = team.FundKey
  5373. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  5374. fps, _ := strconv.ParseFloat(team.Fund, 64)
  5375. ia, _ := strconv.ParseFloat(team.Amt, 64)
  5376. two.MedfeeSumAmt = ms
  5377. two.InscpAmt = ia
  5378. two.FundPaySumAmt = fps
  5379. twos = append(twos, two)
  5380. }
  5381. //startTime := c.GetString("start_time")
  5382. //endTime, _ := c.GetString("end_time")
  5383. times := strings.Split(startTime, "-")
  5384. stmt_mon := times[0] + times[1]
  5385. var funs []models.FundDetail
  5386. for _, item := range datas {
  5387. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  5388. funs = append(funs, fun...)
  5389. }
  5390. var funInfos []models.Fund
  5391. //for _, item := range funs {
  5392. // var rf []models.FundInfo
  5393. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  5394. // for _, subitem := range rf {
  5395. // var fund models.Fund
  5396. // fund.FundCode = subitem.FundPayType
  5397. // fund.FundName = subitem.FundPayTypeName
  5398. // fund.FundAmt = subitem.FundPayAmt
  5399. // fund.FundKey = item.FundKey
  5400. // fund.InsuAdmdvs = "555555"
  5401. // fund.FixBlngAdmdvs = "999999"
  5402. // funInfos = append(funInfos, fund)
  5403. // }
  5404. //}
  5405. var tempFuns []TempFun
  5406. for _, funInfo := range funInfos {
  5407. var tempFun TempFun
  5408. tempFun.FundKey = funInfo.FundKey
  5409. tempFun.FundCode = funInfo.FundCode
  5410. tempFuns = append(tempFuns, tempFun)
  5411. }
  5412. tempFuns = RemoveRepeatedFunElement(tempFuns)
  5413. fmt.Println(tempFuns)
  5414. var funInfosTwo []models.Fund
  5415. decimal.DivisionPrecision = 2
  5416. for _, item := range tempFuns {
  5417. var fund models.Fund
  5418. for _, subItem := range funInfos {
  5419. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  5420. fund.FundKey = subItem.FundKey
  5421. fund.InsuAdmdvs = subItem.InsuAdmdvs
  5422. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  5423. fund.FundName = subItem.FundName
  5424. fund.FundCode = subItem.FundCode
  5425. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  5426. }
  5427. }
  5428. funInfosTwo = append(funInfosTwo, fund)
  5429. }
  5430. fmt.Println("funInfosTwo")
  5431. fmt.Println(funInfosTwo)
  5432. var upld_btch string
  5433. var empty models.JSResultEmpty
  5434. data := make(map[string]interface{})
  5435. data["org_name"] = miConfig.OrgName
  5436. data["doctor"] = curRoles.UserName
  5437. data["doctor_name"] = curRoles.UserName
  5438. data["fixmedins_code"] = miConfig.Code
  5439. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5440. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5441. data["secret_key"] = miConfig.SecretKey
  5442. data["url"] = miConfig.Url
  5443. data["ak"] = miConfig.AccessKey
  5444. data["cainfo"] = miConfig.Cainfo
  5445. data["datas"] = twos
  5446. data["fund"] = funInfosTwo
  5447. fmt.Println(twos)
  5448. month := time.Unix(1557042972, 0).Format("1")
  5449. year := time.Now().Format("2006")
  5450. month = time.Now().Format("01")
  5451. day := time.Now().Format("02")
  5452. hour := time.Now().Format("15")
  5453. min := time.Now().Format("04")
  5454. sec := time.Now().Format("05")
  5455. fix_fill_date := year + month + day + hour + min + sec
  5456. data["fix_fill_dept"] = miConfig.OrgName
  5457. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  5458. data["fix_fill_psn"] = curRoles.UserName
  5459. data["fix_fill_date"] = fix_fill_date
  5460. data["stmt_loc"] = "2"
  5461. data["setl_mon"] = stmt_mon
  5462. upld_btch = "0"
  5463. data["upld_btch"] = upld_btch
  5464. //fmt.Println(data)
  5465. client := &http.Client{}
  5466. bytesData, _ := json.Marshal(data)
  5467. var req *http.Request
  5468. if miConfig.MdtrtareaAdmvs == "320921" {
  5469. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  5470. } else {
  5471. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  5472. }
  5473. resp, _ := client.Do(req)
  5474. defer resp.Body.Close()
  5475. body, ioErr := ioutil.ReadAll(resp.Body)
  5476. if ioErr != nil {
  5477. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5479. }
  5480. var respJSON map[string]interface{}
  5481. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5482. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5484. }
  5485. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5486. //fmt.Println(respJSON)
  5487. result, _ := json.Marshal(respJSON)
  5488. //fmt.Println(result)
  5489. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  5490. utils.ErrorLog("解析失败:%v", err)
  5491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5492. }
  5493. if empty.Infcode != "0" {
  5494. c.ServeSuccessJSON(map[string]interface{}{
  5495. "failed_code": -10,
  5496. "msg": empty.ErrMsg,
  5497. })
  5498. return
  5499. } else {
  5500. c.ServeSuccessJSON(map[string]interface{}{
  5501. "msg": "上传成功",
  5502. })
  5503. return
  5504. }
  5505. }
  5506. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  5507. newArr = make([]TempFun, 0)
  5508. for i := 0; i < len(arr); i++ {
  5509. repeat := false
  5510. for j := i + 1; j < len(arr); j++ {
  5511. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  5512. repeat = true
  5513. break
  5514. }
  5515. }
  5516. if !repeat {
  5517. newArr = append(newArr, arr[i])
  5518. }
  5519. }
  5520. return
  5521. }
  5522. func (c *HisApiController) Get3263() {
  5523. admin_user_id, _ := c.GetInt64("admin_user_id")
  5524. startTime := c.GetString("start_time")
  5525. //endTime, _ := c.GetString("end_time")
  5526. times := strings.Split(startTime, "-")
  5527. setl_mon := times[0] + times[1]
  5528. upld_btch := "0"
  5529. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5530. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5531. var result3263 models.JSResult3263
  5532. data := make(map[string]interface{})
  5533. data["org_name"] = miConfig.OrgName
  5534. data["doctor"] = curRoles.UserName
  5535. data["doctor_name"] = curRoles.UserName
  5536. data["fixmedins_code"] = miConfig.Code
  5537. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5538. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5539. data["secret_key"] = miConfig.SecretKey
  5540. data["url"] = miConfig.Url
  5541. data["ak"] = miConfig.AccessKey
  5542. data["cainfo"] = miConfig.Cainfo
  5543. data["setl_mon"] = setl_mon
  5544. data["stmt_loc"] = "2"
  5545. data["upld_btch"] = upld_btch
  5546. client := &http.Client{}
  5547. bytesData, _ := json.Marshal(data)
  5548. var req *http.Request
  5549. if miConfig.MdtrtareaAdmvs == "320921" {
  5550. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  5551. } else {
  5552. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  5553. }
  5554. resp, _ := client.Do(req)
  5555. defer resp.Body.Close()
  5556. body, ioErr := ioutil.ReadAll(resp.Body)
  5557. if ioErr != nil {
  5558. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5560. }
  5561. var respJSON map[string]interface{}
  5562. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5565. }
  5566. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5567. fmt.Println(respJSON)
  5568. result, _ := json.Marshal(respJSON)
  5569. fmt.Println(result)
  5570. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  5571. utils.ErrorLog("解析失败:%v", err)
  5572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5573. }
  5574. if result3263.Infcode != "0" {
  5575. c.ServeSuccessJSON(map[string]interface{}{
  5576. "failed_code": -10,
  5577. "msg": result3263.ErrMsg,
  5578. })
  5579. return
  5580. } else {
  5581. c.ServeSuccessJSON(map[string]interface{}{
  5582. "list": result3263.Output,
  5583. })
  5584. return
  5585. }
  5586. }
  5587. func (c *HisApiController) Get3264() {
  5588. admin_user_id, _ := c.GetInt64("admin_user_id")
  5589. startTime := c.GetString("start_time")
  5590. //endTime, _ := c.GetString("end_time")
  5591. times := strings.Split(startTime, "-")
  5592. setl_mon := times[0] + times[1]
  5593. upld_btch := "0"
  5594. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5595. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5596. //solidify_id := []
  5597. var result3263 models.JSResult3263
  5598. data := make(map[string]interface{})
  5599. data["org_name"] = miConfig.OrgName
  5600. data["doctor"] = curRoles.UserName
  5601. data["doctor_name"] = curRoles.UserName
  5602. data["fixmedins_code"] = miConfig.Code
  5603. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5604. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5605. data["secret_key"] = miConfig.SecretKey
  5606. data["url"] = miConfig.Url
  5607. data["ak"] = miConfig.AccessKey
  5608. data["cainfo"] = miConfig.Cainfo
  5609. data["setl_mon"] = setl_mon
  5610. data["stmt_loc"] = "2"
  5611. data["upld_btch"] = upld_btch
  5612. client := &http.Client{}
  5613. bytesData, _ := json.Marshal(data)
  5614. var req3263 *http.Request
  5615. if miConfig.MdtrtareaAdmvs == "320921" {
  5616. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  5617. } else {
  5618. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  5619. }
  5620. resp, _ := client.Do(req3263)
  5621. defer resp.Body.Close()
  5622. body, ioErr := ioutil.ReadAll(resp.Body)
  5623. if ioErr != nil {
  5624. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5626. }
  5627. var respJSON3263 map[string]interface{}
  5628. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  5629. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5631. }
  5632. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5633. fmt.Println(respJSON3263)
  5634. result, _ := json.Marshal(respJSON3263)
  5635. fmt.Println(result)
  5636. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  5637. utils.ErrorLog("解析失败:%v", err)
  5638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5639. }
  5640. var ids []string
  5641. for _, item := range result3263.Output {
  5642. ids = append(ids, item.SolidifyID)
  5643. }
  5644. var empty models.JSResultEmpty
  5645. data2 := make(map[string]interface{})
  5646. data2["org_name"] = miConfig.OrgName
  5647. data2["doctor"] = curRoles.UserName
  5648. data2["doctor_name"] = curRoles.UserName
  5649. data2["fixmedins_code"] = miConfig.Code
  5650. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5651. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5652. data2["secret_key"] = miConfig.SecretKey
  5653. data2["url"] = miConfig.Url
  5654. data2["ak"] = miConfig.AccessKey
  5655. data2["cainfo"] = miConfig.Cainfo
  5656. data2["setl_mon"] = setl_mon
  5657. data2["stmt_loc"] = "2"
  5658. data2["upld_btch"] = upld_btch
  5659. data2["solidify_id"] = ids
  5660. client2 := &http.Client{}
  5661. bytesData2, _ := json.Marshal(data2)
  5662. var req *http.Request
  5663. if miConfig.MdtrtareaAdmvs == "320921" {
  5664. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  5665. } else {
  5666. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  5667. }
  5668. resp2, _ := client2.Do(req)
  5669. defer resp.Body.Close()
  5670. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  5671. if ioErr2 != nil {
  5672. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  5673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5674. }
  5675. var respJSON map[string]interface{}
  5676. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  5677. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5679. }
  5680. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5681. fmt.Println(respJSON)
  5682. result2, _ := json.Marshal(respJSON)
  5683. fmt.Println(result2)
  5684. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  5685. utils.ErrorLog("解析失败:%v", err)
  5686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5687. }
  5688. if empty.Infcode != "0" {
  5689. c.ServeSuccessJSON(map[string]interface{}{
  5690. "failed_code": -10,
  5691. "msg": empty.ErrMsg,
  5692. })
  5693. return
  5694. } else {
  5695. c.ServeSuccessJSON(map[string]interface{}{
  5696. "msg": "",
  5697. })
  5698. return
  5699. }
  5700. }
  5701. func (c *HisApiController) Get3265() {
  5702. admin_user_id, _ := c.GetInt64("admin_user_id")
  5703. startTime := c.GetString("start_time")
  5704. //endTime, _ := c.GetString("end_time")
  5705. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5706. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5707. times := strings.Split(startTime, "-")
  5708. setl_mon := times[0] + times[1]
  5709. var upld_btch string
  5710. upld_btch = "0"
  5711. //var empty models.JSResultEmpty
  5712. var result3265 models.JSResult3264
  5713. var result3263 models.JSResult3263
  5714. data2 := make(map[string]interface{})
  5715. data2["org_name"] = miConfig.OrgName
  5716. data2["doctor"] = curRoles.UserName
  5717. data2["doctor_name"] = curRoles.UserName
  5718. data2["fixmedins_code"] = miConfig.Code
  5719. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5720. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5721. data2["secret_key"] = miConfig.SecretKey
  5722. data2["url"] = miConfig.Url
  5723. data2["ak"] = miConfig.AccessKey
  5724. data2["cainfo"] = miConfig.Cainfo
  5725. data2["setl_mon"] = setl_mon
  5726. data2["stmt_loc"] = "2"
  5727. data2["upld_btch"] = upld_btch
  5728. client2 := &http.Client{}
  5729. bytesData2, _ := json.Marshal(data2)
  5730. var req3263 *http.Request
  5731. if miConfig.MdtrtareaAdmvs == "320921" {
  5732. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  5733. } else {
  5734. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  5735. }
  5736. resp2, _ := client2.Do(req3263)
  5737. defer resp2.Body.Close()
  5738. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  5739. if ioErr2 != nil {
  5740. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  5741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5742. }
  5743. var respJSON3263 map[string]interface{}
  5744. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  5745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5747. }
  5748. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5749. fmt.Println(respJSON3263)
  5750. result2, _ := json.Marshal(respJSON3263)
  5751. fmt.Println(result2)
  5752. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  5753. utils.ErrorLog("解析失败:%v", err)
  5754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5755. }
  5756. var ids []string
  5757. for _, item := range result3263.Output {
  5758. ids = append(ids, item.SolidifyID)
  5759. }
  5760. data := make(map[string]interface{})
  5761. data["org_name"] = miConfig.OrgName
  5762. data["doctor"] = curRoles.UserName
  5763. data["doctor_name"] = curRoles.UserName
  5764. data["fixmedins_code"] = miConfig.Code
  5765. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5766. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5767. data["secret_key"] = miConfig.SecretKey
  5768. data["url"] = miConfig.Url
  5769. data["ak"] = miConfig.AccessKey
  5770. data["cainfo"] = miConfig.Cainfo
  5771. data["setl_mon"] = setl_mon
  5772. data["solidify_id"] = ids
  5773. month := time.Unix(1557042972, 0).Format("1")
  5774. year := time.Now().Format("2006")
  5775. month = time.Now().Format("01")
  5776. day := time.Now().Format("02")
  5777. hour := time.Now().Format("15")
  5778. min := time.Now().Format("04")
  5779. sec := time.Now().Format("05")
  5780. fix_fill_date := year + month + day + hour + min + sec
  5781. data["fix_fill_dept"] = miConfig.OrgName
  5782. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  5783. data["fix_fill_psn"] = curRoles.UserName
  5784. data["fix_fill_date"] = fix_fill_date
  5785. data["stmt_loc"] = "2"
  5786. data["upld_btch"] = upld_btch
  5787. client := &http.Client{}
  5788. bytesData, _ := json.Marshal(data)
  5789. var req *http.Request
  5790. if miConfig.MdtrtareaAdmvs == "320921" {
  5791. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  5792. } else {
  5793. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  5794. }
  5795. resp, _ := client.Do(req)
  5796. defer resp.Body.Close()
  5797. body, ioErr := ioutil.ReadAll(resp.Body)
  5798. if ioErr != nil {
  5799. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5801. }
  5802. var respJSON map[string]interface{}
  5803. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5804. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5806. }
  5807. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5808. fmt.Println(respJSON)
  5809. result, _ := json.Marshal(respJSON)
  5810. fmt.Println(result)
  5811. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  5812. utils.ErrorLog("解析失败:%v", err)
  5813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5814. }
  5815. if result3265.Infcode != "0" {
  5816. c.ServeSuccessJSON(map[string]interface{}{
  5817. "failed_code": -10,
  5818. "msg": result3265.ErrMsg,
  5819. })
  5820. return
  5821. } else {
  5822. c.ServeSuccessJSON(map[string]interface{}{
  5823. "info": result3265.Output,
  5824. })
  5825. return
  5826. }
  5827. }
  5828. func (c *HisApiController) Get3266() {
  5829. admin_user_id, _ := c.GetInt64("admin_user_id")
  5830. startTime := c.GetString("start_time")
  5831. //endTime, _ := c.GetString("end_time")
  5832. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5833. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5834. times := strings.Split(startTime, "-")
  5835. stmt_mon := times[0] + times[1]
  5836. var upld_btch string
  5837. //var empty models.JSResultEmpty
  5838. var result3265 models.JSResult3264
  5839. data := make(map[string]interface{})
  5840. data["org_name"] = miConfig.OrgName
  5841. data["doctor"] = curRoles.UserName
  5842. data["doctor_name"] = curRoles.UserName
  5843. data["fixmedins_code"] = miConfig.Code
  5844. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5845. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5846. data["secret_key"] = miConfig.SecretKey
  5847. data["url"] = miConfig.Url
  5848. data["ak"] = miConfig.AccessKey
  5849. data["cainfo"] = miConfig.Cainfo
  5850. data["setl_mon"] = stmt_mon
  5851. month := time.Unix(1557042972, 0).Format("1")
  5852. year := time.Now().Format("2006")
  5853. month = time.Now().Format("01")
  5854. day := time.Now().Format("02")
  5855. hour := time.Now().Format("15")
  5856. min := time.Now().Format("04")
  5857. sec := time.Now().Format("05")
  5858. fix_fill_date := year + month + day + hour + min + sec
  5859. data["fix_fill_dept"] = miConfig.OrgName
  5860. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  5861. data["fix_fill_psn"] = curRoles.UserName
  5862. data["fix_fill_date"] = fix_fill_date
  5863. data["stmt_loc"] = "2"
  5864. upld_btch = "0"
  5865. data["upld_btch"] = upld_btch
  5866. client := &http.Client{}
  5867. bytesData, _ := json.Marshal(data)
  5868. var req *http.Request
  5869. if miConfig.MdtrtareaAdmvs == "320921" {
  5870. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  5871. } else {
  5872. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  5873. }
  5874. resp, _ := client.Do(req)
  5875. defer resp.Body.Close()
  5876. body, ioErr := ioutil.ReadAll(resp.Body)
  5877. if ioErr != nil {
  5878. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5880. }
  5881. var respJSON map[string]interface{}
  5882. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5885. }
  5886. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5887. fmt.Println(respJSON)
  5888. result, _ := json.Marshal(respJSON)
  5889. fmt.Println(result)
  5890. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  5891. utils.ErrorLog("解析失败:%v", err)
  5892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5893. }
  5894. if result3265.Infcode != "0" {
  5895. c.ServeSuccessJSON(map[string]interface{}{
  5896. "failed_code": -10,
  5897. "msg": result3265.ErrMsg,
  5898. })
  5899. return
  5900. } else {
  5901. c.ServeSuccessJSON(map[string]interface{}{
  5902. "info": result3265.Output,
  5903. })
  5904. return
  5905. }
  5906. }
  5907. func (c *HisApiController) Get3267() {
  5908. admin_user_id, _ := c.GetInt64("admin_user_id")
  5909. startTime := c.GetString("start_time")
  5910. //endTime, _ := c.GetString("end_time")
  5911. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5912. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5913. times := strings.Split(startTime, "-")
  5914. setl_mon := times[0] + times[1]
  5915. var upld_btch string
  5916. //var empty models.JSResultEmpty
  5917. var result3265 models.JSResult3264
  5918. upld_btch = "0"
  5919. data := make(map[string]interface{})
  5920. data["org_name"] = miConfig.OrgName
  5921. data["doctor"] = curRoles.UserName
  5922. data["doctor_name"] = curRoles.UserName
  5923. data["fixmedins_code"] = miConfig.Code
  5924. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5925. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5926. data["secret_key"] = miConfig.SecretKey
  5927. data["url"] = miConfig.Url
  5928. data["ak"] = miConfig.AccessKey
  5929. data["cainfo"] = miConfig.Cainfo
  5930. data["setl_mon"] = setl_mon
  5931. data["stmt_loc"] = "2"
  5932. data["upld_btch"] = upld_btch
  5933. client := &http.Client{}
  5934. bytesData, _ := json.Marshal(data)
  5935. var req *http.Request
  5936. if miConfig.MdtrtareaAdmvs == "320921" {
  5937. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  5938. } else {
  5939. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  5940. }
  5941. resp, _ := client.Do(req)
  5942. defer resp.Body.Close()
  5943. body, ioErr := ioutil.ReadAll(resp.Body)
  5944. if ioErr != nil {
  5945. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5947. }
  5948. var respJSON map[string]interface{}
  5949. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5950. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5952. }
  5953. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5954. fmt.Println(respJSON)
  5955. result, _ := json.Marshal(respJSON)
  5956. fmt.Println(result)
  5957. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  5958. utils.ErrorLog("解析失败:%v", err)
  5959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5960. }
  5961. if result3265.Infcode != "0" {
  5962. c.ServeSuccessJSON(map[string]interface{}{
  5963. "failed_code": -10,
  5964. "msg": result3265.ErrMsg,
  5965. })
  5966. return
  5967. } else {
  5968. c.ServeSuccessJSON(map[string]interface{}{
  5969. "info": result3265.Output.Data,
  5970. })
  5971. return
  5972. }
  5973. }
  5974. func (c *HisApiController) Get3268() {
  5975. admin_user_id, _ := c.GetInt64("admin_user_id")
  5976. startTime := c.GetString("start_time")
  5977. endTime := c.GetString("end_time")
  5978. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5979. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5980. times := strings.Split(startTime, "-")
  5981. setl_mon := times[0] + times[1]
  5982. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  5983. var twos []models.FixMonRecDetailFileInTwo
  5984. var funs []models.FundDetail
  5985. for _, item := range datas {
  5986. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  5987. funs = append(funs, fun...)
  5988. }
  5989. var funInfos []models.Fund
  5990. //for _, item := range funs {
  5991. // var rf []models.FundInfo
  5992. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  5993. // for _, subitem := range rf {
  5994. // var fund models.Fund
  5995. // fund.FundCode = subitem.FundPayType
  5996. // fund.FundName = subitem.FundPayTypeName
  5997. // fund.FundAmt = subitem.FundPayAmt
  5998. // fund.FundKey = item.FundKey
  5999. // fund.InsuAdmdvs = "555555"
  6000. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  6001. // funInfos = append(funInfos, fund)
  6002. // }
  6003. //}
  6004. for _, team := range datas {
  6005. var two models.FixMonRecDetailFileInTwo
  6006. two.SetlDate = time.Now().Format("2006-01-02")
  6007. two.MedType = team.MedType
  6008. two.Insutype = team.Insutype
  6009. two.PsnType = team.PsnType
  6010. two.MedType = team.MedType
  6011. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  6012. two.InsuAdmdvs = team.InsuAdmdvs
  6013. two.PsnTime = team.PsnTime
  6014. two.PsnCnt = team.PsnCnt
  6015. two.FundKey = team.FundKey
  6016. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6017. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6018. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6019. two.MedfeeSumAmt = ms
  6020. two.InscpAmt = ia
  6021. two.FundPaySumAmt = fps
  6022. twos = append(twos, two)
  6023. }
  6024. var upld_btch string
  6025. upld_btch = "0"
  6026. var empty models.JSResultEmpty
  6027. data := make(map[string]interface{})
  6028. data["org_name"] = miConfig.OrgName
  6029. data["doctor"] = curRoles.UserName
  6030. data["doctor_name"] = curRoles.UserName
  6031. data["fixmedins_code"] = miConfig.Code
  6032. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6033. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6034. data["secret_key"] = miConfig.SecretKey
  6035. data["url"] = miConfig.Url
  6036. data["ak"] = miConfig.AccessKey
  6037. data["cainfo"] = miConfig.Cainfo
  6038. data["datas"] = twos
  6039. data["fund"] = funInfos
  6040. data["setl_mon"] = setl_mon
  6041. month := time.Unix(1557042972, 0).Format("1")
  6042. year := time.Now().Format("2006")
  6043. month = time.Now().Format("01")
  6044. day := time.Now().Format("02")
  6045. hour := time.Now().Format("15")
  6046. min := time.Now().Format("04")
  6047. sec := time.Now().Format("05")
  6048. fix_fill_date := year + month + day + hour + min + sec
  6049. data["fix_fill_dept"] = miConfig.OrgName
  6050. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6051. data["fix_fill_psn"] = curRoles.UserName
  6052. data["fix_fill_date"] = fix_fill_date
  6053. data["stmt_loc"] = "2"
  6054. data["upld_btch"] = upld_btch
  6055. client := &http.Client{}
  6056. bytesData, _ := json.Marshal(data)
  6057. var req *http.Request
  6058. if miConfig.MdtrtareaAdmvs == "320921" {
  6059. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6060. } else {
  6061. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6062. }
  6063. resp, _ := client.Do(req)
  6064. defer resp.Body.Close()
  6065. body, ioErr := ioutil.ReadAll(resp.Body)
  6066. if ioErr != nil {
  6067. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6069. }
  6070. var respJSON map[string]interface{}
  6071. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6074. }
  6075. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6076. fmt.Println(respJSON)
  6077. result, _ := json.Marshal(respJSON)
  6078. fmt.Println(result)
  6079. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6080. utils.ErrorLog("解析失败:%v", err)
  6081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6082. }
  6083. if empty.Infcode != "0" {
  6084. c.ServeSuccessJSON(map[string]interface{}{
  6085. "failed_code": -10,
  6086. "msg": empty.ErrMsg,
  6087. })
  6088. return
  6089. } else {
  6090. c.ServeSuccessJSON(map[string]interface{}{
  6091. "msg": "上传成功",
  6092. })
  6093. return
  6094. }
  6095. }
  6096. func (c *HisApiController) Get3269() {
  6097. admin_user_id, _ := c.GetInt64("admin_user_id")
  6098. startTime := c.GetString("start_time")
  6099. //endTime, _ := c.GetString("end_time")
  6100. times := strings.Split(startTime, "-")
  6101. setl_mon := times[0] + times[1]
  6102. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6103. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6104. var result3263 models.JSResult3263
  6105. data := make(map[string]interface{})
  6106. data["org_name"] = miConfig.OrgName
  6107. data["doctor"] = curRoles.UserName
  6108. data["doctor_name"] = curRoles.UserName
  6109. data["fixmedins_code"] = miConfig.Code
  6110. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6111. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6112. data["secret_key"] = miConfig.SecretKey
  6113. data["url"] = miConfig.Url
  6114. data["ak"] = miConfig.AccessKey
  6115. data["cainfo"] = miConfig.Cainfo
  6116. data["setl_mon"] = setl_mon
  6117. data["stmt_loc"] = "2"
  6118. client := &http.Client{}
  6119. bytesData, _ := json.Marshal(data)
  6120. var req *http.Request
  6121. if miConfig.MdtrtareaAdmvs == "320921" {
  6122. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6123. } else {
  6124. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6125. }
  6126. resp, _ := client.Do(req)
  6127. defer resp.Body.Close()
  6128. body, ioErr := ioutil.ReadAll(resp.Body)
  6129. if ioErr != nil {
  6130. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6132. }
  6133. var respJSON map[string]interface{}
  6134. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6135. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6137. }
  6138. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6139. fmt.Println(respJSON)
  6140. result, _ := json.Marshal(respJSON)
  6141. fmt.Println(result)
  6142. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6143. utils.ErrorLog("解析失败:%v", err)
  6144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6145. }
  6146. if result3263.Infcode != "0" {
  6147. c.ServeSuccessJSON(map[string]interface{}{
  6148. "failed_code": -10,
  6149. "msg": result3263.ErrMsg,
  6150. })
  6151. return
  6152. } else {
  6153. c.ServeSuccessJSON(map[string]interface{}{
  6154. "msg": "上传成功",
  6155. })
  6156. return
  6157. }
  6158. }
  6159. func (c *HisApiController) Get3270() {
  6160. admin_user_id, _ := c.GetInt64("admin_user_id")
  6161. startTime := c.GetString("start_time")
  6162. //endTime, _ := c.GetString("end_time")
  6163. times := strings.Split(startTime, "-")
  6164. setl_mon := times[0] + times[1]
  6165. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6166. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6167. var result3263 models.JSResult3263
  6168. data2 := make(map[string]interface{})
  6169. data2["org_name"] = miConfig.OrgName
  6170. data2["doctor"] = curRoles.UserName
  6171. data2["doctor_name"] = curRoles.UserName
  6172. data2["fixmedins_code"] = miConfig.Code
  6173. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6174. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6175. data2["secret_key"] = miConfig.SecretKey
  6176. data2["url"] = miConfig.Url
  6177. data2["ak"] = miConfig.AccessKey
  6178. data2["cainfo"] = miConfig.Cainfo
  6179. data2["setl_mon"] = setl_mon
  6180. data2["stmt_loc"] = "2"
  6181. client2 := &http.Client{}
  6182. bytesData2, _ := json.Marshal(data2)
  6183. var req3263 *http.Request
  6184. if miConfig.MdtrtareaAdmvs == "320921" {
  6185. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6186. } else {
  6187. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6188. }
  6189. resp2, _ := client2.Do(req3263)
  6190. defer resp2.Body.Close()
  6191. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6192. if ioErr2 != nil {
  6193. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6195. }
  6196. var respJSON3263 map[string]interface{}
  6197. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6198. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6200. }
  6201. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6202. fmt.Println(respJSON3263)
  6203. result2, _ := json.Marshal(respJSON3263)
  6204. fmt.Println(result2)
  6205. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6206. utils.ErrorLog("解析失败:%v", err)
  6207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6208. }
  6209. var ids []string
  6210. for _, item := range result3263.Output {
  6211. ids = append(ids, item.SolidifyID)
  6212. }
  6213. var result3264 models.JSResult3264
  6214. data := make(map[string]interface{})
  6215. data["org_name"] = miConfig.OrgName
  6216. data["doctor"] = curRoles.UserName
  6217. data["doctor_name"] = curRoles.UserName
  6218. data["fixmedins_code"] = miConfig.Code
  6219. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6220. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6221. data["secret_key"] = miConfig.SecretKey
  6222. data["url"] = miConfig.Url
  6223. data["ak"] = miConfig.AccessKey
  6224. data["cainfo"] = miConfig.Cainfo
  6225. data["setl_mon"] = setl_mon
  6226. data["stmt_loc"] = "2"
  6227. data["solidify_id"] = ids
  6228. client := &http.Client{}
  6229. bytesData, _ := json.Marshal(data)
  6230. var req *http.Request
  6231. if miConfig.MdtrtareaAdmvs == "320921" {
  6232. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  6233. } else {
  6234. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  6235. }
  6236. resp, _ := client.Do(req)
  6237. defer resp.Body.Close()
  6238. body, ioErr := ioutil.ReadAll(resp.Body)
  6239. if ioErr != nil {
  6240. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6242. }
  6243. var respJSON map[string]interface{}
  6244. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6245. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6247. }
  6248. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6249. fmt.Println(respJSON)
  6250. result, _ := json.Marshal(respJSON)
  6251. fmt.Println(result)
  6252. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  6253. utils.ErrorLog("解析失败:%v", err)
  6254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6255. }
  6256. if result3264.Infcode != "0" {
  6257. c.ServeSuccessJSON(map[string]interface{}{
  6258. "failed_code": -10,
  6259. "msg": result3264.ErrMsg,
  6260. })
  6261. return
  6262. } else {
  6263. c.ServeSuccessJSON(map[string]interface{}{
  6264. "info": result3264.Output,
  6265. })
  6266. return
  6267. }
  6268. }
  6269. func (c *HisApiController) Get3271() {
  6270. admin_user_id, _ := c.GetInt64("admin_user_id")
  6271. startTime := c.GetString("start_time")
  6272. //endTime, _ := c.GetString("end_time")
  6273. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6274. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6275. times := strings.Split(startTime, "-")
  6276. setl_mon := times[0] + times[1]
  6277. //var empty models.JSResultEmpty
  6278. var result3265 models.JSResult3264
  6279. var result3263 models.JSResult3263
  6280. data2 := make(map[string]interface{})
  6281. data2["org_name"] = miConfig.OrgName
  6282. data2["doctor"] = curRoles.UserName
  6283. data2["doctor_name"] = curRoles.UserName
  6284. data2["fixmedins_code"] = miConfig.Code
  6285. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6286. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6287. data2["secret_key"] = miConfig.SecretKey
  6288. data2["url"] = miConfig.Url
  6289. data2["ak"] = miConfig.AccessKey
  6290. data2["cainfo"] = miConfig.Cainfo
  6291. data2["setl_mon"] = setl_mon
  6292. data2["stmt_loc"] = "2"
  6293. client2 := &http.Client{}
  6294. bytesData2, _ := json.Marshal(data2)
  6295. var req3263 *http.Request
  6296. if miConfig.MdtrtareaAdmvs == "320921" {
  6297. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6298. } else {
  6299. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6300. }
  6301. resp2, _ := client2.Do(req3263)
  6302. defer resp2.Body.Close()
  6303. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6304. if ioErr2 != nil {
  6305. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6307. }
  6308. var respJSON3263 map[string]interface{}
  6309. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6310. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6312. }
  6313. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6314. fmt.Println(respJSON3263)
  6315. result2, _ := json.Marshal(respJSON3263)
  6316. fmt.Println(result2)
  6317. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6318. utils.ErrorLog("解析失败:%v", err)
  6319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6320. }
  6321. var ids []string
  6322. for _, item := range result3263.Output {
  6323. ids = append(ids, item.SolidifyID)
  6324. }
  6325. data := make(map[string]interface{})
  6326. data["org_name"] = miConfig.OrgName
  6327. data["doctor"] = curRoles.UserName
  6328. data["doctor_name"] = curRoles.UserName
  6329. data["fixmedins_code"] = miConfig.Code
  6330. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6331. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6332. data["secret_key"] = miConfig.SecretKey
  6333. data["url"] = miConfig.Url
  6334. data["ak"] = miConfig.AccessKey
  6335. data["cainfo"] = miConfig.Cainfo
  6336. data["setl_mon"] = setl_mon
  6337. data["solidify_id"] = ids
  6338. month := time.Unix(1557042972, 0).Format("1")
  6339. year := time.Now().Format("2006")
  6340. month = time.Now().Format("01")
  6341. day := time.Now().Format("02")
  6342. hour := time.Now().Format("15")
  6343. min := time.Now().Format("04")
  6344. sec := time.Now().Format("05")
  6345. fix_fill_date := year + month + day + hour + min + sec
  6346. data["fix_fill_dept"] = miConfig.OrgName
  6347. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6348. data["fix_fill_psn"] = curRoles.UserName
  6349. data["fix_fill_date"] = fix_fill_date
  6350. data["stmt_loc"] = "2"
  6351. client := &http.Client{}
  6352. bytesData, _ := json.Marshal(data)
  6353. var req *http.Request
  6354. if miConfig.MdtrtareaAdmvs == "320921" {
  6355. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  6356. } else {
  6357. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  6358. }
  6359. resp, _ := client.Do(req)
  6360. defer resp.Body.Close()
  6361. body, ioErr := ioutil.ReadAll(resp.Body)
  6362. if ioErr != nil {
  6363. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6365. }
  6366. var respJSON map[string]interface{}
  6367. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6370. }
  6371. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6372. fmt.Println(respJSON)
  6373. result, _ := json.Marshal(respJSON)
  6374. fmt.Println(result)
  6375. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6376. utils.ErrorLog("解析失败:%v", err)
  6377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6378. }
  6379. if result3265.Infcode != "0" {
  6380. c.ServeSuccessJSON(map[string]interface{}{
  6381. "failed_code": -10,
  6382. "msg": result3265.ErrMsg,
  6383. })
  6384. return
  6385. } else {
  6386. c.ServeSuccessJSON(map[string]interface{}{
  6387. "info": result3265.Output.Data,
  6388. })
  6389. return
  6390. }
  6391. }
  6392. func (c *HisApiController) Get3272() {
  6393. admin_user_id, _ := c.GetInt64("admin_user_id")
  6394. startTime := c.GetString("start_time")
  6395. //endTime, _ := c.GetString("end_time")
  6396. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6397. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6398. times := strings.Split(startTime, "-")
  6399. setl_mon := times[0] + times[1]
  6400. var upld_btch string
  6401. //var empty models.JSResultEmpty
  6402. var result3265 models.JSResult3264
  6403. data := make(map[string]interface{})
  6404. data["org_name"] = miConfig.OrgName
  6405. data["doctor"] = curRoles.UserName
  6406. data["doctor_name"] = curRoles.UserName
  6407. data["fixmedins_code"] = miConfig.Code
  6408. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6409. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6410. data["secret_key"] = miConfig.SecretKey
  6411. data["url"] = miConfig.Url
  6412. data["ak"] = miConfig.AccessKey
  6413. data["cainfo"] = miConfig.Cainfo
  6414. data["setl_mon"] = setl_mon
  6415. month := time.Unix(1557042972, 0).Format("1")
  6416. year := time.Now().Format("2006")
  6417. month = time.Now().Format("01")
  6418. day := time.Now().Format("02")
  6419. hour := time.Now().Format("15")
  6420. min := time.Now().Format("04")
  6421. sec := time.Now().Format("05")
  6422. fix_fill_date := year + month + day + hour + min + sec
  6423. data["fix_fill_dept"] = miConfig.OrgName
  6424. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6425. data["fix_fill_psn"] = curRoles.UserName
  6426. data["fix_fill_date"] = fix_fill_date
  6427. data["stmt_loc"] = "2"
  6428. data["upld_btch"] = upld_btch
  6429. client := &http.Client{}
  6430. bytesData, _ := json.Marshal(data)
  6431. var req *http.Request
  6432. if miConfig.MdtrtareaAdmvs == "320921" {
  6433. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  6434. } else {
  6435. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  6436. }
  6437. resp, _ := client.Do(req)
  6438. defer resp.Body.Close()
  6439. body, ioErr := ioutil.ReadAll(resp.Body)
  6440. if ioErr != nil {
  6441. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6443. }
  6444. var respJSON map[string]interface{}
  6445. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6446. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6448. }
  6449. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6450. fmt.Println(respJSON)
  6451. result, _ := json.Marshal(respJSON)
  6452. fmt.Println(result)
  6453. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6454. utils.ErrorLog("解析失败:%v", err)
  6455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6456. }
  6457. if result3265.Infcode != "0" {
  6458. c.ServeSuccessJSON(map[string]interface{}{
  6459. "failed_code": -10,
  6460. "msg": result3265.ErrMsg,
  6461. })
  6462. return
  6463. } else {
  6464. c.ServeSuccessJSON(map[string]interface{}{
  6465. "info": result3265.Output,
  6466. })
  6467. return
  6468. }
  6469. }
  6470. func (c *HisApiController) Get3273() {
  6471. admin_user_id, _ := c.GetInt64("admin_user_id")
  6472. startTime := c.GetString("start_time")
  6473. //endTime, _ := c.GetString("end_time")
  6474. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6475. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6476. times := strings.Split(startTime, "-")
  6477. setl_mon := times[0] + times[1]
  6478. var result3265 models.JSResult3264
  6479. data := make(map[string]interface{})
  6480. data["org_name"] = miConfig.OrgName
  6481. data["doctor"] = curRoles.UserName
  6482. data["doctor_name"] = curRoles.UserName
  6483. data["fixmedins_code"] = miConfig.Code
  6484. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6485. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6486. data["secret_key"] = miConfig.SecretKey
  6487. data["url"] = miConfig.Url
  6488. data["ak"] = miConfig.AccessKey
  6489. data["cainfo"] = miConfig.Cainfo
  6490. data["setl_mon"] = setl_mon
  6491. data["stmt_loc"] = "2"
  6492. client := &http.Client{}
  6493. bytesData, _ := json.Marshal(data)
  6494. var req *http.Request
  6495. if miConfig.MdtrtareaAdmvs == "320921" {
  6496. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  6497. } else {
  6498. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  6499. }
  6500. resp, _ := client.Do(req)
  6501. defer resp.Body.Close()
  6502. body, ioErr := ioutil.ReadAll(resp.Body)
  6503. if ioErr != nil {
  6504. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6506. }
  6507. var respJSON map[string]interface{}
  6508. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6509. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6511. }
  6512. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6513. fmt.Println(respJSON)
  6514. result, _ := json.Marshal(respJSON)
  6515. fmt.Println(result)
  6516. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6517. utils.ErrorLog("解析失败:%v", err)
  6518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6519. }
  6520. if result3265.Infcode != "0" {
  6521. c.ServeSuccessJSON(map[string]interface{}{
  6522. "failed_code": -10,
  6523. "msg": result3265.ErrMsg,
  6524. })
  6525. return
  6526. } else {
  6527. c.ServeSuccessJSON(map[string]interface{}{
  6528. "info": result3265.Output.Data,
  6529. })
  6530. return
  6531. }
  6532. }
  6533. func (c *HisApiController) Get3274() {
  6534. //if miConfig.MdtrtareaAdmvs == "320921" {
  6535. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6536. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6537. // "&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
  6538. //
  6539. //} else {
  6540. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6541. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6542. // "&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
  6543. //
  6544. //}
  6545. }
  6546. func (c *HisApiController) Get3275() {
  6547. //if miConfig.MdtrtareaAdmvs == "320921" {
  6548. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6549. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6550. // "&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
  6551. //
  6552. //} else {
  6553. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6554. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6555. // "&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
  6556. //
  6557. //}
  6558. }
  6559. func (c *HisApiController) Get3276() {
  6560. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6561. //month := c.GetString("month")
  6562. //
  6563. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6564. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6565. //var api string
  6566. //var res Result5301
  6567. //
  6568. //if miConfig.MdtrtareaAdmvs == "320921" {
  6569. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6570. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  6571. //} else {
  6572. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6573. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  6574. //}
  6575. //
  6576. //resp, requestErr := http.Get(api)
  6577. //if requestErr != nil {
  6578. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6579. // return
  6580. //}
  6581. //
  6582. //body, ioErr := ioutil.ReadAll(resp.Body)
  6583. //if ioErr != nil {
  6584. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6585. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6586. // return
  6587. //}
  6588. //var respJSON map[string]interface{}
  6589. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6590. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6591. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6592. // return
  6593. //}
  6594. //
  6595. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6596. //result, _ := json.Marshal(respJSON)
  6597. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6598. // utils.ErrorLog("解析失败:%v", err)
  6599. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6600. // return
  6601. //}
  6602. }
  6603. func (c *HisApiController) Get3277() {
  6604. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6605. //month := c.GetString("month")
  6606. //
  6607. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6608. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6609. //var api string
  6610. //var res Result5301
  6611. //
  6612. //if miConfig.MdtrtareaAdmvs == "320921" {
  6613. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6614. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  6615. //} else {
  6616. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6617. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  6618. //}
  6619. //
  6620. //resp, requestErr := http.Get(api)
  6621. //if requestErr != nil {
  6622. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6623. // return
  6624. //}
  6625. //
  6626. //body, ioErr := ioutil.ReadAll(resp.Body)
  6627. //if ioErr != nil {
  6628. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6629. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6630. // return
  6631. //}
  6632. //var respJSON map[string]interface{}
  6633. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6634. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6635. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6636. // return
  6637. //}
  6638. //
  6639. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6640. //result, _ := json.Marshal(respJSON)
  6641. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6642. // utils.ErrorLog("解析失败:%v", err)
  6643. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6644. // return
  6645. //}
  6646. }
  6647. func (c *HisApiController) GetCFYLJG001() {
  6648. admin_user_id, _ := c.GetInt64("admin_user_id")
  6649. patient_id, _ := c.GetInt64("patient_id")
  6650. his_patient_id, _ := c.GetInt64("his_patient_id")
  6651. record_time := c.GetString("record_time")
  6652. admin_user_id = 3626
  6653. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6654. psn, _ := service.GetPsnByPatientId(patient_id)
  6655. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6656. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6657. var cFYLJG001 models.CFYLJG001
  6658. timeLayout := "2006-01-02"
  6659. loc, _ := time.LoadLocation("Local")
  6660. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6661. if err != nil {
  6662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6663. return
  6664. }
  6665. recordDateTime := theTime.Unix()
  6666. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  6667. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  6668. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  6669. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  6670. //dept, _ := service.GetDepartMentDetail(info.Departments)
  6671. for _, item := range prescriptions {
  6672. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  6673. if his.IdCardType == 1 {
  6674. bas := strings.Split(psn.CardInfo, "|")
  6675. basNumber := bas[1]
  6676. fmt.Println(basNumber)
  6677. card_sn := bas[3]
  6678. card_no := bas[2]
  6679. cFYLJG001.MdtrtCertType = "03"
  6680. cFYLJG001.CardSn = card_sn
  6681. cFYLJG001.MdtrtCertNo = card_no
  6682. cFYLJG001.EcToken = ""
  6683. cFYLJG001.AuthNo = ""
  6684. } else if his.IdCardType == 2 {
  6685. cFYLJG001.MdtrtCertType = "02"
  6686. cFYLJG001.CardSn = ""
  6687. cFYLJG001.MdtrtCertNo = his.IdCardNo
  6688. cFYLJG001.EcToken = ""
  6689. cFYLJG001.AuthNo = ""
  6690. } else if his.IdCardType == 4 {
  6691. cFYLJG001.MdtrtCertType = "01"
  6692. cFYLJG001.CardSn = ""
  6693. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  6694. cFYLJG001.EcToken = psn.VerifyNumber
  6695. cFYLJG001.AuthNo = ""
  6696. }
  6697. cFYLJG001.BizTypeCode = "01"
  6698. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  6699. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  6700. cFYLJG001.RxTypeCode = "1"
  6701. tempTime := time.Unix(item.PreTime, 0)
  6702. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  6703. cFYLJG001.PrscTime = timeFormatOne
  6704. var count float64
  6705. if item.Type == 1 {
  6706. for _, sumItem := range item.HisDoctorAdviceInfo {
  6707. count = count + sumItem.PrescribingNumber
  6708. }
  6709. }
  6710. cFYLJG001.RxDrugCnt = count
  6711. cFYLJG001.ValiDays = "5"
  6712. ts := time.Unix(item.PreTime, 0)
  6713. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  6714. tempTime3 := time.Unix(record_time2, 0)
  6715. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  6716. cFYLJG001.ValiEndTime = timeFormat3
  6717. cFYLJG001.RxCotnFlag = "0"
  6718. for _, subItem := range item.HisDoctorAdviceInfo {
  6719. var drug models.RxDrug
  6720. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  6721. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  6722. drug.RxItemTypeCode = "11"
  6723. drug.DrugDosform = "乳膏剂" //TODO
  6724. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  6725. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6726. }
  6727. drug.MedcWayDscr = subItem.DeliveryWay
  6728. tempTime2 := time.Unix(subItem.StartTime, 0)
  6729. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  6730. drug.MedcBegntime = timeFormatTwo
  6731. if subItem.Day > 0 {
  6732. ts := time.Unix(subItem.StartTime, 0)
  6733. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  6734. tempTime4 := time.Unix(record_time, 0)
  6735. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  6736. drug.MedcEndtime = timeFormat5
  6737. } else {
  6738. tempTime2 := time.Unix(subItem.StartTime, 0)
  6739. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  6740. drug.MedcEndtime = timeFormatTwo
  6741. }
  6742. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  6743. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  6744. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  6745. drug.DrugCnt = subItem.PrescribingNumber
  6746. drug.DrugDosunt = subItem.PrescribingNumberUnit
  6747. drug.DrugGenname = subItem.AdviceName
  6748. drug.MedcWayCodg = subItem.DeliveryWay
  6749. //drug.DrugTotlcnt = subItem.PrescribingNumber
  6750. drug.SinDoscnt = subItem.SingleDose
  6751. drug.SinDosunt = subItem.SingleDoseUnit
  6752. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  6753. drug.UsedFrquName = subItem.ExecutionFrequency
  6754. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6755. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  6756. drug.HospApprFlag = "1"
  6757. cFYLJG001.List = append(cFYLJG001.List, drug)
  6758. }
  6759. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  6760. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  6761. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  6762. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  6763. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  6764. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  6765. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  6766. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  6767. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  6768. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  6769. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  6770. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  6771. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  6772. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  6773. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  6774. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  6775. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  6776. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  6777. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  6778. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  6779. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  6780. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  6781. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  6782. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  6783. tempTime2 := time.Now().Unix()
  6784. tempTime6 := time.Unix(tempTime2, 0)
  6785. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  6786. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  6787. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  6788. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  6789. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  6790. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  6791. //memo := make(map[string]interface{})
  6792. //inputData := make(map[string]interface{}, 0)
  6793. //type MyData struct {
  6794. // Insutype string `json:"insutype"`
  6795. //}
  6796. //
  6797. // data := MyData{
  6798. // Insutype: his.Insutype,
  6799. //}
  6800. //
  6801. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  6802. var config []*models.HisXtDiagnoseConfig
  6803. for _, item := range diagnosis_ids {
  6804. id, _ := strconv.ParseInt(item, 10, 64)
  6805. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6806. config = append(config, &diagnosisConfig)
  6807. }
  6808. for index, subitem := range config {
  6809. if index == 0 {
  6810. var dia models.DiseInfo
  6811. dia.DiagType = "1"
  6812. dia.MaindiagFlag = "1"
  6813. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  6814. dia.DiagCode = subitem.CountryCode
  6815. dia.DiagName = subitem.ClassName
  6816. dia.DiagDept = "肾内科"
  6817. dia.DiagDrNo = doctor.DoctorNumber
  6818. dia.DiagDrName = doctor.UserName
  6819. tempTime3 := time.Unix(item.PreTime, 0)
  6820. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  6821. dia.DiagTime = timeFormatTwo
  6822. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  6823. } else {
  6824. var dia models.DiseInfo
  6825. dia.DiagType = "1"
  6826. dia.MaindiagFlag = "0"
  6827. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  6828. dia.DiagCode = subitem.CountryCode
  6829. dia.DiagName = subitem.ClassName
  6830. dia.DiagDept = "肾内科"
  6831. dia.DiagDrNo = doctor.DoctorNumber
  6832. dia.DiagDrName = doctor.UserName
  6833. tempTime3 := time.Unix(item.PreTime, 0)
  6834. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  6835. dia.DiagTime = timeFormatTwo
  6836. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  6837. }
  6838. }
  6839. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  6840. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  6841. var res ResultCFYLJG001
  6842. var respJSON2 map[string]interface{}
  6843. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6844. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6846. return
  6847. }
  6848. userJSONBytes2, _ := json.Marshal(respJSON2)
  6849. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  6850. utils.ErrorLog("解析失败:%v", err)
  6851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6852. return
  6853. }
  6854. if res.Infcode == -1 {
  6855. c.ServeSuccessJSON(map[string]interface{}{
  6856. "failed_code": -10,
  6857. "msg": res.ErrMsg,
  6858. })
  6859. return
  6860. } else {
  6861. var flow models.HisPrescriptionFlow
  6862. flow.Ctime = time.Now().Unix()
  6863. flow.SignDigest = ""
  6864. flow.RxTraceCode = res.Output.RxTraceCode
  6865. flow.HiRxno = res.Output.HiRxno
  6866. flow.MID = his.Number
  6867. flow.Status = 1
  6868. flow.DCode = doctor_info.DoctorNumber
  6869. flow.OriginalRxFile = ""
  6870. flow.OriginalValue = ""
  6871. flow.SignCertDn = ""
  6872. flow.UserOrgId = 10454
  6873. flow.SignCertSn = ""
  6874. flow.Mtime = time.Now().Unix()
  6875. service.Createflow(&flow)
  6876. c.ServeSuccessJSON(map[string]interface{}{
  6877. "msg": "上传成功",
  6878. })
  6879. }
  6880. }
  6881. }
  6882. func (c *HisApiController) GetCFYLJG002() {
  6883. admin_user_id, _ := c.GetInt64("admin_user_id")
  6884. his_patient_id, _ := c.GetInt64("his_patient_id")
  6885. record_time := c.GetString("record_time")
  6886. admin_user_id = 3626
  6887. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6888. //id, _ := c.GetInt64("id")
  6889. admin_user_id = 3626
  6890. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6891. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6892. flow, _ := service.Getflowtwo(his.Number)
  6893. //his, _ := service.GetHisPatientByNumber(flow.MID)
  6894. //record_time := c.GetString("record_time")
  6895. patient_id, _ := c.GetInt64("patient_id")
  6896. //patient_id = 23834
  6897. //record_time = "2023-09-18"
  6898. timeLayout := "2006-01-02"
  6899. loc, _ := time.LoadLocation("Local")
  6900. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6901. if err != nil {
  6902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6903. return
  6904. }
  6905. recordDateTime := theTime.Unix()
  6906. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  6907. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  6908. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  6909. dept, _ := service.GetDepartMentDetail(info.Departments)
  6910. inputData := make(map[string]interface{})
  6911. inputData["rxTraceCode"] = flow.RxTraceCode
  6912. inputData["hiRxno"] = flow.HiRxno
  6913. inputData["mdtrtId"] = flow.MID
  6914. inputData["patnName"] = his.PsnName
  6915. inputData["psnCertType"] = his.PsnCertType
  6916. inputData["certno"] = his.Certno
  6917. inputData["fixmedinsName"] = miConfig.OrgName
  6918. inputData["fixmedinsCode"] = miConfig.Code
  6919. inputData["drCode"] = doctor_info.DoctorNumber
  6920. inputData["prscDrName"] = doctor_info.UserName
  6921. inputData["pharDeptName"] = dept.Name
  6922. inputData["pharDeptCode"] = dept.Number
  6923. inputData["pharProfttlCodg"] = dept.Name
  6924. inputData["pharProfttlName"] = ""
  6925. inputData["pharCode"] = "HY440309002107"
  6926. inputData["pharCertType"] = "01"
  6927. inputData["pharCertno"] = "430482199408260023"
  6928. inputData["pharName"] = "彭斯遥"
  6929. inputData["pharPracCertNo"] = ""
  6930. tempTime2 := time.Unix(info.Ctime, 0)
  6931. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  6932. inputData["pharChkTime"] = timeFormatTwo
  6933. bytesData, _ := json.Marshal(inputData)
  6934. fmt.Println(string(bytesData))
  6935. encoded := base64.StdEncoding.EncodeToString(bytesData)
  6936. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  6937. if err != nil {
  6938. fmt.Println("Error reading PDF file:", err)
  6939. return
  6940. }
  6941. // 将 PDF 文件内容进行 Base64 编码
  6942. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  6943. fmt.Println(err)
  6944. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  6945. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  6946. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  6947. var res2 Result002
  6948. var respJSON2 map[string]interface{}
  6949. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6950. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6952. return
  6953. }
  6954. userJSONBytes2, _ := json.Marshal(respJSON2)
  6955. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6956. utils.ErrorLog("解析失败:%v", err)
  6957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6958. return
  6959. }
  6960. if res2.Infcode == 0 {
  6961. flow.Ctime = time.Now().Unix()
  6962. flow.SignDigest = res2.Output.SignDigest
  6963. flow.RxFile = res2.Output.RxFile
  6964. flow.MID = his.Number
  6965. flow.Status = 1
  6966. flow.DCode = doctor_info.DoctorNumber
  6967. flow.OriginalRxFile = rx_encoded
  6968. flow.OriginalValue = encoded
  6969. flow.SignCertDn = res2.Output.SignCertDn
  6970. flow.SignCertSn = res2.Output.SignCertSn
  6971. flow.Mtime = time.Now().Unix()
  6972. service.Saveflow(flow)
  6973. c.ServeSuccessJSON(map[string]interface{}{
  6974. "msg": "预签名成功",
  6975. })
  6976. } else {
  6977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6978. return
  6979. }
  6980. }
  6981. func (c *HisApiController) GetCFYLJG003() {
  6982. admin_user_id, _ := c.GetInt64("admin_user_id")
  6983. his_patient_id, _ := c.GetInt64("his_patient_id")
  6984. record_time := c.GetString("record_time")
  6985. admin_user_id = 3626
  6986. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6987. //id, _ := c.GetInt64("id")
  6988. admin_user_id = 3626
  6989. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6990. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6991. flow, _ := service.Getflowtwo(his.Number)
  6992. //id = 3
  6993. patient_id, _ := c.GetInt64("patient_id")
  6994. //patient_id = 23834
  6995. //record_time = "2023-09-18"
  6996. timeLayout := "2006-01-02"
  6997. loc, _ := time.LoadLocation("Local")
  6998. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6999. if err != nil {
  7000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7001. return
  7002. }
  7003. recordDateTime := theTime.Unix()
  7004. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7005. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7006. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7007. dept, _ := service.GetDepartMentDetail(info.Departments)
  7008. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  7009. var cFYLJG003 models.CFYLJG003
  7010. cFYLJG003.RxTraceCode = flow.RxTraceCode
  7011. cFYLJG003.HiRxno = flow.HiRxno
  7012. cFYLJG003.MdtrtID = flow.MID
  7013. cFYLJG003.PatnName = his.Name
  7014. cFYLJG003.Certno = his.Certno
  7015. cFYLJG003.FixmedinsName = miConfig.OrgName
  7016. cFYLJG003.FixmedinsCode = miConfig.Code
  7017. cFYLJG003.DrCode = doctor_info.DoctorNumber
  7018. cFYLJG003.PrscDrName = doctor_info.UserName
  7019. cFYLJG003.PharDeptName = dept.Name
  7020. cFYLJG003.PharDeptCode = dept.Number
  7021. cFYLJG003.PharCode = "HY440309002107"
  7022. cFYLJG003.PharCertType = "01"
  7023. cFYLJG003.PharCertno = "430482199408260023"
  7024. cFYLJG003.PharName = "彭斯遥"
  7025. cFYLJG003.PsnCertType = "01"
  7026. cFYLJG003.RxFile = flow.RxFile
  7027. cFYLJG003.SignDigest = flow.SignDigest
  7028. cFYLJG003.FixmedinsCode = miConfig.Code
  7029. cFYLJG003.PsnCertType = "01"
  7030. cFYLJG003.PharProfttlCodg = dept.Name
  7031. //inputData["pharProfttlCodg"] =dept.Name
  7032. tempTime2 := time.Unix(info.Ctime, 0)
  7033. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7034. cFYLJG003.PharChkTime = timeFormatTwo
  7035. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7036. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  7037. var res ResultCFYLJG003
  7038. var respJSON2 map[string]interface{}
  7039. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7040. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7042. return
  7043. }
  7044. userJSONBytes2, _ := json.Marshal(respJSON2)
  7045. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7046. utils.ErrorLog("解析失败:%v", err)
  7047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7048. return
  7049. }
  7050. if res.Infcode == -1 {
  7051. c.ServeSuccessJSON(map[string]interface{}{
  7052. "failed_code": -10,
  7053. "msg": res.ErrMsg,
  7054. })
  7055. return
  7056. } else {
  7057. c.ServeSuccessJSON(map[string]interface{}{
  7058. "info": res.Output,
  7059. })
  7060. }
  7061. }
  7062. func (c *HisApiController) GetCFYLJG004() {
  7063. admin_user_id, _ := c.GetInt64("admin_user_id")
  7064. his_patient_id, _ := c.GetInt64("his_patient_id")
  7065. record_time := c.GetString("record_time")
  7066. admin_user_id = 3626
  7067. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7068. //id, _ := c.GetInt64("id")
  7069. admin_user_id = 3626
  7070. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7071. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7072. flow, _ := service.Getflowtwo(his.Number)
  7073. //id = 3
  7074. patient_id, _ := c.GetInt64("patient_id")
  7075. //patient_id = 23834
  7076. //record_time = "2023-09-18"
  7077. timeLayout := "2006-01-02"
  7078. loc, _ := time.LoadLocation("Local")
  7079. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7080. if err != nil {
  7081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7082. return
  7083. }
  7084. recordDateTime := theTime.Unix()
  7085. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7086. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7087. var cFYLJG004 models.CFYLJG004
  7088. cFYLJG004.HiRxno = flow.HiRxno
  7089. cFYLJG004.FixmedinsCode = miConfig.Code
  7090. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  7091. cFYLJG004.UndoDrCertType = "01"
  7092. cFYLJG004.UndoRea = "撤销处方"
  7093. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  7094. cFYLJG004.UndoDrName = doctor_info.UserName
  7095. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  7096. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  7097. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  7098. var res ResultCFYLJG004
  7099. var respJSON2 map[string]interface{}
  7100. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7103. return
  7104. }
  7105. userJSONBytes2, _ := json.Marshal(respJSON2)
  7106. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7107. utils.ErrorLog("解析失败:%v", err)
  7108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7109. return
  7110. }
  7111. if res.Infcode == -1 {
  7112. c.ServeSuccessJSON(map[string]interface{}{
  7113. "failed_code": -10,
  7114. "msg": res.ErrMsg,
  7115. })
  7116. return
  7117. } else {
  7118. flow.Status = 0
  7119. service.Saveflow(flow)
  7120. c.ServeSuccessJSON(map[string]interface{}{
  7121. "msg": "撤销成功",
  7122. })
  7123. return
  7124. }
  7125. }
  7126. func (c *HisApiController) GetCFYLJG005() {
  7127. admin_user_id, _ := c.GetInt64("admin_user_id")
  7128. his_patient_id, _ := c.GetInt64("his_patient_id")
  7129. //record_time := c.GetString("record_time")
  7130. admin_user_id = 3626
  7131. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7132. //id, _ := c.GetInt64("id")
  7133. admin_user_id = 3626
  7134. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7135. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7136. flow, _ := service.Getflowtwo(his.Number)
  7137. //id = 3
  7138. var cFYLJG005 models.CFYLJG005
  7139. //patient_id, _ := c.GetInt64("patient_id")
  7140. cFYLJG005.HiRxno = flow.HiRxno
  7141. cFYLJG005.MdtrtID = flow.MID
  7142. cFYLJG005.EcToken = ""
  7143. cFYLJG005.PsnName = his.Name
  7144. cFYLJG005.PsnCertType = "01"
  7145. cFYLJG005.Certno = his.IdCardNo
  7146. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7147. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7148. var res ResultCFYLJG005
  7149. var respJSON2 map[string]interface{}
  7150. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7151. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7153. return
  7154. }
  7155. userJSONBytes2, _ := json.Marshal(respJSON2)
  7156. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7157. utils.ErrorLog("解析失败:%v", err)
  7158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7159. return
  7160. }
  7161. if res.Infcode == -1 {
  7162. c.ServeSuccessJSON(map[string]interface{}{
  7163. "failed_code": -10,
  7164. "msg": res.ErrMsg,
  7165. })
  7166. return
  7167. } else {
  7168. c.ServeSuccessJSON(map[string]interface{}{
  7169. "info": res.Output,
  7170. })
  7171. return
  7172. }
  7173. }
  7174. func (c *HisApiController) GetCFYLJG006() {
  7175. admin_user_id, _ := c.GetInt64("admin_user_id")
  7176. his_patient_id, _ := c.GetInt64("his_patient_id")
  7177. admin_user_id = 3626
  7178. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7179. //id, _ := c.GetInt64("id")
  7180. admin_user_id = 3626
  7181. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7182. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7183. flow, _ := service.Getflowtwo(his.Number)
  7184. //id = 3
  7185. patient_id, _ := c.GetInt64("patient_id")
  7186. var cFYLJG006 models.CFYLJG006
  7187. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7188. cFYLJG006.HiRxno = flow.HiRxno
  7189. cFYLJG006.MdtrtID = flow.MID
  7190. cFYLJG006.PsnName = patient.Name
  7191. cFYLJG006.PsnCertType = "01"
  7192. cFYLJG006.Certno = patient.IdCardNo
  7193. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  7194. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  7195. var res ResultCFYLJG006
  7196. var respJSON2 map[string]interface{}
  7197. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7198. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7200. return
  7201. }
  7202. userJSONBytes2, _ := json.Marshal(respJSON2)
  7203. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7204. utils.ErrorLog("解析失败:%v", err)
  7205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7206. return
  7207. }
  7208. if res.Infcode == -1 {
  7209. c.ServeSuccessJSON(map[string]interface{}{
  7210. "failed_code": -10,
  7211. "msg": res.ErrMsg,
  7212. })
  7213. return
  7214. } else {
  7215. c.ServeSuccessJSON(map[string]interface{}{
  7216. "info": res.Output,
  7217. })
  7218. return
  7219. }
  7220. }
  7221. func (c *HisApiController) GetCFYLJG007() {
  7222. admin_user_id, _ := c.GetInt64("admin_user_id")
  7223. his_patient_id, _ := c.GetInt64("his_patient_id")
  7224. admin_user_id = 3626
  7225. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7226. //id, _ := c.GetInt64("id")
  7227. admin_user_id = 3626
  7228. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7229. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7230. flow, _ := service.Getflowtwo(his.Number)
  7231. //id = 3
  7232. patient_id, _ := c.GetInt64("patient_id")
  7233. var cFYLJG007 models.CFYLJG007
  7234. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7235. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7236. cFYLJG007.HiRxno = flow.HiRxno
  7237. cFYLJG007.MdtrtID = flow.MID
  7238. cFYLJG007.PsnNo = his.PsnNo
  7239. cFYLJG007.PsnCertType = "01"
  7240. cFYLJG007.Certno = patient.IdCardNo
  7241. cFYLJG007.PsnName = patient.Name
  7242. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  7243. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  7244. var res ResultCFYLJG007
  7245. var respJSON2 map[string]interface{}
  7246. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7247. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7249. return
  7250. }
  7251. userJSONBytes2, _ := json.Marshal(respJSON2)
  7252. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7253. utils.ErrorLog("解析失败:%v", err)
  7254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7255. return
  7256. }
  7257. if res.Infcode == -1 {
  7258. c.ServeSuccessJSON(map[string]interface{}{
  7259. "failed_code": -10,
  7260. "msg": res.ErrMsg,
  7261. })
  7262. return
  7263. } else {
  7264. c.ServeSuccessJSON(map[string]interface{}{
  7265. "info": res,
  7266. })
  7267. return
  7268. }
  7269. }
  7270. func (c *HisApiController) GetCFYLJG008() {
  7271. admin_user_id, _ := c.GetInt64("admin_user_id")
  7272. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7273. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7274. var cFYLJG008 models.CFYLJG008
  7275. //id, _ := c.GetInt64("id")
  7276. patient_id, _ := c.GetInt64("patient_id")
  7277. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7278. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7279. //id = 3
  7280. //flow, _ := service.Getflow(id)
  7281. //his, _ := service.GetHisPatientByNumber(flow.MID)
  7282. //
  7283. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7284. //patient_id, _ := c.GetInt64("patient_id")
  7285. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7286. record_time := c.GetString("record_time")
  7287. admin_user_id = 3626
  7288. patient_id = 19424
  7289. //his_patient_id = 263947
  7290. record_time = "2023-08-29"
  7291. timeLayout := "2006-01-02"
  7292. loc, _ := time.LoadLocation("Local")
  7293. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7294. if err != nil {
  7295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7296. return
  7297. }
  7298. recordDateTime := theTime.Unix()
  7299. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7300. cFYLJG008.FixmedinsName = ""
  7301. cFYLJG008.Lat = ""
  7302. cFYLJG008.Lng = ""
  7303. cFYLJG008.OrderType = "1"
  7304. cFYLJG008.PoolareaNo = ""
  7305. cFYLJG008.Lng = ""
  7306. cFYLJG008.PageNum = 1
  7307. cFYLJG008.PageSize = 10
  7308. var MPI models.MedinsProdInvChgDDTO
  7309. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  7310. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  7311. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  7312. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  7313. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  7314. var res ResultCFYLJG008
  7315. var respJSON2 map[string]interface{}
  7316. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7317. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7319. return
  7320. }
  7321. userJSONBytes2, _ := json.Marshal(respJSON2)
  7322. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7323. utils.ErrorLog("解析失败:%v", err)
  7324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7325. return
  7326. }
  7327. if res.Infcode == -1 {
  7328. c.ServeSuccessJSON(map[string]interface{}{
  7329. "failed_code": -10,
  7330. "msg": res.ErrMsg,
  7331. })
  7332. return
  7333. } else {
  7334. c.ServeSuccessJSON(map[string]interface{}{
  7335. "info": res.Output,
  7336. })
  7337. return
  7338. }
  7339. }
  7340. func (c *HisApiController) GetBL4201A() {
  7341. order_id, _ := c.GetInt64("order_id")
  7342. admin_user_id, _ := c.GetInt64("admin_user_id")
  7343. order, _ := service.GetHisOrderByIDTwo(order_id)
  7344. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7345. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  7346. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  7347. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7348. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7349. department, _ := service.GetDepartMentDetail(his.Departments)
  7350. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  7351. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  7352. if order.ID == 0 {
  7353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  7354. return
  7355. }
  7356. var struct4201A models.Struct4201A
  7357. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  7358. for _, items := range order_info {
  7359. memo := make(map[string]interface{})
  7360. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  7361. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  7362. fsiOPFLD.MedType = "14"
  7363. fsiOPFLD.BkkpSn = items.FeedetlSn
  7364. fsiOPFLD.FixmedinsCode = miConfig.Code
  7365. fsiOPFLD.FixmedinsName = miConfig.OrgName
  7366. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  7367. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  7368. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  7369. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7370. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  7371. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7372. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7373. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7374. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7375. fsiOPFLD.BilgDeptName = department.Name
  7376. fsiOPFLD.BilgDeptCodg = department.Number
  7377. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7378. fsiOPFLD.BilgDrName = doctor.UserName
  7379. fsiOPFLD.MedChrgitmType = "09"
  7380. memo["hosp_appr_flag"] = "1"
  7381. memo["invoice_no"] = order.MdtrtId
  7382. memo["memo"] = "自费"
  7383. bytesData, _ := json.Marshal(memo)
  7384. fsiOPFLD.Memo = string(bytesData)
  7385. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7386. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  7387. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  7388. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7389. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7390. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7391. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  7392. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  7393. fsiOPFLD.BilgDeptName = department.Name
  7394. fsiOPFLD.BilgDeptCodg = department.Number
  7395. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7396. fsiOPFLD.BilgDrName = doctor.UserName
  7397. switch items.HisPrescriptionProject.HisProject.CostClassify {
  7398. case 0:
  7399. break
  7400. case 1:
  7401. fsiOPFLD.MedChrgitmType = "14"
  7402. break
  7403. case 2:
  7404. fsiOPFLD.MedChrgitmType = "05"
  7405. break
  7406. case 3:
  7407. fsiOPFLD.MedChrgitmType = "03"
  7408. break
  7409. case 4:
  7410. fsiOPFLD.MedChrgitmType = "03"
  7411. break
  7412. case 5:
  7413. fsiOPFLD.MedChrgitmType = "08"
  7414. break
  7415. case 6:
  7416. fsiOPFLD.MedChrgitmType = "14"
  7417. break
  7418. case 7:
  7419. fsiOPFLD.MedChrgitmType = "14"
  7420. break
  7421. case 8:
  7422. fsiOPFLD.MedChrgitmType = "03"
  7423. break
  7424. case 9:
  7425. fsiOPFLD.MedChrgitmType = "14"
  7426. break
  7427. case 10:
  7428. fsiOPFLD.MedChrgitmType = "14"
  7429. break
  7430. case 11:
  7431. fsiOPFLD.MedChrgitmType = "06"
  7432. break
  7433. case 12:
  7434. fsiOPFLD.MedChrgitmType = "12"
  7435. break
  7436. case 13:
  7437. fsiOPFLD.MedChrgitmType = "01"
  7438. break
  7439. case 14:
  7440. fsiOPFLD.MedChrgitmType = "04"
  7441. break
  7442. case 15:
  7443. fsiOPFLD.MedChrgitmType = "14"
  7444. break
  7445. }
  7446. memo["hosp_appr_flag"] = "1"
  7447. memo["invoice_no"] = order.MdtrtId
  7448. memo["memo"] = "自费"
  7449. bytesData, _ := json.Marshal(memo)
  7450. fsiOPFLD.Memo = string(bytesData)
  7451. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7452. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  7453. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7454. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7455. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7456. fsiOPFLD.BilgDeptName = department.Name
  7457. fsiOPFLD.BilgDeptCodg = department.Number
  7458. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7459. fsiOPFLD.BilgDrName = doctor.UserName
  7460. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  7461. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  7462. fsiOPFLD.MedChrgitmType = "08"
  7463. memo["hosp_appr_flag"] = "1"
  7464. memo["invoice_no"] = order.MdtrtId
  7465. memo["memo"] = "自费"
  7466. bytesData, _ := json.Marshal(memo)
  7467. fsiOPFLD.Memo = string(bytesData)
  7468. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7469. }
  7470. }
  7471. }
  7472. for _, items := range order_info_two {
  7473. memo := make(map[string]interface{})
  7474. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  7475. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  7476. fsiOPFLD.MedType = "14"
  7477. fsiOPFLD.BkkpSn = items.FeedetlSn
  7478. fsiOPFLD.FixmedinsCode = miConfig.Code
  7479. fsiOPFLD.FixmedinsName = miConfig.OrgName
  7480. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  7481. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  7482. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  7483. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7484. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  7485. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7486. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7487. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7488. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7489. fsiOPFLD.BilgDeptName = department.Name
  7490. fsiOPFLD.BilgDeptCodg = department.Number
  7491. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7492. fsiOPFLD.BilgDrName = doctor.UserName
  7493. fsiOPFLD.MedChrgitmType = "09"
  7494. memo["hosp_appr_flag"] = "1"
  7495. memo["invoice_no"] = order.MdtrtId
  7496. memo["memo"] = "自费"
  7497. bytesData, _ := json.Marshal(memo)
  7498. fsiOPFLD.Memo = string(bytesData)
  7499. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7500. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  7501. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  7502. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7503. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7504. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  7505. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  7506. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7507. fsiOPFLD.BilgDeptName = department.Name
  7508. fsiOPFLD.BilgDeptCodg = department.Number
  7509. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7510. fsiOPFLD.BilgDrName = doctor.UserName
  7511. switch items.HisPrescriptionProject.HisProject.CostClassify {
  7512. case 0:
  7513. break
  7514. case 1:
  7515. fsiOPFLD.MedChrgitmType = "14"
  7516. break
  7517. case 2:
  7518. fsiOPFLD.MedChrgitmType = "05"
  7519. break
  7520. case 3:
  7521. fsiOPFLD.MedChrgitmType = "03"
  7522. break
  7523. case 4:
  7524. fsiOPFLD.MedChrgitmType = "03"
  7525. break
  7526. case 5:
  7527. fsiOPFLD.MedChrgitmType = "08"
  7528. break
  7529. case 6:
  7530. fsiOPFLD.MedChrgitmType = "14"
  7531. break
  7532. case 7:
  7533. fsiOPFLD.MedChrgitmType = "14"
  7534. break
  7535. case 8:
  7536. fsiOPFLD.MedChrgitmType = "03"
  7537. break
  7538. case 9:
  7539. fsiOPFLD.MedChrgitmType = "14"
  7540. break
  7541. case 10:
  7542. fsiOPFLD.MedChrgitmType = "14"
  7543. break
  7544. case 11:
  7545. fsiOPFLD.MedChrgitmType = "06"
  7546. break
  7547. case 12:
  7548. fsiOPFLD.MedChrgitmType = "12"
  7549. break
  7550. case 13:
  7551. fsiOPFLD.MedChrgitmType = "01"
  7552. break
  7553. case 14:
  7554. fsiOPFLD.MedChrgitmType = "04"
  7555. break
  7556. case 15:
  7557. fsiOPFLD.MedChrgitmType = "14"
  7558. break
  7559. }
  7560. memo["hosp_appr_flag"] = "1"
  7561. memo["invoice_no"] = order.MdtrtId
  7562. memo["memo"] = "自费"
  7563. bytesData, _ := json.Marshal(memo)
  7564. fsiOPFLD.Memo = string(bytesData)
  7565. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7566. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  7567. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7568. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7569. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7570. fsiOPFLD.BilgDeptName = department.Name
  7571. fsiOPFLD.BilgDeptCodg = department.Number
  7572. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7573. fsiOPFLD.BilgDrName = doctor.UserName
  7574. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  7575. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  7576. fsiOPFLD.MedChrgitmType = "08"
  7577. memo["hosp_appr_flag"] = "1"
  7578. memo["invoice_no"] = order.MdtrtId
  7579. memo["memo"] = "自费"
  7580. bytesData, _ := json.Marshal(memo)
  7581. fsiOPFLD.Memo = string(bytesData)
  7582. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7583. }
  7584. }
  7585. }
  7586. fmt.Println(fsiOPFLDs)
  7587. struct4201A.Fopfd = fsiOPFLDs
  7588. fmt.Println(struct4201A.Fopfd)
  7589. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  7590. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  7591. var res2 ResultSix
  7592. var respJSON2 map[string]interface{}
  7593. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7594. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7596. return
  7597. }
  7598. userJSONBytes2, _ := json.Marshal(respJSON2)
  7599. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7600. utils.ErrorLog("解析失败:%v", err)
  7601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7602. return
  7603. }
  7604. if res2.Infcode != 0 {
  7605. c.ServeSuccessJSON(map[string]interface{}{
  7606. "failed_code": -10,
  7607. "msg": res2.ErrMsg,
  7608. })
  7609. return
  7610. } else {
  7611. order.IsUploadOrderInfo = 1
  7612. service.UpdateOrder(order)
  7613. c.ServeSuccessJSON(map[string]interface{}{
  7614. "msg": "上传成功",
  7615. })
  7616. }
  7617. }
  7618. func (c *HisApiController) Get2505() {
  7619. admin_user_id, _ := c.GetInt64("admin_user_id")
  7620. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  7621. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7622. 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)
  7623. }
  7624. func (c *HisApiController) Get4201A() {
  7625. order_id, _ := c.GetInt64("order_id")
  7626. admin_user_id, _ := c.GetInt64("admin_user_id")
  7627. order, _ := service.GetHisOrderByIDTwo(order_id)
  7628. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7629. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  7630. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  7631. //order_info = append(order_info, order_info_two...)
  7632. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7633. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7634. department, _ := service.GetDepartMentDetail(his.Departments)
  7635. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  7636. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  7637. if order.ID == 0 {
  7638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  7639. return
  7640. }
  7641. var struct4201A models.Struct4201A
  7642. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  7643. for _, items := range order_info {
  7644. memo := make(map[string]interface{})
  7645. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  7646. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  7647. fsiOPFLD.MedType = "14"
  7648. fsiOPFLD.BkkpSn = items.FeedetlSn
  7649. fsiOPFLD.FixmedinsCode = miConfig.Code
  7650. fsiOPFLD.FixmedinsName = miConfig.OrgName
  7651. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  7652. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  7653. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  7654. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7655. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  7656. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7657. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7658. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7659. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7660. fsiOPFLD.BilgDeptName = department.Name
  7661. fsiOPFLD.BilgDeptCodg = department.Number
  7662. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7663. fsiOPFLD.BilgDrName = doctor.UserName
  7664. fsiOPFLD.MedChrgitmType = "09"
  7665. memo["hosp_appr_flag"] = "1"
  7666. memo["invoice_no"] = order.MdtrtId
  7667. memo["memo"] = "自费"
  7668. bytesData, _ := json.Marshal(memo)
  7669. fsiOPFLD.Memo = string(bytesData)
  7670. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7671. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  7672. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  7673. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7674. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7675. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7676. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  7677. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  7678. fsiOPFLD.BilgDeptName = department.Name
  7679. fsiOPFLD.BilgDeptCodg = department.Number
  7680. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7681. fsiOPFLD.BilgDrName = doctor.UserName
  7682. switch items.HisPrescriptionProject.HisProject.CostClassify {
  7683. case 0:
  7684. break
  7685. case 1:
  7686. fsiOPFLD.MedChrgitmType = "14"
  7687. break
  7688. case 2:
  7689. fsiOPFLD.MedChrgitmType = "05"
  7690. break
  7691. case 3:
  7692. fsiOPFLD.MedChrgitmType = "03"
  7693. break
  7694. case 4:
  7695. fsiOPFLD.MedChrgitmType = "03"
  7696. break
  7697. case 5:
  7698. fsiOPFLD.MedChrgitmType = "08"
  7699. break
  7700. case 6:
  7701. fsiOPFLD.MedChrgitmType = "14"
  7702. break
  7703. case 7:
  7704. fsiOPFLD.MedChrgitmType = "14"
  7705. break
  7706. case 8:
  7707. fsiOPFLD.MedChrgitmType = "03"
  7708. break
  7709. case 9:
  7710. fsiOPFLD.MedChrgitmType = "14"
  7711. break
  7712. case 10:
  7713. fsiOPFLD.MedChrgitmType = "14"
  7714. break
  7715. case 11:
  7716. fsiOPFLD.MedChrgitmType = "06"
  7717. break
  7718. case 12:
  7719. fsiOPFLD.MedChrgitmType = "12"
  7720. break
  7721. case 13:
  7722. fsiOPFLD.MedChrgitmType = "01"
  7723. break
  7724. case 14:
  7725. fsiOPFLD.MedChrgitmType = "04"
  7726. break
  7727. case 15:
  7728. fsiOPFLD.MedChrgitmType = "14"
  7729. break
  7730. }
  7731. memo["hosp_appr_flag"] = "1"
  7732. memo["invoice_no"] = order.MdtrtId
  7733. memo["memo"] = "自费"
  7734. bytesData, _ := json.Marshal(memo)
  7735. fsiOPFLD.Memo = string(bytesData)
  7736. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7737. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  7738. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7739. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7740. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7741. fsiOPFLD.BilgDeptName = department.Name
  7742. fsiOPFLD.BilgDeptCodg = department.Number
  7743. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7744. fsiOPFLD.BilgDrName = doctor.UserName
  7745. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  7746. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  7747. fsiOPFLD.MedChrgitmType = "08"
  7748. memo["hosp_appr_flag"] = "1"
  7749. memo["invoice_no"] = order.MdtrtId
  7750. memo["memo"] = "自费"
  7751. bytesData, _ := json.Marshal(memo)
  7752. fsiOPFLD.Memo = string(bytesData)
  7753. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7754. }
  7755. }
  7756. }
  7757. for _, items := range order_info_two {
  7758. memo := make(map[string]interface{})
  7759. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  7760. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  7761. fsiOPFLD.MedType = "14"
  7762. fsiOPFLD.BkkpSn = items.FeedetlSn
  7763. fsiOPFLD.FixmedinsCode = miConfig.Code
  7764. fsiOPFLD.FixmedinsName = miConfig.OrgName
  7765. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  7766. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  7767. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  7768. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7769. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  7770. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7771. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7772. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7773. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7774. fsiOPFLD.BilgDeptName = department.Name
  7775. fsiOPFLD.BilgDeptCodg = department.Number
  7776. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7777. fsiOPFLD.BilgDrName = doctor.UserName
  7778. fsiOPFLD.MedChrgitmType = "09"
  7779. memo["hosp_appr_flag"] = "1"
  7780. memo["invoice_no"] = order.MdtrtId
  7781. memo["memo"] = "自费"
  7782. bytesData, _ := json.Marshal(memo)
  7783. fsiOPFLD.Memo = string(bytesData)
  7784. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7785. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  7786. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  7787. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7788. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7789. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  7790. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  7791. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7792. fsiOPFLD.BilgDeptName = department.Name
  7793. fsiOPFLD.BilgDeptCodg = department.Number
  7794. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7795. fsiOPFLD.BilgDrName = doctor.UserName
  7796. switch items.HisPrescriptionProject.HisProject.CostClassify {
  7797. case 0:
  7798. break
  7799. case 1:
  7800. fsiOPFLD.MedChrgitmType = "14"
  7801. break
  7802. case 2:
  7803. fsiOPFLD.MedChrgitmType = "05"
  7804. break
  7805. case 3:
  7806. fsiOPFLD.MedChrgitmType = "03"
  7807. break
  7808. case 4:
  7809. fsiOPFLD.MedChrgitmType = "03"
  7810. break
  7811. case 5:
  7812. fsiOPFLD.MedChrgitmType = "08"
  7813. break
  7814. case 6:
  7815. fsiOPFLD.MedChrgitmType = "14"
  7816. break
  7817. case 7:
  7818. fsiOPFLD.MedChrgitmType = "14"
  7819. break
  7820. case 8:
  7821. fsiOPFLD.MedChrgitmType = "03"
  7822. break
  7823. case 9:
  7824. fsiOPFLD.MedChrgitmType = "14"
  7825. break
  7826. case 10:
  7827. fsiOPFLD.MedChrgitmType = "14"
  7828. break
  7829. case 11:
  7830. fsiOPFLD.MedChrgitmType = "06"
  7831. break
  7832. case 12:
  7833. fsiOPFLD.MedChrgitmType = "12"
  7834. break
  7835. case 13:
  7836. fsiOPFLD.MedChrgitmType = "01"
  7837. break
  7838. case 14:
  7839. fsiOPFLD.MedChrgitmType = "04"
  7840. break
  7841. case 15:
  7842. fsiOPFLD.MedChrgitmType = "14"
  7843. break
  7844. }
  7845. memo["hosp_appr_flag"] = "1"
  7846. memo["invoice_no"] = order.MdtrtId
  7847. memo["memo"] = "自费"
  7848. bytesData, _ := json.Marshal(memo)
  7849. fsiOPFLD.Memo = string(bytesData)
  7850. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7851. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  7852. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7853. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7854. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7855. fsiOPFLD.BilgDeptName = department.Name
  7856. fsiOPFLD.BilgDeptCodg = department.Number
  7857. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7858. fsiOPFLD.BilgDrName = doctor.UserName
  7859. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  7860. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  7861. fsiOPFLD.MedChrgitmType = "08"
  7862. memo["hosp_appr_flag"] = "1"
  7863. memo["invoice_no"] = order.MdtrtId
  7864. memo["memo"] = "自费"
  7865. bytesData, _ := json.Marshal(memo)
  7866. fsiOPFLD.Memo = string(bytesData)
  7867. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7868. }
  7869. }
  7870. }
  7871. fmt.Println(fsiOPFLDs)
  7872. struct4201A.Fopfd = fsiOPFLDs
  7873. fmt.Println(struct4201A.Fopfd)
  7874. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  7875. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  7876. var res2 ResultSix
  7877. var respJSON2 map[string]interface{}
  7878. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7879. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7881. return
  7882. }
  7883. userJSONBytes2, _ := json.Marshal(respJSON2)
  7884. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7885. utils.ErrorLog("解析失败:%v", err)
  7886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7887. return
  7888. }
  7889. if res2.Infcode != 0 {
  7890. c.ServeSuccessJSON(map[string]interface{}{
  7891. "failed_code": -10,
  7892. "msg": res2.ErrMsg,
  7893. })
  7894. return
  7895. } else {
  7896. order.IsUploadOrderInfo = 1
  7897. service.UpdateOrder(order)
  7898. c.ServeSuccessJSON(map[string]interface{}{
  7899. "msg": "上传成功",
  7900. })
  7901. }
  7902. }
  7903. func (c *HisApiController) Get4202() {
  7904. order_id, _ := c.GetInt64("order_id")
  7905. admin_user_id, _ := c.GetInt64("admin_user_id")
  7906. order, _ := service.GetHisOrderByIDTwo(order_id)
  7907. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7908. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7909. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7910. if order.ID == 0 {
  7911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  7912. return
  7913. }
  7914. var struct4202 models.Struct4202
  7915. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  7916. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  7917. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  7918. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  7919. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  7920. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  7921. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  7922. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  7923. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  7924. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  7925. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7926. var config []*models.HisXtDiagnoseConfig
  7927. for _, item := range diagnosis_ids {
  7928. id, _ := strconv.ParseInt(item, 10, 64)
  7929. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7930. config = append(config, &diagnosisConfig)
  7931. }
  7932. var tempDiaginfos []models.OwnPayPatnDiagListD
  7933. for index, item := range config {
  7934. if index == 0 {
  7935. var tempDiaginfo models.OwnPayPatnDiagListD
  7936. tempDiaginfo.InoutDiagType = "1"
  7937. tempDiaginfo.DiagCode = item.CountryCode
  7938. tempDiaginfo.DiagName = item.CountryContentName
  7939. tempDiaginfo.DiagType = "1"
  7940. tempDiaginfo.DiagSrtNo = "1"
  7941. tempDiaginfo.MaindiagFlag = "1"
  7942. tempDiaginfo.ValiFlag = "1"
  7943. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  7944. } else {
  7945. var tempDiaginfo models.OwnPayPatnDiagListD
  7946. tempDiaginfo.DiagCode = item.CountryCode
  7947. tempDiaginfo.DiagName = item.CountryContentName
  7948. tempDiaginfo.DiagType = "2"
  7949. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7950. tempDiaginfo.MaindiagFlag = "0"
  7951. tempDiaginfo.ValiFlag = "1"
  7952. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  7953. }
  7954. }
  7955. struct4202.ODiagListD = tempDiaginfos
  7956. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  7957. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  7958. var res2 ResultSix
  7959. var respJSON2 map[string]interface{}
  7960. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7961. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7963. return
  7964. }
  7965. userJSONBytes2, _ := json.Marshal(respJSON2)
  7966. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7967. utils.ErrorLog("解析失败:%v", err)
  7968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7969. return
  7970. }
  7971. if res2.Infcode != 0 {
  7972. c.ServeSuccessJSON(map[string]interface{}{
  7973. "failed_code": -10,
  7974. "msg": res2.ErrMsg,
  7975. })
  7976. return
  7977. } else {
  7978. order.IsUploadDiagnose = 1
  7979. service.UpdateOrder(order)
  7980. c.ServeSuccessJSON(map[string]interface{}{
  7981. "msg": "上传成功",
  7982. })
  7983. }
  7984. }
  7985. func (c *HisApiController) Get4203() {
  7986. admin_user_id, _ := c.GetInt64("admin_user_id")
  7987. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7988. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7989. order_id, _ := c.GetInt64("order_id")
  7990. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  7991. number := ""
  7992. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7993. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7994. if his.ID == 0 {
  7995. number = hospital.Number
  7996. } else {
  7997. number = his.Number
  7998. }
  7999. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  8000. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  8001. var res2 ResultSix
  8002. var respJSON2 map[string]interface{}
  8003. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8006. return
  8007. }
  8008. userJSONBytes2, _ := json.Marshal(respJSON2)
  8009. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8010. utils.ErrorLog("解析失败:%v", err)
  8011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8012. return
  8013. }
  8014. if res2.Infcode != 0 {
  8015. c.ServeSuccessJSON(map[string]interface{}{
  8016. "failed_code": -10,
  8017. "msg": res2.ErrMsg,
  8018. })
  8019. return
  8020. } else {
  8021. order.IsUploadSuccess = 1
  8022. service.UpdateOrderTwo(order)
  8023. c.ServeSuccessJSON(map[string]interface{}{
  8024. "msg": "上传成功",
  8025. })
  8026. }
  8027. }
  8028. func (c *HisApiController) Get4205() {
  8029. order_id, _ := c.GetInt64("order_id")
  8030. admin_user_id, _ := c.GetInt64("admin_user_id")
  8031. fapiao_code := c.GetString("fapiao_code")
  8032. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8033. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8034. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8035. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8036. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  8037. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8038. //order_info = append(order_info, order_info_two...)
  8039. department, _ := service.GetDepartMentDetail(his.Departments)
  8040. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8041. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8042. if order.ID == 0 {
  8043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8044. return
  8045. }
  8046. var struct4201A models.Struct4201A
  8047. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8048. for _, items := range order_info {
  8049. memo := make(map[string]interface{})
  8050. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8051. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8052. fsiOPFLD.MedType = pre.MedType
  8053. fsiOPFLD.FixmedinsCode = miConfig.Code
  8054. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8055. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8056. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8057. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8058. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8059. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8060. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8061. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  8062. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8063. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8064. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8065. fsiOPFLD.BilgDeptName = department.Name
  8066. fsiOPFLD.BilgDeptCodg = department.Number
  8067. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8068. fsiOPFLD.BilgDrName = doctor.UserName
  8069. fsiOPFLD.MedChrgitmType = "09"
  8070. memo["hosp_appr_flag"] = "1"
  8071. memo["invoice_no"] = fapiao_code
  8072. memo["memo"] = "自费"
  8073. bytesData, _ := json.Marshal(memo)
  8074. fsiOPFLD.Memo = string(bytesData)
  8075. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8076. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8077. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8078. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8079. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8080. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8081. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8082. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8083. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8084. fsiOPFLD.BilgDeptName = department.Name
  8085. fsiOPFLD.BilgDeptCodg = department.Number
  8086. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8087. fsiOPFLD.BilgDrName = doctor.UserName
  8088. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8089. case 0:
  8090. break
  8091. case 1:
  8092. fsiOPFLD.MedChrgitmType = "14"
  8093. break
  8094. case 2:
  8095. fsiOPFLD.MedChrgitmType = "05"
  8096. break
  8097. case 3:
  8098. fsiOPFLD.MedChrgitmType = "03"
  8099. break
  8100. case 4:
  8101. fsiOPFLD.MedChrgitmType = "03"
  8102. break
  8103. case 5:
  8104. fsiOPFLD.MedChrgitmType = "08"
  8105. break
  8106. case 6:
  8107. fsiOPFLD.MedChrgitmType = "14"
  8108. break
  8109. case 7:
  8110. fsiOPFLD.MedChrgitmType = "14"
  8111. break
  8112. case 8:
  8113. fsiOPFLD.MedChrgitmType = "03"
  8114. break
  8115. case 9:
  8116. fsiOPFLD.MedChrgitmType = "14"
  8117. break
  8118. case 10:
  8119. fsiOPFLD.MedChrgitmType = "14"
  8120. break
  8121. case 11:
  8122. fsiOPFLD.MedChrgitmType = "06"
  8123. break
  8124. case 12:
  8125. fsiOPFLD.MedChrgitmType = "12"
  8126. break
  8127. case 13:
  8128. fsiOPFLD.MedChrgitmType = "01"
  8129. break
  8130. case 14:
  8131. fsiOPFLD.MedChrgitmType = "04"
  8132. break
  8133. case 15:
  8134. fsiOPFLD.MedChrgitmType = "14"
  8135. break
  8136. }
  8137. memo["hosp_appr_flag"] = "1"
  8138. memo["invoice_no"] = fapiao_code
  8139. memo["memo"] = "自费"
  8140. bytesData, _ := json.Marshal(memo)
  8141. fsiOPFLD.Memo = string(bytesData)
  8142. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8143. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8144. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8145. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8146. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8147. fsiOPFLD.BilgDeptName = department.Name
  8148. fsiOPFLD.BilgDeptCodg = department.Number
  8149. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8150. fsiOPFLD.BilgDrName = doctor.UserName
  8151. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8152. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8153. fsiOPFLD.MedChrgitmType = "08"
  8154. memo["hosp_appr_flag"] = "1"
  8155. memo["invoice_no"] = fapiao_code
  8156. memo["memo"] = "自费"
  8157. bytesData, _ := json.Marshal(memo)
  8158. fsiOPFLD.Memo = string(bytesData)
  8159. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8160. }
  8161. }
  8162. }
  8163. for _, items := range order_info_two {
  8164. memo := make(map[string]interface{})
  8165. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8166. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8167. fsiOPFLD.MedType = pre.MedType
  8168. fsiOPFLD.BkkpSn = items.FeedetlSn
  8169. fsiOPFLD.FixmedinsCode = miConfig.Code
  8170. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8171. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8172. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8173. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8174. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8175. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8176. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8177. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8178. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8179. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8180. fsiOPFLD.BilgDeptName = department.Name
  8181. fsiOPFLD.BilgDeptCodg = department.Number
  8182. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8183. fsiOPFLD.BilgDrName = doctor.UserName
  8184. fsiOPFLD.MedChrgitmType = "09"
  8185. memo["hosp_appr_flag"] = "1"
  8186. memo["invoice_no"] = fapiao_code
  8187. memo["memo"] = "自费"
  8188. bytesData, _ := json.Marshal(memo)
  8189. fsiOPFLD.Memo = string(bytesData)
  8190. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8191. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8192. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8193. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8194. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8195. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8196. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8197. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8198. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8199. fsiOPFLD.BilgDeptName = department.Name
  8200. fsiOPFLD.BilgDeptCodg = department.Number
  8201. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8202. fsiOPFLD.BilgDrName = doctor.UserName
  8203. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8204. case 0:
  8205. break
  8206. case 1:
  8207. fsiOPFLD.MedChrgitmType = "14"
  8208. break
  8209. case 2:
  8210. fsiOPFLD.MedChrgitmType = "05"
  8211. break
  8212. case 3:
  8213. fsiOPFLD.MedChrgitmType = "03"
  8214. break
  8215. case 4:
  8216. fsiOPFLD.MedChrgitmType = "03"
  8217. break
  8218. case 5:
  8219. fsiOPFLD.MedChrgitmType = "08"
  8220. break
  8221. case 6:
  8222. fsiOPFLD.MedChrgitmType = "14"
  8223. break
  8224. case 7:
  8225. fsiOPFLD.MedChrgitmType = "14"
  8226. break
  8227. case 8:
  8228. fsiOPFLD.MedChrgitmType = "03"
  8229. break
  8230. case 9:
  8231. fsiOPFLD.MedChrgitmType = "14"
  8232. break
  8233. case 10:
  8234. fsiOPFLD.MedChrgitmType = "14"
  8235. break
  8236. case 11:
  8237. fsiOPFLD.MedChrgitmType = "06"
  8238. break
  8239. case 12:
  8240. fsiOPFLD.MedChrgitmType = "12"
  8241. break
  8242. case 13:
  8243. fsiOPFLD.MedChrgitmType = "01"
  8244. break
  8245. case 14:
  8246. fsiOPFLD.MedChrgitmType = "04"
  8247. break
  8248. case 15:
  8249. fsiOPFLD.MedChrgitmType = "14"
  8250. break
  8251. }
  8252. memo["hosp_appr_flag"] = "1"
  8253. memo["invoice_no"] = fapiao_code
  8254. memo["memo"] = "自费"
  8255. bytesData, _ := json.Marshal(memo)
  8256. fsiOPFLD.Memo = string(bytesData)
  8257. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8258. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8259. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8260. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8261. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8262. fsiOPFLD.BilgDeptName = department.Name
  8263. fsiOPFLD.BilgDeptCodg = department.Number
  8264. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8265. fsiOPFLD.BilgDrName = doctor.UserName
  8266. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8267. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8268. fsiOPFLD.MedChrgitmType = "08"
  8269. memo["hosp_appr_flag"] = "1"
  8270. memo["invoice_no"] = fapiao_code
  8271. memo["memo"] = "自费"
  8272. bytesData, _ := json.Marshal(memo)
  8273. fsiOPFLD.Memo = string(bytesData)
  8274. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8275. }
  8276. }
  8277. }
  8278. fmt.Println(fsiOPFLDs)
  8279. struct4201A.Fopfd = fsiOPFLDs
  8280. fmt.Println(struct4201A.Fopfd)
  8281. var struct4202 models.Struct4202
  8282. timeLayout := "2006-01-02 15:04:05"
  8283. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  8284. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8285. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8286. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8287. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8288. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8289. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8290. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  8291. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  8292. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8293. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8294. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8295. var config []*models.HisXtDiagnoseConfig
  8296. for _, item := range diagnosis_ids {
  8297. id, _ := strconv.ParseInt(item, 10, 64)
  8298. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8299. config = append(config, &diagnosisConfig)
  8300. }
  8301. var tempDiaginfos []models.OwnPayPatnDiagListD
  8302. for index, item := range config {
  8303. if index == 0 {
  8304. var tempDiaginfo models.OwnPayPatnDiagListD
  8305. tempDiaginfo.InoutDiagType = "1"
  8306. tempDiaginfo.DiagCode = item.CountryCode
  8307. tempDiaginfo.DiagName = item.CountryContentName
  8308. tempDiaginfo.DiagType = "1"
  8309. tempDiaginfo.DiagSrtNo = "1"
  8310. tempDiaginfo.MaindiagFlag = "1"
  8311. tempDiaginfo.ValiFlag = "1"
  8312. tempDiaginfo.DiagDrName = doctor.UserName
  8313. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  8314. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  8315. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8316. } else {
  8317. var tempDiaginfo models.OwnPayPatnDiagListD
  8318. tempDiaginfo.DiagCode = item.CountryCode
  8319. tempDiaginfo.DiagName = item.CountryContentName
  8320. tempDiaginfo.DiagType = "2"
  8321. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8322. tempDiaginfo.MaindiagFlag = "0"
  8323. tempDiaginfo.ValiFlag = "1"
  8324. tempDiaginfo.DiagDrName = doctor.UserName
  8325. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  8326. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  8327. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8328. }
  8329. }
  8330. struct4202.ODiagListD = tempDiaginfos
  8331. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  8332. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  8333. var res2 ResultSix
  8334. var respJSON2 map[string]interface{}
  8335. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8336. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8338. return
  8339. }
  8340. userJSONBytes2, _ := json.Marshal(respJSON2)
  8341. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8342. utils.ErrorLog("解析失败:%v", err)
  8343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8344. return
  8345. }
  8346. if res2.Infcode != 0 {
  8347. c.ServeSuccessJSON(map[string]interface{}{
  8348. "failed_code": -10,
  8349. "msg": res2.ErrMsg,
  8350. })
  8351. return
  8352. } else {
  8353. order.IsUploadDiagnose = 1
  8354. order.IsUploadOrderInfo = 1
  8355. service.UpdateOrderTwo(order)
  8356. c.ServeSuccessJSON(map[string]interface{}{
  8357. "msg": "上传成功",
  8358. })
  8359. }
  8360. }
  8361. func (c *HisApiController) Get4207() {
  8362. admin_user_id, _ := c.GetInt64("admin_user_id")
  8363. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8364. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8365. order_id, _ := c.GetInt64("order_id")
  8366. order, _ := service.GetHisOrderByIDTwo(order_id)
  8367. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8368. var struct4207 models.Struct4207
  8369. struct4207.PageNum = "1"
  8370. struct4207.PageSize = "1000"
  8371. struct4207.FixmedinsCode = miConfig.Code
  8372. struct4207.FixmedinsMdtrtID = order.Number
  8373. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  8374. saveLog(result, requestLog, "4207", "查询")
  8375. var res2 ResultSix
  8376. var respJSON2 map[string]interface{}
  8377. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8378. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8380. return
  8381. }
  8382. userJSONBytes2, _ := json.Marshal(respJSON2)
  8383. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8384. utils.ErrorLog("解析失败:%v", err)
  8385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8386. return
  8387. }
  8388. if res2.Infcode != 0 {
  8389. c.ServeSuccessJSON(map[string]interface{}{
  8390. "failed_code": -10,
  8391. "msg": res2.ErrMsg,
  8392. })
  8393. return
  8394. } else {
  8395. c.ServeSuccessJSON(map[string]interface{}{
  8396. "msg": "查询成功",
  8397. })
  8398. }
  8399. }
  8400. func (c *HisApiController) Get4208() {
  8401. admin_user_id, _ := c.GetInt64("admin_user_id")
  8402. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8403. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8404. order_id, _ := c.GetInt64("order_id")
  8405. order, _ := service.GetHisOrderByIDTwo(order_id)
  8406. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8407. var struct4208 models.Struct4208
  8408. struct4208.PageNum = "1"
  8409. struct4208.PageSize = "1000"
  8410. struct4208.PsnCertType = "01"
  8411. struct4208.Certno = his.Certno
  8412. struct4208.MedType = order.MedType
  8413. struct4208.PsnName = his.Name
  8414. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  8415. saveLog(result, requestLog, "4208", "查询")
  8416. var res2 ResultSix
  8417. var respJSON2 map[string]interface{}
  8418. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8419. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8421. return
  8422. }
  8423. userJSONBytes2, _ := json.Marshal(respJSON2)
  8424. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8425. utils.ErrorLog("解析失败:%v", err)
  8426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8427. return
  8428. }
  8429. if res2.Infcode != 0 {
  8430. c.ServeSuccessJSON(map[string]interface{}{
  8431. "failed_code": -10,
  8432. "msg": res2.ErrMsg,
  8433. })
  8434. return
  8435. } else {
  8436. c.ServeSuccessJSON(map[string]interface{}{
  8437. "msg": "查询成功",
  8438. })
  8439. }
  8440. }
  8441. func (c *HisApiController) Get4209() {
  8442. admin_user_id, _ := c.GetInt64("admin_user_id")
  8443. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8444. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8445. order_id, _ := c.GetInt64("order_id")
  8446. order, _ := service.GetHisOrderByIDTwo(order_id)
  8447. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8448. var struct4209 models.Struct4209
  8449. struct4209.FixmedinsMdtrtID = order.Number
  8450. struct4209.FixmedinsCode = miConfig.Code
  8451. struct4209.PageSize = "1000"
  8452. struct4209.PageNum = "1"
  8453. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  8454. saveLog(result, requestLog, "4209", "查询")
  8455. var res2 ResultSix
  8456. var respJSON2 map[string]interface{}
  8457. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8460. return
  8461. }
  8462. userJSONBytes2, _ := json.Marshal(respJSON2)
  8463. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8464. utils.ErrorLog("解析失败:%v", err)
  8465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8466. return
  8467. }
  8468. if res2.Infcode != 0 {
  8469. c.ServeSuccessJSON(map[string]interface{}{
  8470. "failed_code": -10,
  8471. "msg": res2.ErrMsg,
  8472. })
  8473. return
  8474. } else {
  8475. c.ServeSuccessJSON(map[string]interface{}{
  8476. "msg": "查询成功",
  8477. })
  8478. }
  8479. }
  8480. type Result3101 struct {
  8481. Infcode string `json:"infcode"`
  8482. InfRefmsgid string `json:"inf_refmsgid"`
  8483. RefmsgTime string `json:"refmsg_time"`
  8484. RespondTime string `json:"respond_time"`
  8485. Enctype string `json:"enctype"`
  8486. Signtype string `json:"signtype"`
  8487. ErrMsg string `json:"err_msg"`
  8488. Output struct {
  8489. Result []struct {
  8490. JudgeResultDetailDtos []struct {
  8491. VolaItemType string `json:"vola_item_type"`
  8492. MdtrtID string `json:"mdtrt_id"`
  8493. JrdID string `json:"jrd_id"`
  8494. PatnID string `json:"patn_id"`
  8495. RxID string `json:"rx_id"`
  8496. VolaAmt interface{} `json:"vola_amt"`
  8497. } `json:"judge_result_detail_dtos"`
  8498. RuleID string `json:"rule_id"`
  8499. VolaEvid string `json:"vola_evid"`
  8500. MdtrtID string `json:"mdtrt_id"`
  8501. RuleName string `json:"rule_name"`
  8502. VolaAmtStas string `json:"vola_amt_stas"`
  8503. JrID string `json:"jr_id"`
  8504. PatnID string `json:"patn_id"`
  8505. SevDeg string `json:"sev_deg"`
  8506. VolaAmt float64 `json:"vola_amt"`
  8507. VolaBhvrType string `json:"vola_bhvr_type"`
  8508. VolaCont string `json:"vola_cont"`
  8509. } `json:"result"`
  8510. } `json:"output"`
  8511. }
  8512. type Resultgd3101 struct {
  8513. Infcode int64 `json:"infcode"`
  8514. InfRefmsgid string `json:"inf_refmsgid"`
  8515. RefmsgTime string `json:"refmsg_time"`
  8516. RespondTime string `json:"respond_time"`
  8517. Enctype string `json:"enctype"`
  8518. Signtype string `json:"signtype"`
  8519. ErrMsg string `json:"err_msg"`
  8520. Output struct {
  8521. Result []struct {
  8522. JudgeResultDetailDtos []struct {
  8523. VolaItemType string `json:"vola_item_type"`
  8524. MdtrtID string `json:"mdtrt_id"`
  8525. JrdID string `json:"jrd_id"`
  8526. PatnID string `json:"patn_id"`
  8527. RxID string `json:"rx_id"`
  8528. VolaAmt interface{} `json:"vola_amt"`
  8529. } `json:"judge_result_detail_dtos"`
  8530. RuleID string `json:"rule_id"`
  8531. VolaEvid string `json:"vola_evid"`
  8532. MdtrtID string `json:"mdtrt_id"`
  8533. RuleName string `json:"rule_name"`
  8534. VolaAmtStas string `json:"vola_amt_stas"`
  8535. JrID string `json:"jr_id"`
  8536. PatnID string `json:"patn_id"`
  8537. SevDeg string `json:"sev_deg"`
  8538. VolaAmt float64 `json:"vola_amt"`
  8539. VolaBhvrType string `json:"vola_bhvr_type"`
  8540. VolaCont string `json:"vola_cont"`
  8541. } `json:"result"`
  8542. } `json:"output"`
  8543. }
  8544. func (c *HisApiController) ReadEleToken() {
  8545. admin_user_id, _ := c.GetInt64("admin_user_id")
  8546. his_patient_id, _ := c.GetInt64("his_patient_id")
  8547. adminUser := c.GetAdminUserInfo()
  8548. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8549. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8550. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8551. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8552. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  8553. if len(tokens) > 0 {
  8554. c.ServeSuccessJSON(map[string]interface{}{
  8555. "msg": "读取成功",
  8556. })
  8557. } else {
  8558. c.ServeSuccessJSON(map[string]interface{}{
  8559. "failed_code": -10,
  8560. "msg": "读取失败",
  8561. })
  8562. }
  8563. } else if miConfig.MdtrtareaAdmvs == "341203" {
  8564. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  8565. if len(tokens) > 0 {
  8566. c.ServeSuccessJSON(map[string]interface{}{
  8567. "msg": "读取成功",
  8568. })
  8569. } else {
  8570. c.ServeSuccessJSON(map[string]interface{}{
  8571. "failed_code": -10,
  8572. "msg": "读取失败",
  8573. })
  8574. }
  8575. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8576. var api string
  8577. 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 +
  8578. "&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"
  8579. resp, requestErr := http.Get(api)
  8580. if requestErr != nil {
  8581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8582. }
  8583. body, ioErr := ioutil.ReadAll(resp.Body)
  8584. if ioErr != nil {
  8585. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8587. }
  8588. var respJSON map[string]interface{}
  8589. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8590. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8592. return
  8593. }
  8594. var status string
  8595. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8596. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8597. var token string
  8598. var res ResultTwo //1101结果
  8599. var res10265 ResultTwo10265 //1101结果
  8600. if status == "0" { //读卡成功
  8601. var card_info string //卡信息
  8602. var busi_card_info string
  8603. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8604. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8605. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8606. fmt.Println(card_info)
  8607. fmt.Println(busi_card_info)
  8608. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8609. result, _ := json.Marshal(respJSON)
  8610. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8611. utils.ErrorLog("解析失败:%v", err)
  8612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8613. return
  8614. }
  8615. res.ErrMsg = res10265.ErrMsg
  8616. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8617. res.Infcode = infocode
  8618. res.Output = res10265.Output
  8619. res.InfRefmsgid = res10265.InfRefmsgid
  8620. if res.Infcode == 0 {
  8621. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8622. if err == gorm.ErrRecordNotFound {
  8623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8624. return
  8625. } else if err != nil {
  8626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8627. return
  8628. } else {
  8629. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8630. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8631. infoStr := string(Iinfos)
  8632. idetinfoStr := string(Idetinfos)
  8633. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  8634. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  8635. psn := &models.HisPsn{
  8636. PsnNo: res.Output.Baseinfo.PsnNo,
  8637. PatientId: patient.ID,
  8638. Certno: res.Output.Baseinfo.Certno,
  8639. Gend: res.Output.Baseinfo.Gend,
  8640. Naty: res.Output.Baseinfo.Naty,
  8641. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8642. PsnName: res.Output.Baseinfo.PsnName,
  8643. Age: float64(age),
  8644. Brdy: b,
  8645. Idetinfo: idetinfoStr,
  8646. Insuinfo: infoStr,
  8647. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8648. CardInfo: card_info,
  8649. VerifyNumber: token,
  8650. IdCardType: 4,
  8651. }
  8652. var rf []*ResultFive
  8653. json.Unmarshal([]byte(infoStr), &rf)
  8654. var insutypes []*ResultFive
  8655. var insutype string
  8656. var is390 int = 0
  8657. var is310 int = 0
  8658. for _, item := range rf {
  8659. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8660. insutypes = append(insutypes, item)
  8661. }
  8662. }
  8663. if len(insutypes) == 1 {
  8664. insutype = insutypes[0].Insutype
  8665. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8666. } else {
  8667. for _, i := range insutypes {
  8668. if i.Insutype == "390" {
  8669. is390 = 1
  8670. }
  8671. if i.Insutype == "310" {
  8672. is310 = 1
  8673. }
  8674. }
  8675. }
  8676. if is390 == 1 {
  8677. insutype = "390"
  8678. }
  8679. if is310 == 1 {
  8680. insutype = "310"
  8681. }
  8682. if len(insutypes) == 0 {
  8683. insutype = "310"
  8684. }
  8685. service.CreateHisPsn(psn)
  8686. c.ServeSuccessJSON(map[string]interface{}{
  8687. "patient": patient,
  8688. "number": token,
  8689. "insutype": insutype,
  8690. })
  8691. }
  8692. } else {
  8693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8694. return
  8695. }
  8696. } else { //读卡失败
  8697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8698. return
  8699. }
  8700. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8701. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  8702. if len(errMsg) == 0 {
  8703. type ELeData struct {
  8704. Data struct {
  8705. IdNo string `json:"idNo"`
  8706. IdType string `json:"idType"`
  8707. UserName string `json:"userName"`
  8708. EcToken string `json:"ecToken"`
  8709. InsuOrg string `json:"insuOrg"`
  8710. Gender string `json:"gender"`
  8711. Birthday string `json:"birthday"`
  8712. Nationality string `json:"nationality"`
  8713. Email string `json:"email"`
  8714. Extra string `json:"extra"`
  8715. } `json:"data"`
  8716. Code int `json:"code"`
  8717. Message string `json:"message"`
  8718. }
  8719. var ele ELeData
  8720. err := json.Unmarshal([]byte(outPutInfo), &ele)
  8721. if err != nil {
  8722. utils.ErrorLog("解析失败:%v", err)
  8723. }
  8724. token := ele.Data.EcToken
  8725. if len(token) > 0 {
  8726. psn := &models.HisPsn{
  8727. PsnNo: his.PsnNo,
  8728. Age: 0,
  8729. PatientId: his.PatientId,
  8730. Certno: his.Certno,
  8731. Brdy: his.Brdy,
  8732. Gend: his.Gend,
  8733. Naty: his.Naty,
  8734. PsnCertType: his.PsnCertType,
  8735. PsnName: his.PsnName,
  8736. Idetinfo: his.Idetinfo,
  8737. Insuinfo: his.Iinfo,
  8738. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8739. CardInfo: outPutInfo,
  8740. VerifyNumber: token,
  8741. }
  8742. service.CreateHisPsn(psn)
  8743. }
  8744. if len(token) > 0 {
  8745. c.ServeSuccessJSON(map[string]interface{}{
  8746. "msg": "读取成功",
  8747. })
  8748. } else {
  8749. c.ServeSuccessJSON(map[string]interface{}{
  8750. "failed_code": -10,
  8751. "msg": "读取失败",
  8752. })
  8753. }
  8754. }
  8755. } else if miConfig.MdtrtareaAdmvs == "360302" {
  8756. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  8757. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  8758. type ELeData struct {
  8759. Data struct {
  8760. IdNo string `json:"idNo"`
  8761. IdType string `json:"idType"`
  8762. UserName string `json:"userName"`
  8763. EcToken string `json:"ecToken"`
  8764. InsuOrg string `json:"insuOrg"`
  8765. Gender string `json:"gender"`
  8766. Birthday string `json:"birthday"`
  8767. Nationality string `json:"nationality"`
  8768. Email string `json:"email"`
  8769. Extra string `json:"extra"`
  8770. } `json:"data"`
  8771. Code int `json:"code"`
  8772. Message string `json:"message"`
  8773. }
  8774. var ele ELeData
  8775. err := json.Unmarshal([]byte(result), &ele)
  8776. if err != nil {
  8777. utils.ErrorLog("解析失败:%v", err)
  8778. }
  8779. token := ele.Data.EcToken
  8780. token = Remove0000(token)
  8781. fmt.Println(ele.Data.UserName)
  8782. 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)
  8783. saveLog(result2, requestLog2, "1101", "获取人员信息")
  8784. var res ResultTwo
  8785. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8786. utils.ErrorLog("解析失败:%v", err)
  8787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8788. return
  8789. }
  8790. if res.Infcode == 0 {
  8791. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8792. if err == gorm.ErrRecordNotFound {
  8793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8794. return
  8795. } else if err != nil {
  8796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8797. return
  8798. } else {
  8799. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8800. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8801. infoStr := string(Iinfos)
  8802. idetinfoStr := string(Idetinfos)
  8803. psn := &models.HisPsn{
  8804. PsnNo: res.Output.Baseinfo.PsnNo,
  8805. PatientId: patient.ID,
  8806. Certno: res.Output.Baseinfo.Certno,
  8807. Gend: res.Output.Baseinfo.Gend,
  8808. Naty: res.Output.Baseinfo.Naty,
  8809. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8810. PsnName: res.Output.Baseinfo.PsnName,
  8811. Idetinfo: idetinfoStr,
  8812. Insuinfo: infoStr,
  8813. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8814. CardInfo: "",
  8815. VerifyNumber: token,
  8816. }
  8817. service.CreateHisPsn(psn)
  8818. c.ServeSuccessJSON(map[string]interface{}{
  8819. "patient": patient,
  8820. "number": token,
  8821. })
  8822. }
  8823. } else {
  8824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8825. return
  8826. }
  8827. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8828. //if initFlag == 0 {
  8829. //c.TestGetJiangXiBasBaseInit()
  8830. //}
  8831. //if initEleFlag == 0 {
  8832. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  8833. //}
  8834. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  8835. utils.ErrorLog("解析失败:%v", json_result)
  8836. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  8837. type ELeData struct {
  8838. Data struct {
  8839. IdNo string `json:"idNo"`
  8840. IdType string `json:"idType"`
  8841. UserName string `json:"userName"`
  8842. EcToken string `json:"ecToken"`
  8843. InsuOrg string `json:"insuOrg"`
  8844. Gender string `json:"gender"`
  8845. Birthday string `json:"birthday"`
  8846. Nationality string `json:"nationality"`
  8847. Email string `json:"email"`
  8848. Extra string `json:"extra"`
  8849. } `json:"data"`
  8850. Code int `json:"code"`
  8851. Message string `json:"message"`
  8852. }
  8853. var ele ELeData
  8854. err := json.Unmarshal([]byte(json_result), &ele)
  8855. if err != nil {
  8856. utils.ErrorLog("解析失败:%v", err)
  8857. }
  8858. token := ele.Data.EcToken
  8859. token = Remove0000(token)
  8860. //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)
  8861. 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)
  8862. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  8863. saveLog(result2, requestLog2, "1101", "获取人员信息")
  8864. var res ResultTwo
  8865. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8866. utils.ErrorLog("解析失败:%v", err)
  8867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8868. return
  8869. }
  8870. if res.Infcode == 0 {
  8871. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8872. if err == gorm.ErrRecordNotFound {
  8873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8874. return
  8875. } else if err != nil {
  8876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8877. return
  8878. } else {
  8879. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8880. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8881. infoStr := string(Iinfos)
  8882. idetinfoStr := string(Idetinfos)
  8883. psn := &models.HisPsn{
  8884. PsnNo: res.Output.Baseinfo.PsnNo,
  8885. PatientId: patient.ID,
  8886. Certno: res.Output.Baseinfo.Certno,
  8887. Gend: res.Output.Baseinfo.Gend,
  8888. Naty: res.Output.Baseinfo.Naty,
  8889. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8890. PsnName: res.Output.Baseinfo.PsnName,
  8891. Idetinfo: idetinfoStr,
  8892. Insuinfo: infoStr,
  8893. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8894. CardInfo: "",
  8895. VerifyNumber: token,
  8896. InsuplcAdmdvs: ele.Data.InsuOrg,
  8897. }
  8898. service.CreateHisPsn(psn)
  8899. c.ServeSuccessJSON(map[string]interface{}{
  8900. "patient": patient,
  8901. "number": token,
  8902. })
  8903. }
  8904. } else {
  8905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8906. return
  8907. }
  8908. } else if miConfig.MdtrtareaAdmvs == "450721" {
  8909. res := c.GetoleInfo()
  8910. if res.Infcode == 0 {
  8911. var result string
  8912. if res.Output.MdtrtCertType == "01" {
  8913. 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)
  8914. } else if res.Output.MdtrtCertType == "02" {
  8915. 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)
  8916. } else if res.Output.MdtrtCertType == "03" {
  8917. 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)
  8918. }
  8919. var dat map[string]interface{}
  8920. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8921. fmt.Println(dat)
  8922. } else {
  8923. fmt.Println(err)
  8924. }
  8925. userJSONBytes, _ := json.Marshal(dat)
  8926. var res2 ResultTwo
  8927. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8928. utils.ErrorLog("解析失败:%v", err)
  8929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8930. return
  8931. }
  8932. if res2.Infcode == 0 {
  8933. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  8934. if err == gorm.ErrRecordNotFound {
  8935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8936. return
  8937. } else if err != nil {
  8938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8939. return
  8940. } else {
  8941. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  8942. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  8943. infoStr := string(Iinfos)
  8944. idetinfoStr := string(Idetinfos)
  8945. var rf []*ResultFive
  8946. json.Unmarshal([]byte(infoStr), &rf)
  8947. var insutypes []*ResultFive
  8948. var insutype string
  8949. var is390 int = 0
  8950. var is310 int = 0
  8951. //var insuplc_admdvs string
  8952. for _, item := range rf {
  8953. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8954. insutypes = append(insutypes, item)
  8955. }
  8956. }
  8957. if len(insutypes) == 1 {
  8958. insutype = insutypes[0].Insutype
  8959. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8960. } else {
  8961. for _, i := range insutypes {
  8962. if i.Insutype == "390" {
  8963. is390 = 1
  8964. }
  8965. if i.Insutype == "310" {
  8966. is310 = 1
  8967. }
  8968. }
  8969. }
  8970. if is390 == 1 {
  8971. insutype = "390"
  8972. }
  8973. if is310 == 1 {
  8974. insutype = "310"
  8975. }
  8976. if len(insutypes) == 0 {
  8977. insutype = "310"
  8978. }
  8979. psn := &models.HisPsn{
  8980. PsnNo: res2.Output.Baseinfo.PsnNo,
  8981. PatientId: patient.ID,
  8982. Certno: res2.Output.Baseinfo.Certno,
  8983. Gend: res2.Output.Baseinfo.Gend,
  8984. Naty: res2.Output.Baseinfo.Naty,
  8985. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  8986. PsnName: res2.Output.Baseinfo.PsnName,
  8987. Idetinfo: idetinfoStr,
  8988. Insuinfo: infoStr,
  8989. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8990. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  8991. VerifyNumber: res.Output.EcToken,
  8992. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  8993. }
  8994. service.CreateHisPsn(psn)
  8995. c.ServeSuccessJSON(map[string]interface{}{
  8996. "patient": patient,
  8997. "number": res.Output.CardNo,
  8998. "insutype": insutype,
  8999. })
  9000. }
  9001. } else {
  9002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9003. return
  9004. }
  9005. } else {
  9006. c.ServeSuccessJSON(map[string]interface{}{
  9007. "failed_code": -10,
  9008. "msg": res.ErrMsg,
  9009. })
  9010. }
  9011. } else {
  9012. //if initFlag == 0 {
  9013. // c.TestGetBasBaseInit()
  9014. //}
  9015. //token := c.GetEleBaseInfo()
  9016. //token = Remove0000(token)
  9017. type ELeData struct {
  9018. Code string `json:"code"`
  9019. Data struct {
  9020. Aac002 string `json:"aac002"`
  9021. Aaz500 string `json:"aaz500"`
  9022. ActCardNo string `json:"actCardNo"`
  9023. Bab520 string `json:"bab520"`
  9024. Bkz543 string `json:"bkz543"`
  9025. BusinessType string `json:"businessType"`
  9026. CertfCodg string `json:"certfCodg"`
  9027. EcIndexNo string `json:"ecIndexNo"`
  9028. EcToken string `json:"ecToken"`
  9029. ID0000 string `json:"id0000"`
  9030. IDNo string `json:"idNo"`
  9031. IDType string `json:"idType"`
  9032. Idcode string `json:"idcode"`
  9033. IdentityToken string `json:"identity_token"`
  9034. InsuOrg string `json:"insuOrg"`
  9035. OfficeID string `json:"officeId"`
  9036. OfficeName string `json:"officeName"`
  9037. OperatorID string `json:"operatorId"`
  9038. OperatorName string `json:"operatorName"`
  9039. OrgID string `json:"orgId"`
  9040. UserName string `json:"userName"`
  9041. } `json:"data"`
  9042. Infno interface{} `json:"infno"`
  9043. Message string `json:"message"`
  9044. OrgID string `json:"orgId"`
  9045. TransType string `json:"transType"`
  9046. }
  9047. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9048. fmt.Println(result)
  9049. outPutInfo := Remove0000(result)
  9050. fmt.Println(outPutInfo)
  9051. var ele ELeData
  9052. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9053. if err != nil {
  9054. utils.ErrorLog("解析失败:%v", err)
  9055. }
  9056. token := ele.Data.EcToken
  9057. var result2 string
  9058. var requestLog2 string
  9059. if len(token) > 0 {
  9060. if strings.Contains(ele.Data.IDNo, "HKG") {
  9061. 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)
  9062. } else {
  9063. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  9064. }
  9065. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9066. var res ResultTwo
  9067. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9068. utils.ErrorLog("解析失败:%v", err)
  9069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9070. return
  9071. }
  9072. if res.Infcode == 0 {
  9073. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9074. if err == gorm.ErrRecordNotFound {
  9075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9076. return
  9077. } else if err != nil {
  9078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9079. return
  9080. } else {
  9081. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9082. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9083. infoStr := string(Iinfos)
  9084. idetinfoStr := string(Idetinfos)
  9085. psn := &models.HisPsn{
  9086. PsnNo: res.Output.Baseinfo.PsnNo,
  9087. PatientId: patient.ID,
  9088. Certno: res.Output.Baseinfo.Certno,
  9089. Gend: res.Output.Baseinfo.Gend,
  9090. Naty: res.Output.Baseinfo.Naty,
  9091. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9092. PsnName: res.Output.Baseinfo.PsnName,
  9093. Idetinfo: idetinfoStr,
  9094. Insuinfo: infoStr,
  9095. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9096. CardInfo: "",
  9097. VerifyNumber: token,
  9098. }
  9099. service.CreateHisPsn(psn)
  9100. c.ServeSuccessJSON(map[string]interface{}{
  9101. "msg": "读取成功",
  9102. })
  9103. }
  9104. } else {
  9105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9106. return
  9107. }
  9108. } else {
  9109. c.ServeSuccessJSON(map[string]interface{}{
  9110. "failed_code": -10,
  9111. "msg": "读取失败",
  9112. })
  9113. }
  9114. }
  9115. }
  9116. func (c *HisApiController) ReadEleFace() {
  9117. admin_user_id, _ := c.GetInt64("admin_user_id")
  9118. //his_patient_id, _ := c.GetInt64("his_patient_id")
  9119. adminUser := c.GetAdminUserInfo()
  9120. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9121. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9122. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9123. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9124. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9125. if len(tokens) > 0 {
  9126. c.ServeSuccessJSON(map[string]interface{}{
  9127. "msg": "读取成功",
  9128. })
  9129. } else {
  9130. c.ServeSuccessJSON(map[string]interface{}{
  9131. "failed_code": -10,
  9132. "msg": "读取失败",
  9133. })
  9134. }
  9135. }
  9136. }
  9137. func (c *HisApiController) Get9001() {
  9138. adminUser := c.GetAdminUserInfo()
  9139. admin_user_id, _ := c.GetInt64("admin_user_id")
  9140. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9141. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9142. if miConfig.MdtrtareaAdmvs == "350500" {
  9143. service.GetFjAuthorizationInfo(miConfig.Code)
  9144. } else if miConfig.MdtrtareaAdmvs == "131023" {
  9145. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9146. var dat map[string]interface{}
  9147. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9148. fmt.Println(dat)
  9149. } else {
  9150. fmt.Println(err)
  9151. }
  9152. userJSONBytes, _ := json.Marshal(dat)
  9153. var res models.Result9001
  9154. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9155. utils.ErrorLog("解析失败:%v", err)
  9156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9157. return
  9158. }
  9159. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9160. fmt.Println(miConfig.SecretKey)
  9161. var res models.Result9001Two
  9162. 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 +
  9163. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  9164. resp, requestErr := http.Get(api)
  9165. if requestErr != nil {
  9166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9167. return
  9168. }
  9169. body, ioErr := ioutil.ReadAll(resp.Body)
  9170. if ioErr != nil {
  9171. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9173. return
  9174. }
  9175. var respJSON map[string]interface{}
  9176. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9177. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9179. return
  9180. }
  9181. status := respJSON["data"].(map[string]interface{})["status"].(string)
  9182. if status == "0" {
  9183. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  9184. c.ServeSuccessJSON(map[string]interface{}{
  9185. "failed_code": -10,
  9186. "msg": err_msg,
  9187. })
  9188. return
  9189. }
  9190. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9191. result, _ := json.Marshal(respJSON)
  9192. fmt.Println("log")
  9193. fmt.Println(string(result))
  9194. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9195. utils.ErrorLog("解析失败:%v", err)
  9196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9197. return
  9198. }
  9199. if res.Infcode == 0 {
  9200. sign := models.HisSignIn{
  9201. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9202. SignNo: res.Output.Signinoutb.SignNo,
  9203. SignTime: "",
  9204. Ctime: time.Now().Unix(),
  9205. Mtime: time.Now().Unix(),
  9206. Status: 1,
  9207. InputLog: "",
  9208. OutputLog: "",
  9209. FixmedinsCode: miConfig.Code,
  9210. }
  9211. err := service.CreateSignIn(&sign)
  9212. if err == nil {
  9213. c.ServeSuccessJSON(map[string]interface{}{
  9214. "msg": "签到成功",
  9215. })
  9216. }
  9217. } else {
  9218. c.ServeSuccessJSON(map[string]interface{}{
  9219. "failed_code": -10,
  9220. "msg": res.ErrMsg,
  9221. })
  9222. return
  9223. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9224. //return
  9225. }
  9226. } else {
  9227. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  9228. var dat map[string]interface{}
  9229. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9230. fmt.Println(dat)
  9231. } else {
  9232. fmt.Println(err)
  9233. }
  9234. userJSONBytes, _ := json.Marshal(dat)
  9235. var res models.Result9001
  9236. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9237. utils.ErrorLog("解析失败:%v", err)
  9238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9239. return
  9240. }
  9241. if res.Infcode == 0 {
  9242. sign := models.HisSignIn{
  9243. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9244. SignNo: res.Output.Signinoutb.SignNo,
  9245. SignTime: res.Output.Signinoutb.SignTime,
  9246. Ctime: time.Now().Unix(),
  9247. Mtime: time.Now().Unix(),
  9248. Status: 1,
  9249. InputLog: "",
  9250. OutputLog: "",
  9251. FixmedinsCode: miConfig.Code,
  9252. }
  9253. err := service.CreateSignIn(&sign)
  9254. if err == nil {
  9255. c.ServeSuccessJSON(map[string]interface{}{
  9256. "msg": "签到成功",
  9257. })
  9258. }
  9259. }
  9260. }
  9261. }
  9262. 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) {
  9263. var res Result3101
  9264. adminUser := c.GetAdminUserInfo()
  9265. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9266. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9267. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9268. //record_time := c.GetString("record_time")
  9269. //trig_scen := c.GetString("trig_scen")
  9270. timeLayout := "2006-01-02"
  9271. loc, _ := time.LoadLocation("Local")
  9272. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9273. if err != nil {
  9274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9275. return res
  9276. }
  9277. recordDateTime := theTime.Unix()
  9278. var patientPrescription models.HisPrescriptionInfo
  9279. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9280. //if patientPrescription.ID == 0 {
  9281. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  9282. //}
  9283. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9284. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9285. //
  9286. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  9287. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9288. var pp models.PublicParams
  9289. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9290. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9291. pp.FixmedinsName = miConfig.OrgName
  9292. pp.FixmedinsCode = miConfig.Code
  9293. pp.RequestUrl = miConfig.Url
  9294. pp.Cainfo = miConfig.Cainfo
  9295. pp.SecretKey = miConfig.SecretKey
  9296. pp.AccessKey = miConfig.AccessKey
  9297. pp.OpterName = roles.UserName
  9298. var config []*models.HisXtDiagnoseConfig
  9299. for _, item := range diagnosis_ids {
  9300. id, _ := strconv.ParseInt(item, 10, 64)
  9301. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9302. config = append(config, &diagnosisConfig)
  9303. }
  9304. var pd models.PatientDtos
  9305. pd.PatnID = his.PsnNo
  9306. pd.PatnName = his.Name
  9307. pd.Gend = his.Gend
  9308. pd.Brdy = his.Brdy
  9309. pd.Poolarea = miConfig.MdtrtareaAdmvs
  9310. pd.CurrMdtrtID = his.Number
  9311. var fed models.FsiEncounterDtos
  9312. fed.MdtrtID = his.Number
  9313. fed.MedinsID = miConfig.Code
  9314. fed.MedinsName = miConfig.OrgName
  9315. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  9316. fed.MedMdtrtType = "1"
  9317. fed.MedinsType = "1"
  9318. fed.MedinsLv = "11"
  9319. tm := time.Unix(his.RecordDate, 0)
  9320. s_tm := tm.Format("2006-01-02 15:04:05")
  9321. fed.AdmDate = s_tm
  9322. fed.DscgDate = s_tm
  9323. fed.DscgMainDiseCodg = config[0].CountryCode
  9324. fed.DscgMainDiseName = config[0].CountryContentName
  9325. //诊断信息
  9326. var fdds []*models.FsiDiagnoseDtos
  9327. for index, item := range config {
  9328. if index == 0 {
  9329. var fdd models.FsiDiagnoseDtos
  9330. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9331. fdd.InoutDiseType = "1"
  9332. fdd.MaindiseFlag = "1"
  9333. fdd.DiseDate = s_tm
  9334. fdd.DiasSrtNo = "1"
  9335. fdd.DiseName = item.CountryContentName
  9336. fdd.DiseCodg = item.CountryCode
  9337. fdds = append(fdds, &fdd)
  9338. } else {
  9339. var fdd models.FsiDiagnoseDtos
  9340. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9341. fdd.InoutDiseType = "1"
  9342. fdd.MaindiseFlag = "1"
  9343. fdd.DiseDate = s_tm
  9344. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  9345. fdd.DiseName = item.CountryContentName
  9346. fdd.DiseCodg = item.CountryCode
  9347. fdds = append(fdds, &fdd)
  9348. }
  9349. }
  9350. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  9351. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  9352. fed.AdmDeptName = de.Name
  9353. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  9354. fed.DscgDeptName = de.Name
  9355. fed.MedMdtrtType = "1"
  9356. fed.MedType = "11"
  9357. //if his.Insutype == "390" {
  9358. // fed.MedType = "1402"
  9359. //} else {
  9360. // fed.MedType = "9933"
  9361. //}
  9362. var orders []*models.FsiOrderDtos
  9363. if trig_scen == "2" {
  9364. //处方医嘱信息
  9365. for _, item := range prescriptions {
  9366. for _, subItem := range item.HisDoctorAdviceInfo {
  9367. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9368. var order models.FsiOrderDtos
  9369. order.RxID = strconv.FormatInt(item.ID, 10)
  9370. order.Rxno = strconv.FormatInt(item.ID, 10)
  9371. order.LongDrordFlag = "0"
  9372. order.HilistType = "1"
  9373. order.ChrgType = "1"
  9374. order.DrordBhvr = "-"
  9375. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9376. order.HosplistName = subItem.BaseDrugLib.DrugName
  9377. order.HilistLv = "1"
  9378. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9379. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9380. order.HosplistName = subItem.BaseDrugLib.DrugName
  9381. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  9382. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9383. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  9384. order.OwnpayAmt = ""
  9385. order.SelfpayAmt = ""
  9386. order.Spec = ""
  9387. order.SpecUnt = ""
  9388. order.DrordBegnDate = s_tm
  9389. order.DrordStopDate = ""
  9390. order.DrordDrCodg = doctor_info.DoctorNumber
  9391. order.DrordDeptName = department.Name
  9392. order.DrordDeptCodg = department.Number
  9393. order.DrordDrName = doctor_info.UserName
  9394. order.DrordDrProfttl = "234"
  9395. order.CurrDrordFlag = "1"
  9396. orders = append(orders, &order)
  9397. }
  9398. }
  9399. for _, subItem := range item.HisPrescriptionProject {
  9400. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  9401. var order models.FsiOrderDtos
  9402. order.RxID = strconv.FormatInt(item.ID, 10)
  9403. order.Rxno = strconv.FormatInt(item.ID, 10)
  9404. order.LongDrordFlag = "0"
  9405. order.HilistType = "1"
  9406. order.ChrgType = "1"
  9407. order.DrordBhvr = "-"
  9408. order.HilistCode = subItem.HisProject.MedicalCode
  9409. order.HosplistName = subItem.HisProject.ProjectName
  9410. order.HilistLv = "1"
  9411. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9412. order.HosplistCode = subItem.HisProject.MedicalCode
  9413. order.HosplistName = subItem.HisProject.ProjectName
  9414. order.Cnt = subItem.Count
  9415. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9416. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9417. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9418. order.OwnpayAmt = ""
  9419. order.SelfpayAmt = ""
  9420. order.Spec = ""
  9421. order.SpecUnt = ""
  9422. order.DrordBegnDate = s_tm
  9423. order.DrordStopDate = ""
  9424. order.DrordDrCodg = doctor_info.DoctorNumber
  9425. order.DrordDeptName = department.Name
  9426. order.DrordDeptCodg = department.Number
  9427. order.DrordDrName = doctor_info.UserName
  9428. order.DrordDrProfttl = "234"
  9429. order.CurrDrordFlag = "1"
  9430. orders = append(orders, &order)
  9431. }
  9432. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  9433. var order models.FsiOrderDtos
  9434. order.RxID = strconv.FormatInt(item.ID, 10)
  9435. order.Rxno = strconv.FormatInt(item.ID, 10)
  9436. order.LongDrordFlag = "0"
  9437. order.HilistType = "1"
  9438. order.ChrgType = "1"
  9439. order.DrordBhvr = "-"
  9440. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9441. order.HosplistName = subItem.GoodInfo.GoodName
  9442. order.HilistLv = "1"
  9443. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9444. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9445. order.HosplistName = subItem.GoodInfo.GoodName
  9446. order.Cnt = subItem.Count
  9447. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9448. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9449. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9450. order.OwnpayAmt = ""
  9451. order.SelfpayAmt = ""
  9452. order.Spec = ""
  9453. order.SpecUnt = ""
  9454. order.DrordBegnDate = s_tm
  9455. order.DrordStopDate = ""
  9456. order.DrordDrCodg = doctor_info.DoctorNumber
  9457. order.DrordDeptName = department.Name
  9458. order.DrordDeptCodg = department.Number
  9459. order.DrordDrName = doctor_info.UserName
  9460. order.DrordDrProfttl = "234"
  9461. order.CurrDrordFlag = "1"
  9462. orders = append(orders, &order)
  9463. }
  9464. }
  9465. }
  9466. //处方医嘱信息
  9467. }
  9468. fed.MatnStas = "0"
  9469. fed.MedfeeSumamt = "0"
  9470. fed.OwnpayAmt = "0"
  9471. fed.SelfpayAmt = "0"
  9472. fed.AcctPayamt = "0"
  9473. fed.MaAmt = "0"
  9474. fed.HifpPayamt = "0"
  9475. fed.SetlTotlnum = "1"
  9476. fed.Insutype = his.Insutype
  9477. fed.ReimFlag = "0"
  9478. fed.OutSetlFlag = "0"
  9479. var fopd []*models.FsiOperationDtosData
  9480. data := make(map[string]interface{})
  9481. data["fed"] = fed
  9482. data["fdd"] = fdds
  9483. data["fod"] = orders
  9484. data["pd"] = pd
  9485. data["pp"] = pp
  9486. data["fopd"] = fopd
  9487. data["trig_scen"] = trig_scen
  9488. fmt.Println(data)
  9489. fmt.Println(fed)
  9490. fmt.Println(fdds)
  9491. fmt.Println(orders)
  9492. fmt.Println(pd)
  9493. fmt.Println(pp)
  9494. fmt.Println(fopd)
  9495. client := &http.Client{}
  9496. bytesData, _ := json.Marshal(data)
  9497. var req *http.Request
  9498. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9499. if miConfig.MdtrtareaAdmvs == "320921" {
  9500. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  9501. } else {
  9502. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  9503. }
  9504. resp, _ := client.Do(req)
  9505. defer resp.Body.Close()
  9506. body, ioErr := ioutil.ReadAll(resp.Body)
  9507. if ioErr != nil {
  9508. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9510. return res
  9511. }
  9512. var respJSON map[string]interface{}
  9513. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9514. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9516. return res
  9517. }
  9518. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  9519. fmt.Println(respJSON)
  9520. result, _ := json.Marshal(respJSON)
  9521. fmt.Println(result)
  9522. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9523. utils.ErrorLog("解析失败:%v", err)
  9524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9525. return res
  9526. }
  9527. return res
  9528. } else {
  9529. //if miConfig.MdtrtareaAdmvs == "441202" {
  9530. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  9531. saveLog(output, input, "3101", "事前")
  9532. if err := json.Unmarshal([]byte(output), &res); err != nil {
  9533. utils.ErrorLog("解析失败:%v", err)
  9534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9535. return
  9536. }
  9537. return res
  9538. //}
  9539. }
  9540. }
  9541. 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) {
  9542. adminUser := c.GetAdminUserInfo()
  9543. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9544. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9545. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9546. //record_time := c.GetString("record_time")
  9547. //trig_scen := c.GetString("trig_scen")
  9548. timeLayout := "2006-01-02"
  9549. loc, _ := time.LoadLocation("Local")
  9550. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9551. if err != nil {
  9552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9553. return res
  9554. }
  9555. recordDateTime := theTime.Unix()
  9556. var patientPrescription models.HisPrescriptionInfo
  9557. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9558. if patientPrescription.ID == 0 {
  9559. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  9560. }
  9561. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9562. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9563. //
  9564. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  9565. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9566. var pp models.PublicParams
  9567. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9568. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9569. pp.FixmedinsName = miConfig.OrgName
  9570. pp.FixmedinsCode = miConfig.Code
  9571. pp.RequestUrl = miConfig.Url
  9572. pp.Cainfo = miConfig.Cainfo
  9573. pp.SecretKey = miConfig.SecretKey
  9574. pp.AccessKey = miConfig.AccessKey
  9575. pp.OpterName = roles.UserName
  9576. var config []*models.HisXtDiagnoseConfig
  9577. for _, item := range diagnosis_ids {
  9578. id, _ := strconv.ParseInt(item, 10, 64)
  9579. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9580. config = append(config, &diagnosisConfig)
  9581. }
  9582. var pd models.PatientDtos
  9583. pd.PatnID = his.PsnNo
  9584. pd.PatnName = his.Name
  9585. pd.Gend = his.Gend
  9586. pd.Brdy = his.Brdy
  9587. pd.Poolarea = his.InsuplcAdmdvs
  9588. pd.CurrMdtrtID = his.Number
  9589. var fed models.FsiEncounterDtos
  9590. fed.MdtrtID = his.Number
  9591. fed.MedinsID = miConfig.Code
  9592. fed.MedinsName = miConfig.OrgName
  9593. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  9594. fed.MedMdtrtType = "1"
  9595. fed.MedinsType = "1"
  9596. fed.MedinsLv = "11"
  9597. tm := time.Unix(his.RecordDate, 0)
  9598. s_tm := tm.Format("2006-01-02 15:04:05")
  9599. fed.AdmDate = s_tm
  9600. fed.DscgDate = s_tm
  9601. fed.DscgMainDiseCodg = config[0].CountryCode
  9602. fed.DscgMainDiseName = config[0].CountryContentName
  9603. //诊断信息
  9604. var fdds []*models.FsiDiagnoseDtos
  9605. for index, item := range config {
  9606. if index == 0 {
  9607. var fdd models.FsiDiagnoseDtos
  9608. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9609. fdd.InoutDiseType = "1"
  9610. fdd.MaindiseFlag = "1"
  9611. fdd.DiseDate = s_tm
  9612. fdd.DiasSrtNo = "1"
  9613. fdd.DiseName = item.CountryContentName
  9614. fdd.DiseCodg = item.CountryCode
  9615. fdds = append(fdds, &fdd)
  9616. } else {
  9617. var fdd models.FsiDiagnoseDtos
  9618. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9619. fdd.InoutDiseType = "1"
  9620. fdd.MaindiseFlag = "1"
  9621. fdd.DiseDate = s_tm
  9622. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  9623. fdd.DiseName = item.CountryContentName
  9624. fdd.DiseCodg = item.CountryCode
  9625. fdds = append(fdds, &fdd)
  9626. }
  9627. }
  9628. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  9629. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  9630. fed.AdmDeptName = department.Name
  9631. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  9632. fed.DscgDeptName = department.Name
  9633. fed.MedMdtrtType = "1"
  9634. fed.MedType = "11"
  9635. //if his.Insutype == "390" {
  9636. // fed.MedType = "1402"
  9637. //} else {
  9638. // fed.MedType = "9933"
  9639. //}
  9640. var orders []*models.FsiOrderDtos
  9641. if trig_scen == "2" {
  9642. //处方医嘱信息
  9643. for _, item := range prescriptions {
  9644. for _, subItem := range item.HisDoctorAdviceInfo {
  9645. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9646. var order models.FsiOrderDtos
  9647. order.RxID = strconv.FormatInt(item.ID, 10)
  9648. order.Rxno = strconv.FormatInt(item.ID, 10)
  9649. order.LongDrordFlag = "0"
  9650. order.HilistType = "1"
  9651. order.ChrgType = "1"
  9652. order.DrordBhvr = "-"
  9653. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9654. order.HosplistName = subItem.BaseDrugLib.DrugName
  9655. order.HilistLv = "1"
  9656. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9657. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9658. order.HosplistName = subItem.BaseDrugLib.DrugName
  9659. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  9660. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9661. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  9662. order.OwnpayAmt = ""
  9663. order.SelfpayAmt = ""
  9664. order.Spec = ""
  9665. order.SpecUnt = ""
  9666. order.DrordBegnDate = s_tm
  9667. order.DrordStopDate = ""
  9668. order.DrordDrCodg = doctor_info.DoctorNumber
  9669. order.DrordDeptName = department.Name
  9670. order.DrordDeptCodg = department.Number
  9671. order.DrordDrName = doctor_info.UserName
  9672. order.DrordDrProfttl = "234"
  9673. order.CurrDrordFlag = "1"
  9674. orders = append(orders, &order)
  9675. }
  9676. }
  9677. for _, subItem := range item.HisPrescriptionProject {
  9678. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  9679. var order models.FsiOrderDtos
  9680. order.RxID = strconv.FormatInt(item.ID, 10)
  9681. order.Rxno = strconv.FormatInt(item.ID, 10)
  9682. order.LongDrordFlag = "0"
  9683. order.HilistType = "1"
  9684. order.ChrgType = "1"
  9685. order.DrordBhvr = "-"
  9686. order.HilistCode = subItem.HisProject.MedicalCode
  9687. order.HosplistName = subItem.HisProject.ProjectName
  9688. order.HilistLv = "1"
  9689. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9690. order.HosplistCode = subItem.HisProject.MedicalCode
  9691. order.HosplistName = subItem.HisProject.ProjectName
  9692. order.Cnt = subItem.Count
  9693. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9694. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9695. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9696. order.OwnpayAmt = ""
  9697. order.SelfpayAmt = ""
  9698. order.Spec = ""
  9699. order.SpecUnt = ""
  9700. order.DrordBegnDate = s_tm
  9701. order.DrordStopDate = ""
  9702. order.DrordDrCodg = doctor_info.DoctorNumber
  9703. order.DrordDeptName = department.Name
  9704. order.DrordDeptCodg = department.Number
  9705. order.DrordDrName = doctor_info.UserName
  9706. order.DrordDrProfttl = "234"
  9707. order.CurrDrordFlag = "1"
  9708. orders = append(orders, &order)
  9709. }
  9710. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  9711. var order models.FsiOrderDtos
  9712. order.RxID = strconv.FormatInt(item.ID, 10)
  9713. order.Rxno = strconv.FormatInt(item.ID, 10)
  9714. order.LongDrordFlag = "0"
  9715. order.HilistType = "1"
  9716. order.ChrgType = "1"
  9717. order.DrordBhvr = "-"
  9718. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9719. order.HosplistName = subItem.GoodInfo.GoodName
  9720. order.HilistLv = "1"
  9721. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9722. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9723. order.HosplistName = subItem.GoodInfo.GoodName
  9724. order.Cnt = subItem.Count
  9725. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9726. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9727. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9728. order.OwnpayAmt = ""
  9729. order.SelfpayAmt = ""
  9730. order.Spec = ""
  9731. order.SpecUnt = ""
  9732. order.DrordBegnDate = s_tm
  9733. order.DrordStopDate = ""
  9734. order.DrordDrCodg = doctor_info.DoctorNumber
  9735. order.DrordDeptName = department.Name
  9736. order.DrordDeptCodg = department.Number
  9737. order.DrordDrName = doctor_info.UserName
  9738. order.DrordDrProfttl = "234"
  9739. order.CurrDrordFlag = "1"
  9740. orders = append(orders, &order)
  9741. }
  9742. }
  9743. }
  9744. //处方医嘱信息
  9745. }
  9746. fed.MatnStas = "0"
  9747. fed.MedfeeSumamt = "0"
  9748. fed.OwnpayAmt = "0"
  9749. fed.SelfpayAmt = "0"
  9750. fed.AcctPayamt = "0"
  9751. fed.MaAmt = "0"
  9752. fed.HifpPayamt = "0"
  9753. fed.SetlTotlnum = "1"
  9754. fed.Insutype = his.Insutype
  9755. fed.ReimFlag = "0"
  9756. fed.OutSetlFlag = "0"
  9757. var fopd []*models.FsiOperationDtosData
  9758. data := make(map[string]interface{})
  9759. data["fed"] = fed
  9760. data["fdd"] = fdds
  9761. data["fod"] = orders
  9762. data["pd"] = pd
  9763. data["pp"] = pp
  9764. data["fopd"] = fopd
  9765. data["trig_scen"] = trig_scen
  9766. fmt.Println(data)
  9767. fmt.Println(fed)
  9768. fmt.Println(fdds)
  9769. fmt.Println(orders)
  9770. fmt.Println(pd)
  9771. fmt.Println(pp)
  9772. fmt.Println(fopd)
  9773. client := &http.Client{}
  9774. bytesData, _ := json.Marshal(data)
  9775. var req *http.Request
  9776. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9777. if miConfig.MdtrtareaAdmvs == "320921" {
  9778. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  9779. } else {
  9780. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  9781. }
  9782. resp, _ := client.Do(req)
  9783. defer resp.Body.Close()
  9784. body, ioErr := ioutil.ReadAll(resp.Body)
  9785. if ioErr != nil {
  9786. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9788. return res
  9789. }
  9790. var respJSON map[string]interface{}
  9791. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9792. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9794. return res
  9795. }
  9796. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  9797. fmt.Println(respJSON)
  9798. result, _ := json.Marshal(respJSON)
  9799. fmt.Println(result)
  9800. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9801. utils.ErrorLog("解析失败:%v", err)
  9802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9803. return res
  9804. }
  9805. return res
  9806. } else {
  9807. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  9808. saveLog(output, input, "3101", "事前")
  9809. if err := json.Unmarshal([]byte(output), &res); err != nil {
  9810. utils.ErrorLog("解析失败:%v", err)
  9811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9812. return
  9813. }
  9814. return res
  9815. }
  9816. return res
  9817. }
  9818. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  9819. ////patient_id, _ := c.GetInt64("patient_id")
  9820. //order_id, _ := c.GetInt64("order_id")
  9821. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  9822. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  9823. //trig_scen := c.GetString("trig_scen")
  9824. adminUser := c.GetAdminUserInfo()
  9825. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9826. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9827. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9828. record_time := c.GetString("record_time")
  9829. order, _ := service.GetHisOrderByID(order_id)
  9830. psn_info, _ := service.GetPsnByPatientId(patient_id)
  9831. timeLayout := "2006-01-02"
  9832. loc, _ := time.LoadLocation("Local")
  9833. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9834. if err != nil {
  9835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9836. return
  9837. }
  9838. recordDateTime := theTime.Unix()
  9839. var patientPrescription models.HisPrescriptionInfo
  9840. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9841. if patientPrescription.ID == 0 {
  9842. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  9843. }
  9844. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9845. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9846. //
  9847. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9848. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9849. var pp models.PublicParams
  9850. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9851. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9852. pp.FixmedinsName = miConfig.OrgName
  9853. pp.FixmedinsCode = miConfig.Code
  9854. pp.RequestUrl = miConfig.Url
  9855. pp.Cainfo = miConfig.Cainfo
  9856. pp.SecretKey = miConfig.SecretKey
  9857. pp.AccessKey = miConfig.AccessKey
  9858. pp.OpterName = roles.UserName
  9859. var config []*models.HisXtDiagnoseConfig
  9860. for _, item := range diagnosis_ids {
  9861. id, _ := strconv.ParseInt(item, 10, 64)
  9862. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9863. config = append(config, &diagnosisConfig)
  9864. }
  9865. var pd models.PatientDtos
  9866. pd.PatnID = his.PsnNo
  9867. pd.PatnName = his.Name
  9868. pd.Gend = his.Gend
  9869. pd.Brdy = psn_info.Brdy
  9870. pd.Poolarea = his.InsuplcAdmdvs
  9871. pd.CurrMdtrtID = his.Number
  9872. var fed models.FsiEncounterDtos
  9873. fed.MdtrtID = his.Number
  9874. fed.MedinsID = miConfig.Code
  9875. fed.MedinsName = miConfig.OrgName
  9876. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  9877. fed.MedMdtrtType = "1"
  9878. fed.MedinsType = "1"
  9879. fed.MedinsLv = "11"
  9880. tm := time.Unix(his.RecordDate, 0)
  9881. s_tm := tm.Format("2006-01-02 15:04:05")
  9882. fed.AdmDate = s_tm
  9883. fed.DscgDate = s_tm
  9884. fed.DscgMainDiseCodg = config[0].CountryCode
  9885. fed.DscgMainDiseName = config[0].CountryContentName
  9886. //诊断信息
  9887. var fdds []*models.FsiDiagnoseDtos
  9888. for index, item := range config {
  9889. if index == 0 {
  9890. var fdd models.FsiDiagnoseDtos
  9891. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9892. fdd.InoutDiseType = "1"
  9893. fdd.MaindiseFlag = "1"
  9894. fdd.DiseDate = s_tm
  9895. fdd.DiasSrtNo = "1"
  9896. fdd.DiseName = item.CountryContentName
  9897. fdd.DiseCodg = item.CountryCode
  9898. fdds = append(fdds, &fdd)
  9899. } else {
  9900. var fdd models.FsiDiagnoseDtos
  9901. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9902. fdd.InoutDiseType = "1"
  9903. fdd.MaindiseFlag = "1"
  9904. fdd.DiseDate = s_tm
  9905. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  9906. fdd.DiseName = item.CountryContentName
  9907. fdd.DiseCodg = item.CountryCode
  9908. fdds = append(fdds, &fdd)
  9909. }
  9910. }
  9911. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  9912. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  9913. fed.AdmDeptName = department.Name
  9914. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  9915. fed.DscgDeptName = department.Name
  9916. fed.MedType = order.MedType
  9917. //处方医嘱信息
  9918. var orders []*models.FsiOrderDtos
  9919. //for _, item := range prescriptions {
  9920. // for _, subItem := range item.HisDoctorAdviceInfo {
  9921. // var order models.FsiOrderDtos
  9922. // order.RxID = strconv.FormatInt(item.ID, 10)
  9923. // order.Rxno = strconv.FormatInt(item.ID, 10)
  9924. // order.LongDrordFlag = "0"
  9925. // order.HilistType = "1"
  9926. // order.ChrgType = "1"
  9927. // order.DrordBhvr = "-"
  9928. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9929. // order.HosplistName = subItem.BaseDrugLib.DrugName
  9930. // order.HilistLv = "1"
  9931. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  9932. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9933. // order.HosplistName = subItem.BaseDrugLib.DrugName
  9934. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  9935. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  9936. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  9937. // order.OwnpayAmt = ""
  9938. // order.SelfpayAmt = ""
  9939. // order.Spec = ""
  9940. // order.SpecUnt = ""
  9941. // order.DrordBegnDate = s_tm
  9942. // order.DrordStopDate = ""
  9943. // order.DrordDrCodg = "1"
  9944. // order.DrordDeptName = department.Name
  9945. // order.DrordDrCodg = "1"
  9946. // order.DrordDrName = doctor_info.UserName
  9947. // order.DrordDrProfttl = ""
  9948. // order.CurrDrordFlag = "1"
  9949. // orders = append(orders, &order)
  9950. // }
  9951. // for _, subItem := range item.HisPrescriptionProject {
  9952. // if subItem.Type == 2 {
  9953. // var order models.FsiOrderDtos
  9954. // order.RxID = strconv.FormatInt(item.ID, 10)
  9955. // order.Rxno = strconv.FormatInt(item.ID, 10)
  9956. // order.LongDrordFlag = "0"
  9957. // order.HilistType = "1"
  9958. // order.ChrgType = "1"
  9959. // order.DrordBhvr = "-"
  9960. // order.HilistCode = subItem.HisProject.MedicalCode
  9961. // order.HosplistName = subItem.HisProject.ProjectName
  9962. // order.HilistLv = "1"
  9963. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  9964. // order.HosplistCode = subItem.HisProject.MedicalCode
  9965. // order.HosplistName = subItem.HisProject.ProjectName
  9966. // order.Cnt = subItem.Count
  9967. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9968. //
  9969. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  9970. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  9971. // order.OwnpayAmt = ""
  9972. // order.SelfpayAmt = ""
  9973. // order.Spec = ""
  9974. // order.SpecUnt = ""
  9975. // order.DrordBegnDate = s_tm
  9976. // order.DrordStopDate = ""
  9977. // order.DrordDrCodg = "1"
  9978. // order.DrordDeptName = department.Name
  9979. // order.DrordDrCodg = "1"
  9980. // order.DrordDrName = doctor_info.UserName
  9981. // order.DrordDrProfttl = ""
  9982. // order.CurrDrordFlag = "1"
  9983. // orders = append(orders, &order)
  9984. //
  9985. // }
  9986. // if subItem.Type == 3 {
  9987. //
  9988. // var order models.FsiOrderDtos
  9989. // order.RxID = strconv.FormatInt(item.ID, 10)
  9990. // order.Rxno = strconv.FormatInt(item.ID, 10)
  9991. // order.LongDrordFlag = "0"
  9992. // order.HilistType = "1"
  9993. // order.ChrgType = "1"
  9994. // order.DrordBhvr = "-"
  9995. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9996. // order.HosplistName = subItem.GoodInfo.GoodName
  9997. // order.HilistLv = "1"
  9998. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  9999. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10000. // order.HosplistName = subItem.GoodInfo.GoodName
  10001. // order.Cnt = subItem.Count
  10002. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10003. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10004. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10005. // order.OwnpayAmt = ""
  10006. // order.SelfpayAmt = ""
  10007. // order.Spec = ""
  10008. // order.SpecUnt = ""
  10009. // order.DrordBegnDate = s_tm
  10010. // order.DrordStopDate = ""
  10011. // order.DrordDrCodg = "1"
  10012. // order.DrordDeptName = department.Name
  10013. // order.DrordDrCodg = "1"
  10014. // order.DrordDrName = doctor_info.UserName
  10015. // order.DrordDrProfttl = ""
  10016. // order.CurrDrordFlag = "1"
  10017. // orders = append(orders, &order)
  10018. //
  10019. // }
  10020. // }
  10021. //}
  10022. for _, item := range prescriptions {
  10023. for _, subItem := range item.HisDoctorAdviceInfo {
  10024. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10025. var order models.FsiOrderDtos
  10026. order.RxID = strconv.FormatInt(item.ID, 10)
  10027. order.Rxno = strconv.FormatInt(item.ID, 10)
  10028. order.LongDrordFlag = "0"
  10029. order.HilistType = "1"
  10030. order.ChrgType = "1"
  10031. order.DrordBhvr = "-"
  10032. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10033. order.HosplistName = subItem.BaseDrugLib.DrugName
  10034. order.HilistLv = "1"
  10035. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10036. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10037. order.HosplistName = subItem.BaseDrugLib.DrugName
  10038. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10039. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10040. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10041. order.OwnpayAmt = ""
  10042. order.SelfpayAmt = ""
  10043. order.Spec = ""
  10044. order.SpecUnt = ""
  10045. order.DrordBegnDate = s_tm
  10046. order.DrordStopDate = ""
  10047. order.DrordDrCodg = doctor_info.DoctorNumber
  10048. order.DrordDeptName = department.Name
  10049. order.DrordDeptCodg = department.Number
  10050. order.DrordDrName = doctor_info.UserName
  10051. order.DrordDrProfttl = "234"
  10052. order.CurrDrordFlag = "1"
  10053. orders = append(orders, &order)
  10054. }
  10055. }
  10056. for _, subItem := range item.HisPrescriptionProject {
  10057. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10058. var order models.FsiOrderDtos
  10059. order.RxID = strconv.FormatInt(item.ID, 10)
  10060. order.Rxno = strconv.FormatInt(item.ID, 10)
  10061. order.LongDrordFlag = "0"
  10062. order.HilistType = "1"
  10063. order.ChrgType = "1"
  10064. order.DrordBhvr = "-"
  10065. order.HilistCode = subItem.HisProject.MedicalCode
  10066. order.HosplistName = subItem.HisProject.ProjectName
  10067. order.HilistLv = "1"
  10068. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10069. order.HosplistCode = subItem.HisProject.MedicalCode
  10070. order.HosplistName = subItem.HisProject.ProjectName
  10071. order.Cnt = subItem.Count
  10072. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10073. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10074. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10075. order.OwnpayAmt = ""
  10076. order.SelfpayAmt = ""
  10077. order.Spec = ""
  10078. order.SpecUnt = ""
  10079. order.DrordBegnDate = s_tm
  10080. order.DrordStopDate = ""
  10081. order.DrordDrCodg = doctor_info.DoctorNumber
  10082. order.DrordDeptName = department.Name
  10083. order.DrordDeptCodg = department.Number
  10084. order.DrordDrName = doctor_info.UserName
  10085. order.DrordDrProfttl = "234"
  10086. order.CurrDrordFlag = "1"
  10087. orders = append(orders, &order)
  10088. }
  10089. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10090. var order models.FsiOrderDtos
  10091. order.RxID = strconv.FormatInt(item.ID, 10)
  10092. order.Rxno = strconv.FormatInt(item.ID, 10)
  10093. order.LongDrordFlag = "0"
  10094. order.HilistType = "1"
  10095. order.ChrgType = "1"
  10096. order.DrordBhvr = "0"
  10097. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10098. order.HosplistName = subItem.GoodInfo.GoodName
  10099. order.HilistLv = "1"
  10100. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10101. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10102. order.HosplistName = subItem.GoodInfo.GoodName
  10103. order.Cnt = subItem.Count
  10104. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10105. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10106. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10107. order.OwnpayAmt = ""
  10108. order.SelfpayAmt = ""
  10109. order.Spec = ""
  10110. order.SpecUnt = ""
  10111. order.DrordBegnDate = s_tm
  10112. order.DrordStopDate = ""
  10113. order.DrordDrCodg = doctor_info.DoctorNumber
  10114. order.DrordDeptName = department.Name
  10115. order.DrordDeptCodg = department.Number
  10116. order.DrordDrName = doctor_info.UserName
  10117. order.DrordDrProfttl = "234"
  10118. order.CurrDrordFlag = "1"
  10119. orders = append(orders, &order)
  10120. }
  10121. }
  10122. }
  10123. //处方医嘱信息
  10124. fed.MatnStas = "0"
  10125. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  10126. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  10127. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  10128. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  10129. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  10130. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  10131. fed.SetlTotlnum = "1"
  10132. fed.Insutype = his.Insutype
  10133. fed.ReimFlag = "0"
  10134. fed.OutSetlFlag = "0"
  10135. var fopd []*models.FsiOperationDtosData
  10136. data := make(map[string]interface{})
  10137. data["fed"] = fed
  10138. data["fdd"] = fdds
  10139. data["fod"] = orders
  10140. data["pd"] = pd
  10141. data["pp"] = pp
  10142. data["fopd"] = fopd
  10143. data["trig_scen"] = trig_scen
  10144. client := &http.Client{}
  10145. bytesData, _ := json.Marshal(data)
  10146. var req *http.Request
  10147. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10148. if miConfig.MdtrtareaAdmvs == "320921" {
  10149. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  10150. } else {
  10151. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  10152. }
  10153. resp, _ := client.Do(req)
  10154. defer resp.Body.Close()
  10155. body, ioErr := ioutil.ReadAll(resp.Body)
  10156. if ioErr != nil {
  10157. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10159. return res
  10160. }
  10161. var respJSON map[string]interface{}
  10162. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10163. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10165. return res
  10166. }
  10167. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10168. result, _ := json.Marshal(respJSON)
  10169. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10170. utils.ErrorLog("解析失败:%v", err)
  10171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10172. return res
  10173. }
  10174. return res
  10175. } else {
  10176. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10177. saveLog(output, input, "3102", "事中")
  10178. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10179. utils.ErrorLog("解析失败:%v", err)
  10180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10181. return
  10182. }
  10183. return res
  10184. }
  10185. return res
  10186. }
  10187. 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) {
  10188. var res Resultgd3101
  10189. adminUser := c.GetAdminUserInfo()
  10190. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10191. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10192. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10193. //record_time := c.GetString("record_time")
  10194. //trig_scen := c.GetString("trig_scen")
  10195. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  10196. //psn_info, _ := service.GetPatientId(patient_id)
  10197. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  10198. timeLayout := "2006-01-02"
  10199. loc, _ := time.LoadLocation("Local")
  10200. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10201. if err != nil {
  10202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10203. return res
  10204. }
  10205. recordDateTime := theTime.Unix()
  10206. var patientPrescription models.HisPrescriptionInfo
  10207. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10208. //if patientPrescription.ID == 0 {
  10209. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10210. //}
  10211. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10212. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10213. //
  10214. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10215. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10216. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  10217. var pp models.PublicParams
  10218. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10219. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10220. pp.FixmedinsName = miConfig.OrgName
  10221. pp.FixmedinsCode = miConfig.Code
  10222. pp.RequestUrl = miConfig.Url
  10223. pp.Cainfo = miConfig.Cainfo
  10224. pp.SecretKey = miConfig.SecretKey
  10225. pp.AccessKey = miConfig.AccessKey
  10226. pp.OpterName = roles.UserName
  10227. var config []*models.HisXtDiagnoseConfig
  10228. for _, item := range diagnosis_ids {
  10229. id, _ := strconv.ParseInt(item, 10, 64)
  10230. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10231. config = append(config, &diagnosisConfig)
  10232. }
  10233. var pd models.PatientDtos
  10234. pd.PatnID = his.PsnNo
  10235. pd.PatnName = his.Name
  10236. pd.Gend = his.Gend
  10237. pd.Brdy = str
  10238. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10239. pd.CurrMdtrtID = his.Number
  10240. var fed models.FsiEncounterDtos
  10241. fed.MdtrtID = his.Number
  10242. fed.MedinsID = miConfig.Code
  10243. fed.MedinsName = miConfig.OrgName
  10244. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10245. fed.MedMdtrtType = "1"
  10246. fed.MedinsType = "1"
  10247. fed.MedinsLv = "11"
  10248. tm := time.Unix(his.RecordDate, 0)
  10249. s_tm := tm.Format("2006-01-02 15:04:05")
  10250. fed.AdmDate = s_tm
  10251. fed.DscgDate = s_tm
  10252. fed.DscgMainDiseCodg = config[0].CountryCode
  10253. fed.DscgMainDiseName = config[0].CountryContentName
  10254. //诊断信息
  10255. var fdds []*models.FsiDiagnoseDtos
  10256. for index, item := range config {
  10257. if index == 0 {
  10258. var fdd models.FsiDiagnoseDtos
  10259. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10260. fdd.InoutDiseType = "1"
  10261. fdd.MaindiseFlag = "1"
  10262. fdd.DiseDate = s_tm
  10263. fdd.DiasSrtNo = "1"
  10264. fdd.DiseName = item.CountryContentName
  10265. fdd.DiseCodg = item.CountryCode
  10266. fdds = append(fdds, &fdd)
  10267. } else {
  10268. var fdd models.FsiDiagnoseDtos
  10269. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10270. fdd.InoutDiseType = "1"
  10271. fdd.MaindiseFlag = "1"
  10272. fdd.DiseDate = s_tm
  10273. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10274. fdd.DiseName = item.CountryContentName
  10275. fdd.DiseCodg = item.CountryCode
  10276. fdds = append(fdds, &fdd)
  10277. }
  10278. }
  10279. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10280. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  10281. fed.AdmDeptName = de.Name
  10282. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  10283. fed.DscgDeptName = de.Name
  10284. fed.MedMdtrtType = "1"
  10285. fed.MedType = "11"
  10286. //if his.Insutype == "390" {
  10287. // fed.MedType = "1402"
  10288. //} else {
  10289. // fed.MedType = "9933"
  10290. //}
  10291. var orders []*models.FsiOrderDtos
  10292. if trig_scen == "2" {
  10293. //处方医嘱信息
  10294. for _, item := range prescriptions {
  10295. for _, subItem := range item.HisDoctorAdviceInfo {
  10296. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10297. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  10298. var order models.FsiOrderDtos
  10299. order.RxID = strconv.FormatInt(item.ID, 10)
  10300. order.Rxno = strconv.FormatInt(item.ID, 10)
  10301. order.LongDrordFlag = "0"
  10302. order.HilistType = "1"
  10303. order.ChrgType = "1"
  10304. order.DrordBhvr = "0"
  10305. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10306. order.HosplistName = subItem.BaseDrugLib.DrugName
  10307. order.HilistLv = "1"
  10308. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10309. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10310. order.HosplistName = subItem.BaseDrugLib.DrugName
  10311. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10312. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10313. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10314. order.OwnpayAmt = ""
  10315. order.SelfpayAmt = ""
  10316. order.Spec = spec
  10317. order.SpecUnt = subItem.PrescribingNumberUnit
  10318. order.DrordBegnDate = s_tm
  10319. order.DrordStopDate = ""
  10320. order.DrordDrCodg = doctor_info.DoctorNumber
  10321. order.DrordDeptName = department.Name
  10322. order.DrordDeptCodg = department.Number
  10323. order.DrordDrName = doctor_info.UserName
  10324. order.DrordDrProfttl = "234"
  10325. order.CurrDrordFlag = "1"
  10326. orders = append(orders, &order)
  10327. }
  10328. }
  10329. for _, subItem := range item.HisPrescriptionProject {
  10330. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10331. var order models.FsiOrderDtos
  10332. order.RxID = strconv.FormatInt(item.ID, 10)
  10333. order.Rxno = strconv.FormatInt(item.ID, 10)
  10334. order.LongDrordFlag = "0"
  10335. order.HilistType = "1"
  10336. order.ChrgType = "1"
  10337. order.DrordBhvr = "0"
  10338. order.HilistCode = subItem.HisProject.MedicalCode
  10339. order.HosplistName = subItem.HisProject.ProjectName
  10340. order.HilistLv = "1"
  10341. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10342. order.HosplistCode = subItem.HisProject.MedicalCode
  10343. order.HosplistName = subItem.HisProject.ProjectName
  10344. order.Cnt = subItem.Count
  10345. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10346. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10347. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10348. order.OwnpayAmt = ""
  10349. order.SelfpayAmt = ""
  10350. order.Spec = subItem.Unit
  10351. order.SpecUnt = subItem.Unit
  10352. order.DrordBegnDate = s_tm
  10353. order.DrordStopDate = ""
  10354. order.DrordDrCodg = doctor_info.DoctorNumber
  10355. order.DrordDeptName = department.Name
  10356. order.DrordDeptCodg = department.Number
  10357. order.DrordDrName = doctor_info.UserName
  10358. order.DrordDrProfttl = "234"
  10359. order.CurrDrordFlag = "1"
  10360. orders = append(orders, &order)
  10361. }
  10362. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10363. var order models.FsiOrderDtos
  10364. order.RxID = strconv.FormatInt(item.ID, 10)
  10365. order.Rxno = strconv.FormatInt(item.ID, 10)
  10366. order.LongDrordFlag = "0"
  10367. order.HilistType = "1"
  10368. order.ChrgType = "1"
  10369. order.DrordBhvr = "0"
  10370. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10371. order.HosplistName = subItem.GoodInfo.GoodName
  10372. order.HilistLv = "1"
  10373. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10374. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10375. order.HosplistName = subItem.GoodInfo.GoodName
  10376. order.Cnt = subItem.Count
  10377. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10378. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10379. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10380. order.OwnpayAmt = ""
  10381. order.SelfpayAmt = ""
  10382. order.Spec = subItem.GoodInfo.SpecificationName
  10383. order.SpecUnt = subItem.Unit
  10384. order.DrordBegnDate = s_tm
  10385. order.DrordStopDate = ""
  10386. order.DrordDrCodg = doctor_info.DoctorNumber
  10387. order.DrordDeptName = department.Name
  10388. order.DrordDeptCodg = department.Number
  10389. order.DrordDrName = doctor_info.UserName
  10390. order.DrordDrProfttl = "234"
  10391. order.CurrDrordFlag = "1"
  10392. orders = append(orders, &order)
  10393. }
  10394. }
  10395. }
  10396. //处方医嘱信息
  10397. }
  10398. fed.MatnStas = "0"
  10399. fed.MedfeeSumamt = "0"
  10400. fed.OwnpayAmt = "0"
  10401. fed.SelfpayAmt = "0"
  10402. fed.AcctPayamt = "0"
  10403. fed.MaAmt = "0"
  10404. fed.HifpPayamt = "0"
  10405. fed.SetlTotlnum = "1"
  10406. fed.Insutype = his.Insutype
  10407. fed.ReimFlag = "0"
  10408. fed.OutSetlFlag = "0"
  10409. var fopd []*models.FsiOperationDtosData
  10410. data := make(map[string]interface{})
  10411. data["fed"] = fed
  10412. data["fdd"] = fdds
  10413. data["fod"] = orders
  10414. data["pd"] = pd
  10415. data["pp"] = pp
  10416. data["fopd"] = fopd
  10417. data["trig_scen"] = trig_scen
  10418. fmt.Println(data)
  10419. fmt.Println(fed)
  10420. fmt.Println(fdds)
  10421. fmt.Println(orders)
  10422. fmt.Println(pd)
  10423. fmt.Println(pp)
  10424. fmt.Println(fopd)
  10425. client := &http.Client{}
  10426. bytesData, _ := json.Marshal(data)
  10427. var req *http.Request
  10428. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10429. if miConfig.MdtrtareaAdmvs == "320921" {
  10430. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10431. } else {
  10432. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10433. }
  10434. resp, _ := client.Do(req)
  10435. defer resp.Body.Close()
  10436. body, ioErr := ioutil.ReadAll(resp.Body)
  10437. if ioErr != nil {
  10438. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10440. return res
  10441. }
  10442. var respJSON map[string]interface{}
  10443. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10444. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10446. return res
  10447. }
  10448. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10449. fmt.Println(respJSON)
  10450. result, _ := json.Marshal(respJSON)
  10451. fmt.Println(result)
  10452. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10453. utils.ErrorLog("解析失败:%v", err)
  10454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10455. return res
  10456. }
  10457. return res
  10458. } else {
  10459. //if miConfig.MdtrtareaAdmvs == "441202" {
  10460. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10461. saveLog(output, input, "3101", "事前")
  10462. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10463. utils.ErrorLog("解析失败:%v", err)
  10464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10465. return
  10466. }
  10467. return res
  10468. //}
  10469. }
  10470. }
  10471. 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) {
  10472. adminUser := c.GetAdminUserInfo()
  10473. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10474. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10475. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10476. //record_time := c.GetString("record_time")
  10477. //trig_scen := c.GetString("trig_scen")
  10478. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  10479. timeLayout := "2006-01-02"
  10480. loc, _ := time.LoadLocation("Local")
  10481. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10482. if err != nil {
  10483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10484. return res
  10485. }
  10486. recordDateTime := theTime.Unix()
  10487. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  10488. var patientPrescription models.HisPrescriptionInfo
  10489. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10490. if patientPrescription.ID == 0 {
  10491. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10492. }
  10493. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10494. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10495. //
  10496. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10497. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10498. var pp models.PublicParams
  10499. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10500. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10501. pp.FixmedinsName = miConfig.OrgName
  10502. pp.FixmedinsCode = miConfig.Code
  10503. pp.RequestUrl = miConfig.Url
  10504. pp.Cainfo = miConfig.Cainfo
  10505. pp.SecretKey = miConfig.SecretKey
  10506. pp.AccessKey = miConfig.AccessKey
  10507. pp.OpterName = roles.UserName
  10508. var config []*models.HisXtDiagnoseConfig
  10509. for _, item := range diagnosis_ids {
  10510. id, _ := strconv.ParseInt(item, 10, 64)
  10511. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10512. config = append(config, &diagnosisConfig)
  10513. }
  10514. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  10515. var pd models.PatientDtos
  10516. pd.PatnID = his.PsnNo
  10517. pd.PatnName = his.Name
  10518. pd.Gend = his.Gend
  10519. pd.Brdy = str
  10520. pd.Poolarea = his.InsuplcAdmdvs
  10521. pd.CurrMdtrtID = his.Number
  10522. var fed models.FsiEncounterDtos
  10523. fed.MdtrtID = his.Number
  10524. fed.MedinsID = miConfig.Code
  10525. fed.MedinsName = miConfig.OrgName
  10526. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10527. fed.MedMdtrtType = "1"
  10528. fed.MedinsType = "1"
  10529. fed.MedinsLv = "11"
  10530. tm := time.Unix(his.RecordDate, 0)
  10531. s_tm := tm.Format("2006-01-02 15:04:05")
  10532. fed.AdmDate = s_tm
  10533. fed.DscgDate = s_tm
  10534. fed.DscgMainDiseCodg = config[0].CountryCode
  10535. fed.DscgMainDiseName = config[0].CountryContentName
  10536. //诊断信息
  10537. var fdds []*models.FsiDiagnoseDtos
  10538. for index, item := range config {
  10539. if index == 0 {
  10540. var fdd models.FsiDiagnoseDtos
  10541. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10542. fdd.InoutDiseType = "1"
  10543. fdd.MaindiseFlag = "1"
  10544. fdd.DiseDate = s_tm
  10545. fdd.DiasSrtNo = "1"
  10546. fdd.DiseName = item.CountryContentName
  10547. fdd.DiseCodg = item.CountryCode
  10548. fdds = append(fdds, &fdd)
  10549. } else {
  10550. var fdd models.FsiDiagnoseDtos
  10551. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10552. fdd.InoutDiseType = "1"
  10553. fdd.MaindiseFlag = "1"
  10554. fdd.DiseDate = s_tm
  10555. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10556. fdd.DiseName = item.CountryContentName
  10557. fdd.DiseCodg = item.CountryCode
  10558. fdds = append(fdds, &fdd)
  10559. }
  10560. }
  10561. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10562. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10563. fed.AdmDeptName = department.Name
  10564. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10565. fed.DscgDeptName = department.Name
  10566. fed.MedMdtrtType = "1"
  10567. fed.MedType = "11"
  10568. //if his.Insutype == "390" {
  10569. // fed.MedType = "1402"
  10570. //} else {
  10571. // fed.MedType = "9933"
  10572. //}
  10573. var orders []*models.FsiOrderDtos
  10574. if trig_scen == "2" {
  10575. //处方医嘱信息
  10576. for _, item := range prescriptions {
  10577. for _, subItem := range item.HisDoctorAdviceInfo {
  10578. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10579. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  10580. var order models.FsiOrderDtos
  10581. order.RxID = strconv.FormatInt(item.ID, 10)
  10582. order.Rxno = strconv.FormatInt(item.ID, 10)
  10583. order.LongDrordFlag = "0"
  10584. order.HilistType = "1"
  10585. order.ChrgType = "1"
  10586. order.DrordBhvr = "0"
  10587. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10588. order.HosplistName = subItem.BaseDrugLib.DrugName
  10589. order.HilistLv = "1"
  10590. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10591. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10592. order.HosplistName = subItem.BaseDrugLib.DrugName
  10593. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10594. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10595. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10596. order.OwnpayAmt = ""
  10597. order.SelfpayAmt = ""
  10598. order.Spec = spec
  10599. order.SpecUnt = subItem.PrescribingNumberUnit
  10600. order.DrordBegnDate = s_tm
  10601. order.DrordStopDate = ""
  10602. order.DrordDrCodg = doctor_info.DoctorNumber
  10603. order.DrordDeptName = department.Name
  10604. order.DrordDeptCodg = department.Number
  10605. order.DrordDrName = doctor_info.UserName
  10606. order.DrordDrProfttl = "234"
  10607. order.CurrDrordFlag = "1"
  10608. orders = append(orders, &order)
  10609. }
  10610. }
  10611. for _, subItem := range item.HisPrescriptionProject {
  10612. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10613. var order models.FsiOrderDtos
  10614. order.RxID = strconv.FormatInt(item.ID, 10)
  10615. order.Rxno = strconv.FormatInt(item.ID, 10)
  10616. order.LongDrordFlag = "0"
  10617. order.HilistType = "1"
  10618. order.ChrgType = "1"
  10619. order.DrordBhvr = "0"
  10620. order.HilistCode = subItem.HisProject.MedicalCode
  10621. order.HosplistName = subItem.HisProject.ProjectName
  10622. order.HilistLv = "1"
  10623. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10624. order.HosplistCode = subItem.HisProject.MedicalCode
  10625. order.HosplistName = subItem.HisProject.ProjectName
  10626. order.Cnt = subItem.Count
  10627. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10628. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10629. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10630. order.OwnpayAmt = ""
  10631. order.SelfpayAmt = ""
  10632. order.Spec = subItem.Unit
  10633. order.SpecUnt = subItem.Unit
  10634. order.DrordBegnDate = s_tm
  10635. order.DrordStopDate = ""
  10636. order.DrordDrCodg = doctor_info.DoctorNumber
  10637. order.DrordDeptName = department.Name
  10638. order.DrordDeptCodg = department.Number
  10639. order.DrordDrName = doctor_info.UserName
  10640. order.DrordDrProfttl = "234"
  10641. order.CurrDrordFlag = "1"
  10642. orders = append(orders, &order)
  10643. }
  10644. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10645. var order models.FsiOrderDtos
  10646. order.RxID = strconv.FormatInt(item.ID, 10)
  10647. order.Rxno = strconv.FormatInt(item.ID, 10)
  10648. order.LongDrordFlag = "0"
  10649. order.HilistType = "1"
  10650. order.ChrgType = "1"
  10651. order.DrordBhvr = "0"
  10652. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10653. order.HosplistName = subItem.GoodInfo.GoodName
  10654. order.HilistLv = "1"
  10655. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10656. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10657. order.HosplistName = subItem.GoodInfo.GoodName
  10658. order.Cnt = subItem.Count
  10659. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10660. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10661. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10662. order.OwnpayAmt = ""
  10663. order.SelfpayAmt = ""
  10664. order.Spec = subItem.GoodInfo.SpecificationName
  10665. order.SpecUnt = subItem.Unit
  10666. order.DrordBegnDate = s_tm
  10667. order.DrordStopDate = ""
  10668. order.DrordDrCodg = doctor_info.DoctorNumber
  10669. order.DrordDeptName = department.Name
  10670. order.DrordDeptCodg = department.Number
  10671. order.DrordDrName = doctor_info.UserName
  10672. order.DrordDrProfttl = "234"
  10673. order.CurrDrordFlag = "1"
  10674. orders = append(orders, &order)
  10675. }
  10676. }
  10677. }
  10678. //处方医嘱信息
  10679. }
  10680. fed.MatnStas = "0"
  10681. fed.MedfeeSumamt = "0"
  10682. fed.OwnpayAmt = "0"
  10683. fed.SelfpayAmt = "0"
  10684. fed.AcctPayamt = "0"
  10685. fed.MaAmt = "0"
  10686. fed.HifpPayamt = "0"
  10687. fed.SetlTotlnum = "1"
  10688. fed.Insutype = his.Insutype
  10689. fed.ReimFlag = "0"
  10690. fed.OutSetlFlag = "0"
  10691. var fopd []*models.FsiOperationDtosData
  10692. data := make(map[string]interface{})
  10693. data["fed"] = fed
  10694. data["fdd"] = fdds
  10695. data["fod"] = orders
  10696. data["pd"] = pd
  10697. data["pp"] = pp
  10698. data["fopd"] = fopd
  10699. data["trig_scen"] = trig_scen
  10700. fmt.Println(data)
  10701. fmt.Println(fed)
  10702. fmt.Println(fdds)
  10703. fmt.Println(orders)
  10704. fmt.Println(pd)
  10705. fmt.Println(pp)
  10706. fmt.Println(fopd)
  10707. client := &http.Client{}
  10708. bytesData, _ := json.Marshal(data)
  10709. var req *http.Request
  10710. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10711. if miConfig.MdtrtareaAdmvs == "320921" {
  10712. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10713. } else {
  10714. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10715. }
  10716. resp, _ := client.Do(req)
  10717. defer resp.Body.Close()
  10718. body, ioErr := ioutil.ReadAll(resp.Body)
  10719. if ioErr != nil {
  10720. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10722. return res
  10723. }
  10724. var respJSON map[string]interface{}
  10725. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10726. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10728. return res
  10729. }
  10730. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10731. fmt.Println(respJSON)
  10732. result, _ := json.Marshal(respJSON)
  10733. fmt.Println(result)
  10734. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10735. utils.ErrorLog("解析失败:%v", err)
  10736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10737. return res
  10738. }
  10739. return res
  10740. } else {
  10741. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10742. saveLog(output, input, "3101", "事前")
  10743. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10744. utils.ErrorLog("解析失败:%v", err)
  10745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10746. return
  10747. }
  10748. return res
  10749. }
  10750. return res
  10751. }
  10752. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  10753. ////patient_id, _ := c.GetInt64("patient_id")
  10754. //order_id, _ := c.GetInt64("order_id")
  10755. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  10756. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  10757. //trig_scen := c.GetString("trig_scen")
  10758. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  10759. //utils.ErrorLog("解析失败:%v", psn_info)
  10760. adminUser := c.GetAdminUserInfo()
  10761. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10762. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10763. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10764. record_time := c.GetString("record_time")
  10765. order, _ := service.GetHisOrderByID(order_id)
  10766. timeLayout := "2006-01-02"
  10767. loc, _ := time.LoadLocation("Local")
  10768. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10769. if err != nil {
  10770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10771. return
  10772. }
  10773. recordDateTime := theTime.Unix()
  10774. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  10775. var patientPrescription models.HisPrescriptionInfo
  10776. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10777. if patientPrescription.ID == 0 {
  10778. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10779. }
  10780. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10781. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10782. //
  10783. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10784. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10785. var pp models.PublicParams
  10786. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10787. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10788. pp.FixmedinsName = miConfig.OrgName
  10789. pp.FixmedinsCode = miConfig.Code
  10790. pp.RequestUrl = miConfig.Url
  10791. pp.Cainfo = miConfig.Cainfo
  10792. pp.SecretKey = miConfig.SecretKey
  10793. pp.AccessKey = miConfig.AccessKey
  10794. pp.OpterName = roles.UserName
  10795. var config []*models.HisXtDiagnoseConfig
  10796. for _, item := range diagnosis_ids {
  10797. id, _ := strconv.ParseInt(item, 10, 64)
  10798. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10799. config = append(config, &diagnosisConfig)
  10800. }
  10801. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  10802. var pd models.PatientDtos
  10803. pd.PatnID = his.PsnNo
  10804. pd.PatnName = his.Name
  10805. pd.Gend = his.Gend
  10806. pd.Brdy = str
  10807. pd.Poolarea = his.InsuplcAdmdvs
  10808. pd.CurrMdtrtID = his.Number
  10809. var fed models.FsiEncounterDtos
  10810. fed.MdtrtID = his.Number
  10811. fed.MedinsID = miConfig.Code
  10812. fed.MedinsName = miConfig.OrgName
  10813. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10814. fed.MedMdtrtType = "1"
  10815. fed.MedinsType = "1"
  10816. fed.MedinsLv = "11"
  10817. tm := time.Unix(his.RecordDate, 0)
  10818. s_tm := tm.Format("2006-01-02 15:04:05")
  10819. fed.AdmDate = s_tm
  10820. fed.DscgDate = s_tm
  10821. fed.DscgMainDiseCodg = config[0].CountryCode
  10822. fed.DscgMainDiseName = config[0].CountryContentName
  10823. //诊断信息
  10824. var fdds []*models.FsiDiagnoseDtos
  10825. for index, item := range config {
  10826. if index == 0 {
  10827. var fdd models.FsiDiagnoseDtos
  10828. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10829. fdd.InoutDiseType = "1"
  10830. fdd.MaindiseFlag = "1"
  10831. fdd.DiseDate = s_tm
  10832. fdd.DiasSrtNo = "1"
  10833. fdd.DiseName = item.CountryContentName
  10834. fdd.DiseCodg = item.CountryCode
  10835. fdds = append(fdds, &fdd)
  10836. } else {
  10837. var fdd models.FsiDiagnoseDtos
  10838. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10839. fdd.InoutDiseType = "1"
  10840. fdd.MaindiseFlag = "1"
  10841. fdd.DiseDate = s_tm
  10842. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10843. fdd.DiseName = item.CountryContentName
  10844. fdd.DiseCodg = item.CountryCode
  10845. fdds = append(fdds, &fdd)
  10846. }
  10847. }
  10848. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10849. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10850. fed.AdmDeptName = department.Name
  10851. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10852. fed.DscgDeptName = department.Name
  10853. fed.MedType = order.MedType
  10854. //处方医嘱信息
  10855. var orders []*models.FsiOrderDtos
  10856. //for _, item := range prescriptions {
  10857. // for _, subItem := range item.HisDoctorAdviceInfo {
  10858. // var order models.FsiOrderDtos
  10859. // order.RxID = strconv.FormatInt(item.ID, 10)
  10860. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10861. // order.LongDrordFlag = "0"
  10862. // order.HilistType = "1"
  10863. // order.ChrgType = "1"
  10864. // order.DrordBhvr = "-"
  10865. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10866. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10867. // order.HilistLv = "1"
  10868. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10869. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10870. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10871. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  10872. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10873. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  10874. // order.OwnpayAmt = ""
  10875. // order.SelfpayAmt = ""
  10876. // order.Spec = ""
  10877. // order.SpecUnt = ""
  10878. // order.DrordBegnDate = s_tm
  10879. // order.DrordStopDate = ""
  10880. // order.DrordDrCodg = "1"
  10881. // order.DrordDeptName = department.Name
  10882. // order.DrordDrCodg = "1"
  10883. // order.DrordDrName = doctor_info.UserName
  10884. // order.DrordDrProfttl = ""
  10885. // order.CurrDrordFlag = "1"
  10886. // orders = append(orders, &order)
  10887. // }
  10888. // for _, subItem := range item.HisPrescriptionProject {
  10889. // if subItem.Type == 2 {
  10890. // var order models.FsiOrderDtos
  10891. // order.RxID = strconv.FormatInt(item.ID, 10)
  10892. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10893. // order.LongDrordFlag = "0"
  10894. // order.HilistType = "1"
  10895. // order.ChrgType = "1"
  10896. // order.DrordBhvr = "-"
  10897. // order.HilistCode = subItem.HisProject.MedicalCode
  10898. // order.HosplistName = subItem.HisProject.ProjectName
  10899. // order.HilistLv = "1"
  10900. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10901. // order.HosplistCode = subItem.HisProject.MedicalCode
  10902. // order.HosplistName = subItem.HisProject.ProjectName
  10903. // order.Cnt = subItem.Count
  10904. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10905. //
  10906. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10907. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10908. // order.OwnpayAmt = ""
  10909. // order.SelfpayAmt = ""
  10910. // order.Spec = ""
  10911. // order.SpecUnt = ""
  10912. // order.DrordBegnDate = s_tm
  10913. // order.DrordStopDate = ""
  10914. // order.DrordDrCodg = "1"
  10915. // order.DrordDeptName = department.Name
  10916. // order.DrordDrCodg = "1"
  10917. // order.DrordDrName = doctor_info.UserName
  10918. // order.DrordDrProfttl = ""
  10919. // order.CurrDrordFlag = "1"
  10920. // orders = append(orders, &order)
  10921. //
  10922. // }
  10923. // if subItem.Type == 3 {
  10924. //
  10925. // var order models.FsiOrderDtos
  10926. // order.RxID = strconv.FormatInt(item.ID, 10)
  10927. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10928. // order.LongDrordFlag = "0"
  10929. // order.HilistType = "1"
  10930. // order.ChrgType = "1"
  10931. // order.DrordBhvr = "-"
  10932. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10933. // order.HosplistName = subItem.GoodInfo.GoodName
  10934. // order.HilistLv = "1"
  10935. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10936. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10937. // order.HosplistName = subItem.GoodInfo.GoodName
  10938. // order.Cnt = subItem.Count
  10939. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10940. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10941. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10942. // order.OwnpayAmt = ""
  10943. // order.SelfpayAmt = ""
  10944. // order.Spec = ""
  10945. // order.SpecUnt = ""
  10946. // order.DrordBegnDate = s_tm
  10947. // order.DrordStopDate = ""
  10948. // order.DrordDrCodg = "1"
  10949. // order.DrordDeptName = department.Name
  10950. // order.DrordDrCodg = "1"
  10951. // order.DrordDrName = doctor_info.UserName
  10952. // order.DrordDrProfttl = ""
  10953. // order.CurrDrordFlag = "1"
  10954. // orders = append(orders, &order)
  10955. //
  10956. // }
  10957. // }
  10958. //}
  10959. for _, item := range prescriptions {
  10960. for _, subItem := range item.HisDoctorAdviceInfo {
  10961. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10962. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  10963. var order models.FsiOrderDtos
  10964. order.RxID = strconv.FormatInt(item.ID, 10)
  10965. order.Rxno = strconv.FormatInt(item.ID, 10)
  10966. order.LongDrordFlag = "0"
  10967. order.HilistType = "1"
  10968. order.ChrgType = "1"
  10969. order.DrordBhvr = "0"
  10970. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10971. order.HosplistName = subItem.BaseDrugLib.DrugName
  10972. order.HilistLv = "1"
  10973. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10974. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10975. order.HosplistName = subItem.BaseDrugLib.DrugName
  10976. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10977. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10978. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10979. order.OwnpayAmt = ""
  10980. order.SelfpayAmt = ""
  10981. order.Spec = spec
  10982. order.SpecUnt = subItem.PrescribingNumberUnit
  10983. order.DrordBegnDate = s_tm
  10984. order.DrordStopDate = ""
  10985. order.DrordDrCodg = doctor_info.DoctorNumber
  10986. order.DrordDeptName = department.Name
  10987. order.DrordDeptCodg = department.Number
  10988. order.DrordDrName = doctor_info.UserName
  10989. order.DrordDrProfttl = "234"
  10990. order.CurrDrordFlag = "1"
  10991. orders = append(orders, &order)
  10992. }
  10993. }
  10994. for _, subItem := range item.HisPrescriptionProject {
  10995. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10996. var order models.FsiOrderDtos
  10997. order.RxID = strconv.FormatInt(item.ID, 10)
  10998. order.Rxno = strconv.FormatInt(item.ID, 10)
  10999. order.LongDrordFlag = "0"
  11000. order.HilistType = "1"
  11001. order.ChrgType = "1"
  11002. order.DrordBhvr = "0"
  11003. order.HilistCode = subItem.HisProject.MedicalCode
  11004. order.HosplistName = subItem.HisProject.ProjectName
  11005. order.HilistLv = "1"
  11006. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11007. order.HosplistCode = subItem.HisProject.MedicalCode
  11008. order.HosplistName = subItem.HisProject.ProjectName
  11009. order.Cnt = subItem.Count
  11010. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11011. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11012. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11013. order.OwnpayAmt = ""
  11014. order.SelfpayAmt = ""
  11015. order.Spec = subItem.Unit
  11016. order.SpecUnt = subItem.Unit
  11017. order.DrordBegnDate = s_tm
  11018. order.DrordStopDate = ""
  11019. order.DrordDrCodg = doctor_info.DoctorNumber
  11020. order.DrordDeptName = department.Name
  11021. order.DrordDeptCodg = department.Number
  11022. order.DrordDrName = doctor_info.UserName
  11023. order.DrordDrProfttl = "234"
  11024. order.CurrDrordFlag = "1"
  11025. orders = append(orders, &order)
  11026. }
  11027. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11028. var order models.FsiOrderDtos
  11029. order.RxID = strconv.FormatInt(item.ID, 10)
  11030. order.Rxno = strconv.FormatInt(item.ID, 10)
  11031. order.LongDrordFlag = "0"
  11032. order.HilistType = "1"
  11033. order.ChrgType = "1"
  11034. order.DrordBhvr = "0"
  11035. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11036. order.HosplistName = subItem.GoodInfo.GoodName
  11037. order.HilistLv = "1"
  11038. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11039. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11040. order.HosplistName = subItem.GoodInfo.GoodName
  11041. order.Cnt = subItem.Count
  11042. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11043. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11044. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11045. order.OwnpayAmt = ""
  11046. order.SelfpayAmt = ""
  11047. order.Spec = subItem.GoodInfo.SpecificationName
  11048. order.SpecUnt = subItem.Unit
  11049. order.DrordBegnDate = s_tm
  11050. order.DrordStopDate = ""
  11051. order.DrordDrCodg = doctor_info.DoctorNumber
  11052. order.DrordDeptName = department.Name
  11053. order.DrordDeptCodg = department.Number
  11054. order.DrordDrName = doctor_info.UserName
  11055. order.DrordDrProfttl = "234"
  11056. order.CurrDrordFlag = "1"
  11057. orders = append(orders, &order)
  11058. }
  11059. }
  11060. }
  11061. //处方医嘱信息
  11062. fed.MatnStas = "0"
  11063. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11064. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11065. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11066. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11067. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11068. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11069. fed.SetlTotlnum = "1"
  11070. fed.Insutype = his.Insutype
  11071. fed.ReimFlag = "0"
  11072. fed.OutSetlFlag = "0"
  11073. var fopd []*models.FsiOperationDtosData
  11074. data := make(map[string]interface{})
  11075. data["fed"] = fed
  11076. data["fdd"] = fdds
  11077. data["fod"] = orders
  11078. data["pd"] = pd
  11079. data["pp"] = pp
  11080. data["fopd"] = fopd
  11081. data["trig_scen"] = trig_scen
  11082. client := &http.Client{}
  11083. bytesData, _ := json.Marshal(data)
  11084. var req *http.Request
  11085. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11086. if miConfig.MdtrtareaAdmvs == "320921" {
  11087. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11088. } else {
  11089. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11090. }
  11091. resp, _ := client.Do(req)
  11092. defer resp.Body.Close()
  11093. body, ioErr := ioutil.ReadAll(resp.Body)
  11094. if ioErr != nil {
  11095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11097. return res
  11098. }
  11099. var respJSON map[string]interface{}
  11100. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11103. return res
  11104. }
  11105. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11106. result, _ := json.Marshal(respJSON)
  11107. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11108. utils.ErrorLog("解析失败:%v", err)
  11109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11110. return res
  11111. }
  11112. return res
  11113. } else {
  11114. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11115. saveLog(output, input, "3102", "事中")
  11116. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11117. utils.ErrorLog("解析失败:%v", err)
  11118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11119. return
  11120. }
  11121. return res
  11122. }
  11123. return res
  11124. }
  11125. func (c *HisApiController) Check() {
  11126. psn_no := c.GetString("psn_no")
  11127. in := c.GetString("in")
  11128. mt := c.GetString("mt")
  11129. baseParams := models.BaseParams{
  11130. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  11131. FixmedinsCode: "H15049901371",
  11132. InsuplcAdmdvs: "150499",
  11133. MdtrtareaAdmvs: "150499",
  11134. OrgName: "赤峰费森血液透析中心",
  11135. Doctor: "1111",
  11136. }
  11137. service.Gdyb2001(baseParams, psn_no, in, mt)
  11138. }
  11139. func (c *HisApiController) GetPsnNcdsInfo() {
  11140. admin_user_id, _ := c.GetInt64("admin_user_id")
  11141. patient_id, _ := c.GetInt64("patient_id")
  11142. //id, _ := c.GetInt64("id")
  11143. adminUser := c.GetAdminUserInfo()
  11144. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11145. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11146. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  11147. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11148. //psn_record, _ := service.GetP(id)
  11149. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11150. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  11151. //
  11152. //if psn_record.ID == 0 {
  11153. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  11154. // return
  11155. //}
  11156. var res Result5301
  11157. var res10265 Result5301For10265
  11158. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11159. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11160. var api string
  11161. if miConfig.MdtrtareaAdmvs == "320921" {
  11162. 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 +
  11163. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11164. } else {
  11165. 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 +
  11166. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11167. }
  11168. resp, requestErr := http.Get(api)
  11169. if requestErr != nil {
  11170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11171. return
  11172. }
  11173. body, ioErr := ioutil.ReadAll(resp.Body)
  11174. if ioErr != nil {
  11175. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11177. return
  11178. }
  11179. var respJSON map[string]interface{}
  11180. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11181. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11183. return
  11184. }
  11185. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11186. result, _ := json.Marshal(respJSON)
  11187. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11188. utils.ErrorLog("解析失败:%v", err)
  11189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11190. return
  11191. }
  11192. res.ErrMsg = res10265.ErrMsg
  11193. res.Output = res10265.Output
  11194. res.InfRefmsgid = res10265.InfRefmsgid
  11195. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11196. res.Infcode = infocode
  11197. } else if miConfig.MdtrtareaAdmvs == "341203" {
  11198. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11199. var api string
  11200. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  11201. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11202. resp, requestErr := http.Get(api)
  11203. if requestErr != nil {
  11204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11205. return
  11206. }
  11207. body, ioErr := ioutil.ReadAll(resp.Body)
  11208. if ioErr != nil {
  11209. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11211. return
  11212. }
  11213. var respJSON map[string]interface{}
  11214. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11215. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11217. return
  11218. }
  11219. status := respJSON["data"].(map[string]interface{})["status"].(string)
  11220. if status == "0" {
  11221. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  11222. c.ServeSuccessJSON(map[string]interface{}{
  11223. "failed_code": -10,
  11224. "msg": err_msg,
  11225. })
  11226. return
  11227. }
  11228. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11229. result, _ := json.Marshal(respJSON)
  11230. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11231. utils.ErrorLog("解析失败:%v", err)
  11232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11233. return
  11234. }
  11235. } else if miConfig.MdtrtareaAdmvs == "360302" {
  11236. p, _ := service.GetHisPatientById(patient_id)
  11237. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  11238. var dat map[string]interface{}
  11239. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11240. fmt.Println(dat)
  11241. } else {
  11242. fmt.Println(err)
  11243. }
  11244. userJSONBytes, _ := json.Marshal(dat)
  11245. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11246. utils.ErrorLog("解析失败:%v", err)
  11247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11248. return
  11249. }
  11250. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11251. p, _ := service.GetHisPatientById(patient_id)
  11252. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  11253. var dat map[string]interface{}
  11254. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11255. fmt.Println(dat)
  11256. } else {
  11257. fmt.Println(err)
  11258. }
  11259. userJSONBytes, _ := json.Marshal(dat)
  11260. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11261. utils.ErrorLog("解析失败:%v", err)
  11262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11263. return
  11264. }
  11265. } else if miConfig.MdtrtareaAdmvs == "420200" {
  11266. p, _ := service.GetHisPatientById(patient_id)
  11267. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  11268. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11269. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11270. resp, requestErr := http.Get(api)
  11271. if requestErr != nil {
  11272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11273. return
  11274. }
  11275. body, ioErr := ioutil.ReadAll(resp.Body)
  11276. if ioErr != nil {
  11277. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11279. return
  11280. }
  11281. var respJSON map[string]interface{}
  11282. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11283. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11285. return
  11286. }
  11287. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11288. result, _ := json.Marshal(respJSON)
  11289. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11290. utils.ErrorLog("解析失败:%v", err)
  11291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11292. return
  11293. }
  11294. } else if miConfig.MdtrtareaAdmvs == "420902" {
  11295. p, _ := service.GetHisPatientById(patient_id)
  11296. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  11297. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11298. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11299. resp, requestErr := http.Get(api)
  11300. if requestErr != nil {
  11301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11302. return
  11303. }
  11304. body, ioErr := ioutil.ReadAll(resp.Body)
  11305. if ioErr != nil {
  11306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11308. return
  11309. }
  11310. var respJSON map[string]interface{}
  11311. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11314. return
  11315. }
  11316. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11317. result, _ := json.Marshal(respJSON)
  11318. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11319. utils.ErrorLog("解析失败:%v", err)
  11320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11321. return
  11322. }
  11323. } else if miConfig.MdtrtareaAdmvs == "421182" {
  11324. p, _ := service.GetHisPatientById(patient_id)
  11325. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  11326. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11327. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11328. resp, requestErr := http.Get(api)
  11329. if requestErr != nil {
  11330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11331. return
  11332. }
  11333. body, ioErr := ioutil.ReadAll(resp.Body)
  11334. if ioErr != nil {
  11335. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11337. return
  11338. }
  11339. var respJSON map[string]interface{}
  11340. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11341. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11343. return
  11344. }
  11345. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11346. result, _ := json.Marshal(respJSON)
  11347. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11348. utils.ErrorLog("解析失败:%v", err)
  11349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11350. return
  11351. }
  11352. } else if miConfig.MdtrtareaAdmvs == "420902" {
  11353. p, _ := service.GetHisPatientById(patient_id)
  11354. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  11355. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11356. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11357. resp, requestErr := http.Get(api)
  11358. if requestErr != nil {
  11359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11360. return
  11361. }
  11362. body, ioErr := ioutil.ReadAll(resp.Body)
  11363. if ioErr != nil {
  11364. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11366. return
  11367. }
  11368. var respJSON map[string]interface{}
  11369. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11370. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11372. return
  11373. }
  11374. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11375. result, _ := json.Marshal(respJSON)
  11376. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11377. utils.ErrorLog("解析失败:%v", err)
  11378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11379. return
  11380. }
  11381. } else if miConfig.MdtrtareaAdmvs == "421300" {
  11382. p, _ := service.GetHisPatientById(patient_id)
  11383. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  11384. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11385. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11386. resp, requestErr := http.Get(api)
  11387. if requestErr != nil {
  11388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11389. return
  11390. }
  11391. body, ioErr := ioutil.ReadAll(resp.Body)
  11392. if ioErr != nil {
  11393. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11395. return
  11396. }
  11397. var respJSON map[string]interface{}
  11398. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11401. return
  11402. }
  11403. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11404. result, _ := json.Marshal(respJSON)
  11405. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11406. utils.ErrorLog("解析失败:%v", err)
  11407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11408. return
  11409. }
  11410. } else if miConfig.MdtrtareaAdmvs == "441799" {
  11411. p, _ := service.GetHisPatientById(patient_id)
  11412. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  11413. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11414. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11415. resp, requestErr := http.Get(api)
  11416. if requestErr != nil {
  11417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11418. return
  11419. }
  11420. body, ioErr := ioutil.ReadAll(resp.Body)
  11421. if ioErr != nil {
  11422. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11424. return
  11425. }
  11426. var respJSON map[string]interface{}
  11427. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11428. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11430. return
  11431. }
  11432. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11433. result, _ := json.Marshal(respJSON)
  11434. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11435. utils.ErrorLog("解析失败:%v", err)
  11436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11437. return
  11438. }
  11439. } else {
  11440. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  11441. var dat map[string]interface{}
  11442. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11443. fmt.Println(dat)
  11444. } else {
  11445. fmt.Println(err)
  11446. }
  11447. userJSONBytes, _ := json.Marshal(dat)
  11448. if miConfig.Code == "H15049901371" {
  11449. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  11450. utils.ErrorLog("解析失败:%v", err)
  11451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11452. return
  11453. }
  11454. res.InfRefmsgid = res10265.InfRefmsgid
  11455. res.Output = res10265.Output
  11456. res.ErrMsg = res10265.ErrMsg
  11457. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11458. res.Infcode = infocode
  11459. } else {
  11460. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11461. utils.ErrorLog("解析失败:%v", err)
  11462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11463. return
  11464. }
  11465. }
  11466. }
  11467. if res.Infcode == 0 {
  11468. c.ServeSuccessJSON(map[string]interface{}{
  11469. "result": res.Output.Result,
  11470. })
  11471. }
  11472. }
  11473. func (c *HisApiController) CheckInsutype() {
  11474. his_patient_id, _ := c.GetInt64("his_patient_id")
  11475. admin_user_id, _ := c.GetInt64("admin_user_id")
  11476. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11477. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11478. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11479. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  11480. var dat map[string]interface{}
  11481. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11482. fmt.Println(dat)
  11483. } else {
  11484. fmt.Println(err)
  11485. }
  11486. userJSONBytes, _ := json.Marshal(dat)
  11487. var res Result90100
  11488. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11489. utils.ErrorLog("解析失败:%v", err)
  11490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11491. return
  11492. }
  11493. if res.Infcode != 0 {
  11494. c.ServeSuccessJSON(map[string]interface{}{
  11495. "failed_code": -10,
  11496. "msg": res.ErrMsg,
  11497. })
  11498. return
  11499. } else {
  11500. fmt.Println(res)
  11501. }
  11502. }
  11503. func (c *HisApiController) CheckCardPWD() {
  11504. card_pwd := c.GetString("card_pwd")
  11505. his_patient_id, _ := c.GetInt64("his_patient_id")
  11506. admin_user_id, _ := c.GetInt64("admin_user_id")
  11507. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11508. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11509. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11510. psn, _ := service.GetPsnByPatientId(his.PatientId)
  11511. bas := strings.Split(psn.CardInfo, "|")
  11512. basNumber := bas[2]
  11513. if psn.InsuplcAdmdvs[:4] == "4403" {
  11514. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  11515. var dat map[string]interface{}
  11516. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11517. fmt.Println(dat)
  11518. } else {
  11519. fmt.Println(err)
  11520. }
  11521. userJSONBytes, _ := json.Marshal(dat)
  11522. var res Result90991
  11523. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11524. utils.ErrorLog("解析失败:%v", err)
  11525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11526. return
  11527. }
  11528. if res.Infcode != 0 {
  11529. c.ServeSuccessJSON(map[string]interface{}{
  11530. "failed_code": -10,
  11531. "msg": res.ErrMsg,
  11532. })
  11533. return
  11534. } else {
  11535. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  11536. var msg string
  11537. switch res.Output.Result.CardStat {
  11538. case "00":
  11539. msg = "未激活"
  11540. break
  11541. case "10":
  11542. msg = "激活"
  11543. break
  11544. case "20":
  11545. msg = "窗口挂失"
  11546. break
  11547. case "21":
  11548. msg = "电话挂失"
  11549. break
  11550. case "22":
  11551. msg = "单位网上申报挂失"
  11552. break
  11553. case "23":
  11554. msg = "保健办挂失"
  11555. break
  11556. case "24":
  11557. msg = "个人网上挂失"
  11558. break
  11559. case "25":
  11560. msg = "网上服务大厅挂失"
  11561. break
  11562. case "30":
  11563. msg = "注销"
  11564. break
  11565. case "40":
  11566. msg = "回收"
  11567. break
  11568. case "99":
  11569. msg = "制卡中(无效卡)"
  11570. break
  11571. }
  11572. c.ServeSuccessJSON(map[string]interface{}{
  11573. "failed_code": -10,
  11574. "msg": msg,
  11575. })
  11576. return
  11577. } else {
  11578. c.ServeSuccessJSON(map[string]interface{}{
  11579. "msg": "校验成功",
  11580. })
  11581. return
  11582. }
  11583. }
  11584. } else {
  11585. c.ServeSuccessJSON(map[string]interface{}{
  11586. "msg": "校验成功",
  11587. })
  11588. return
  11589. }
  11590. }
  11591. func (c *HisApiController) CheckCardPWDTwo() {
  11592. //card_pwd := c.GetString("card_pwd")
  11593. //his_patient_id, _ := c.GetInt64("his_patient_id")
  11594. admin_user_id, _ := c.GetInt64("admin_user_id")
  11595. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11596. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11597. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  11598. var dat map[string]interface{}
  11599. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11600. fmt.Println(dat)
  11601. } else {
  11602. fmt.Println(err)
  11603. }
  11604. userJSONBytes, _ := json.Marshal(dat)
  11605. var res Result90991
  11606. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11607. utils.ErrorLog("解析失败:%v", err)
  11608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11609. return
  11610. }
  11611. if res.Infcode != 0 {
  11612. c.ServeSuccessJSON(map[string]interface{}{
  11613. "failed_code": -10,
  11614. "msg": res.ErrMsg,
  11615. })
  11616. return
  11617. } else {
  11618. if res.Output.Result.SscnoCheckStat == "0" {
  11619. var msg string
  11620. switch res.Output.Result.CardStat {
  11621. case "00":
  11622. msg = "未激活"
  11623. break
  11624. case "10":
  11625. msg = "激活"
  11626. break
  11627. case "20":
  11628. msg = "窗口挂失"
  11629. break
  11630. case "21":
  11631. msg = "电话挂失"
  11632. break
  11633. case "22":
  11634. msg = "单位网上申报挂失"
  11635. break
  11636. case "23":
  11637. msg = "保健办挂失"
  11638. break
  11639. case "24":
  11640. msg = "个人网上挂失"
  11641. break
  11642. case "25":
  11643. msg = "网上服务大厅挂失"
  11644. break
  11645. case "30":
  11646. msg = "注销"
  11647. break
  11648. case "40":
  11649. msg = "回收"
  11650. break
  11651. case "99":
  11652. msg = "制卡中(无效卡)"
  11653. break
  11654. }
  11655. c.ServeSuccessJSON(map[string]interface{}{
  11656. "failed_code": -10,
  11657. "msg": msg,
  11658. })
  11659. return
  11660. } else {
  11661. c.ServeSuccessJSON(map[string]interface{}{
  11662. "msg": "校验成功",
  11663. })
  11664. return
  11665. }
  11666. }
  11667. }
  11668. type ELeCertData struct {
  11669. Data struct {
  11670. Extra string `json:"extra"`
  11671. IDNo string `json:"idNo"`
  11672. IDType string `json:"idType"`
  11673. EcToken string `json:"ecToken"`
  11674. InsuOrg string `json:"insuOrg"`
  11675. UserName string `json:"userName"`
  11676. EcIndexNo string `json:"ecIndexNo"`
  11677. Gender string `json:"gender"`
  11678. Birthday string `json:"birthday"`
  11679. Nationality string `json:"nationality"`
  11680. Email string `json:"email"`
  11681. } `json:"OutData"`
  11682. }
  11683. func (c *HisApiController) ReadCard() {
  11684. id_card_type, _ := c.GetInt64("id_card_type")
  11685. admin_user_id, _ := c.GetInt64("admin_user_id")
  11686. certificates, _ := c.GetInt64("certificates")
  11687. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  11688. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11689. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11690. switch id_card_type {
  11691. case 1:
  11692. if miConfig.MdtrtareaAdmvs == "421300" {
  11693. var res ResultTwo
  11694. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  11695. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11696. "&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)
  11697. resp, requestErr := http.Get(api)
  11698. if requestErr != nil {
  11699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11700. return
  11701. }
  11702. body, ioErr := ioutil.ReadAll(resp.Body)
  11703. if ioErr != nil {
  11704. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11706. return
  11707. }
  11708. var respJSON map[string]interface{}
  11709. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11710. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11712. return
  11713. }
  11714. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11715. result, _ := json.Marshal(respJSON)
  11716. fmt.Println("log")
  11717. fmt.Println(string(result))
  11718. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11719. utils.ErrorLog("解析失败:%v", err)
  11720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11721. return
  11722. }
  11723. if res.Infcode == 0 {
  11724. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11725. if err == gorm.ErrRecordNotFound {
  11726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11727. return
  11728. } else if err != nil {
  11729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11730. return
  11731. } else {
  11732. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11733. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11734. infoStr := string(Iinfos)
  11735. idetinfoStr := string(Idetinfos)
  11736. var rf []*ResultFive
  11737. json.Unmarshal([]byte(infoStr), &rf)
  11738. var insutypes []*ResultFive
  11739. var insutype string
  11740. var is390 int = 0
  11741. var is310 int = 0
  11742. for _, item := range rf {
  11743. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  11744. insutypes = append(insutypes, item)
  11745. }
  11746. }
  11747. if len(insutypes) == 1 {
  11748. insutype = insutypes[0].Insutype
  11749. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11750. } else {
  11751. for _, i := range insutypes {
  11752. if i.Insutype == "390" {
  11753. is390 = 1
  11754. }
  11755. if i.Insutype == "310" {
  11756. is310 = 1
  11757. }
  11758. }
  11759. }
  11760. if is390 == 1 {
  11761. insutype = "390"
  11762. }
  11763. if is310 == 1 {
  11764. insutype = "310"
  11765. }
  11766. if len(insutypes) == 0 {
  11767. insutype = "390"
  11768. }
  11769. var insuplc_admdvs string
  11770. for _, item := range rf {
  11771. if item.Insutype == insutype {
  11772. insuplc_admdvs = item.InsuplcAdmdvs
  11773. }
  11774. }
  11775. if strings.Contains(insuplc_admdvs, "4213") {
  11776. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  11777. }
  11778. psn := &models.HisPsn{
  11779. PsnNo: res.Output.Baseinfo.PsnNo,
  11780. PatientId: patient.ID,
  11781. Certno: res.Output.Baseinfo.Certno,
  11782. Gend: res.Output.Baseinfo.Gend,
  11783. Naty: res.Output.Baseinfo.Naty,
  11784. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11785. PsnName: res.Output.Baseinfo.PsnName,
  11786. Idetinfo: idetinfoStr,
  11787. Insuinfo: infoStr,
  11788. InsuplcAdmdvs: insuplc_admdvs,
  11789. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11790. }
  11791. service.CreateHisPsn(psn)
  11792. c.ServeSuccessJSON(map[string]interface{}{
  11793. "patient": patient,
  11794. "number": res.Output.Baseinfo.Certno,
  11795. })
  11796. }
  11797. } else {
  11798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11799. return
  11800. }
  11801. } else if miConfig.MdtrtareaAdmvs == "420200" {
  11802. var res ResultTwo
  11803. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  11804. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11805. "&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)
  11806. resp, requestErr := http.Get(api)
  11807. if requestErr != nil {
  11808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11809. return
  11810. }
  11811. body, ioErr := ioutil.ReadAll(resp.Body)
  11812. if ioErr != nil {
  11813. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11815. return
  11816. }
  11817. var respJSON map[string]interface{}
  11818. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11819. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11821. return
  11822. }
  11823. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11824. result, _ := json.Marshal(respJSON)
  11825. fmt.Println("log")
  11826. fmt.Println(string(result))
  11827. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11828. utils.ErrorLog("解析失败:%v", err)
  11829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11830. return
  11831. }
  11832. if res.Infcode == 0 {
  11833. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11834. if err == gorm.ErrRecordNotFound {
  11835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11836. return
  11837. } else if err != nil {
  11838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11839. return
  11840. } else {
  11841. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11842. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11843. infoStr := string(Iinfos)
  11844. idetinfoStr := string(Idetinfos)
  11845. psn := &models.HisPsn{
  11846. PsnNo: res.Output.Baseinfo.PsnNo,
  11847. PatientId: patient.ID,
  11848. Certno: res.Output.Baseinfo.Certno,
  11849. Gend: res.Output.Baseinfo.Gend,
  11850. Naty: res.Output.Baseinfo.Naty,
  11851. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11852. PsnName: res.Output.Baseinfo.PsnName,
  11853. Idetinfo: idetinfoStr,
  11854. Insuinfo: infoStr,
  11855. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11856. }
  11857. service.CreateHisPsn(psn)
  11858. var rf []*ResultFive
  11859. json.Unmarshal([]byte(infoStr), &rf)
  11860. var insutypes []*ResultFive
  11861. var insutype string
  11862. var is390 int = 0
  11863. var is310 int = 0
  11864. for _, item := range rf {
  11865. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11866. insutypes = append(insutypes, item)
  11867. }
  11868. }
  11869. if len(insutypes) == 1 {
  11870. insutype = insutypes[0].Insutype
  11871. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11872. } else {
  11873. for _, i := range insutypes {
  11874. if i.Insutype == "390" {
  11875. is390 = 1
  11876. }
  11877. if i.Insutype == "310" {
  11878. is310 = 1
  11879. }
  11880. }
  11881. }
  11882. if is390 == 1 {
  11883. insutype = "390"
  11884. }
  11885. if is310 == 1 {
  11886. insutype = "310"
  11887. }
  11888. if len(insutypes) == 0 {
  11889. insutype = "310"
  11890. }
  11891. c.ServeSuccessJSON(map[string]interface{}{
  11892. "patient": patient,
  11893. "number": res.Output.Baseinfo.Certno,
  11894. "insutype": insutype,
  11895. })
  11896. }
  11897. } else {
  11898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11899. return
  11900. }
  11901. } else if miConfig.MdtrtareaAdmvs == "420902" {
  11902. var res ResultTwo
  11903. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  11904. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11905. "&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)
  11906. resp, requestErr := http.Get(api)
  11907. if requestErr != nil {
  11908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11909. return
  11910. }
  11911. body, ioErr := ioutil.ReadAll(resp.Body)
  11912. if ioErr != nil {
  11913. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11915. return
  11916. }
  11917. var respJSON map[string]interface{}
  11918. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11919. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11921. return
  11922. }
  11923. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11924. result, _ := json.Marshal(respJSON)
  11925. fmt.Println("log")
  11926. fmt.Println(string(result))
  11927. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11928. utils.ErrorLog("解析失败:%v", err)
  11929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11930. return
  11931. }
  11932. if res.Infcode == 0 {
  11933. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11934. if err == gorm.ErrRecordNotFound {
  11935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11936. return
  11937. } else if err != nil {
  11938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11939. return
  11940. } else {
  11941. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11942. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11943. infoStr := string(Iinfos)
  11944. idetinfoStr := string(Idetinfos)
  11945. var rf []*ResultFive
  11946. json.Unmarshal([]byte(infoStr), &rf)
  11947. var insutypes []*ResultFive
  11948. var insutype string
  11949. var is390 int = 0
  11950. var is310 int = 0
  11951. for _, item := range rf {
  11952. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  11953. insutypes = append(insutypes, item)
  11954. }
  11955. }
  11956. if len(insutypes) == 1 {
  11957. insutype = insutypes[0].Insutype
  11958. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11959. } else {
  11960. for _, i := range insutypes {
  11961. if i.Insutype == "390" {
  11962. is390 = 1
  11963. }
  11964. if i.Insutype == "310" {
  11965. is310 = 1
  11966. }
  11967. }
  11968. }
  11969. if is390 == 1 {
  11970. insutype = "390"
  11971. }
  11972. if is310 == 1 {
  11973. insutype = "310"
  11974. }
  11975. if len(insutypes) == 0 {
  11976. insutype = "390"
  11977. }
  11978. var insuplc_admdvs string
  11979. for _, item := range rf {
  11980. if item.Insutype == insutype {
  11981. insuplc_admdvs = item.InsuplcAdmdvs
  11982. }
  11983. }
  11984. psn := &models.HisPsn{
  11985. PsnNo: res.Output.Baseinfo.PsnNo,
  11986. PatientId: patient.ID,
  11987. Certno: res.Output.Baseinfo.Certno,
  11988. Gend: res.Output.Baseinfo.Gend,
  11989. Naty: res.Output.Baseinfo.Naty,
  11990. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11991. PsnName: res.Output.Baseinfo.PsnName,
  11992. Idetinfo: idetinfoStr,
  11993. Insuinfo: infoStr,
  11994. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11995. InsuplcAdmdvs: insuplc_admdvs,
  11996. }
  11997. service.CreateHisPsn(psn)
  11998. for _, item := range rf {
  11999. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12000. insutypes = append(insutypes, item)
  12001. }
  12002. }
  12003. if len(insutypes) == 1 {
  12004. insutype = insutypes[0].Insutype
  12005. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12006. } else {
  12007. for _, i := range insutypes {
  12008. if i.Insutype == "390" {
  12009. is390 = 1
  12010. }
  12011. if i.Insutype == "310" {
  12012. is310 = 1
  12013. }
  12014. }
  12015. }
  12016. if is390 == 1 {
  12017. insutype = "390"
  12018. }
  12019. if is310 == 1 {
  12020. insutype = "310"
  12021. }
  12022. if len(insutypes) == 0 {
  12023. insutype = "310"
  12024. }
  12025. c.ServeSuccessJSON(map[string]interface{}{
  12026. "patient": patient,
  12027. "number": res.Output.Baseinfo.Certno,
  12028. "insutype": insutype,
  12029. })
  12030. }
  12031. } else {
  12032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12033. return
  12034. }
  12035. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12036. var res ResultTwo
  12037. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  12038. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12039. "&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)
  12040. resp, requestErr := http.Get(api)
  12041. if requestErr != nil {
  12042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12043. return
  12044. }
  12045. body, ioErr := ioutil.ReadAll(resp.Body)
  12046. if ioErr != nil {
  12047. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12049. return
  12050. }
  12051. var respJSON map[string]interface{}
  12052. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12053. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12055. return
  12056. }
  12057. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12058. result, _ := json.Marshal(respJSON)
  12059. fmt.Println("log")
  12060. fmt.Println(string(result))
  12061. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12062. utils.ErrorLog("解析失败:%v", err)
  12063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12064. return
  12065. }
  12066. if res.Infcode == 0 {
  12067. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12068. if err == gorm.ErrRecordNotFound {
  12069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12070. return
  12071. } else if err != nil {
  12072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12073. return
  12074. } else {
  12075. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12076. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12077. infoStr := string(Iinfos)
  12078. idetinfoStr := string(Idetinfos)
  12079. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  12080. psn := &models.HisPsn{
  12081. PsnNo: res.Output.Baseinfo.PsnNo,
  12082. PatientId: patient.ID,
  12083. Certno: res.Output.Baseinfo.Certno,
  12084. Brdy: b,
  12085. Age: float64(age),
  12086. Gend: res.Output.Baseinfo.Gend,
  12087. Naty: res.Output.Baseinfo.Naty,
  12088. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12089. PsnName: res.Output.Baseinfo.PsnName,
  12090. Idetinfo: idetinfoStr,
  12091. Insuinfo: infoStr,
  12092. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12093. }
  12094. service.CreateHisPsn(psn)
  12095. var rf []*ResultFive
  12096. json.Unmarshal([]byte(infoStr), &rf)
  12097. var insutypes []*ResultFive
  12098. var insutype string
  12099. var is390 int = 0
  12100. var is310 int = 0
  12101. for _, item := range rf {
  12102. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12103. insutypes = append(insutypes, item)
  12104. }
  12105. }
  12106. if len(insutypes) == 1 {
  12107. insutype = insutypes[0].Insutype
  12108. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12109. } else {
  12110. for _, i := range insutypes {
  12111. if i.Insutype == "390" {
  12112. is390 = 1
  12113. }
  12114. if i.Insutype == "310" {
  12115. is310 = 1
  12116. }
  12117. }
  12118. }
  12119. if is390 == 1 {
  12120. insutype = "390"
  12121. }
  12122. if is310 == 1 {
  12123. insutype = "310"
  12124. }
  12125. if len(insutypes) == 0 {
  12126. insutype = "310"
  12127. }
  12128. c.ServeSuccessJSON(map[string]interface{}{
  12129. "patient": patient,
  12130. "number": res.Output.Baseinfo.Certno,
  12131. "insutype": insutype,
  12132. })
  12133. }
  12134. } else {
  12135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12136. return
  12137. }
  12138. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12139. var api string
  12140. if miConfig.MdtrtareaAdmvs == "320921" {
  12141. 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 +
  12142. "&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
  12143. fmt.Println(api)
  12144. } else {
  12145. 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 +
  12146. "&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)
  12147. }
  12148. resp, requestErr := http.Get(api)
  12149. if requestErr != nil {
  12150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12151. return
  12152. }
  12153. body, ioErr := ioutil.ReadAll(resp.Body)
  12154. if ioErr != nil {
  12155. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12157. return
  12158. }
  12159. var respJSON map[string]interface{}
  12160. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12161. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12163. return
  12164. }
  12165. var status string
  12166. status = respJSON["data"].(map[string]interface{})["status"].(string)
  12167. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  12168. //console.log()
  12169. fmt.Println("type===")
  12170. fmt.Println(card_type)
  12171. var token string
  12172. var res ResultTwo //1101结果
  12173. var res10265 ResultTwo10265 //1101结果
  12174. var card_info string //卡信息
  12175. var busi_card_info string
  12176. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  12177. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12178. if status == "0" { //读卡成功
  12179. if card_type == "1" {
  12180. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12181. result, _ := json.Marshal(respJSON)
  12182. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12183. utils.ErrorLog("解析失败:%v", err)
  12184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12185. return
  12186. }
  12187. res.ErrMsg = res10265.ErrMsg
  12188. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12189. res.Infcode = infocode
  12190. res.Output = res10265.Output
  12191. res.InfRefmsgid = res10265.InfRefmsgid
  12192. } else {
  12193. //var card_info string //卡信息
  12194. //var busi_card_info string
  12195. token = respJSON["data"].(map[string]interface{})["token"].(string)
  12196. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12197. //fmt.Println(card_info)
  12198. //fmt.Println(busi_card_info)
  12199. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12200. result, _ := json.Marshal(respJSON)
  12201. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12202. utils.ErrorLog("解析失败:%v", err)
  12203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12204. return
  12205. }
  12206. res.ErrMsg = res10265.ErrMsg
  12207. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12208. res.Infcode = infocode
  12209. res.Output = res10265.Output
  12210. res.InfRefmsgid = res10265.InfRefmsgid
  12211. }
  12212. if res.Infcode == 0 {
  12213. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12214. if err == gorm.ErrRecordNotFound {
  12215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12216. return
  12217. } else if err != nil {
  12218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12219. return
  12220. } else {
  12221. if card_type == "1" {
  12222. bas := strings.Split(card_info, "|")
  12223. basNumber := bas[2]
  12224. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12225. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12226. infoStr := string(Iinfos)
  12227. idetinfoStr := string(Idetinfos)
  12228. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  12229. psn := &models.HisPsn{
  12230. PsnNo: res.Output.Baseinfo.PsnNo,
  12231. PatientId: patient.ID,
  12232. Certno: res.Output.Baseinfo.Certno,
  12233. Brdy: b,
  12234. Age: float64(age),
  12235. Gend: res.Output.Baseinfo.Gend,
  12236. Naty: res.Output.Baseinfo.Naty,
  12237. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12238. PsnName: res.Output.Baseinfo.PsnName,
  12239. Idetinfo: idetinfoStr,
  12240. Insuinfo: infoStr,
  12241. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12242. CardInfo: card_info,
  12243. VerifyNumber: busi_card_info,
  12244. }
  12245. service.CreateHisPsn(psn)
  12246. var rf []*ResultFive
  12247. json.Unmarshal([]byte(infoStr), &rf)
  12248. var insutypes []*ResultFive
  12249. var insutype string
  12250. var is390 int = 0
  12251. var is310 int = 0
  12252. for _, item := range rf {
  12253. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12254. insutypes = append(insutypes, item)
  12255. }
  12256. }
  12257. if len(insutypes) == 1 {
  12258. insutype = insutypes[0].Insutype
  12259. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12260. } else {
  12261. for _, i := range insutypes {
  12262. if i.Insutype == "390" {
  12263. is390 = 1
  12264. }
  12265. if i.Insutype == "310" {
  12266. is310 = 1
  12267. }
  12268. }
  12269. }
  12270. if is390 == 1 {
  12271. insutype = "390"
  12272. }
  12273. if is310 == 1 {
  12274. insutype = "310"
  12275. }
  12276. if len(insutypes) == 0 {
  12277. insutype = "310"
  12278. }
  12279. c.ServeSuccessJSON(map[string]interface{}{
  12280. "patient": patient,
  12281. "number": basNumber,
  12282. "insutype": insutype,
  12283. })
  12284. } else {
  12285. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12286. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12287. infoStr := string(Iinfos)
  12288. idetinfoStr := string(Idetinfos)
  12289. psn := &models.HisPsn{
  12290. PsnNo: res.Output.Baseinfo.PsnNo,
  12291. PatientId: patient.ID,
  12292. Certno: res.Output.Baseinfo.Certno,
  12293. Gend: res.Output.Baseinfo.Gend,
  12294. Naty: res.Output.Baseinfo.Naty,
  12295. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12296. PsnName: res.Output.Baseinfo.PsnName,
  12297. Idetinfo: idetinfoStr,
  12298. Insuinfo: infoStr,
  12299. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12300. CardInfo: card_info,
  12301. VerifyNumber: token,
  12302. }
  12303. service.CreateHisPsn(psn)
  12304. c.ServeSuccessJSON(map[string]interface{}{
  12305. "patient": patient,
  12306. "number": token,
  12307. })
  12308. }
  12309. }
  12310. } else {
  12311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12312. return
  12313. }
  12314. } else { //读卡失败
  12315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12316. return
  12317. }
  12318. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12319. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  12320. cardnum = DeleteExtraSpaceTwo(cardnum)
  12321. cardCode = DeleteExtraSpaceTwo(cardCode)
  12322. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  12323. name = DeleteExtraSpaceTwo(name)
  12324. errmsg = DeleteExtraSpaceTwo(errmsg)
  12325. cardnum = Remove0000(cardnum)
  12326. cardCode = Remove0000(cardCode)
  12327. id_card_no = Remove0000(id_card_no)
  12328. name = Remove0000(name)
  12329. errmsg = Remove0000(errmsg)
  12330. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  12331. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  12332. //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)
  12333. //fmt.Println(result2)
  12334. //fmt.Println(requestLog2)
  12335. //fmt.Println(errMsgLog2)
  12336. 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)
  12337. saveLog(result, requestLog, "1101", "获取人员信息")
  12338. fmt.Println(errMsgLog)
  12339. if len(errMsgLog) > 0 {
  12340. } else {
  12341. var dat map[string]interface{}
  12342. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12343. fmt.Println(dat)
  12344. } else {
  12345. fmt.Println(err)
  12346. }
  12347. userJSONBytes, _ := json.Marshal(dat)
  12348. var res ResultTwo
  12349. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12350. utils.ErrorLog("解析失败:%v", err)
  12351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12352. return
  12353. }
  12354. res.ErrMsg = errMsgLog
  12355. if res.Infcode == 0 {
  12356. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12357. if err == gorm.ErrRecordNotFound {
  12358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12359. return
  12360. } else if err != nil {
  12361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12362. return
  12363. } else {
  12364. fmt.Println(res)
  12365. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12366. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12367. infoStr := string(Iinfos)
  12368. idetinfoStr := string(Idetinfos)
  12369. var rf []*ResultFive
  12370. json.Unmarshal([]byte(infoStr), &rf)
  12371. var insutypes []*ResultFive
  12372. var insutype string
  12373. var is390 int = 0
  12374. var is310 int = 0
  12375. for _, item := range rf {
  12376. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12377. insutypes = append(insutypes, item)
  12378. }
  12379. }
  12380. if len(insutypes) == 1 {
  12381. insutype = insutypes[0].Insutype
  12382. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12383. } else {
  12384. for _, i := range insutypes {
  12385. if i.Insutype == "390" {
  12386. is390 = 1
  12387. }
  12388. if i.Insutype == "310" {
  12389. is310 = 1
  12390. }
  12391. }
  12392. }
  12393. if is390 == 1 {
  12394. insutype = "390"
  12395. }
  12396. if is310 == 1 {
  12397. insutype = "310"
  12398. }
  12399. if len(insutypes) == 0 {
  12400. insutype = "390"
  12401. }
  12402. var insuplc_admdvs string
  12403. for _, item := range rf {
  12404. if item.Insutype == insutype {
  12405. insuplc_admdvs = item.InsuplcAdmdvs
  12406. }
  12407. }
  12408. psn := &models.HisPsn{
  12409. PsnNo: res.Output.Baseinfo.PsnNo,
  12410. PatientId: patient.ID,
  12411. Certno: res.Output.Baseinfo.Certno,
  12412. Gend: res.Output.Baseinfo.Gend,
  12413. Naty: res.Output.Baseinfo.Naty,
  12414. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12415. PsnName: res.Output.Baseinfo.PsnName,
  12416. Idetinfo: idetinfoStr,
  12417. Insuinfo: infoStr,
  12418. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12419. CardInfo: basStr,
  12420. VerifyNumber: "",
  12421. InsuplcAdmdvs: insuplc_admdvs,
  12422. }
  12423. service.CreateHisPsn(psn)
  12424. c.ServeSuccessJSON(map[string]interface{}{
  12425. "patient": patient,
  12426. "number": cardnum,
  12427. "insutype": insutype,
  12428. })
  12429. }
  12430. } else {
  12431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12432. return
  12433. }
  12434. }
  12435. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12436. fmt.Println(initFlag)
  12437. fmt.Println("initFlag")
  12438. if initFlag == 0 {
  12439. c.TestGetJiangXiBasBaseInit()
  12440. }
  12441. basStr := c.GetBasBaseInfo()
  12442. if len(basStr) == 0 {
  12443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  12444. return
  12445. }
  12446. fmt.Println(basStr)
  12447. bas := strings.Split(basStr, "|")
  12448. basNumber := bas[1]
  12449. fmt.Println(basNumber)
  12450. card_sn := bas[3]
  12451. fmt.Println(card_sn)
  12452. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  12453. 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)
  12454. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  12455. var dat map[string]interface{}
  12456. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12457. fmt.Println(dat)
  12458. } else {
  12459. fmt.Println(err)
  12460. }
  12461. userJSONBytes, _ := json.Marshal(dat)
  12462. var res ResultTwo
  12463. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12464. utils.ErrorLog("解析失败:%v", err)
  12465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12466. return
  12467. }
  12468. if res.Infcode == 0 {
  12469. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  12470. if err == gorm.ErrRecordNotFound {
  12471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12472. return
  12473. } else if err != nil {
  12474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12475. return
  12476. } else {
  12477. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12478. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12479. infoStr := string(Iinfos)
  12480. idetinfoStr := string(Idetinfos)
  12481. var rf []*ResultFive
  12482. json.Unmarshal([]byte(infoStr), &rf)
  12483. var insutypes []*ResultFive
  12484. var insutype string
  12485. var is390 int = 0
  12486. var is310 int = 0
  12487. var insuplc_admdvs string
  12488. for _, item := range rf {
  12489. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12490. insutypes = append(insutypes, item)
  12491. }
  12492. }
  12493. if len(insutypes) == 1 {
  12494. insutype = insutypes[0].Insutype
  12495. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12496. } else {
  12497. for _, i := range insutypes {
  12498. if i.Insutype == "390" {
  12499. is390 = 1
  12500. }
  12501. if i.Insutype == "310" {
  12502. is310 = 1
  12503. }
  12504. }
  12505. }
  12506. if is390 == 1 {
  12507. insutype = "390"
  12508. }
  12509. if is310 == 1 {
  12510. insutype = "310"
  12511. }
  12512. if len(insutypes) == 0 {
  12513. insutype = "310"
  12514. }
  12515. for _, item := range rf {
  12516. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  12517. insuplc_admdvs = item.InsuplcAdmdvs
  12518. }
  12519. }
  12520. psn := &models.HisPsn{
  12521. PsnNo: res.Output.Baseinfo.PsnNo,
  12522. PatientId: patient.ID,
  12523. Certno: res.Output.Baseinfo.Certno,
  12524. Gend: res.Output.Baseinfo.Gend,
  12525. Naty: res.Output.Baseinfo.Naty,
  12526. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12527. PsnName: res.Output.Baseinfo.PsnName,
  12528. Idetinfo: idetinfoStr,
  12529. Insuinfo: infoStr,
  12530. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12531. CardInfo: basStr,
  12532. InsuplcAdmdvs: insuplc_admdvs,
  12533. VerifyNumber: "",
  12534. }
  12535. service.CreateHisPsn(psn)
  12536. c.ServeSuccessJSON(map[string]interface{}{
  12537. "patient": patient,
  12538. "number": basNumber,
  12539. "insutype": insutype,
  12540. })
  12541. }
  12542. } else {
  12543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12544. return
  12545. }
  12546. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12547. fmt.Println(initFlag)
  12548. fmt.Println("initFlag")
  12549. if initFlag == 0 {
  12550. c.TestGetHnBasBaseInit()
  12551. }
  12552. basStr := c.GetBasBaseInfo()
  12553. if len(basStr) == 0 {
  12554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  12555. return
  12556. }
  12557. fmt.Println(basStr)
  12558. bas := strings.Split(basStr, "|")
  12559. basNumber := bas[1]
  12560. fmt.Println(basNumber)
  12561. card_sn := bas[3]
  12562. card_no := bas[2]
  12563. fmt.Println(card_sn)
  12564. name := bas[4]
  12565. name = ConvertToString(name, "gbk", "utf-8")
  12566. 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)
  12567. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  12568. var dat map[string]interface{}
  12569. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12570. fmt.Println(dat)
  12571. } else {
  12572. fmt.Println(err)
  12573. }
  12574. userJSONBytes, _ := json.Marshal(dat)
  12575. var res ResultTwo
  12576. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12577. utils.ErrorLog("解析失败:%v", err)
  12578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12579. return
  12580. }
  12581. if res.Infcode == 0 {
  12582. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  12583. if err == gorm.ErrRecordNotFound {
  12584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12585. return
  12586. } else if err != nil {
  12587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12588. return
  12589. } else {
  12590. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12591. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12592. infoStr := string(Iinfos)
  12593. idetinfoStr := string(Idetinfos)
  12594. psn := &models.HisPsn{
  12595. PsnNo: res.Output.Baseinfo.PsnNo,
  12596. PatientId: patient.ID,
  12597. Certno: res.Output.Baseinfo.Certno,
  12598. Gend: res.Output.Baseinfo.Gend,
  12599. Naty: res.Output.Baseinfo.Naty,
  12600. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12601. PsnName: res.Output.Baseinfo.PsnName,
  12602. Idetinfo: idetinfoStr,
  12603. Insuinfo: infoStr,
  12604. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12605. CardInfo: basStr,
  12606. VerifyNumber: "",
  12607. }
  12608. service.CreateHisPsn(psn)
  12609. var rf []*ResultFive
  12610. json.Unmarshal([]byte(infoStr), &rf)
  12611. var insutypes []*ResultFive
  12612. var insutype string
  12613. var is390 int = 0
  12614. var is310 int = 0
  12615. for _, item := range rf {
  12616. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12617. insutypes = append(insutypes, item)
  12618. }
  12619. }
  12620. if len(insutypes) == 1 {
  12621. insutype = insutypes[0].Insutype
  12622. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12623. } else {
  12624. for _, i := range insutypes {
  12625. if i.Insutype == "390" {
  12626. is390 = 1
  12627. }
  12628. if i.Insutype == "310" {
  12629. is310 = 1
  12630. }
  12631. }
  12632. }
  12633. if is390 == 1 {
  12634. insutype = "390"
  12635. }
  12636. if is310 == 1 {
  12637. insutype = "310"
  12638. }
  12639. if len(insutypes) == 0 {
  12640. insutype = "310"
  12641. }
  12642. c.ServeSuccessJSON(map[string]interface{}{
  12643. "patient": patient,
  12644. "number": basNumber,
  12645. "insutype": insutype,
  12646. })
  12647. }
  12648. } else {
  12649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12650. return
  12651. }
  12652. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12653. var api string
  12654. 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 +
  12655. "&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
  12656. fmt.Println(api)
  12657. resp, requestErr := http.Get(api)
  12658. if requestErr != nil {
  12659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12660. return
  12661. }
  12662. body, ioErr := ioutil.ReadAll(resp.Body)
  12663. if ioErr != nil {
  12664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12666. return
  12667. }
  12668. var respJSON map[string]interface{}
  12669. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12670. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12672. return
  12673. }
  12674. var res ResultTwo //1101结果
  12675. var res10265 ResultTwo10265 //1101结果
  12676. var card_info string //卡信息
  12677. token := respJSON["data"].(map[string]interface{})["token"].(string)
  12678. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12679. result, _ := json.Marshal(respJSON)
  12680. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12681. utils.ErrorLog("解析失败:%v", err)
  12682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12683. return
  12684. }
  12685. res.ErrMsg = res10265.ErrMsg
  12686. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12687. res.Infcode = infocode
  12688. res.Output = res10265.Output
  12689. res.InfRefmsgid = res10265.InfRefmsgid
  12690. if res.Infcode == 0 {
  12691. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12692. if err == gorm.ErrRecordNotFound {
  12693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12694. return
  12695. } else if err != nil {
  12696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12697. return
  12698. } else {
  12699. bas := strings.Split(card_info, "|")
  12700. basNumber := bas[2]
  12701. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12702. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12703. infoStr := string(Iinfos)
  12704. idetinfoStr := string(Idetinfos)
  12705. psn := &models.HisPsn{
  12706. PsnNo: res.Output.Baseinfo.PsnNo,
  12707. PatientId: patient.ID,
  12708. Certno: res.Output.Baseinfo.Certno,
  12709. Gend: res.Output.Baseinfo.Gend,
  12710. Naty: res.Output.Baseinfo.Naty,
  12711. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12712. PsnName: res.Output.Baseinfo.PsnName,
  12713. Idetinfo: idetinfoStr,
  12714. Insuinfo: infoStr,
  12715. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12716. CardInfo: card_info,
  12717. VerifyNumber: token,
  12718. }
  12719. service.CreateHisPsn(psn)
  12720. var rf []*ResultFive
  12721. json.Unmarshal([]byte(infoStr), &rf)
  12722. var insutypes []*ResultFive
  12723. var insutype string
  12724. var is390 int = 0
  12725. var is310 int = 0
  12726. for _, item := range rf {
  12727. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12728. insutypes = append(insutypes, item)
  12729. }
  12730. }
  12731. if len(insutypes) == 1 {
  12732. insutype = insutypes[0].Insutype
  12733. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12734. } else {
  12735. for _, i := range insutypes {
  12736. if i.Insutype == "390" {
  12737. is390 = 1
  12738. }
  12739. if i.Insutype == "310" {
  12740. is310 = 1
  12741. }
  12742. }
  12743. }
  12744. if is390 == 1 {
  12745. insutype = "390"
  12746. }
  12747. if is310 == 1 {
  12748. insutype = "310"
  12749. }
  12750. if len(insutypes) == 0 {
  12751. insutype = "310"
  12752. }
  12753. c.ServeSuccessJSON(map[string]interface{}{
  12754. "patient": patient,
  12755. "number": basNumber,
  12756. "insutype": insutype,
  12757. })
  12758. }
  12759. } else {
  12760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12761. return
  12762. }
  12763. } else if miConfig.MdtrtareaAdmvs == "450721" {
  12764. res := c.GetoleInfo()
  12765. if res.Infcode == 0 {
  12766. var result string
  12767. if res.Output.MdtrtCertType == "01" {
  12768. 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)
  12769. } else if res.Output.MdtrtCertType == "02" {
  12770. 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)
  12771. } else if res.Output.MdtrtCertType == "03" {
  12772. 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)
  12773. }
  12774. var dat map[string]interface{}
  12775. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12776. fmt.Println(dat)
  12777. } else {
  12778. fmt.Println(err)
  12779. }
  12780. userJSONBytes, _ := json.Marshal(dat)
  12781. var res2 ResultTwo
  12782. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12783. utils.ErrorLog("解析失败:%v", err)
  12784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12785. return
  12786. }
  12787. if res2.Infcode == 0 {
  12788. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  12789. if err == gorm.ErrRecordNotFound {
  12790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12791. return
  12792. } else if err != nil {
  12793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12794. return
  12795. } else {
  12796. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  12797. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  12798. infoStr := string(Iinfos)
  12799. idetinfoStr := string(Idetinfos)
  12800. var rf []*ResultFive
  12801. json.Unmarshal([]byte(infoStr), &rf)
  12802. var insutypes []*ResultFive
  12803. var insutype string
  12804. var is390 int = 0
  12805. var is310 int = 0
  12806. //var insuplc_admdvs string
  12807. for _, item := range rf {
  12808. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12809. insutypes = append(insutypes, item)
  12810. }
  12811. }
  12812. if len(insutypes) == 1 {
  12813. insutype = insutypes[0].Insutype
  12814. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12815. } else {
  12816. for _, i := range insutypes {
  12817. if i.Insutype == "390" {
  12818. is390 = 1
  12819. }
  12820. if i.Insutype == "310" {
  12821. is310 = 1
  12822. }
  12823. }
  12824. }
  12825. if is390 == 1 {
  12826. insutype = "390"
  12827. }
  12828. if is310 == 1 {
  12829. insutype = "310"
  12830. }
  12831. if len(insutypes) == 0 {
  12832. insutype = "310"
  12833. }
  12834. psn := &models.HisPsn{
  12835. PsnNo: res2.Output.Baseinfo.PsnNo,
  12836. PatientId: patient.ID,
  12837. Certno: res2.Output.Baseinfo.Certno,
  12838. Gend: res2.Output.Baseinfo.Gend,
  12839. Naty: res2.Output.Baseinfo.Naty,
  12840. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  12841. PsnName: res2.Output.Baseinfo.PsnName,
  12842. Idetinfo: idetinfoStr,
  12843. Insuinfo: infoStr,
  12844. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12845. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  12846. VerifyNumber: res.Output.EcToken,
  12847. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  12848. }
  12849. if res.Output.MdtrtCertType == "01" {
  12850. psn.VerifyNumber = res.Output.EcToken
  12851. //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)
  12852. } else if res.Output.MdtrtCertType == "02" {
  12853. psn.VerifyNumber = res.Output.MdtrtCertNo
  12854. //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)
  12855. } else if res.Output.MdtrtCertType == "03" {
  12856. psn.VerifyNumber = res.Output.MdtrtCertNo
  12857. //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)
  12858. }
  12859. var balc float64
  12860. for _, item := range rf {
  12861. if item.Insutype == insutype {
  12862. balc = item.Balc
  12863. }
  12864. }
  12865. service.CreateHisPsn(psn)
  12866. c.ServeSuccessJSON(map[string]interface{}{
  12867. "patient": patient,
  12868. "number": res.Output.CardNo,
  12869. "insutype": insutype,
  12870. "blac": balc,
  12871. "desc": idetinfoStr,
  12872. })
  12873. }
  12874. } else {
  12875. c.ServeSuccessJSON(map[string]interface{}{
  12876. "failed_code": -10,
  12877. "msg": res2.ErrMsg,
  12878. })
  12879. }
  12880. } else {
  12881. c.ServeSuccessJSON(map[string]interface{}{
  12882. "failed_code": -10,
  12883. "msg": res.ErrMsg,
  12884. })
  12885. }
  12886. } else if miConfig.MdtrtareaAdmvs == "341203" {
  12887. var api string
  12888. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  12889. "&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
  12890. fmt.Println(api)
  12891. resp, requestErr := http.Get(api)
  12892. if requestErr != nil {
  12893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12894. return
  12895. }
  12896. body, ioErr := ioutil.ReadAll(resp.Body)
  12897. if ioErr != nil {
  12898. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12900. return
  12901. }
  12902. var respJSON map[string]interface{}
  12903. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12904. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12906. return
  12907. }
  12908. var status string
  12909. status = respJSON["data"].(map[string]interface{})["status"].(string)
  12910. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  12911. //console.log()
  12912. fmt.Println("type===")
  12913. fmt.Println(card_type)
  12914. var token string
  12915. var res ResultTwo //1101结果
  12916. //var res10265 ResultTwoesultTwo10265 //1101结果
  12917. var card_info string //卡信息
  12918. var busi_card_info string
  12919. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  12920. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12921. if status == "0" { //读卡成功
  12922. if card_type == "1" {
  12923. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12924. result, _ := json.Marshal(respJSON)
  12925. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12926. utils.ErrorLog("解析失败:%v", err)
  12927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12928. return
  12929. }
  12930. } else {
  12931. token = respJSON["data"].(map[string]interface{})["token"].(string)
  12932. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12933. result, _ := json.Marshal(respJSON)
  12934. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12935. utils.ErrorLog("解析失败:%v", err)
  12936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12937. return
  12938. }
  12939. }
  12940. if res.Infcode == 0 {
  12941. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12942. if err == gorm.ErrRecordNotFound {
  12943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12944. return
  12945. } else if err != nil {
  12946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12947. return
  12948. } else {
  12949. if card_type == "1" {
  12950. bas := strings.Split(card_info, "|")
  12951. basNumber := bas[2]
  12952. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12953. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12954. infoStr := string(Iinfos)
  12955. idetinfoStr := string(Idetinfos)
  12956. psn := &models.HisPsn{
  12957. PsnNo: res.Output.Baseinfo.PsnNo,
  12958. PatientId: patient.ID,
  12959. Certno: res.Output.Baseinfo.Certno,
  12960. Gend: res.Output.Baseinfo.Gend,
  12961. Naty: res.Output.Baseinfo.Naty,
  12962. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12963. PsnName: res.Output.Baseinfo.PsnName,
  12964. Idetinfo: idetinfoStr,
  12965. Insuinfo: infoStr,
  12966. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12967. CardInfo: card_info,
  12968. VerifyNumber: busi_card_info,
  12969. }
  12970. service.CreateHisPsn(psn)
  12971. var rf []*ResultFive
  12972. json.Unmarshal([]byte(infoStr), &rf)
  12973. var insutypes []*ResultFive
  12974. var insutype string
  12975. var is390 int = 0
  12976. var is310 int = 0
  12977. for _, item := range rf {
  12978. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12979. insutypes = append(insutypes, item)
  12980. }
  12981. }
  12982. if len(insutypes) == 1 {
  12983. insutype = insutypes[0].Insutype
  12984. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12985. } else {
  12986. for _, i := range insutypes {
  12987. if i.Insutype == "390" {
  12988. is390 = 1
  12989. }
  12990. if i.Insutype == "310" {
  12991. is310 = 1
  12992. }
  12993. }
  12994. }
  12995. if is390 == 1 {
  12996. insutype = "390"
  12997. }
  12998. if is310 == 1 {
  12999. insutype = "310"
  13000. }
  13001. if len(insutypes) == 0 {
  13002. insutype = "310"
  13003. }
  13004. c.ServeSuccessJSON(map[string]interface{}{
  13005. "patient": patient,
  13006. "number": basNumber,
  13007. "insutype": insutype,
  13008. })
  13009. } else {
  13010. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13011. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13012. infoStr := string(Iinfos)
  13013. idetinfoStr := string(Idetinfos)
  13014. psn := &models.HisPsn{
  13015. PsnNo: res.Output.Baseinfo.PsnNo,
  13016. PatientId: patient.ID,
  13017. Certno: res.Output.Baseinfo.Certno,
  13018. Gend: res.Output.Baseinfo.Gend,
  13019. Naty: res.Output.Baseinfo.Naty,
  13020. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13021. PsnName: res.Output.Baseinfo.PsnName,
  13022. Idetinfo: idetinfoStr,
  13023. Insuinfo: infoStr,
  13024. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13025. CardInfo: card_info,
  13026. VerifyNumber: token,
  13027. }
  13028. service.CreateHisPsn(psn)
  13029. c.ServeSuccessJSON(map[string]interface{}{
  13030. "patient": patient,
  13031. "number": token,
  13032. })
  13033. }
  13034. }
  13035. } else {
  13036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13037. return
  13038. }
  13039. } else { //读卡失败
  13040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13041. return
  13042. }
  13043. } else {
  13044. if initFlag == 0 {
  13045. c.TestGetBasBaseInit()
  13046. }
  13047. basStr := c.GetBasBaseInfo()
  13048. if len(basStr) == 0 {
  13049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13050. return
  13051. }
  13052. fmt.Println(basStr)
  13053. bas := strings.Split(basStr, "|")
  13054. basNumber := bas[1]
  13055. fmt.Println(basNumber)
  13056. card_sn := bas[3]
  13057. fmt.Println(card_sn)
  13058. cardNumber := bas[2]
  13059. fmt.Println(cardNumber)
  13060. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  13061. var result string
  13062. if bas[0][:2] == "44" {
  13063. 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)
  13064. } else {
  13065. 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)
  13066. }
  13067. var dat map[string]interface{}
  13068. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13069. fmt.Println(dat)
  13070. } else {
  13071. fmt.Println(err)
  13072. }
  13073. userJSONBytes, _ := json.Marshal(dat)
  13074. var res ResultTwo
  13075. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13076. utils.ErrorLog("解析失败:%v", err)
  13077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13078. return
  13079. }
  13080. if res.Infcode == 0 {
  13081. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13082. if err == gorm.ErrRecordNotFound {
  13083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13084. return
  13085. } else if err != nil {
  13086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13087. return
  13088. } else {
  13089. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13090. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13091. infoStr := string(Iinfos)
  13092. idetinfoStr := string(Idetinfos)
  13093. var rf []*ResultFive
  13094. json.Unmarshal([]byte(infoStr), &rf)
  13095. var insutypes []*ResultFive
  13096. var insutype string
  13097. var is390 int = 0
  13098. var is310 int = 0
  13099. var insuplc_admdvs string
  13100. for _, item := range rf {
  13101. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13102. insutypes = append(insutypes, item)
  13103. }
  13104. }
  13105. if len(insutypes) == 1 {
  13106. insutype = insutypes[0].Insutype
  13107. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13108. } else {
  13109. for _, i := range insutypes {
  13110. if i.Insutype == "390" {
  13111. is390 = 1
  13112. }
  13113. if i.Insutype == "310" {
  13114. is310 = 1
  13115. }
  13116. }
  13117. }
  13118. if is390 == 1 {
  13119. insutype = "390"
  13120. }
  13121. if is310 == 1 {
  13122. insutype = "310"
  13123. }
  13124. if len(insutypes) == 0 {
  13125. insutype = "310"
  13126. }
  13127. for _, item := range rf {
  13128. if item.Insutype == insutype {
  13129. insuplc_admdvs = item.InsuplcAdmdvs
  13130. }
  13131. }
  13132. psn := &models.HisPsn{
  13133. PsnNo: res.Output.Baseinfo.PsnNo,
  13134. PatientId: patient.ID,
  13135. Certno: res.Output.Baseinfo.Certno,
  13136. Gend: res.Output.Baseinfo.Gend,
  13137. Naty: res.Output.Baseinfo.Naty,
  13138. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13139. PsnName: res.Output.Baseinfo.PsnName,
  13140. Idetinfo: idetinfoStr,
  13141. Insuinfo: infoStr,
  13142. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13143. CardInfo: basStr,
  13144. VerifyNumber: "",
  13145. InsuplcAdmdvs: insuplc_admdvs,
  13146. }
  13147. service.CreateHisPsn(psn)
  13148. c.ServeSuccessJSON(map[string]interface{}{
  13149. "patient": patient,
  13150. "number": basNumber,
  13151. })
  13152. }
  13153. } else {
  13154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13155. return
  13156. }
  13157. break
  13158. }
  13159. case 2:
  13160. if miConfig.MdtrtareaAdmvs == "430800" {
  13161. if initFlag == 0 {
  13162. c.TestGetHnBasBaseInit()
  13163. }
  13164. SFZStr := c.GetSFZBaseInfo()
  13165. if len(SFZStr) == 0 {
  13166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13167. return
  13168. }
  13169. fmt.Println(SFZStr)
  13170. id_card_str := strings.Split(SFZStr, "^")
  13171. card_no := id_card_str[0]
  13172. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  13173. //name := id_card_str[1]
  13174. //name = ConvertToString(name, "gbk", "utf-8")
  13175. 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)
  13176. var dat map[string]interface{}
  13177. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13178. fmt.Println(dat)
  13179. } else {
  13180. fmt.Println(err)
  13181. }
  13182. userJSONBytes, _ := json.Marshal(dat)
  13183. var res ResultTwo
  13184. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13185. utils.ErrorLog("解析失败:%v", err)
  13186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13187. return
  13188. }
  13189. if res.Infcode == 0 {
  13190. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  13191. if err == gorm.ErrRecordNotFound {
  13192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13193. return
  13194. } else if err != nil {
  13195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13196. return
  13197. } else {
  13198. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13199. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13200. infoStr := string(Iinfos)
  13201. idetinfoStr := string(Idetinfos)
  13202. var rf []*ResultFive
  13203. json.Unmarshal([]byte(infoStr), &rf)
  13204. var insutypes []*ResultFive
  13205. var insutype string
  13206. var is390 int = 0
  13207. var is310 int = 0
  13208. for _, item := range rf {
  13209. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13210. insutypes = append(insutypes, item)
  13211. }
  13212. }
  13213. if len(insutypes) == 1 {
  13214. insutype = insutypes[0].Insutype
  13215. } else {
  13216. for _, i := range insutypes {
  13217. if i.Insutype == "390" {
  13218. is390 = 1
  13219. }
  13220. if i.Insutype == "310" {
  13221. is310 = 1
  13222. }
  13223. }
  13224. }
  13225. if is390 == 1 {
  13226. insutype = "390"
  13227. }
  13228. if is310 == 1 {
  13229. insutype = "310"
  13230. }
  13231. if len(insutypes) == 0 {
  13232. insutype = "310"
  13233. }
  13234. var InsuplcAdmdvs string
  13235. for _, item := range rf {
  13236. if item.Insutype == insutype {
  13237. InsuplcAdmdvs = item.InsuplcAdmdvs
  13238. }
  13239. }
  13240. psn := &models.HisPsn{
  13241. PsnNo: res.Output.Baseinfo.PsnNo,
  13242. PatientId: patient.ID,
  13243. Certno: res.Output.Baseinfo.Certno,
  13244. Gend: res.Output.Baseinfo.Gend,
  13245. Naty: res.Output.Baseinfo.Naty,
  13246. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13247. PsnName: res.Output.Baseinfo.PsnName,
  13248. Idetinfo: idetinfoStr,
  13249. Insuinfo: infoStr,
  13250. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13251. CardInfo: SFZStr,
  13252. VerifyNumber: "",
  13253. InsuplcAdmdvs: InsuplcAdmdvs,
  13254. }
  13255. service.CreateHisPsn(psn)
  13256. c.ServeSuccessJSON(map[string]interface{}{
  13257. "patient": patient,
  13258. "number": card_no,
  13259. "insutype": insutype,
  13260. })
  13261. }
  13262. } else {
  13263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13264. return
  13265. }
  13266. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13267. var res ResultTwo
  13268. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  13269. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13270. "&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)
  13271. resp, requestErr := http.Get(api)
  13272. if requestErr != nil {
  13273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13274. return
  13275. }
  13276. body, ioErr := ioutil.ReadAll(resp.Body)
  13277. if ioErr != nil {
  13278. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13280. return
  13281. }
  13282. var respJSON map[string]interface{}
  13283. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13284. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13286. return
  13287. }
  13288. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13289. result, _ := json.Marshal(respJSON)
  13290. fmt.Println("log")
  13291. fmt.Println(string(result))
  13292. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13293. utils.ErrorLog("解析失败:%v", err)
  13294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13295. return
  13296. }
  13297. if res.Infcode == 0 {
  13298. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13299. if err == gorm.ErrRecordNotFound {
  13300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13301. return
  13302. } else if err != nil {
  13303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13304. return
  13305. } else {
  13306. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13307. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13308. infoStr := string(Iinfos)
  13309. idetinfoStr := string(Idetinfos)
  13310. psn := &models.HisPsn{
  13311. PsnNo: res.Output.Baseinfo.PsnNo,
  13312. PatientId: patient.ID,
  13313. Certno: res.Output.Baseinfo.Certno,
  13314. Gend: res.Output.Baseinfo.Gend,
  13315. Naty: res.Output.Baseinfo.Naty,
  13316. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13317. PsnName: res.Output.Baseinfo.PsnName,
  13318. Idetinfo: idetinfoStr,
  13319. Insuinfo: infoStr,
  13320. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13321. }
  13322. service.CreateHisPsn(psn)
  13323. c.ServeSuccessJSON(map[string]interface{}{
  13324. "patient": patient,
  13325. "number": res.Output.Baseinfo.Certno,
  13326. })
  13327. }
  13328. } else {
  13329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13330. return
  13331. }
  13332. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13333. var res ResultTwo
  13334. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13335. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13336. "&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)
  13337. resp, requestErr := http.Get(api)
  13338. if requestErr != nil {
  13339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13340. return
  13341. }
  13342. body, ioErr := ioutil.ReadAll(resp.Body)
  13343. if ioErr != nil {
  13344. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13346. return
  13347. }
  13348. var respJSON map[string]interface{}
  13349. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13352. return
  13353. }
  13354. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13355. result, _ := json.Marshal(respJSON)
  13356. fmt.Println("log")
  13357. fmt.Println(string(result))
  13358. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13359. utils.ErrorLog("解析失败:%v", err)
  13360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13361. return
  13362. }
  13363. if res.Infcode == 0 {
  13364. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13365. if err == gorm.ErrRecordNotFound {
  13366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13367. return
  13368. } else if err != nil {
  13369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13370. return
  13371. } else {
  13372. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13373. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13374. infoStr := string(Iinfos)
  13375. idetinfoStr := string(Idetinfos)
  13376. psn := &models.HisPsn{
  13377. PsnNo: res.Output.Baseinfo.PsnNo,
  13378. PatientId: patient.ID,
  13379. Certno: res.Output.Baseinfo.Certno,
  13380. Gend: res.Output.Baseinfo.Gend,
  13381. Naty: res.Output.Baseinfo.Naty,
  13382. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13383. PsnName: res.Output.Baseinfo.PsnName,
  13384. Idetinfo: idetinfoStr,
  13385. Insuinfo: infoStr,
  13386. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13387. }
  13388. service.CreateHisPsn(psn)
  13389. c.ServeSuccessJSON(map[string]interface{}{
  13390. "patient": patient,
  13391. "number": res.Output.Baseinfo.Certno,
  13392. })
  13393. }
  13394. } else {
  13395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13396. return
  13397. }
  13398. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13399. var res ResultTwo
  13400. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13401. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13402. "&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)
  13403. resp, requestErr := http.Get(api)
  13404. if requestErr != nil {
  13405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13406. return
  13407. }
  13408. body, ioErr := ioutil.ReadAll(resp.Body)
  13409. if ioErr != nil {
  13410. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13412. return
  13413. }
  13414. var respJSON map[string]interface{}
  13415. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13416. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13418. return
  13419. }
  13420. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13421. result, _ := json.Marshal(respJSON)
  13422. fmt.Println("log")
  13423. fmt.Println(string(result))
  13424. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13425. utils.ErrorLog("解析失败:%v", err)
  13426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13427. return
  13428. }
  13429. if res.Infcode == 0 {
  13430. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13431. if err == gorm.ErrRecordNotFound {
  13432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13433. return
  13434. } else if err != nil {
  13435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13436. return
  13437. } else {
  13438. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13439. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13440. infoStr := string(Iinfos)
  13441. idetinfoStr := string(Idetinfos)
  13442. var rf []*ResultFive
  13443. json.Unmarshal([]byte(infoStr), &rf)
  13444. var insutypes []*ResultFive
  13445. var insutype string
  13446. var is390 int = 0
  13447. var is310 int = 0
  13448. for _, item := range rf {
  13449. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13450. insutypes = append(insutypes, item)
  13451. }
  13452. }
  13453. if len(insutypes) == 1 {
  13454. insutype = insutypes[0].Insutype
  13455. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13456. } else {
  13457. for _, i := range insutypes {
  13458. if i.Insutype == "390" {
  13459. is390 = 1
  13460. }
  13461. if i.Insutype == "310" {
  13462. is310 = 1
  13463. }
  13464. }
  13465. }
  13466. if is390 == 1 {
  13467. insutype = "390"
  13468. }
  13469. if is310 == 1 {
  13470. insutype = "310"
  13471. }
  13472. if len(insutypes) == 0 {
  13473. insutype = "390"
  13474. }
  13475. var insuplc_admdvs string
  13476. for _, item := range rf {
  13477. if item.Insutype == insutype {
  13478. insuplc_admdvs = item.InsuplcAdmdvs
  13479. }
  13480. }
  13481. psn := &models.HisPsn{
  13482. PsnNo: res.Output.Baseinfo.PsnNo,
  13483. PatientId: patient.ID,
  13484. Certno: res.Output.Baseinfo.Certno,
  13485. Gend: res.Output.Baseinfo.Gend,
  13486. Naty: res.Output.Baseinfo.Naty,
  13487. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13488. PsnName: res.Output.Baseinfo.PsnName,
  13489. Idetinfo: idetinfoStr,
  13490. Insuinfo: infoStr,
  13491. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13492. InsuplcAdmdvs: insuplc_admdvs,
  13493. }
  13494. service.CreateHisPsn(psn)
  13495. c.ServeSuccessJSON(map[string]interface{}{
  13496. "patient": patient,
  13497. "number": res.Output.Baseinfo.Certno,
  13498. })
  13499. }
  13500. } else {
  13501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13502. return
  13503. }
  13504. } else if miConfig.MdtrtareaAdmvs == "450721" {
  13505. res := c.GetoleInfo()
  13506. if res.Infcode == 0 {
  13507. var result string
  13508. if res.Output.MdtrtCertType == "01" {
  13509. 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)
  13510. } else if res.Output.MdtrtCertType == "02" {
  13511. 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)
  13512. } else if res.Output.MdtrtCertType == "03" {
  13513. 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)
  13514. }
  13515. var dat map[string]interface{}
  13516. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13517. fmt.Println(dat)
  13518. } else {
  13519. fmt.Println(err)
  13520. }
  13521. userJSONBytes, _ := json.Marshal(dat)
  13522. var res2 ResultTwo
  13523. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13524. utils.ErrorLog("解析失败:%v", err)
  13525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13526. return
  13527. }
  13528. if res2.Infcode == 0 {
  13529. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  13530. if err == gorm.ErrRecordNotFound {
  13531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13532. return
  13533. } else if err != nil {
  13534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13535. return
  13536. } else {
  13537. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  13538. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  13539. infoStr := string(Iinfos)
  13540. idetinfoStr := string(Idetinfos)
  13541. var rf []*ResultFive
  13542. json.Unmarshal([]byte(infoStr), &rf)
  13543. var insutypes []*ResultFive
  13544. var insutype string
  13545. var is390 int = 0
  13546. var is310 int = 0
  13547. //var insuplc_admdvs string
  13548. for _, item := range rf {
  13549. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13550. insutypes = append(insutypes, item)
  13551. }
  13552. }
  13553. if len(insutypes) == 1 {
  13554. insutype = insutypes[0].Insutype
  13555. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13556. } else {
  13557. for _, i := range insutypes {
  13558. if i.Insutype == "390" {
  13559. is390 = 1
  13560. }
  13561. if i.Insutype == "310" {
  13562. is310 = 1
  13563. }
  13564. }
  13565. }
  13566. if is390 == 1 {
  13567. insutype = "390"
  13568. }
  13569. if is310 == 1 {
  13570. insutype = "310"
  13571. }
  13572. if len(insutypes) == 0 {
  13573. insutype = "310"
  13574. }
  13575. psn := &models.HisPsn{
  13576. PsnNo: res2.Output.Baseinfo.PsnNo,
  13577. PatientId: patient.ID,
  13578. //Brdy: res2.Output.Baseinfo.Brdy,
  13579. Certno: res2.Output.Baseinfo.Certno,
  13580. Gend: res2.Output.Baseinfo.Gend,
  13581. Naty: res2.Output.Baseinfo.Naty,
  13582. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  13583. PsnName: res2.Output.Baseinfo.PsnName,
  13584. Idetinfo: idetinfoStr,
  13585. Insuinfo: infoStr,
  13586. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13587. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  13588. VerifyNumber: res.Output.EcToken,
  13589. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  13590. }
  13591. service.CreateHisPsn(psn)
  13592. var balc float64
  13593. for _, item := range rf {
  13594. if item.Insutype == insutype {
  13595. balc = item.Balc
  13596. }
  13597. }
  13598. c.ServeSuccessJSON(map[string]interface{}{
  13599. "patient": patient,
  13600. "number": res.Output.CardNo,
  13601. "insutype": insutype,
  13602. "blac": balc,
  13603. "desc": idetinfoStr,
  13604. })
  13605. }
  13606. } else {
  13607. c.ServeSuccessJSON(map[string]interface{}{
  13608. "failed_code": -10,
  13609. "msg": res2.ErrMsg,
  13610. })
  13611. }
  13612. } else {
  13613. c.ServeSuccessJSON(map[string]interface{}{
  13614. "failed_code": -10,
  13615. "msg": res.ErrMsg,
  13616. })
  13617. }
  13618. } else {
  13619. SFZStr := c.GetSFZBaseInfo()
  13620. id_card_str := strings.Split(SFZStr, "^")
  13621. id_card_number := id_card_str[0]
  13622. card_sn := ""
  13623. 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)
  13624. var dat map[string]interface{}
  13625. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13626. fmt.Println(dat)
  13627. } else {
  13628. fmt.Println(err)
  13629. }
  13630. userJSONBytes, _ := json.Marshal(dat)
  13631. var res ResultTwo
  13632. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13633. utils.ErrorLog("解析失败:%v", err)
  13634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13635. return
  13636. }
  13637. if res.Infcode == 0 {
  13638. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  13639. if err == gorm.ErrRecordNotFound {
  13640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13641. return
  13642. } else if err != nil {
  13643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13644. return
  13645. } else {
  13646. c.ServeSuccessJSON(map[string]interface{}{
  13647. "patient": patient,
  13648. "number": id_card_number,
  13649. })
  13650. }
  13651. } else {
  13652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13653. return
  13654. }
  13655. }
  13656. break
  13657. case 3:
  13658. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13659. var api string
  13660. if miConfig.MdtrtareaAdmvs == "320921" {
  13661. 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 +
  13662. "&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
  13663. fmt.Println(api)
  13664. } else {
  13665. 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 +
  13666. "&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)
  13667. }
  13668. resp, requestErr := http.Get(api)
  13669. if requestErr != nil {
  13670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13671. return
  13672. }
  13673. body, ioErr := ioutil.ReadAll(resp.Body)
  13674. if ioErr != nil {
  13675. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13677. return
  13678. }
  13679. var respJSON map[string]interface{}
  13680. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13681. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13683. return
  13684. }
  13685. var status string
  13686. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13687. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13688. var token string
  13689. var res ResultTwo //1101结果
  13690. var res10265 ResultTwo10265 //1101结果
  13691. var card_info string //卡信息
  13692. var busi_card_info string
  13693. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13694. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13695. if status == "0" { //读卡成功
  13696. if card_type == "1" {
  13697. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13698. result, _ := json.Marshal(respJSON)
  13699. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13700. utils.ErrorLog("解析失败:%v", err)
  13701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13702. return
  13703. }
  13704. res.ErrMsg = res10265.ErrMsg
  13705. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13706. res.Infcode = infocode
  13707. res.Output = res10265.Output
  13708. res.InfRefmsgid = res10265.InfRefmsgid
  13709. } else {
  13710. //var card_info string //卡信息
  13711. //var busi_card_info string
  13712. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13713. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13714. //fmt.Println(card_info)
  13715. //fmt.Println(busi_card_info)
  13716. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13717. result, _ := json.Marshal(respJSON)
  13718. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13719. utils.ErrorLog("解析失败:%v", err)
  13720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13721. return
  13722. }
  13723. res.ErrMsg = res10265.ErrMsg
  13724. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13725. res.Infcode = infocode
  13726. res.Output = res10265.Output
  13727. res.InfRefmsgid = res10265.InfRefmsgid
  13728. }
  13729. if res.Infcode == 0 {
  13730. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13731. if err == gorm.ErrRecordNotFound {
  13732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13733. return
  13734. } else if err != nil {
  13735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13736. return
  13737. } else {
  13738. if card_type == "1" {
  13739. bas := strings.Split(card_info, "|")
  13740. basNumber := bas[2]
  13741. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13742. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13743. infoStr := string(Iinfos)
  13744. idetinfoStr := string(Idetinfos)
  13745. psn := &models.HisPsn{
  13746. PsnNo: res.Output.Baseinfo.PsnNo,
  13747. PatientId: patient.ID,
  13748. Certno: res.Output.Baseinfo.Certno,
  13749. //Brdy: res.Output.Baseinfo.Brdy,
  13750. Gend: res.Output.Baseinfo.Gend,
  13751. Naty: res.Output.Baseinfo.Naty,
  13752. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13753. PsnName: res.Output.Baseinfo.PsnName,
  13754. Idetinfo: idetinfoStr,
  13755. Insuinfo: infoStr,
  13756. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13757. CardInfo: card_info,
  13758. VerifyNumber: busi_card_info,
  13759. }
  13760. service.CreateHisPsn(psn)
  13761. c.ServeSuccessJSON(map[string]interface{}{
  13762. "patient": patient,
  13763. "number": basNumber,
  13764. })
  13765. } else {
  13766. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13767. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13768. infoStr := string(Iinfos)
  13769. idetinfoStr := string(Idetinfos)
  13770. psn := &models.HisPsn{
  13771. PsnNo: res.Output.Baseinfo.PsnNo,
  13772. PatientId: patient.ID,
  13773. Certno: res.Output.Baseinfo.Certno,
  13774. Gend: res.Output.Baseinfo.Gend,
  13775. Naty: res.Output.Baseinfo.Naty,
  13776. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13777. PsnName: res.Output.Baseinfo.PsnName,
  13778. Idetinfo: idetinfoStr,
  13779. Insuinfo: infoStr,
  13780. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13781. CardInfo: card_info,
  13782. VerifyNumber: token,
  13783. }
  13784. service.CreateHisPsn(psn)
  13785. var rf []*ResultFive
  13786. json.Unmarshal([]byte(infoStr), &rf)
  13787. var insutypes []*ResultFive
  13788. var insutype string
  13789. var is390 int = 0
  13790. var is310 int = 0
  13791. for _, item := range rf {
  13792. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13793. insutypes = append(insutypes, item)
  13794. }
  13795. }
  13796. if len(insutypes) == 1 {
  13797. insutype = insutypes[0].Insutype
  13798. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13799. } else {
  13800. for _, i := range insutypes {
  13801. if i.Insutype == "390" {
  13802. is390 = 1
  13803. }
  13804. if i.Insutype == "310" {
  13805. is310 = 1
  13806. }
  13807. }
  13808. }
  13809. if is390 == 1 {
  13810. insutype = "390"
  13811. }
  13812. if is310 == 1 {
  13813. insutype = "310"
  13814. }
  13815. if len(insutypes) == 0 {
  13816. insutype = "310"
  13817. }
  13818. c.ServeSuccessJSON(map[string]interface{}{
  13819. "patient": patient,
  13820. "number": token,
  13821. "insutype": insutype,
  13822. })
  13823. }
  13824. }
  13825. } else {
  13826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13827. return
  13828. }
  13829. } else { //读卡失败
  13830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13831. return
  13832. }
  13833. }
  13834. break
  13835. case 4:
  13836. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13837. var api string
  13838. if miConfig.MdtrtareaAdmvs == "320921" {
  13839. 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 +
  13840. "&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
  13841. fmt.Println(api)
  13842. } else {
  13843. 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 +
  13844. "&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)
  13845. }
  13846. resp, requestErr := http.Get(api)
  13847. if requestErr != nil {
  13848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13849. return
  13850. }
  13851. body, ioErr := ioutil.ReadAll(resp.Body)
  13852. if ioErr != nil {
  13853. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13855. return
  13856. }
  13857. var respJSON map[string]interface{}
  13858. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13859. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13861. return
  13862. }
  13863. var status string
  13864. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13865. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13866. var token string
  13867. var res ResultTwo //1101结果
  13868. var res10265 ResultTwo10265 //1101结果
  13869. if status == "0" { //读卡成功
  13870. var card_info string //卡信息
  13871. var busi_card_info string
  13872. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13873. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13874. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13875. fmt.Println(card_info)
  13876. fmt.Println(busi_card_info)
  13877. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13878. result, _ := json.Marshal(respJSON)
  13879. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13880. utils.ErrorLog("解析失败:%v", err)
  13881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13882. return
  13883. }
  13884. res.ErrMsg = res10265.ErrMsg
  13885. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13886. res.Infcode = infocode
  13887. res.Output = res10265.Output
  13888. res.InfRefmsgid = res10265.InfRefmsgid
  13889. if res.Infcode == 0 {
  13890. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13891. if err == gorm.ErrRecordNotFound {
  13892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13893. return
  13894. } else if err != nil {
  13895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13896. return
  13897. } else {
  13898. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13899. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13900. infoStr := string(Iinfos)
  13901. idetinfoStr := string(Idetinfos)
  13902. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13903. psn := &models.HisPsn{
  13904. PsnNo: res.Output.Baseinfo.PsnNo,
  13905. PatientId: patient.ID,
  13906. Certno: res.Output.Baseinfo.Certno,
  13907. Brdy: b,
  13908. Age: float64(age),
  13909. //Brdy: res.Output.Baseinfo.Brdy,
  13910. Gend: res.Output.Baseinfo.Gend,
  13911. Naty: res.Output.Baseinfo.Naty,
  13912. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13913. PsnName: res.Output.Baseinfo.PsnName,
  13914. Idetinfo: idetinfoStr,
  13915. Insuinfo: infoStr,
  13916. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13917. CardInfo: card_info,
  13918. VerifyNumber: token,
  13919. }
  13920. var rf []*ResultFive
  13921. json.Unmarshal([]byte(infoStr), &rf)
  13922. var insutypes []*ResultFive
  13923. var insutype string
  13924. var is390 int = 0
  13925. var is310 int = 0
  13926. for _, item := range rf {
  13927. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13928. insutypes = append(insutypes, item)
  13929. }
  13930. }
  13931. if len(insutypes) == 1 {
  13932. insutype = insutypes[0].Insutype
  13933. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13934. } else {
  13935. for _, i := range insutypes {
  13936. if i.Insutype == "390" {
  13937. is390 = 1
  13938. }
  13939. if i.Insutype == "310" {
  13940. is310 = 1
  13941. }
  13942. }
  13943. }
  13944. if is390 == 1 {
  13945. insutype = "390"
  13946. }
  13947. if is310 == 1 {
  13948. insutype = "310"
  13949. }
  13950. if len(insutypes) == 0 {
  13951. insutype = "310"
  13952. }
  13953. service.CreateHisPsn(psn)
  13954. c.ServeSuccessJSON(map[string]interface{}{
  13955. "patient": patient,
  13956. "number": token,
  13957. "insutype": insutype,
  13958. })
  13959. }
  13960. } else {
  13961. c.ServeSuccessJSON(map[string]interface{}{
  13962. "failed_code": -10,
  13963. "msg": res.ErrMsg,
  13964. })
  13965. }
  13966. } else { //读卡失败
  13967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13968. return
  13969. }
  13970. } else if miConfig.MdtrtareaAdmvs == "341203" {
  13971. var api string
  13972. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  13973. "&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
  13974. resp, requestErr := http.Get(api)
  13975. if requestErr != nil {
  13976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13977. return
  13978. }
  13979. body, ioErr := ioutil.ReadAll(resp.Body)
  13980. if ioErr != nil {
  13981. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13983. return
  13984. }
  13985. var respJSON map[string]interface{}
  13986. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13989. return
  13990. }
  13991. var status string
  13992. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13993. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13994. var token string
  13995. var res ResultTwo //1101结果
  13996. if status == "1" { //读卡成功
  13997. var card_info string //卡信息
  13998. var busi_card_info string
  13999. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14000. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14001. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14002. fmt.Println(card_info)
  14003. fmt.Println(busi_card_info)
  14004. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14005. result, _ := json.Marshal(respJSON)
  14006. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14007. utils.ErrorLog("解析失败:%v", err)
  14008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14009. return
  14010. }
  14011. if res.Infcode == 0 {
  14012. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14013. if err == gorm.ErrRecordNotFound {
  14014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14015. return
  14016. } else if err != nil {
  14017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14018. return
  14019. } else {
  14020. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14021. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14022. infoStr := string(Iinfos)
  14023. idetinfoStr := string(Idetinfos)
  14024. psn := &models.HisPsn{
  14025. PsnNo: res.Output.Baseinfo.PsnNo,
  14026. PatientId: patient.ID,
  14027. Certno: res.Output.Baseinfo.Certno,
  14028. Gend: res.Output.Baseinfo.Gend,
  14029. Naty: res.Output.Baseinfo.Naty,
  14030. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14031. PsnName: res.Output.Baseinfo.PsnName,
  14032. Idetinfo: idetinfoStr,
  14033. Insuinfo: infoStr,
  14034. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14035. CardInfo: card_info,
  14036. VerifyNumber: token,
  14037. }
  14038. var rf []*ResultFive
  14039. json.Unmarshal([]byte(infoStr), &rf)
  14040. var insutypes []*ResultFive
  14041. var insutype string
  14042. var is390 int = 0
  14043. var is310 int = 0
  14044. for _, item := range rf {
  14045. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14046. insutypes = append(insutypes, item)
  14047. }
  14048. }
  14049. if len(insutypes) == 1 {
  14050. insutype = insutypes[0].Insutype
  14051. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14052. } else {
  14053. for _, i := range insutypes {
  14054. if i.Insutype == "390" {
  14055. is390 = 1
  14056. }
  14057. if i.Insutype == "310" {
  14058. is310 = 1
  14059. }
  14060. }
  14061. }
  14062. if is390 == 1 {
  14063. insutype = "390"
  14064. }
  14065. if is310 == 1 {
  14066. insutype = "310"
  14067. }
  14068. if len(insutypes) == 0 {
  14069. insutype = "310"
  14070. }
  14071. service.CreateHisPsn(psn)
  14072. c.ServeSuccessJSON(map[string]interface{}{
  14073. "patient": patient,
  14074. "number": token,
  14075. "insutype": insutype,
  14076. })
  14077. }
  14078. } else {
  14079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14080. return
  14081. }
  14082. } else { //读卡失败
  14083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14084. return
  14085. }
  14086. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14087. //idNo := c.GetString("idNo")
  14088. //userName := c.GetString("userName")
  14089. //ecToken := c.GetString("ecToken")
  14090. //insuOrg := c.GetString("insuOrg")
  14091. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  14092. utils.ErrorLog("解析失败:%v", json_result)
  14093. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  14094. type ELeData struct {
  14095. Data struct {
  14096. IdNo string `json:"idNo"`
  14097. IdType string `json:"idType"`
  14098. UserName string `json:"userName"`
  14099. EcToken string `json:"ecToken"`
  14100. InsuOrg string `json:"insuOrg"`
  14101. Gender string `json:"gender"`
  14102. Birthday string `json:"birthday"`
  14103. Nationality string `json:"nationality"`
  14104. Email string `json:"email"`
  14105. Extra string `json:"extra"`
  14106. } `json:"data"`
  14107. Code int `json:"code"`
  14108. Message string `json:"message"`
  14109. }
  14110. var ele ELeData
  14111. err := json.Unmarshal([]byte(json_result), &ele)
  14112. if err != nil {
  14113. utils.ErrorLog("解析失败:%v", err)
  14114. }
  14115. token := ele.Data.EcToken
  14116. token = Remove0000(token)
  14117. 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)
  14118. saveLog(result2, requestLog2, "1101", "获取人员信息")
  14119. var res ResultTwo
  14120. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  14121. utils.ErrorLog("解析失败:%v", err)
  14122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14123. return
  14124. }
  14125. if res.Infcode == 0 {
  14126. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14127. if err == gorm.ErrRecordNotFound {
  14128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14129. return
  14130. } else if err != nil {
  14131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14132. return
  14133. } else {
  14134. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14135. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14136. infoStr := string(Iinfos)
  14137. idetinfoStr := string(Idetinfos)
  14138. psn := &models.HisPsn{
  14139. PsnNo: res.Output.Baseinfo.PsnNo,
  14140. PatientId: patient.ID,
  14141. Certno: res.Output.Baseinfo.Certno,
  14142. Gend: res.Output.Baseinfo.Gend,
  14143. Naty: res.Output.Baseinfo.Naty,
  14144. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14145. PsnName: res.Output.Baseinfo.PsnName,
  14146. Idetinfo: idetinfoStr,
  14147. Insuinfo: infoStr,
  14148. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14149. CardInfo: "",
  14150. Stage: "1",
  14151. VerifyNumber: token,
  14152. InsuplcAdmdvs: ele.Data.InsuOrg,
  14153. }
  14154. service.CreateHisPsn(psn)
  14155. var rf []*ResultFive
  14156. json.Unmarshal([]byte(infoStr), &rf)
  14157. var insutypes []*ResultFive
  14158. var insutype string
  14159. var is390 int = 0
  14160. var is310 int = 0
  14161. for _, item := range rf {
  14162. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14163. insutypes = append(insutypes, item)
  14164. }
  14165. }
  14166. if len(insutypes) == 1 {
  14167. insutype = insutypes[0].Insutype
  14168. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14169. } else {
  14170. for _, i := range insutypes {
  14171. if i.Insutype == "390" {
  14172. is390 = 1
  14173. }
  14174. if i.Insutype == "310" {
  14175. is310 = 1
  14176. }
  14177. }
  14178. }
  14179. if is390 == 1 {
  14180. insutype = "390"
  14181. }
  14182. if is310 == 1 {
  14183. insutype = "310"
  14184. }
  14185. if len(insutypes) == 0 {
  14186. insutype = "310"
  14187. }
  14188. c.ServeSuccessJSON(map[string]interface{}{
  14189. "patient": patient,
  14190. "number": token,
  14191. "insutype": insutype,
  14192. })
  14193. }
  14194. } else {
  14195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14196. return
  14197. }
  14198. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14199. //if initFlag == 0 {
  14200. //c.TestGetJiangXiBasBaseInit()
  14201. //}
  14202. //if initEleFlag == 0 {
  14203. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  14204. //}
  14205. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  14206. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  14207. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  14208. type ELeData struct {
  14209. Data struct {
  14210. IdNo string `json:"idNo"`
  14211. IdType string `json:"idType"`
  14212. UserName string `json:"userName"`
  14213. EcToken string `json:"ecToken"`
  14214. InsuOrg string `json:"insuOrg"`
  14215. Gender string `json:"gender"`
  14216. Birthday string `json:"birthday"`
  14217. Nationality string `json:"nationality"`
  14218. Email string `json:"email"`
  14219. Extra string `json:"extra"`
  14220. } `json:"data"`
  14221. Code int `json:"code"`
  14222. Message string `json:"message"`
  14223. }
  14224. var ele ELeData
  14225. err := json.Unmarshal([]byte(result), &ele)
  14226. if err != nil {
  14227. utils.ErrorLog("解析失败:%v", err)
  14228. }
  14229. token := ele.Data.EcToken
  14230. token = Remove0000(token)
  14231. 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)
  14232. saveLog(result2, requestLog2, "1101", "获取人员信息")
  14233. var res ResultTwo
  14234. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  14235. utils.ErrorLog("解析失败:%v", err)
  14236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14237. return
  14238. }
  14239. if res.Infcode == 0 {
  14240. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14241. if err == gorm.ErrRecordNotFound {
  14242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14243. return
  14244. } else if err != nil {
  14245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14246. return
  14247. } else {
  14248. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14249. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14250. infoStr := string(Iinfos)
  14251. idetinfoStr := string(Idetinfos)
  14252. psn := &models.HisPsn{
  14253. PsnNo: res.Output.Baseinfo.PsnNo,
  14254. PatientId: patient.ID,
  14255. Certno: res.Output.Baseinfo.Certno,
  14256. Gend: res.Output.Baseinfo.Gend,
  14257. Naty: res.Output.Baseinfo.Naty,
  14258. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14259. PsnName: res.Output.Baseinfo.PsnName,
  14260. Idetinfo: idetinfoStr,
  14261. Insuinfo: infoStr,
  14262. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14263. CardInfo: "",
  14264. VerifyNumber: token,
  14265. InsuplcAdmdvs: ele.Data.InsuOrg,
  14266. }
  14267. service.CreateHisPsn(psn)
  14268. var rf []*ResultFive
  14269. json.Unmarshal([]byte(infoStr), &rf)
  14270. var insutypes []*ResultFive
  14271. var insutype string
  14272. var is390 int = 0
  14273. var is310 int = 0
  14274. for _, item := range rf {
  14275. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14276. insutypes = append(insutypes, item)
  14277. }
  14278. }
  14279. if len(insutypes) == 1 {
  14280. insutype = insutypes[0].Insutype
  14281. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14282. } else {
  14283. for _, i := range insutypes {
  14284. if i.Insutype == "390" {
  14285. is390 = 1
  14286. }
  14287. if i.Insutype == "310" {
  14288. is310 = 1
  14289. }
  14290. }
  14291. }
  14292. if is390 == 1 {
  14293. insutype = "390"
  14294. }
  14295. if is310 == 1 {
  14296. insutype = "310"
  14297. }
  14298. if len(insutypes) == 0 {
  14299. insutype = "310"
  14300. }
  14301. c.ServeSuccessJSON(map[string]interface{}{
  14302. "patient": patient,
  14303. "number": token,
  14304. "insutype": insutype,
  14305. })
  14306. }
  14307. } else {
  14308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14309. return
  14310. }
  14311. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14312. //if initFlag == 0 {
  14313. c.TestGetJiangXiBasBaseInit()
  14314. //}
  14315. //if initEleFlag == 0 {
  14316. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  14317. //}
  14318. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  14319. type ELeData struct {
  14320. Data struct {
  14321. IdNo string `json:"idNo"`
  14322. IdType string `json:"idType"`
  14323. UserName string `json:"userName"`
  14324. EcToken string `json:"ecToken"`
  14325. InsuOrg string `json:"insuOrg"`
  14326. Gender string `json:"gender"`
  14327. Birthday string `json:"birthday"`
  14328. Nationality string `json:"nationality"`
  14329. Email string `json:"email"`
  14330. Extra string `json:"extra"`
  14331. } `json:"data"`
  14332. Code int `json:"code"`
  14333. Message string `json:"message"`
  14334. }
  14335. var ele ELeData
  14336. err := json.Unmarshal([]byte(json_result), &ele)
  14337. if err != nil {
  14338. utils.ErrorLog("解析失败:%v", err)
  14339. }
  14340. token := ele.Data.EcToken
  14341. token = Remove0000(token)
  14342. 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)
  14343. saveLog(result2, requestLog2, "1101", "获取人员信息")
  14344. var res ResultTwo
  14345. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  14346. utils.ErrorLog("解析失败:%v", err)
  14347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14348. return
  14349. }
  14350. if res.Infcode == 0 {
  14351. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14352. if err == gorm.ErrRecordNotFound {
  14353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14354. return
  14355. } else if err != nil {
  14356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14357. return
  14358. } else {
  14359. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14360. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14361. infoStr := string(Iinfos)
  14362. idetinfoStr := string(Idetinfos)
  14363. psn := &models.HisPsn{
  14364. PsnNo: res.Output.Baseinfo.PsnNo,
  14365. PatientId: patient.ID,
  14366. Certno: res.Output.Baseinfo.Certno,
  14367. Gend: res.Output.Baseinfo.Gend,
  14368. Naty: res.Output.Baseinfo.Naty,
  14369. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14370. PsnName: res.Output.Baseinfo.PsnName,
  14371. Idetinfo: idetinfoStr,
  14372. Insuinfo: infoStr,
  14373. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14374. CardInfo: "",
  14375. VerifyNumber: token,
  14376. }
  14377. service.CreateHisPsn(psn)
  14378. var rf []*ResultFive
  14379. json.Unmarshal([]byte(infoStr), &rf)
  14380. var insutypes []*ResultFive
  14381. var insutype string
  14382. var is390 int = 0
  14383. var is310 int = 0
  14384. for _, item := range rf {
  14385. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14386. insutypes = append(insutypes, item)
  14387. }
  14388. }
  14389. if len(insutypes) == 1 {
  14390. insutype = insutypes[0].Insutype
  14391. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14392. } else {
  14393. for _, i := range insutypes {
  14394. if i.Insutype == "390" {
  14395. is390 = 1
  14396. }
  14397. if i.Insutype == "310" {
  14398. is310 = 1
  14399. }
  14400. }
  14401. }
  14402. if is390 == 1 {
  14403. insutype = "390"
  14404. }
  14405. if is310 == 1 {
  14406. insutype = "310"
  14407. }
  14408. if len(insutypes) == 0 {
  14409. insutype = "310"
  14410. }
  14411. c.ServeSuccessJSON(map[string]interface{}{
  14412. "patient": patient,
  14413. "number": token,
  14414. "insutype": insutype,
  14415. })
  14416. }
  14417. } else {
  14418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14419. return
  14420. }
  14421. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14422. type ELeData struct {
  14423. Code string `json:"code"`
  14424. Data struct {
  14425. Aac002 string `json:"aac002"`
  14426. Aaz500 string `json:"aaz500"`
  14427. ActCardNo string `json:"actCardNo"`
  14428. Bab520 string `json:"bab520"`
  14429. Bkz543 string `json:"bkz543"`
  14430. BusinessType string `json:"businessType"`
  14431. CertfCodg string `json:"certfCodg"`
  14432. EcIndexNo string `json:"ecIndexNo"`
  14433. EcToken string `json:"ecToken"`
  14434. ID0000 string `json:"id0000"`
  14435. IDNo string `json:"idNo"`
  14436. IDType string `json:"idType"`
  14437. Idcode string `json:"idcode"`
  14438. IdentityToken string `json:"identity_token"`
  14439. InsuOrg string `json:"insuOrg"`
  14440. OfficeID string `json:"officeId"`
  14441. OfficeName string `json:"officeName"`
  14442. OperatorID string `json:"operatorId"`
  14443. OperatorName string `json:"operatorName"`
  14444. OrgID string `json:"orgId"`
  14445. UserName string `json:"userName"`
  14446. } `json:"data"`
  14447. Infno interface{} `json:"infno"`
  14448. Message string `json:"message"`
  14449. OrgID string `json:"orgId"`
  14450. TransType string `json:"transType"`
  14451. }
  14452. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  14453. outPutInfo = Remove0000(outPutInfo)
  14454. if len(outPutInfo) > 0 {
  14455. var ele ELeData
  14456. err := json.Unmarshal([]byte(outPutInfo), &ele)
  14457. if err != nil {
  14458. utils.ErrorLog("解析失败:%v", err)
  14459. }
  14460. token := ele.Data.EcToken
  14461. fmt.Println(inputInfo)
  14462. fmt.Println(outPutInfo)
  14463. 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)
  14464. saveLog(result, requestLog, "1101", "获取人员信息")
  14465. var dat map[string]interface{}
  14466. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14467. fmt.Println(dat)
  14468. } else {
  14469. fmt.Println(err)
  14470. }
  14471. userJSONBytes, _ := json.Marshal(dat)
  14472. var res ResultTwo
  14473. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14474. utils.ErrorLog("解析失败:%v", err)
  14475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14476. return
  14477. }
  14478. res.ErrMsg = errMsgLog
  14479. if res.Infcode == 0 {
  14480. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  14481. if err == gorm.ErrRecordNotFound {
  14482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14483. return
  14484. } else if err != nil {
  14485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14486. return
  14487. } else {
  14488. fmt.Println(res)
  14489. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14490. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14491. infoStr := string(Iinfos)
  14492. idetinfoStr := string(Idetinfos)
  14493. psn := &models.HisPsn{
  14494. PsnNo: res.Output.Baseinfo.PsnNo,
  14495. PatientId: patient.ID,
  14496. Certno: res.Output.Baseinfo.Certno,
  14497. Gend: res.Output.Baseinfo.Gend,
  14498. Naty: res.Output.Baseinfo.Naty,
  14499. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14500. PsnName: res.Output.Baseinfo.PsnName,
  14501. Idetinfo: idetinfoStr,
  14502. Insuinfo: infoStr,
  14503. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14504. CardInfo: outPutInfo,
  14505. VerifyNumber: token,
  14506. InsuplcAdmdvs: ele.Data.InsuOrg,
  14507. }
  14508. service.CreateHisPsn(psn)
  14509. var rf []*ResultFive
  14510. json.Unmarshal([]byte(infoStr), &rf)
  14511. var insutypes []*ResultFive
  14512. var insutype string
  14513. var is390 int = 0
  14514. var is310 int = 0
  14515. for _, item := range rf {
  14516. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14517. insutypes = append(insutypes, item)
  14518. }
  14519. }
  14520. if len(insutypes) == 1 {
  14521. insutype = insutypes[0].Insutype
  14522. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14523. } else {
  14524. for _, i := range insutypes {
  14525. if i.Insutype == "390" {
  14526. is390 = 1
  14527. }
  14528. if i.Insutype == "310" {
  14529. is310 = 1
  14530. }
  14531. }
  14532. }
  14533. if is390 == 1 {
  14534. insutype = "390"
  14535. }
  14536. if is310 == 1 {
  14537. insutype = "310"
  14538. }
  14539. if len(insutypes) == 0 {
  14540. insutype = "310"
  14541. }
  14542. c.ServeSuccessJSON(map[string]interface{}{
  14543. "patient": patient,
  14544. "number": token,
  14545. "insutype": insutype,
  14546. })
  14547. }
  14548. } else {
  14549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14550. return
  14551. }
  14552. }
  14553. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14554. var api string
  14555. 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 +
  14556. "&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
  14557. resp, requestErr := http.Get(api)
  14558. if requestErr != nil {
  14559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14560. return
  14561. }
  14562. body, ioErr := ioutil.ReadAll(resp.Body)
  14563. if ioErr != nil {
  14564. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14566. return
  14567. }
  14568. var respJSON map[string]interface{}
  14569. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14572. return
  14573. }
  14574. var status string
  14575. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14576. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14577. var token string
  14578. var res ResultTwo //1101结果
  14579. var res10265 ResultTwo10265 //1101结果
  14580. if status == "0" { //读卡成功
  14581. var card_info string //卡信息
  14582. var busi_card_info string
  14583. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14584. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14585. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14586. fmt.Println(card_info)
  14587. fmt.Println(busi_card_info)
  14588. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14589. result, _ := json.Marshal(respJSON)
  14590. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14591. utils.ErrorLog("解析失败:%v", err)
  14592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14593. return
  14594. }
  14595. res.ErrMsg = res10265.ErrMsg
  14596. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14597. res.Infcode = infocode
  14598. res.Output = res10265.Output
  14599. res.InfRefmsgid = res10265.InfRefmsgid
  14600. if res.Infcode == 0 {
  14601. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14602. if err == gorm.ErrRecordNotFound {
  14603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14604. return
  14605. } else if err != nil {
  14606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14607. return
  14608. } else {
  14609. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14610. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14611. infoStr := string(Iinfos)
  14612. idetinfoStr := string(Idetinfos)
  14613. psn := &models.HisPsn{
  14614. PsnNo: res.Output.Baseinfo.PsnNo,
  14615. PatientId: patient.ID,
  14616. Certno: res.Output.Baseinfo.Certno,
  14617. Gend: res.Output.Baseinfo.Gend,
  14618. Naty: res.Output.Baseinfo.Naty,
  14619. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14620. PsnName: res.Output.Baseinfo.PsnName,
  14621. Idetinfo: idetinfoStr,
  14622. Insuinfo: infoStr,
  14623. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14624. CardInfo: card_info,
  14625. VerifyNumber: token,
  14626. }
  14627. var rf []*ResultFive
  14628. json.Unmarshal([]byte(infoStr), &rf)
  14629. var insutypes []*ResultFive
  14630. var insutype string
  14631. var is390 int = 0
  14632. var is310 int = 0
  14633. for _, item := range rf {
  14634. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14635. insutypes = append(insutypes, item)
  14636. }
  14637. }
  14638. if len(insutypes) == 1 {
  14639. insutype = insutypes[0].Insutype
  14640. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14641. } else {
  14642. for _, i := range insutypes {
  14643. if i.Insutype == "390" {
  14644. is390 = 1
  14645. }
  14646. if i.Insutype == "310" {
  14647. is310 = 1
  14648. }
  14649. }
  14650. }
  14651. if is390 == 1 {
  14652. insutype = "390"
  14653. }
  14654. if is310 == 1 {
  14655. insutype = "310"
  14656. }
  14657. if len(insutypes) == 0 {
  14658. insutype = "310"
  14659. }
  14660. service.CreateHisPsn(psn)
  14661. c.ServeSuccessJSON(map[string]interface{}{
  14662. "patient": patient,
  14663. "number": token,
  14664. "insutype": insutype,
  14665. })
  14666. }
  14667. } else {
  14668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14669. return
  14670. }
  14671. } else { //读卡失败
  14672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14673. return
  14674. }
  14675. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14676. res := c.GetoleInfo()
  14677. if res.Infcode == 0 {
  14678. var result string
  14679. if res.Output.MdtrtCertType == "01" {
  14680. 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)
  14681. } else if res.Output.MdtrtCertType == "02" {
  14682. 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)
  14683. } else if res.Output.MdtrtCertType == "03" {
  14684. 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)
  14685. }
  14686. var dat map[string]interface{}
  14687. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14688. fmt.Println(dat)
  14689. } else {
  14690. fmt.Println(err)
  14691. }
  14692. userJSONBytes, _ := json.Marshal(dat)
  14693. var res2 ResultTwo
  14694. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14695. utils.ErrorLog("解析失败:%v", err)
  14696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14697. return
  14698. }
  14699. if res2.Infcode == 0 {
  14700. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14701. if err == gorm.ErrRecordNotFound {
  14702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14703. return
  14704. } else if err != nil {
  14705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14706. return
  14707. } else {
  14708. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14709. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14710. infoStr := string(Iinfos)
  14711. idetinfoStr := string(Idetinfos)
  14712. var rf []*ResultFive
  14713. json.Unmarshal([]byte(infoStr), &rf)
  14714. var insutypes []*ResultFive
  14715. var insutype string
  14716. var is390 int = 0
  14717. var is310 int = 0
  14718. //var insuplc_admdvs string
  14719. for _, item := range rf {
  14720. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14721. insutypes = append(insutypes, item)
  14722. }
  14723. }
  14724. if len(insutypes) == 1 {
  14725. insutype = insutypes[0].Insutype
  14726. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14727. } else {
  14728. for _, i := range insutypes {
  14729. if i.Insutype == "390" {
  14730. is390 = 1
  14731. }
  14732. if i.Insutype == "310" {
  14733. is310 = 1
  14734. }
  14735. }
  14736. }
  14737. if is390 == 1 {
  14738. insutype = "390"
  14739. }
  14740. if is310 == 1 {
  14741. insutype = "310"
  14742. }
  14743. if len(insutypes) == 0 {
  14744. insutype = "310"
  14745. }
  14746. psn := &models.HisPsn{
  14747. PsnNo: res2.Output.Baseinfo.PsnNo,
  14748. PatientId: patient.ID,
  14749. Certno: res2.Output.Baseinfo.Certno,
  14750. Gend: res2.Output.Baseinfo.Gend,
  14751. Naty: res2.Output.Baseinfo.Naty,
  14752. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14753. PsnName: res2.Output.Baseinfo.PsnName,
  14754. Idetinfo: idetinfoStr,
  14755. Insuinfo: infoStr,
  14756. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14757. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14758. VerifyNumber: res.Output.EcToken,
  14759. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14760. }
  14761. if res.Output.MdtrtCertType == "01" {
  14762. psn.VerifyNumber = res.Output.EcToken
  14763. //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)
  14764. } else if res.Output.MdtrtCertType == "02" {
  14765. psn.VerifyNumber = res.Output.CardNo
  14766. //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)
  14767. } else if res.Output.MdtrtCertType == "03" {
  14768. psn.VerifyNumber = res.Output.MdtrtCertNo
  14769. //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)
  14770. }
  14771. service.CreateHisPsn(psn)
  14772. var balc float64
  14773. for _, item := range rf {
  14774. if item.Insutype == insutype {
  14775. balc = item.Balc
  14776. }
  14777. }
  14778. c.ServeSuccessJSON(map[string]interface{}{
  14779. "patient": patient,
  14780. "number": res.Output.CardNo,
  14781. "insutype": insutype,
  14782. "blac": balc,
  14783. "desc": idetinfoStr,
  14784. })
  14785. }
  14786. } else {
  14787. c.ServeSuccessJSON(map[string]interface{}{
  14788. "failed_code": -10,
  14789. "msg": res2.ErrMsg,
  14790. })
  14791. }
  14792. } else {
  14793. c.ServeSuccessJSON(map[string]interface{}{
  14794. "failed_code": -10,
  14795. "msg": res.ErrMsg,
  14796. })
  14797. }
  14798. } else if miConfig.MdtrtareaAdmvs == "420902" {
  14799. var res ResultTwo
  14800. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14801. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14802. "&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)
  14803. resp, requestErr := http.Get(api)
  14804. if requestErr != nil {
  14805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14806. return
  14807. }
  14808. body, ioErr := ioutil.ReadAll(resp.Body)
  14809. if ioErr != nil {
  14810. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14812. return
  14813. }
  14814. var respJSON map[string]interface{}
  14815. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14816. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14818. return
  14819. }
  14820. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14821. result, _ := json.Marshal(respJSON)
  14822. fmt.Println("log")
  14823. fmt.Println(string(result))
  14824. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14825. utils.ErrorLog("解析失败:%v", err)
  14826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14827. return
  14828. }
  14829. if res.Infcode == 0 {
  14830. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14831. if err == gorm.ErrRecordNotFound {
  14832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14833. return
  14834. } else if err != nil {
  14835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14836. return
  14837. } else {
  14838. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14839. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14840. infoStr := string(Iinfos)
  14841. idetinfoStr := string(Idetinfos)
  14842. var rf []*ResultFive
  14843. json.Unmarshal([]byte(infoStr), &rf)
  14844. var insutypes []*ResultFive
  14845. var insutype string
  14846. var is390 int = 0
  14847. var is310 int = 0
  14848. for _, item := range rf {
  14849. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14850. insutypes = append(insutypes, item)
  14851. }
  14852. }
  14853. if len(insutypes) == 1 {
  14854. insutype = insutypes[0].Insutype
  14855. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14856. } else {
  14857. for _, i := range insutypes {
  14858. if i.Insutype == "390" {
  14859. is390 = 1
  14860. }
  14861. if i.Insutype == "310" {
  14862. is310 = 1
  14863. }
  14864. }
  14865. }
  14866. if is390 == 1 {
  14867. insutype = "390"
  14868. }
  14869. if is310 == 1 {
  14870. insutype = "310"
  14871. }
  14872. if len(insutypes) == 0 {
  14873. insutype = "390"
  14874. }
  14875. var insuplc_admdvs string
  14876. for _, item := range rf {
  14877. if item.Insutype == insutype {
  14878. insuplc_admdvs = item.InsuplcAdmdvs
  14879. }
  14880. }
  14881. psn := &models.HisPsn{
  14882. PsnNo: res.Output.Baseinfo.PsnNo,
  14883. PatientId: patient.ID,
  14884. Certno: res.Output.Baseinfo.Certno,
  14885. Gend: res.Output.Baseinfo.Gend,
  14886. Naty: res.Output.Baseinfo.Naty,
  14887. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14888. PsnName: res.Output.Baseinfo.PsnName,
  14889. Idetinfo: idetinfoStr,
  14890. Insuinfo: infoStr,
  14891. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14892. InsuplcAdmdvs: insuplc_admdvs,
  14893. }
  14894. service.CreateHisPsn(psn)
  14895. c.ServeSuccessJSON(map[string]interface{}{
  14896. "patient": patient,
  14897. "number": res.Output.Baseinfo.Certno,
  14898. })
  14899. }
  14900. } else {
  14901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14902. return
  14903. }
  14904. } else {
  14905. type ELeData struct {
  14906. Code string `json:"code"`
  14907. Data struct {
  14908. Aac002 string `json:"aac002"`
  14909. Aaz500 string `json:"aaz500"`
  14910. ActCardNo string `json:"actCardNo"`
  14911. Bab520 string `json:"bab520"`
  14912. Bkz543 string `json:"bkz543"`
  14913. BusinessType string `json:"businessType"`
  14914. CertfCodg string `json:"certfCodg"`
  14915. EcIndexNo string `json:"ecIndexNo"`
  14916. EcToken string `json:"ecToken"`
  14917. ID0000 string `json:"id0000"`
  14918. IDNo string `json:"idNo"`
  14919. IDType string `json:"idType"`
  14920. Idcode string `json:"idcode"`
  14921. IdentityToken string `json:"identity_token"`
  14922. InsuOrg string `json:"insuOrg"`
  14923. OfficeID string `json:"officeId"`
  14924. OfficeName string `json:"officeName"`
  14925. OperatorID string `json:"operatorId"`
  14926. OperatorName string `json:"operatorName"`
  14927. OrgID string `json:"orgId"`
  14928. UserName string `json:"userName"`
  14929. } `json:"data"`
  14930. Infno interface{} `json:"infno"`
  14931. Message string `json:"message"`
  14932. OrgID string `json:"orgId"`
  14933. TransType string `json:"transType"`
  14934. }
  14935. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  14936. fmt.Println(result)
  14937. outPutInfo := Remove0000(result)
  14938. fmt.Println(outPutInfo)
  14939. if len(outPutInfo) > 0 {
  14940. var ele ELeData
  14941. err := json.Unmarshal([]byte(outPutInfo), &ele)
  14942. if err != nil {
  14943. utils.ErrorLog("解析失败:%v", err)
  14944. }
  14945. token := ele.Data.EcToken
  14946. fmt.Println(outPutInfo)
  14947. 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)
  14948. saveLog(result, requestLog, "1101", "获取人员信息")
  14949. var dat map[string]interface{}
  14950. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14951. fmt.Println(dat)
  14952. } else {
  14953. fmt.Println(err)
  14954. }
  14955. userJSONBytes, _ := json.Marshal(dat)
  14956. var res ResultTwo
  14957. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14958. utils.ErrorLog("解析失败:%v", err)
  14959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14960. return
  14961. }
  14962. if res.Infcode == 0 {
  14963. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  14964. if err == gorm.ErrRecordNotFound {
  14965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14966. return
  14967. } else if err != nil {
  14968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14969. return
  14970. } else {
  14971. fmt.Println(res)
  14972. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14973. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14974. infoStr := string(Iinfos)
  14975. idetinfoStr := string(Idetinfos)
  14976. psn := &models.HisPsn{
  14977. PsnNo: res.Output.Baseinfo.PsnNo,
  14978. PatientId: patient.ID,
  14979. Certno: res.Output.Baseinfo.Certno,
  14980. Gend: res.Output.Baseinfo.Gend,
  14981. Naty: res.Output.Baseinfo.Naty,
  14982. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14983. PsnName: res.Output.Baseinfo.PsnName,
  14984. Idetinfo: idetinfoStr,
  14985. Insuinfo: infoStr,
  14986. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14987. CardInfo: outPutInfo,
  14988. VerifyNumber: token,
  14989. InsuplcAdmdvs: ele.Data.InsuOrg,
  14990. }
  14991. service.CreateHisPsn(psn)
  14992. var rf []*ResultFive
  14993. json.Unmarshal([]byte(infoStr), &rf)
  14994. var insutypes []*ResultFive
  14995. var insutype string
  14996. var is390 int = 0
  14997. var is310 int = 0
  14998. for _, item := range rf {
  14999. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15000. insutypes = append(insutypes, item)
  15001. }
  15002. }
  15003. if len(insutypes) == 1 {
  15004. insutype = insutypes[0].Insutype
  15005. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15006. } else {
  15007. for _, i := range insutypes {
  15008. if i.Insutype == "390" {
  15009. is390 = 1
  15010. }
  15011. if i.Insutype == "310" {
  15012. is310 = 1
  15013. }
  15014. }
  15015. }
  15016. if is390 == 1 {
  15017. insutype = "390"
  15018. }
  15019. if is310 == 1 {
  15020. insutype = "310"
  15021. }
  15022. if len(insutypes) == 0 {
  15023. insutype = "310"
  15024. }
  15025. c.ServeSuccessJSON(map[string]interface{}{
  15026. "patient": patient,
  15027. "number": token,
  15028. "insutype": insutype,
  15029. })
  15030. }
  15031. } else {
  15032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15033. return
  15034. }
  15035. }
  15036. //fmt.Println(result)
  15037. //
  15038. //if initFlag == 0 {
  15039. // c.TestGetBasBaseInit()
  15040. //}
  15041. //token := c.GetEleBaseInfo()
  15042. //
  15043. //token = Remove0000(token)
  15044. //
  15045. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  15046. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  15047. ////
  15048. //var res ResultTwo
  15049. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15050. // utils.ErrorLog("解析失败:%v", err)
  15051. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15052. // return
  15053. //}
  15054. //
  15055. //if res.Infcode == 0 {
  15056. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15057. // if err == gorm.ErrRecordNotFound {
  15058. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15059. // return
  15060. // } else if err != nil {
  15061. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15062. // return
  15063. //
  15064. // } else {
  15065. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15066. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15067. // infoStr := string(Iinfos)
  15068. // idetinfoStr := string(Idetinfos)
  15069. //
  15070. //
  15071. //
  15072. //
  15073. // var rf []*ResultFive
  15074. // json.Unmarshal([]byte(infoStr), &rf)
  15075. //
  15076. // var insutypes []*ResultFive
  15077. // var insutype string
  15078. // var is390 int = 0
  15079. // var is310 int = 0
  15080. // var insuplc_admdvs string
  15081. //
  15082. // for _, item := range rf {
  15083. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15084. // insutypes = append(insutypes, item)
  15085. // }
  15086. // }
  15087. //
  15088. // if len(insutypes) == 1 {
  15089. // insutype = insutypes[0].Insutype
  15090. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15091. // } else {
  15092. // for _, i := range insutypes {
  15093. // if i.Insutype == "390" {
  15094. // is390 = 1
  15095. // }
  15096. //
  15097. // if i.Insutype == "310" {
  15098. // is310 = 1
  15099. // }
  15100. // }
  15101. // }
  15102. // if is390 == 1 {
  15103. // insutype = "390"
  15104. // }
  15105. //
  15106. // if is310 == 1 {
  15107. // insutype = "310"
  15108. // }
  15109. // if len(insutypes) == 0 {
  15110. // insutype = "310"
  15111. // }
  15112. // for _, item := range rf {
  15113. // if item.Insutype == insutype {
  15114. // insuplc_admdvs = item.InsuplcAdmdvs
  15115. // }
  15116. // }
  15117. // psn := &models.HisPsn{
  15118. // PsnNo: res.Output.Baseinfo.PsnNo,
  15119. // Age: res.Output.Baseinfo.Age,
  15120. // PatientId: patient.ID,
  15121. // Certno: res.Output.Baseinfo.Certno,
  15122. // Brdy: res.Output.Baseinfo.Brdy,
  15123. // Gend: res.Output.Baseinfo.Gend,
  15124. // Naty: res.Output.Baseinfo.Naty,
  15125. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  15126. // PsnName: res.Output.Baseinfo.PsnName,
  15127. // Idetinfo: idetinfoStr,
  15128. // Insuinfo: infoStr,
  15129. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15130. // CardInfo: "",
  15131. // VerifyNumber: token,
  15132. // InsuplcAdmdvs: insuplc_admdvs,
  15133. // }
  15134. // service.CreateHisPsn(psn)
  15135. //
  15136. // c.ServeSuccessJSON(map[string]interface{}{
  15137. // "patient": patient,
  15138. // "number": token,
  15139. // })
  15140. // }
  15141. //} else {
  15142. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15143. // return
  15144. //}
  15145. }
  15146. break
  15147. case 5:
  15148. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15149. var api string
  15150. if miConfig.MdtrtareaAdmvs == "320921" {
  15151. 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 +
  15152. "&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
  15153. fmt.Println(api)
  15154. } else {
  15155. 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 +
  15156. "&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)
  15157. }
  15158. resp, requestErr := http.Get(api)
  15159. if requestErr != nil {
  15160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15161. return
  15162. }
  15163. body, ioErr := ioutil.ReadAll(resp.Body)
  15164. if ioErr != nil {
  15165. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15167. return
  15168. }
  15169. var respJSON map[string]interface{}
  15170. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15171. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15173. return
  15174. }
  15175. var status string
  15176. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15177. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15178. var token string
  15179. var res ResultTwo //1101结果
  15180. var res10265 ResultTwo10265 //1101结果
  15181. if status == "0" { //读卡成功
  15182. var card_info string //卡信息
  15183. //var busi_card_info string
  15184. var auth_info string
  15185. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15186. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15187. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15188. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  15189. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15190. result, _ := json.Marshal(respJSON)
  15191. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15192. utils.ErrorLog("解析失败:%v", err)
  15193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15194. return
  15195. }
  15196. res.ErrMsg = res10265.ErrMsg
  15197. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15198. res.Infcode = infocode
  15199. res.Output = res10265.Output
  15200. res.InfRefmsgid = res10265.InfRefmsgid
  15201. if res.Infcode == 0 {
  15202. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15203. if err == gorm.ErrRecordNotFound {
  15204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15205. return
  15206. } else if err != nil {
  15207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15208. return
  15209. } else {
  15210. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15211. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15212. infoStr := string(Iinfos)
  15213. idetinfoStr := string(Idetinfos)
  15214. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  15215. psn := &models.HisPsn{
  15216. PsnNo: res.Output.Baseinfo.PsnNo,
  15217. PatientId: patient.ID,
  15218. Certno: res.Output.Baseinfo.Certno,
  15219. Gend: res.Output.Baseinfo.Gend,
  15220. Brdy: b,
  15221. Age: float64(age),
  15222. Naty: res.Output.Baseinfo.Naty,
  15223. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15224. PsnName: res.Output.Baseinfo.PsnName,
  15225. Idetinfo: idetinfoStr,
  15226. Insuinfo: infoStr,
  15227. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15228. CardInfo: card_info,
  15229. VerifyNumber: token,
  15230. AuthInfo: auth_info,
  15231. }
  15232. var rf []*ResultFive
  15233. json.Unmarshal([]byte(infoStr), &rf)
  15234. var insutypes []*ResultFive
  15235. var insutype string
  15236. var is390 int = 0
  15237. var is310 int = 0
  15238. for _, item := range rf {
  15239. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15240. insutypes = append(insutypes, item)
  15241. }
  15242. }
  15243. if len(insutypes) == 1 {
  15244. insutype = insutypes[0].Insutype
  15245. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15246. } else {
  15247. for _, i := range insutypes {
  15248. if i.Insutype == "390" {
  15249. is390 = 1
  15250. }
  15251. if i.Insutype == "310" {
  15252. is310 = 1
  15253. }
  15254. }
  15255. }
  15256. if is390 == 1 {
  15257. insutype = "390"
  15258. }
  15259. if is310 == 1 {
  15260. insutype = "310"
  15261. }
  15262. if len(insutypes) == 0 {
  15263. insutype = "310"
  15264. }
  15265. service.CreateHisPsn(psn)
  15266. c.ServeSuccessJSON(map[string]interface{}{
  15267. "patient": patient,
  15268. "number": token,
  15269. "insutype": insutype,
  15270. })
  15271. }
  15272. } else {
  15273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15274. return
  15275. }
  15276. } else { //读卡失败
  15277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15278. return
  15279. }
  15280. }
  15281. break
  15282. }
  15283. }
  15284. var initFlag int64 = 0
  15285. var initEleFlag int64 = 0
  15286. func (c *HisApiController) TestGetBasBaseInit() {
  15287. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15288. Iinit := DllDef.MustFindProc("Init")
  15289. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15290. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  15291. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  15292. if ret != 0 {
  15293. fmt.Println("SSCard的报错原因:", err)
  15294. fmt.Println("SSCard的运算结果为:", ret)
  15295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15296. return
  15297. }
  15298. result := int(ret)
  15299. fmt.Println("SSCard的运算结果为1:", result)
  15300. initFlag = 1
  15301. return
  15302. }
  15303. func (c *HisApiController) HandleJiangXiReadCard() {
  15304. fmt.Println("~~~~~~")
  15305. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15306. admin_user_id, _ := c.GetInt64("admin_user_id")
  15307. id_card_type, _ := c.GetInt64("id_card_type")
  15308. //certificates, _ := c.GetInt64("certificates")
  15309. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  15310. if initFlag == 0 {
  15311. c.TestGetJiangXiBasBaseInit()
  15312. }
  15313. basStr := c.GetBasBaseInfo()
  15314. if len(basStr) == 0 {
  15315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15316. return
  15317. }
  15318. fmt.Println(basStr)
  15319. bas := strings.Split(basStr, "|")
  15320. basNumber := bas[1]
  15321. fmt.Println(basNumber)
  15322. card_sn := bas[3]
  15323. fmt.Println(card_sn)
  15324. 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, "")
  15325. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  15326. var dat map[string]interface{}
  15327. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15328. fmt.Println(dat)
  15329. } else {
  15330. fmt.Println(err)
  15331. }
  15332. userJSONBytes, _ := json.Marshal(dat)
  15333. var res ResultTwo
  15334. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15335. utils.ErrorLog("解析失败:%v", err)
  15336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15337. return
  15338. }
  15339. if res.Infcode == 0 {
  15340. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  15341. if err == gorm.ErrRecordNotFound {
  15342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15343. return
  15344. } else if err != nil {
  15345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15346. return
  15347. } else {
  15348. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15349. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15350. infoStr := string(Iinfos)
  15351. idetinfoStr := string(Idetinfos)
  15352. psn := &models.HisPsn{
  15353. PsnNo: res.Output.Baseinfo.PsnNo,
  15354. PatientId: patient.ID,
  15355. Certno: res.Output.Baseinfo.Certno,
  15356. Gend: res.Output.Baseinfo.Gend,
  15357. Naty: res.Output.Baseinfo.Naty,
  15358. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15359. PsnName: res.Output.Baseinfo.PsnName,
  15360. Idetinfo: idetinfoStr,
  15361. Insuinfo: infoStr,
  15362. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15363. CardInfo: basStr,
  15364. VerifyNumber: "",
  15365. }
  15366. service.CreateHisPsn(psn)
  15367. c.ServeSuccessJSON(map[string]interface{}{
  15368. "patient": patient,
  15369. "number": basNumber,
  15370. })
  15371. }
  15372. } else {
  15373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15374. return
  15375. }
  15376. }
  15377. func (c *HisApiController) TestGetHnBasBaseInit() {
  15378. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15379. Iinit := DllDef.MustFindProc("Init")
  15380. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15381. //http://10.77.211.236/CSB/hsa-fsi-1303
  15382. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  15383. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  15384. // 调用 Init 函数
  15385. 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"))))
  15386. //if ret != 0 {
  15387. fmt.Println("SSCard的报错原因:", err)
  15388. fmt.Println("SSCard的运算结果为:", ret)
  15389. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15390. // return
  15391. //}
  15392. result := int(ret)
  15393. fmt.Println("SSCard的运算结果为1:", result)
  15394. initFlag = 1
  15395. return
  15396. }
  15397. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  15398. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15399. Iinit := DllDef.MustFindProc("Init")
  15400. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15401. //http://10.77.211.236/CSB/hsa-fsi-1303
  15402. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  15403. if ret != 0 {
  15404. fmt.Println("SSCard的报错原因:", err)
  15405. fmt.Println("SSCard的运算结果为:", ret)
  15406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15407. return
  15408. }
  15409. result := int(ret)
  15410. fmt.Println("SSCard的运算结果为1:", result)
  15411. initFlag = 1
  15412. return
  15413. }
  15414. func (c *HisApiController) GetSFZBaseInfo() string {
  15415. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15416. readCard := DllDef.MustFindProc("ReadSFZ")
  15417. if readCard == nil {
  15418. fmt.Println("readcard is nil")
  15419. readCard = DllDef.MustFindProc("ReadSFZ")
  15420. }
  15421. str := make([]byte, 8096)
  15422. str1 := make([]byte, 8096)
  15423. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  15424. fmt.Println(r)
  15425. return Remove0000(string(str))
  15426. }
  15427. func (c *HisApiController) GetEleBaseInfo() string {
  15428. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15429. readCard := DllDef.MustFindProc("GetQRBase")
  15430. fmt.Println(readCard)
  15431. if readCard == nil {
  15432. fmt.Println("readcard is nil")
  15433. readCard = DllDef.MustFindProc("GetQRBase")
  15434. }
  15435. str := make([]byte, 1024)
  15436. str1 := make([]byte, 1024)
  15437. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  15438. fmt.Println(ret2)
  15439. fmt.Println(string(str1))
  15440. fmt.Println(string(str))
  15441. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15442. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  15443. if ret2 != 0 {
  15444. return ""
  15445. }
  15446. return string(str)
  15447. }
  15448. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  15449. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  15450. readCard := DllDef.MustFindProc("NationEcTrans")
  15451. fmt.Println(readCard)
  15452. fmt.Println("!!!!!")
  15453. pBusiCardInfo := make([]byte, 2048)
  15454. input := make(map[string]interface{})
  15455. inputData := make(map[string]interface{})
  15456. inputData["orgId"] = code
  15457. inputData["businessType"] = "01101"
  15458. inputData["operatorId"] = "1"
  15459. inputData["operatorName"] = "admin"
  15460. inputData["officeId"] = "001"
  15461. inputData["officeName"] = "血透室"
  15462. inputData["deviceType"] = ""
  15463. input["data"] = inputData
  15464. input["orgId"] = code
  15465. input["transType"] = "ec.query"
  15466. bytesData, _ := json.Marshal(input)
  15467. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  15468. fmt.Println(ret2)
  15469. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  15470. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  15471. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  15472. }
  15473. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  15474. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  15475. readCard := DllDef.MustFindProc("NationEcTrans")
  15476. fmt.Println(readCard)
  15477. fmt.Println("!!!!!")
  15478. pBusiCardInfo := make([]byte, 2048)
  15479. input := make(map[string]interface{})
  15480. inputData := make(map[string]interface{})
  15481. inputData["orgId"] = code
  15482. inputData["businessType"] = "01101"
  15483. inputData["operatorId"] = "9"
  15484. inputData["operatorName"] = "admin"
  15485. inputData["officeId"] = "001"
  15486. inputData["officeName"] = "血透室"
  15487. inputData["deviceType"] = ""
  15488. input["data"] = inputData
  15489. input["orgId"] = code
  15490. input["transType"] = "ec.query"
  15491. bytesData, _ := json.Marshal(input)
  15492. 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])))
  15493. fmt.Println(ret2)
  15494. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  15495. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  15496. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  15497. }
  15498. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  15499. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  15500. readCard := DllDef.MustFindProc("NationEcTrans")
  15501. fmt.Println(readCard)
  15502. fmt.Println("!!!!!")
  15503. pBusiCardInfo := make([]byte, 2048)
  15504. input := make(map[string]interface{})
  15505. inputData := make(map[string]interface{})
  15506. inputData["orgId"] = code
  15507. inputData["businessType"] = "01301"
  15508. inputData["operatorId"] = "9"
  15509. inputData["operatorName"] = "admin"
  15510. inputData["officeId"] = "001"
  15511. inputData["officeName"] = "血透室"
  15512. inputData["deviceType"] = ""
  15513. input["data"] = inputData
  15514. input["orgId"] = code
  15515. input["transType"] = "ec.query"
  15516. bytesData, _ := json.Marshal(input)
  15517. 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])))
  15518. fmt.Println(ret2)
  15519. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  15520. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  15521. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  15522. }
  15523. func GetJxEleBaseInfo(org_id int64) string {
  15524. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15525. readCard := DllDef.MustFindProc("NationEcTrans")
  15526. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  15527. if readCard == nil {
  15528. fmt.Println("readcard is nil")
  15529. readCard = DllDef.MustFindProc("NationEcTrans")
  15530. }
  15531. str1 := make([]byte, 1024)
  15532. data := make(map[string]interface{})
  15533. inputData := make(map[string]interface{})
  15534. inputData["orgId"] = miConfig.Code
  15535. inputData["businessType"] = "01101"
  15536. inputData["operatorId"] = "test001"
  15537. inputData["operatorName"] = "cn"
  15538. inputData["officeId"] = "32760"
  15539. inputData["officeName"] = "waike"
  15540. inputData["deviceType"] = ""
  15541. data["data"] = inputData
  15542. data["transType"] = "ec.query"
  15543. data["extra "] = ""
  15544. data["orgId"] = miConfig.Code
  15545. bytesData, _ := json.Marshal(data)
  15546. //bytesData, _ := json.Marshal(data)
  15547. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  15548. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  15549. fmt.Println(ret2)
  15550. fmt.Println(string(str1))
  15551. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15552. if ret2 != 0 {
  15553. return ""
  15554. }
  15555. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  15556. }
  15557. //func GetJxEleBaseInfoTWO(org_id int64) string {
  15558. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  15559. // readCard := DllDef.MustFindProc("NationEcTrans")
  15560. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  15561. //
  15562. // if readCard == nil {
  15563. // fmt.Println("readcard is nil")
  15564. // readCard = DllDef.MustFindProc("NationEcTrans")
  15565. // }
  15566. // str1 := make([]byte, 1024)
  15567. //
  15568. // data := make(map[string]interface{})
  15569. //
  15570. // inputData := make(map[string]interface{})
  15571. // inputData["orgId"] = miConfig.Code
  15572. // inputData["businessType"] = "01101"
  15573. // inputData["operatorId"] = "test001"
  15574. // inputData["operatorName"] = "cn"
  15575. // inputData["officeId"] = "32760"
  15576. // inputData["officeName"] = "waike"
  15577. // inputData["deviceType"] = ""
  15578. //
  15579. // data["data"] = inputData
  15580. // data["transType"] = "ec.query"
  15581. // data["extra "] = ""
  15582. // data["orgId"] = miConfig.Code
  15583. // bytesData, _ := json.Marshal(data)
  15584. // //bytesData, _ := json.Marshal(data)
  15585. //
  15586. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  15587. //
  15588. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  15589. // fmt.Println(ret2)
  15590. // fmt.Println(string(str1))
  15591. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15592. //
  15593. // if ret2 != 0 {
  15594. // return ""
  15595. // }
  15596. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  15597. //}
  15598. func GetJxEleBaseInitInfo(org_id int64) string {
  15599. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15600. readCard := DllDef.MustFindProc("NationEcTrans")
  15601. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  15602. if readCard == nil {
  15603. fmt.Println("readcard is nil")
  15604. readCard = DllDef.MustFindProc("NationEcTrans")
  15605. }
  15606. str1 := make([]byte, 2048)
  15607. data := make(map[string]interface{})
  15608. inputData := make(map[string]interface{})
  15609. inputData["orgId"] = miConfig.Code
  15610. inputData["businessType"] = "01101"
  15611. inputData["operatorId"] = "1"
  15612. inputData["operatorName"] = "huangchuang"
  15613. inputData["officeId"] = "101"
  15614. inputData["officeName"] = "xuetou"
  15615. inputData["deviceType"] = ""
  15616. data["data"] = inputData
  15617. data["transType"] = "ec.query"
  15618. data["orgId"] = miConfig.Code
  15619. bytesData, _ := json.Marshal(data)
  15620. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  15621. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  15622. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  15623. fmt.Println(ret2)
  15624. fmt.Println(string(str1))
  15625. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15626. if ret2 != 0 {
  15627. return ""
  15628. }
  15629. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  15630. initEleFlag = 1
  15631. }
  15632. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  15633. }
  15634. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  15635. // // 构建命令
  15636. // cmd := exec.Command("python", "b.py")
  15637. //
  15638. // // 执行命令并等待完成
  15639. // output, err := cmd.CombinedOutput()
  15640. // if err != nil {
  15641. // fmt.Println("Error executing Python script:", err)
  15642. // return
  15643. // }
  15644. //
  15645. // // 打印Python脚本的输出
  15646. // fmt.Println(string(output))
  15647. //}
  15648. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  15649. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  15650. readCard := DllDef.MustFindProc("gxyb_call")
  15651. if readCard == nil {
  15652. fmt.Println("readcard is nil")
  15653. readCard = DllDef.MustFindProc("gxyb_call")
  15654. }
  15655. str := make([]byte, 1024)
  15656. str1 := make([]byte, 1024)
  15657. //data := make(map[string]interface{})
  15658. currentTime := time.Now()
  15659. // 格式化时间为 "YYYYMMDDHH24MISS"
  15660. formattedTime := currentTime.Format("20060102150405")
  15661. inputData := make(map[string]interface{})
  15662. inputData2 := make(map[string]interface{})
  15663. inputData["transNo"] = "1401"
  15664. inputData["transType"] = "passwordCheck"
  15665. inputData["timestamp"] = formattedTime
  15666. inputData2["fixmedinsCode"] = code
  15667. inputData2["psnNo"] = ""
  15668. inputData["data"] = inputData2
  15669. jsonBytes, err := json.Marshal(inputData)
  15670. if err != nil {
  15671. fmt.Println("Error encoding map to JSON:", err)
  15672. }
  15673. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  15674. fmt.Println(string(str1))
  15675. fmt.Println(string(str))
  15676. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15677. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  15678. if ret2 != 0 {
  15679. return ""
  15680. }
  15681. return string(str)
  15682. }
  15683. func (c *HisApiController) GetoleInfo() Response {
  15684. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  15685. defer ole.CoUninitialize()
  15686. // Replace with the ProgID or CLSID of your COM object
  15687. progID := "YinHai.XJ.Actual.Interface.New"
  15688. // Create COM object
  15689. unknown, err := oleutil.CreateObject(progID)
  15690. if err != nil {
  15691. fmt.Println("Unable to create COM object:", err)
  15692. }
  15693. defer unknown.Release()
  15694. // Query for the IDispatch interface
  15695. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  15696. if err != nil {
  15697. fmt.Println("Unable to get IDispatch interface:", err)
  15698. }
  15699. defer dispatch.Release()
  15700. // Prepare parameters
  15701. transNo := "1401"
  15702. transType := "passwordCheck"
  15703. timestamp := time.Now().Unix()
  15704. fixmedinsCode := "H45072101171"
  15705. psnNo := ""
  15706. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  15707. result2 := ""
  15708. // Call COM object's method using the IDispatch interface
  15709. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  15710. fmt.Println(resulr)
  15711. fmt.Println(result2)
  15712. if err != nil {
  15713. fmt.Println("调用COM对象方法失败:", err)
  15714. }
  15715. var response Response
  15716. err2 := json.Unmarshal([]byte(result2), &response)
  15717. if err2 != nil {
  15718. fmt.Println("解析JSON失败:", err)
  15719. }
  15720. return response
  15721. }
  15722. func (c *HisApiController) GetBasBaseInfo() string {
  15723. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15724. readCard := DllDef.MustFindProc("ReadCardBas")
  15725. if readCard == nil {
  15726. fmt.Println("readcard is nil")
  15727. readCard = DllDef.MustFindProc("ReadCardBas")
  15728. }
  15729. str := make([]byte, 1024)
  15730. str1 := make([]byte, 1024)
  15731. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  15732. fmt.Println(string(str1))
  15733. fmt.Println(string(str))
  15734. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15735. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  15736. if ret2 != 0 {
  15737. return ""
  15738. }
  15739. return string(str)
  15740. }
  15741. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  15742. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  15743. readCard := DllDef.MustFindProc("read_cardinfo")
  15744. if readCard == nil {
  15745. fmt.Println("readcard is nil")
  15746. readCard = DllDef.MustFindProc("read_cardinfo")
  15747. }
  15748. str := make([]byte, 1024) //卡号
  15749. str1 := make([]byte, 1024) //卡识别码
  15750. str2 := make([]byte, 1024) //身份证号
  15751. str3 := make([]byte, 1024) //姓名
  15752. str4 := make([]byte, 1024) //错误信息
  15753. 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])))
  15754. fmt.Println(string(str1))
  15755. fmt.Println(string(str))
  15756. fmt.Println(string(str2))
  15757. fmt.Println(string(str3))
  15758. fmt.Println(string(str4))
  15759. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15760. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  15761. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  15762. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  15763. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  15764. if ret2 != 0 {
  15765. return "", "", "", "", ""
  15766. }
  15767. return string(str), string(str1), string(str2), string(str3), string(str4)
  15768. }
  15769. type CustomFundPay struct {
  15770. FundPayType string `json:"fund_pay_type"`
  15771. FundPayamt float64 `json:"fund_payamt"`
  15772. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15773. }
  15774. //func (c *HisApiController) GetBatchSettleList() {
  15775. // start_time_str := c.GetString("start_time")
  15776. // //end_time_str := c.GetString("end_time")
  15777. // admin_user_id, _ := c.GetInt64("admin_user_id")
  15778. //
  15779. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  15780. //
  15781. // for _, item := range orders {
  15782. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  15783. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  15784. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  15785. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  15786. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  15787. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  15788. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15789. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  15790. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  15791. //
  15792. // if order.ID == 0 {
  15793. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  15794. // return
  15795. // }
  15796. //
  15797. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  15798. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  15799. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  15800. // //fmt.Println(count)
  15801. // //var zero string
  15802. // //number := count + 1
  15803. // //if number >= 1000 {
  15804. // // zero = "0000" + strconv.FormatInt(number, 10)
  15805. // //} else if number >= 10000 {
  15806. // // zero = "000" + strconv.FormatInt(number, 10)
  15807. // //} else if number >= 100000 {
  15808. // // zero = "00" + strconv.FormatInt(number, 10)
  15809. // //} else if number >= 1000000 {
  15810. // // zero = "0" + strconv.FormatInt(number, 10)
  15811. // //} else {
  15812. // // zero = strconv.FormatInt(number, 10)
  15813. // //}
  15814. // //fmt.Println(zero)
  15815. //
  15816. // struct4101 := service.Struct4101{
  15817. // PsnNo: order.PsnNo,
  15818. // MdtrtId: order.MdtrtId,
  15819. // SetlId: order.SetlId,
  15820. // PsnName: order.PsnName,
  15821. // Gend: order.Gend,
  15822. // Brdy: his.Brdy,
  15823. // Age: his.Age,
  15824. // Naty: order.Naty,
  15825. // PatnCertType: "01",
  15826. // Certno: order.Certno,
  15827. // Prfs: "90",
  15828. // ConerName: roles[0].UserName,
  15829. // PatnRlts: "99",
  15830. // ConerAddr: miConfig.OrgName,
  15831. // ConerTel: admin.Mobile,
  15832. // HiType: order.Insutype,
  15833. // Insuplc: miConfig.InsuplcAdmdvs,
  15834. // MaindiagFlag: "1",
  15835. // BillCode: order.SetlId,
  15836. // BillNo: order.SetlId,
  15837. // BizSn: order.Number,
  15838. // PsnSelfPay: order.PsnPartAmt,
  15839. // PsnOwnPay: order.PsnPartAmt,
  15840. // AcctPay: order.AcctPay,
  15841. // PsnCashpay: order.PsnCashPay,
  15842. // HiPaymtd: "1",
  15843. // Hsorg: miConfig.InsuplcAdmdvs,
  15844. // HsorgOpter: miConfig.InsuplcAdmdvs,
  15845. // MedinsFillPsn: curRoles.UserName,
  15846. // MedinsFillDept: miConfig.OrgName,
  15847. // IptMedType: "2",
  15848. // }
  15849. // struct4101.SetlBegnDate = order.SetlTime
  15850. // struct4101.SetlEndDate = order.SetlTime
  15851. // time_arr := strings.Split(order.SetlTime, " ")
  15852. // struct4101.AdmTime = time_arr[0]
  15853. // struct4101.AdmEndTime = time_arr[0]
  15854. //
  15855. // var rf []CustomFundPay
  15856. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  15857. //
  15858. // var tempFunPays []service.CustomStruct
  15859. // for _, item := range rf {
  15860. // var tempFunPay service.CustomStruct
  15861. // tempFunPay.FundPayamt = item.FundPayamt
  15862. // tempFunPay.FundPayType = item.FundPayType
  15863. // tempFunPays = append(tempFunPays, tempFunPay)
  15864. // }
  15865. // struct4101.CustomStruct = tempFunPays
  15866. //
  15867. // var tempDiaginfos []service.DiaginfoStructTwo
  15868. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  15869. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  15870. //
  15871. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  15872. // var config []*models.HisXtDiagnoseConfig
  15873. // for _, item := range diagnosis_ids {
  15874. // id, _ := strconv.ParseInt(item, 10, 64)
  15875. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  15876. // config = append(config, &diagnosisConfig)
  15877. // }
  15878. //
  15879. // for index, item := range config {
  15880. // if index == 0 {
  15881. // var tempDiaginfo service.DiaginfoStructTwo
  15882. // tempDiaginfo.DiagCode = item.CountryCode
  15883. // tempDiaginfo.DiagName = item.CountryContentName
  15884. // tempDiaginfo.DiagType = "1"
  15885. // tempDiaginfo.MaindiagFlag = "1"
  15886. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  15887. // } else {
  15888. // var tempDiaginfo service.DiaginfoStructTwo
  15889. // tempDiaginfo.DiagCode = item.CountryCode
  15890. // tempDiaginfo.DiagName = item.CountryContentName
  15891. // tempDiaginfo.DiagType = "1"
  15892. // tempDiaginfo.MaindiagFlag = "0"
  15893. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  15894. // }
  15895. // }
  15896. // struct4101.Diseinfo = tempDiaginfos
  15897. //
  15898. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  15899. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  15900. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  15901. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  15902. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  15903. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  15904. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  15905. //
  15906. // var iteminfo service.IteminfoStruct
  15907. //
  15908. // var bedCostTotal float64 = 0 //床位总费
  15909. // var bedCostSelfTotal float64 = 0 //床位自费
  15910. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  15911. //
  15912. // var operationCostTotal float64 = 0 //手术费
  15913. // var operationCostSelfTotal float64 = 0 //手术费
  15914. // var operationCostPartSelfTotal float64 = 0 //手术费
  15915. //
  15916. // var otherCostTotal float64 = 0 //其他费用
  15917. // var otherCostSelfTotal float64 = 0 //其他费用
  15918. // var otherCostPartSelfTotal float64 = 0 //其他费用
  15919. //
  15920. // var materialCostTotal float64 = 0 //材料费
  15921. // var materialCostSelfTotal float64 = 0 //材料费
  15922. // var materialCostPartSelfTotal float64 = 0 //材料费
  15923. //
  15924. // var westernMedicineCostTotal float64 = 0 //西药费
  15925. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  15926. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  15927. //
  15928. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  15929. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  15930. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  15931. //
  15932. // var checkCostTotal float64 = 0 //检查费
  15933. // var checkCostSelfTotal float64 = 0 //检查费
  15934. // var checkCostPartSelfTotal float64 = 0 //检查费
  15935. //
  15936. // var laboratoryCostTotal float64 = 0 //化验费
  15937. // var laboratoryCostSelfTotal float64 = 0 //化验费
  15938. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  15939. //
  15940. // var treatCostTotal float64 = 0 //治疗费用
  15941. // var treatCostSelfTotal float64 = 0 //治疗费用
  15942. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  15943. //
  15944. // decimal.DivisionPrecision = 2
  15945. //
  15946. // var bed_fulamt_ownpay_amt float64 = 0
  15947. // var operation_fulamt_ownpay_amt float64 = 0
  15948. // var other_fulamt_ownpay_amt float64 = 0
  15949. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  15950. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  15951. // var check_fulamt_ownpay_amt float64 = 0
  15952. // var material_fulamt_ownpay_amt float64 = 0
  15953. // var laboratory_fulamt_ownpay_amt float64 = 0
  15954. // var treat_fulamt_ownpay_amt float64 = 0
  15955. //
  15956. // var bed_claa_sunmfee float64 = 0
  15957. // var bed_clab_amt float64 = 0
  15958. // var bed_other_amt float64 = 0
  15959. //
  15960. // var operation_claa_sunmfee float64 = 0
  15961. // var operation_clab_amt float64 = 0
  15962. // var operation_other_amt float64 = 0
  15963. //
  15964. // var other_claa_sunmfee float64 = 0
  15965. // var other_clab_amt float64 = 0
  15966. // var other_other_amt float64 = 0
  15967. //
  15968. // var westernMedicine_claa_sunmfee float64 = 0
  15969. // var westernMedicine_clab_amt float64 = 0
  15970. // var westernMedicine_other_amt float64 = 0
  15971. //
  15972. // var chineseTraditional_claa_sunmfee float64 = 0
  15973. // var chineseTraditional_clab_amt float64 = 0
  15974. // var chineseTraditional_other_amt float64 = 0
  15975. //
  15976. // var check_claa_sunmfee float64 = 0
  15977. // var check_clab_amt float64 = 0
  15978. // var check_other_amt float64 = 0
  15979. //
  15980. // var material_claa_sunmfee float64 = 0
  15981. // var material_clab_amt float64 = 0
  15982. // var material_other_amt float64 = 0
  15983. //
  15984. // var laboratory_claa_sunmfee float64 = 0
  15985. // var laboratory_clab_amt float64 = 0
  15986. // var laboratory_other_amt float64 = 0
  15987. //
  15988. // var treat_claa_sunmfee float64 = 0
  15989. // var treat_clab_amt float64 = 0
  15990. // var treat_other_amt float64 = 0
  15991. //
  15992. // for _, item := range order.HisOrderInfo {
  15993. // if item.MedChrgitmType == "01" { //床位费
  15994. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15995. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15996. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15997. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15998. // if item.ChrgitmLv == "1" {
  15999. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16000. // }
  16001. // if item.ChrgitmLv == "2" {
  16002. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16003. //
  16004. // }
  16005. // if item.ChrgitmLv == "3" {
  16006. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16007. // }
  16008. //
  16009. // }
  16010. //
  16011. // if item.MedChrgitmType == "03" { //检查费
  16012. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16013. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16014. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16015. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16016. // if item.ChrgitmLv == "1" {
  16017. //
  16018. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16019. //
  16020. // }
  16021. // if item.ChrgitmLv == "2" {
  16022. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16023. //
  16024. // }
  16025. // if item.ChrgitmLv == "3" {
  16026. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16027. // }
  16028. // }
  16029. //
  16030. // if item.MedChrgitmType == "04" { //化验费
  16031. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16032. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16033. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16034. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16035. // if item.ChrgitmLv == "1" {
  16036. //
  16037. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16038. //
  16039. // }
  16040. // if item.ChrgitmLv == "2" {
  16041. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16042. //
  16043. // }
  16044. // if item.ChrgitmLv == "3" {
  16045. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16046. // }
  16047. // }
  16048. //
  16049. // if item.MedChrgitmType == "05" { //治疗费
  16050. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16051. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16052. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16053. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16054. // if item.ChrgitmLv == "1" {
  16055. //
  16056. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16057. //
  16058. // }
  16059. // if item.ChrgitmLv == "2" {
  16060. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16061. //
  16062. // }
  16063. // if item.ChrgitmLv == "3" {
  16064. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16065. // }
  16066. // }
  16067. //
  16068. // if item.MedChrgitmType == "06" { //手术费
  16069. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16070. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16071. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16072. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16073. //
  16074. // if item.ChrgitmLv == "1" {
  16075. //
  16076. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16077. //
  16078. // }
  16079. // if item.ChrgitmLv == "2" {
  16080. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16081. //
  16082. // }
  16083. // if item.ChrgitmLv == "3" {
  16084. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16085. // }
  16086. // }
  16087. //
  16088. // if item.MedChrgitmType == "08" { //材料费
  16089. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16090. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16091. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16092. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16093. // if item.ChrgitmLv == "1" {
  16094. //
  16095. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16096. //
  16097. // }
  16098. // if item.ChrgitmLv == "2" {
  16099. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16100. //
  16101. // }
  16102. // if item.ChrgitmLv == "3" {
  16103. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16104. // }
  16105. // }
  16106. //
  16107. // if item.MedChrgitmType == "09" { //西药费
  16108. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16109. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16110. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16111. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16112. // if item.ChrgitmLv == "1" {
  16113. //
  16114. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16115. //
  16116. // }
  16117. // if item.ChrgitmLv == "2" {
  16118. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16119. //
  16120. // }
  16121. // if item.ChrgitmLv == "3" {
  16122. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16123. // }
  16124. // }
  16125. //
  16126. // if item.MedChrgitmType == "11" { //中成费
  16127. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16128. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16129. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16130. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16131. // if item.ChrgitmLv == "1" {
  16132. //
  16133. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16134. //
  16135. // }
  16136. // if item.ChrgitmLv == "2" {
  16137. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16138. //
  16139. // }
  16140. // if item.ChrgitmLv == "3" {
  16141. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16142. // }
  16143. // }
  16144. //
  16145. // if item.MedChrgitmType == "14" { //其他费
  16146. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16147. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16148. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16149. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16150. // if item.ChrgitmLv == "1" {
  16151. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16152. //
  16153. // }
  16154. // if item.ChrgitmLv == "2" {
  16155. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16156. //
  16157. // }
  16158. // if item.ChrgitmLv == "3" {
  16159. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16160. // }
  16161. // }
  16162. //
  16163. // }
  16164. //
  16165. // var iteminfoStructs []service.IteminfoStruct
  16166. //
  16167. // if bedCostTotal != 0 {
  16168. // iteminfo.MedChrgitm = "01"
  16169. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  16170. // iteminfo.Amt = bedCostTotal
  16171. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  16172. // iteminfo.ClabAmt = bed_clab_amt
  16173. // iteminfo.OthAmt = bed_other_amt
  16174. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16175. // }
  16176. //
  16177. // if checkCostTotal != 0 {
  16178. // iteminfo.MedChrgitm = "03"
  16179. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  16180. // iteminfo.Amt = checkCostTotal
  16181. // iteminfo.ClaaSumfee = check_claa_sunmfee
  16182. // iteminfo.ClabAmt = check_clab_amt
  16183. // iteminfo.OthAmt = check_other_amt
  16184. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16185. //
  16186. // }
  16187. //
  16188. // if laboratoryCostTotal != 0 {
  16189. // iteminfo.MedChrgitm = "04"
  16190. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  16191. // iteminfo.Amt = laboratoryCostTotal
  16192. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  16193. // iteminfo.ClabAmt = laboratory_clab_amt
  16194. // iteminfo.OthAmt = laboratory_other_amt
  16195. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16196. //
  16197. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16198. //
  16199. // }
  16200. //
  16201. // if treatCostTotal != 0 {
  16202. // iteminfo.MedChrgitm = "05"
  16203. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  16204. // iteminfo.Amt = treatCostTotal
  16205. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  16206. // iteminfo.ClabAmt = treat_clab_amt
  16207. // iteminfo.OthAmt = treat_other_amt
  16208. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16209. // //(struct4101.IteminfoStruct, iteminfo)
  16210. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16211. // }
  16212. //
  16213. // if operationCostTotal != 0 {
  16214. // iteminfo.MedChrgitm = "06"
  16215. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  16216. // iteminfo.Amt = operationCostTotal
  16217. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  16218. // iteminfo.ClabAmt = operation_clab_amt
  16219. // iteminfo.OthAmt = operation_other_amt
  16220. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16221. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16222. // }
  16223. //
  16224. // if materialCostTotal != 0 {
  16225. // iteminfo.MedChrgitm = "08"
  16226. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  16227. // iteminfo.Amt = materialCostTotal
  16228. // iteminfo.ClaaSumfee = material_claa_sunmfee
  16229. // iteminfo.ClabAmt = material_clab_amt
  16230. // iteminfo.OthAmt = material_other_amt
  16231. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16232. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16233. // }
  16234. //
  16235. // if westernMedicineCostTotal != 0 {
  16236. // iteminfo.MedChrgitm = "09"
  16237. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  16238. // iteminfo.Amt = westernMedicineCostTotal
  16239. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  16240. // iteminfo.ClabAmt = westernMedicine_clab_amt
  16241. // iteminfo.OthAmt = westernMedicine_other_amt
  16242. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16243. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16244. //
  16245. // }
  16246. // if chineseTraditionalMedicineCostTotal != 0 {
  16247. // iteminfo.MedChrgitm = "11"
  16248. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  16249. // iteminfo.Amt = westernMedicineCostTotal
  16250. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  16251. // iteminfo.ClabAmt = westernMedicine_clab_amt
  16252. // iteminfo.OthAmt = westernMedicine_other_amt
  16253. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16254. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16255. //
  16256. // }
  16257. // if otherCostTotal != 0 {
  16258. // iteminfo.MedChrgitm = "14"
  16259. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  16260. // iteminfo.Amt = otherCostTotal
  16261. // iteminfo.ClaaSumfee = other_claa_sunmfee
  16262. // iteminfo.ClabAmt = other_clab_amt
  16263. // iteminfo.OthAmt = other_other_amt
  16264. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16265. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16266. //
  16267. // }
  16268. // struct4101.IteminfoStruct = iteminfoStructs
  16269. // struct4101.Ntly = "中国"
  16270. // struct4101.AdmCaty = "A03.06"
  16271. //
  16272. // struct4101.DoctorName = doctor.UserName
  16273. // struct4101.DoctorCode = doctor.DoctorNumber
  16274. //
  16275. // var res ResultSeventeen
  16276. //
  16277. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16278. // struct4101.BillCode = order.Number
  16279. // struct4101.BillNo = order.SetlId
  16280. // var resOther ResultSeventeenOther
  16281. // var pp models.PublicParams
  16282. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16283. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16284. // pp.FixmedinsName = miConfig.OrgName
  16285. // pp.FixmedinsCode = miConfig.Code
  16286. // pp.RequestUrl = miConfig.Url
  16287. // pp.Cainfo = miConfig.Cainfo
  16288. // pp.SecretKey = miConfig.SecretKey
  16289. // pp.AccessKey = miConfig.AccessKey
  16290. // pp.OpterName = curRoles.UserName
  16291. //
  16292. // client := &http.Client{}
  16293. // var req *http.Request
  16294. // data := make(map[string]interface{})
  16295. // data["struct4101"] = struct4101
  16296. // data["pp"] = pp
  16297. // bytesData, _ := json.Marshal(data)
  16298. // if miConfig.MdtrtareaAdmvs == "320921" {
  16299. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  16300. // } else {
  16301. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  16302. // }
  16303. // resp, _ := client.Do(req)
  16304. // defer resp.Body.Close()
  16305. // body, ioErr := ioutil.ReadAll(resp.Body)
  16306. // if ioErr != nil {
  16307. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16308. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16309. // return
  16310. // }
  16311. // var respJSON map[string]interface{}
  16312. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16313. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16314. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16315. // return
  16316. // }
  16317. //
  16318. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16319. // userJSONBytes, _ := json.Marshal(respJSON)
  16320. // fmt.Println("log")
  16321. // fmt.Println(string(userJSONBytes))
  16322. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  16323. // utils.ErrorLog("解析失败:%v", err)
  16324. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16325. // return
  16326. // }
  16327. // res.InfRefmsgid = resOther.InfRefmsgid
  16328. // res.Output = resOther.Output
  16329. // res.ErrMsg = resOther.ErrMsg
  16330. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  16331. // res.Infcode = infocode
  16332. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  16333. //
  16334. // var pp models.PublicParams
  16335. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16336. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16337. // pp.FixmedinsName = miConfig.OrgName
  16338. // pp.FixmedinsCode = miConfig.Code
  16339. // pp.RequestUrl = miConfig.Url
  16340. // pp.Cainfo = miConfig.Cainfo
  16341. // pp.SecretKey = miConfig.SecretKey
  16342. // pp.AccessKey = miConfig.AccessKey
  16343. // pp.OpterName = curRoles.UserName
  16344. // result, _ := service.Jxyb4101(struct4101, pp)
  16345. // var dat map[string]interface{}
  16346. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16347. // fmt.Println(dat)
  16348. // } else {
  16349. // fmt.Println(err)
  16350. // }
  16351. // userJSONBytes, _ := json.Marshal(dat)
  16352. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16353. // utils.ErrorLog("解析失败:%v", err)
  16354. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16355. // return
  16356. // }
  16357. //
  16358. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  16359. // var pp models.PublicParams
  16360. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16361. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16362. // pp.FixmedinsName = miConfig.OrgName
  16363. // pp.FixmedinsCode = miConfig.Code
  16364. // pp.RequestUrl = miConfig.Url
  16365. // pp.Cainfo = miConfig.Cainfo
  16366. // pp.SecretKey = miConfig.SecretKey
  16367. // pp.AccessKey = miConfig.AccessKey
  16368. // pp.OpterName = curRoles.UserName
  16369. // result, _ := service.Hnyb4101(struct4101, pp)
  16370. // var dat map[string]interface{}
  16371. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16372. // fmt.Println(dat)
  16373. // } else {
  16374. // fmt.Println(err)
  16375. // }
  16376. // userJSONBytes, _ := json.Marshal(dat)
  16377. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16378. // utils.ErrorLog("解析失败:%v", err)
  16379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16380. // return
  16381. // }
  16382. //
  16383. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  16384. // var resOther ResultSeventeenOther
  16385. //
  16386. // var pp models.PublicParams
  16387. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16388. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16389. // pp.FixmedinsName = miConfig.OrgName
  16390. // pp.FixmedinsCode = miConfig.Code
  16391. // pp.RequestUrl = miConfig.Url
  16392. // pp.Cainfo = miConfig.Cainfo
  16393. // pp.SecretKey = miConfig.SecretKey
  16394. // pp.AccessKey = miConfig.AccessKey
  16395. // pp.OpterName = curRoles.UserName
  16396. // client := &http.Client{}
  16397. // var req *http.Request
  16398. // data := make(map[string]interface{})
  16399. // data["struct4101"] = struct4101
  16400. // data["pp"] = pp
  16401. // bytesData, _ := json.Marshal(data)
  16402. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  16403. // resp, _ := client.Do(req)
  16404. // defer resp.Body.Close()
  16405. // body, ioErr := ioutil.ReadAll(resp.Body)
  16406. // if ioErr != nil {
  16407. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16408. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16409. // return
  16410. // }
  16411. // var respJSON map[string]interface{}
  16412. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16413. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16414. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16415. // return
  16416. // }
  16417. //
  16418. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16419. // userJSONBytes, _ := json.Marshal(respJSON)
  16420. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  16421. // utils.ErrorLog("解析失败:%v", err)
  16422. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16423. // return
  16424. // }
  16425. // res.InfRefmsgid = resOther.InfRefmsgid
  16426. // res.Output = resOther.Output
  16427. // res.ErrMsg = resOther.ErrMsg
  16428. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  16429. // res.Infcode = infocode
  16430. //
  16431. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  16432. // var pp models.PublicParams
  16433. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16434. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16435. // pp.FixmedinsName = miConfig.OrgName
  16436. // pp.FixmedinsCode = miConfig.Code
  16437. // pp.RequestUrl = miConfig.Url
  16438. // pp.Cainfo = miConfig.Cainfo
  16439. // pp.SecretKey = miConfig.SecretKey
  16440. // pp.AccessKey = miConfig.AccessKey
  16441. // pp.OpterName = curRoles.UserName
  16442. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  16443. // fmt.Println(requestLog)
  16444. // fmt.Println(errMsgLog)
  16445. //
  16446. // saveLog(result, requestLog, "4101a", "上传清单")
  16447. //
  16448. // var dat map[string]interface{}
  16449. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16450. // fmt.Println(dat)
  16451. // } else {
  16452. // fmt.Println(err)
  16453. // }
  16454. // userJSONBytes, _ := json.Marshal(dat)
  16455. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16456. // utils.ErrorLog("解析失败:%v", err)
  16457. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16458. // return
  16459. // }
  16460. //
  16461. // } else {
  16462. //
  16463. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  16464. // var dat map[string]interface{}
  16465. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16466. // fmt.Println(dat)
  16467. // } else {
  16468. // fmt.Println(err)
  16469. // }
  16470. // userJSONBytes, _ := json.Marshal(dat)
  16471. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16472. // utils.ErrorLog("解析失败:%v", err)
  16473. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16474. // return
  16475. // }
  16476. // }
  16477. //
  16478. // if res.Infcode != 0 {
  16479. // adminUser := c.GetAdminUserInfo()
  16480. // errlog := &models.HisOrderError{
  16481. // UserOrgId: adminUser.CurrentOrgId,
  16482. // Ctime: time.Now().Unix(),
  16483. // Mtime: time.Now().Unix(),
  16484. // ErrMsg: res.ErrMsg,
  16485. // Status: 1,
  16486. // PatientId: order.ID,
  16487. // Stage: 10265,
  16488. // }
  16489. // service.CreateErrMsgLog(errlog)
  16490. // continue
  16491. // } else {
  16492. // //order.FaPiaoNumber = zero
  16493. // //order.FaPiaoCode = last_order.FaPiaoCode
  16494. // //service.UpdateOrder(order)
  16495. // hisFundSettleListResult := &models.HisFundSettleListResult{
  16496. // Number: res.Output.SetlListId,
  16497. // Status: 1,
  16498. // Ctime: time.Now().Unix(),
  16499. // Mtime: time.Now().Unix(),
  16500. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16501. // IsUpload: 1,
  16502. // OrderId: order.ID,
  16503. // }
  16504. // service.CreateUploadRecord(hisFundSettleListResult)
  16505. // c.ServeSuccessJSON(map[string]interface{}{
  16506. // "msg": "上传成功",
  16507. // "result": hisFundSettleListResult,
  16508. // })
  16509. // continue
  16510. // }
  16511. // }
  16512. //}
  16513. func (c *HisApiController) GetbatchSettleList() {
  16514. //order_id, _ := c.GetInt64("order_id")
  16515. admin_user_id, _ := c.GetInt64("admin_user_id")
  16516. orders, _ := service.GetAllHisOrderTwo10485()
  16517. for _, item := range orders {
  16518. order, _ := service.GetHisOrderByIDTwo(item.ID)
  16519. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  16520. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  16521. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  16522. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  16523. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  16524. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16525. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  16526. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  16527. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  16528. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  16529. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  16530. //fmt.Println(count)
  16531. //var zero string
  16532. //number := count + 1
  16533. //if number >= 1000 {
  16534. // zero = "0000" + strconv.FormatInt(number, 10)
  16535. //} else if number >= 10000 {
  16536. // zero = "000" + strconv.FormatInt(number, 10)
  16537. //} else if number >= 100000 {
  16538. // zero = "00" + strconv.FormatInt(number, 10)
  16539. //} else if number >= 1000000 {
  16540. // zero = "0" + strconv.FormatInt(number, 10)
  16541. //} else {
  16542. // zero = strconv.FormatInt(number, 10)
  16543. //}
  16544. //fmt.Println(zero)
  16545. struct4101 := service.Struct4101{
  16546. PsnNo: order.PsnNo,
  16547. MdtrtId: order.MdtrtId,
  16548. SetlId: order.SetlId,
  16549. PsnName: order.PsnName,
  16550. Gend: order.Gend,
  16551. Brdy: his.Brdy,
  16552. Age: his.Age,
  16553. Naty: order.Naty,
  16554. PatnCertType: "01",
  16555. Certno: order.Certno,
  16556. Prfs: "90",
  16557. ConerName: roles[0].UserName,
  16558. PatnRlts: "99",
  16559. ConerAddr: miConfig.OrgName,
  16560. ConerTel: admin.Mobile,
  16561. HiType: order.Insutype,
  16562. Insuplc: miConfig.InsuplcAdmdvs,
  16563. MaindiagFlag: "1",
  16564. BillCode: order.SetlId,
  16565. BillNo: order.SetlId,
  16566. BizSn: order.Number,
  16567. PsnSelfPay: order.PsnPartAmt,
  16568. PsnOwnPay: order.PsnPartAmt,
  16569. AcctPay: order.AcctPay,
  16570. PsnCashpay: order.PsnCashPay,
  16571. HiPaymtd: "1",
  16572. Hsorg: miConfig.InsuplcAdmdvs,
  16573. HsorgOpter: miConfig.InsuplcAdmdvs,
  16574. MedinsFillPsn: curRoles.UserName,
  16575. MedinsFillDept: miConfig.OrgName,
  16576. IptMedType: "2",
  16577. }
  16578. struct4101.SetlBegnDate = order.SetlTime
  16579. struct4101.SetlEndDate = order.SetlTime
  16580. time_arr := strings.Split(order.SetlTime, " ")
  16581. struct4101.AdmTime = time_arr[0]
  16582. struct4101.AdmEndTime = time_arr[0]
  16583. //var rf []CustomFundPay
  16584. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  16585. //
  16586. //var tempFunPays []service.CustomStruct
  16587. //for _, item := range rf {
  16588. // var tempFunPay service.CustomStruct
  16589. // tempFunPay.FundPayamt = item.FundPayamt
  16590. // tempFunPay.FundPayType = item.FundPayType
  16591. // tempFunPays = append(tempFunPays, tempFunPay)
  16592. //}
  16593. //struct4101.CustomStruct = tempFunPays
  16594. var tempDiaginfos []service.DiaginfoStructTwo
  16595. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  16596. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  16597. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  16598. var config []*models.HisXtDiagnoseConfig
  16599. for _, item := range diagnosis_ids {
  16600. id, _ := strconv.ParseInt(item, 10, 64)
  16601. diagnosisConfig, _ := service.FindDiagnoseById(id)
  16602. config = append(config, &diagnosisConfig)
  16603. }
  16604. for index, item := range config {
  16605. if index == 0 {
  16606. var tempDiaginfo service.DiaginfoStructTwo
  16607. tempDiaginfo.DiagCode = item.CountryCode
  16608. tempDiaginfo.DiagName = item.CountryContentName
  16609. tempDiaginfo.DiagType = "1"
  16610. tempDiaginfo.MaindiagFlag = "1"
  16611. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  16612. } else {
  16613. var tempDiaginfo service.DiaginfoStructTwo
  16614. tempDiaginfo.DiagCode = item.CountryCode
  16615. tempDiaginfo.DiagName = item.CountryContentName
  16616. tempDiaginfo.DiagType = "1"
  16617. tempDiaginfo.MaindiagFlag = "0"
  16618. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  16619. }
  16620. }
  16621. struct4101.Diseinfo = tempDiaginfos
  16622. sickConfigTwo, _ := service.FindSickById(his.SickType)
  16623. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  16624. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  16625. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  16626. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  16627. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  16628. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  16629. var iteminfo service.IteminfoStruct
  16630. var bedCostTotal float64 = 0 //床位总费
  16631. var bedCostSelfTotal float64 = 0 //床位自费
  16632. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  16633. var operationCostTotal float64 = 0 //手术费
  16634. var operationCostSelfTotal float64 = 0 //手术费
  16635. var operationCostPartSelfTotal float64 = 0 //手术费
  16636. var otherCostTotal float64 = 0 //其他费用
  16637. var otherCostSelfTotal float64 = 0 //其他费用
  16638. var otherCostPartSelfTotal float64 = 0 //其他费用
  16639. var materialCostTotal float64 = 0 //材料费
  16640. var materialCostSelfTotal float64 = 0 //材料费
  16641. var materialCostPartSelfTotal float64 = 0 //材料费
  16642. var westernMedicineCostTotal float64 = 0 //西药费
  16643. var westernMedicineCostSelfTotal float64 = 0 //西药费
  16644. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  16645. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  16646. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  16647. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  16648. var checkCostTotal float64 = 0 //检查费
  16649. var checkCostSelfTotal float64 = 0 //检查费
  16650. var checkCostPartSelfTotal float64 = 0 //检查费
  16651. var laboratoryCostTotal float64 = 0 //化验费
  16652. var laboratoryCostSelfTotal float64 = 0 //化验费
  16653. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  16654. var treatCostTotal float64 = 0 //治疗费用
  16655. var treatCostSelfTotal float64 = 0 //治疗费用
  16656. var treatCostPartSelfTotal float64 = 0 //治疗费用
  16657. decimal.DivisionPrecision = 2
  16658. var bed_fulamt_ownpay_amt float64 = 0
  16659. var operation_fulamt_ownpay_amt float64 = 0
  16660. var other_fulamt_ownpay_amt float64 = 0
  16661. var westernMedicine_fulamt_ownpay_amt float64 = 0
  16662. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  16663. var check_fulamt_ownpay_amt float64 = 0
  16664. var material_fulamt_ownpay_amt float64 = 0
  16665. var laboratory_fulamt_ownpay_amt float64 = 0
  16666. var treat_fulamt_ownpay_amt float64 = 0
  16667. var bed_claa_sunmfee float64 = 0
  16668. var bed_clab_amt float64 = 0
  16669. var bed_other_amt float64 = 0
  16670. var operation_claa_sunmfee float64 = 0
  16671. var operation_clab_amt float64 = 0
  16672. var operation_other_amt float64 = 0
  16673. var other_claa_sunmfee float64 = 0
  16674. var other_clab_amt float64 = 0
  16675. var other_other_amt float64 = 0
  16676. var westernMedicine_claa_sunmfee float64 = 0
  16677. var westernMedicine_clab_amt float64 = 0
  16678. var westernMedicine_other_amt float64 = 0
  16679. var chineseTraditional_claa_sunmfee float64 = 0
  16680. var chineseTraditional_clab_amt float64 = 0
  16681. var chineseTraditional_other_amt float64 = 0
  16682. var check_claa_sunmfee float64 = 0
  16683. var check_clab_amt float64 = 0
  16684. var check_other_amt float64 = 0
  16685. var material_claa_sunmfee float64 = 0
  16686. var material_clab_amt float64 = 0
  16687. var material_other_amt float64 = 0
  16688. var laboratory_claa_sunmfee float64 = 0
  16689. var laboratory_clab_amt float64 = 0
  16690. var laboratory_other_amt float64 = 0
  16691. var treat_claa_sunmfee float64 = 0
  16692. var treat_clab_amt float64 = 0
  16693. var treat_other_amt float64 = 0
  16694. for _, item := range order.HisOrderInfo {
  16695. if item.MedChrgitmType == "01" { //床位费
  16696. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16697. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16698. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16699. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16700. if item.ChrgitmLv == "1" {
  16701. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16702. }
  16703. if item.ChrgitmLv == "2" {
  16704. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16705. }
  16706. if item.ChrgitmLv == "3" {
  16707. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16708. }
  16709. }
  16710. if item.MedChrgitmType == "03" { //检查费
  16711. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16712. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16713. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16714. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16715. if item.ChrgitmLv == "1" {
  16716. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16717. }
  16718. if item.ChrgitmLv == "2" {
  16719. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16720. }
  16721. if item.ChrgitmLv == "3" {
  16722. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16723. }
  16724. }
  16725. if item.MedChrgitmType == "04" { //化验费
  16726. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16727. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16728. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16729. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16730. if item.ChrgitmLv == "1" {
  16731. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16732. }
  16733. if item.ChrgitmLv == "2" {
  16734. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16735. }
  16736. if item.ChrgitmLv == "3" {
  16737. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16738. }
  16739. }
  16740. if item.MedChrgitmType == "05" { //治疗费
  16741. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16742. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16743. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16744. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16745. if item.ChrgitmLv == "1" {
  16746. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16747. }
  16748. if item.ChrgitmLv == "2" {
  16749. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16750. }
  16751. if item.ChrgitmLv == "3" {
  16752. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16753. }
  16754. }
  16755. if item.MedChrgitmType == "06" { //手术费
  16756. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16757. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16758. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16759. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16760. if item.ChrgitmLv == "1" {
  16761. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16762. }
  16763. if item.ChrgitmLv == "2" {
  16764. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16765. }
  16766. if item.ChrgitmLv == "3" {
  16767. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16768. }
  16769. }
  16770. if item.MedChrgitmType == "08" { //材料费
  16771. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16772. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16773. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16774. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16775. if item.ChrgitmLv == "1" {
  16776. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16777. }
  16778. if item.ChrgitmLv == "2" {
  16779. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16780. }
  16781. if item.ChrgitmLv == "3" {
  16782. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16783. }
  16784. }
  16785. if item.MedChrgitmType == "09" { //西药费
  16786. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16787. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16788. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16789. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16790. if item.ChrgitmLv == "1" {
  16791. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16792. }
  16793. if item.ChrgitmLv == "2" {
  16794. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16795. }
  16796. if item.ChrgitmLv == "3" {
  16797. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16798. }
  16799. }
  16800. if item.MedChrgitmType == "11" { //中成费
  16801. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16802. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16803. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16804. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16805. if item.ChrgitmLv == "1" {
  16806. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16807. }
  16808. if item.ChrgitmLv == "2" {
  16809. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16810. }
  16811. if item.ChrgitmLv == "3" {
  16812. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16813. }
  16814. }
  16815. if item.MedChrgitmType == "14" { //其他费
  16816. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16817. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16818. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16819. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16820. if item.ChrgitmLv == "1" {
  16821. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16822. }
  16823. if item.ChrgitmLv == "2" {
  16824. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16825. }
  16826. if item.ChrgitmLv == "3" {
  16827. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16828. }
  16829. }
  16830. }
  16831. var iteminfoStructs []service.IteminfoStruct
  16832. if bedCostTotal != 0 {
  16833. iteminfo.MedChrgitm = "01"
  16834. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  16835. iteminfo.Amt = bedCostTotal
  16836. iteminfo.ClaaSumfee = bed_claa_sunmfee
  16837. iteminfo.ClabAmt = bed_clab_amt
  16838. iteminfo.OthAmt = bed_other_amt
  16839. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16840. }
  16841. if checkCostTotal != 0 {
  16842. iteminfo.MedChrgitm = "03"
  16843. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  16844. iteminfo.Amt = checkCostTotal
  16845. iteminfo.ClaaSumfee = check_claa_sunmfee
  16846. iteminfo.ClabAmt = check_clab_amt
  16847. iteminfo.OthAmt = check_other_amt
  16848. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16849. }
  16850. if laboratoryCostTotal != 0 {
  16851. iteminfo.MedChrgitm = "04"
  16852. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  16853. iteminfo.Amt = laboratoryCostTotal
  16854. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  16855. iteminfo.ClabAmt = laboratory_clab_amt
  16856. iteminfo.OthAmt = laboratory_other_amt
  16857. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16858. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16859. }
  16860. if treatCostTotal != 0 {
  16861. iteminfo.MedChrgitm = "05"
  16862. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  16863. iteminfo.Amt = treatCostTotal
  16864. iteminfo.ClaaSumfee = treat_claa_sunmfee
  16865. iteminfo.ClabAmt = treat_clab_amt
  16866. iteminfo.OthAmt = treat_other_amt
  16867. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16868. //(struct4101.IteminfoStruct, iteminfo)
  16869. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16870. }
  16871. if operationCostTotal != 0 {
  16872. iteminfo.MedChrgitm = "06"
  16873. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  16874. iteminfo.Amt = operationCostTotal
  16875. iteminfo.ClaaSumfee = operation_claa_sunmfee
  16876. iteminfo.ClabAmt = operation_clab_amt
  16877. iteminfo.OthAmt = operation_other_amt
  16878. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16879. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16880. }
  16881. if materialCostTotal != 0 {
  16882. iteminfo.MedChrgitm = "08"
  16883. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  16884. iteminfo.Amt = materialCostTotal
  16885. iteminfo.ClaaSumfee = material_claa_sunmfee
  16886. iteminfo.ClabAmt = material_clab_amt
  16887. iteminfo.OthAmt = material_other_amt
  16888. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16889. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16890. }
  16891. if westernMedicineCostTotal != 0 {
  16892. iteminfo.MedChrgitm = "09"
  16893. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  16894. iteminfo.Amt = westernMedicineCostTotal
  16895. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  16896. iteminfo.ClabAmt = westernMedicine_clab_amt
  16897. iteminfo.OthAmt = westernMedicine_other_amt
  16898. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16899. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16900. }
  16901. if chineseTraditionalMedicineCostTotal != 0 {
  16902. iteminfo.MedChrgitm = "11"
  16903. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  16904. iteminfo.Amt = westernMedicineCostTotal
  16905. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  16906. iteminfo.ClabAmt = westernMedicine_clab_amt
  16907. iteminfo.OthAmt = westernMedicine_other_amt
  16908. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16909. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16910. }
  16911. if otherCostTotal != 0 {
  16912. iteminfo.MedChrgitm = "14"
  16913. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  16914. iteminfo.Amt = otherCostTotal
  16915. iteminfo.ClaaSumfee = other_claa_sunmfee
  16916. iteminfo.ClabAmt = other_clab_amt
  16917. iteminfo.OthAmt = other_other_amt
  16918. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16919. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16920. }
  16921. struct4101.IteminfoStruct = iteminfoStructs
  16922. struct4101.Ntly = "中国"
  16923. struct4101.AdmCaty = "A03.06"
  16924. struct4101.DoctorName = doctor.UserName
  16925. struct4101.DoctorCode = doctor.DoctorNumber
  16926. var res ResultSeventeen
  16927. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16928. struct4101.BillCode = order.Number
  16929. struct4101.BillNo = order.SetlId
  16930. var resOther ResultSeventeenOther
  16931. var pp models.PublicParams
  16932. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16933. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16934. pp.FixmedinsName = miConfig.OrgName
  16935. pp.FixmedinsCode = miConfig.Code
  16936. pp.RequestUrl = miConfig.Url
  16937. pp.Cainfo = miConfig.Cainfo
  16938. pp.SecretKey = miConfig.SecretKey
  16939. pp.AccessKey = miConfig.AccessKey
  16940. pp.OpterName = curRoles.UserName
  16941. client := &http.Client{}
  16942. var req *http.Request
  16943. data := make(map[string]interface{})
  16944. data["struct4101"] = struct4101
  16945. data["pp"] = pp
  16946. bytesData, _ := json.Marshal(data)
  16947. if miConfig.MdtrtareaAdmvs == "320921" {
  16948. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  16949. } else {
  16950. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  16951. }
  16952. resp, _ := client.Do(req)
  16953. defer resp.Body.Close()
  16954. body, ioErr := ioutil.ReadAll(resp.Body)
  16955. if ioErr != nil {
  16956. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16958. return
  16959. }
  16960. var respJSON map[string]interface{}
  16961. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16962. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16964. return
  16965. }
  16966. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16967. userJSONBytes, _ := json.Marshal(respJSON)
  16968. fmt.Println("log")
  16969. fmt.Println(string(userJSONBytes))
  16970. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  16971. utils.ErrorLog("解析失败:%v", err)
  16972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16973. return
  16974. }
  16975. res.InfRefmsgid = resOther.InfRefmsgid
  16976. res.Output = resOther.Output
  16977. res.ErrMsg = resOther.ErrMsg
  16978. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  16979. res.Infcode = infocode
  16980. } else if miConfig.MdtrtareaAdmvs == "360302" {
  16981. var pp models.PublicParams
  16982. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  16983. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16984. pp.FixmedinsName = miConfig.OrgName
  16985. pp.FixmedinsCode = miConfig.Code
  16986. pp.RequestUrl = miConfig.Url
  16987. pp.Cainfo = miConfig.Cainfo
  16988. pp.SecretKey = miConfig.SecretKey
  16989. pp.AccessKey = miConfig.AccessKey
  16990. pp.OpterName = curRoles.UserName
  16991. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  16992. result, _ := service.Jxyb4101(struct4101, pp)
  16993. var dat map[string]interface{}
  16994. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16995. fmt.Println(dat)
  16996. } else {
  16997. fmt.Println(err)
  16998. }
  16999. userJSONBytes, _ := json.Marshal(dat)
  17000. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17001. utils.ErrorLog("解析失败:%v", err)
  17002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17003. return
  17004. }
  17005. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17006. var pp models.PublicParams
  17007. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17008. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17009. pp.FixmedinsName = miConfig.OrgName
  17010. pp.FixmedinsCode = miConfig.Code
  17011. pp.RequestUrl = miConfig.Url
  17012. pp.Cainfo = miConfig.Cainfo
  17013. pp.SecretKey = miConfig.SecretKey
  17014. pp.AccessKey = miConfig.AccessKey
  17015. pp.OpterName = curRoles.UserName
  17016. result, _ := service.Hnyb4101(struct4101, pp)
  17017. var dat map[string]interface{}
  17018. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17019. fmt.Println(dat)
  17020. } else {
  17021. fmt.Println(err)
  17022. }
  17023. userJSONBytes, _ := json.Marshal(dat)
  17024. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17025. utils.ErrorLog("解析失败:%v", err)
  17026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17027. return
  17028. }
  17029. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17030. var resOther ResultSeventeenOther
  17031. var pp models.PublicParams
  17032. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17033. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17034. pp.FixmedinsName = miConfig.OrgName
  17035. pp.FixmedinsCode = miConfig.Code
  17036. pp.RequestUrl = miConfig.Url
  17037. pp.Cainfo = miConfig.Cainfo
  17038. pp.SecretKey = miConfig.SecretKey
  17039. pp.AccessKey = miConfig.AccessKey
  17040. pp.OpterName = curRoles.UserName
  17041. client := &http.Client{}
  17042. var req *http.Request
  17043. data := make(map[string]interface{})
  17044. data["struct4101"] = struct4101
  17045. data["pp"] = pp
  17046. bytesData, _ := json.Marshal(data)
  17047. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  17048. resp, _ := client.Do(req)
  17049. defer resp.Body.Close()
  17050. body, ioErr := ioutil.ReadAll(resp.Body)
  17051. if ioErr != nil {
  17052. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17054. return
  17055. }
  17056. var respJSON map[string]interface{}
  17057. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17058. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17060. return
  17061. }
  17062. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17063. userJSONBytes, _ := json.Marshal(respJSON)
  17064. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  17065. utils.ErrorLog("解析失败:%v", err)
  17066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17067. return
  17068. }
  17069. res.InfRefmsgid = resOther.InfRefmsgid
  17070. res.Output = resOther.Output
  17071. res.ErrMsg = resOther.ErrMsg
  17072. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  17073. res.Infcode = infocode
  17074. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17075. var pp models.PublicParams
  17076. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17077. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17078. pp.FixmedinsName = miConfig.OrgName
  17079. pp.FixmedinsCode = miConfig.Code
  17080. pp.RequestUrl = miConfig.Url
  17081. pp.Cainfo = miConfig.Cainfo
  17082. pp.SecretKey = miConfig.SecretKey
  17083. pp.AccessKey = miConfig.AccessKey
  17084. pp.OpterName = curRoles.UserName
  17085. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  17086. fmt.Println(requestLog)
  17087. fmt.Println(errMsgLog)
  17088. saveLog(result, requestLog, "4101a", "上传清单")
  17089. var dat map[string]interface{}
  17090. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17091. fmt.Println(dat)
  17092. } else {
  17093. fmt.Println(err)
  17094. }
  17095. userJSONBytes, _ := json.Marshal(dat)
  17096. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17097. utils.ErrorLog("解析失败:%v", err)
  17098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17099. return
  17100. }
  17101. } else if miConfig.MdtrtareaAdmvs == "441799" {
  17102. var pp models.PublicParams
  17103. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17104. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17105. pp.FixmedinsName = miConfig.OrgName
  17106. pp.FixmedinsCode = miConfig.Code
  17107. pp.RequestUrl = miConfig.Url
  17108. pp.Cainfo = miConfig.Cainfo
  17109. pp.SecretKey = miConfig.SecretKey
  17110. pp.AccessKey = miConfig.AccessKey
  17111. pp.OpterName = curRoles.UserName
  17112. client := &http.Client{}
  17113. var req *http.Request
  17114. data := make(map[string]interface{})
  17115. data["struct4101"] = struct4101
  17116. data["pp"] = pp
  17117. bytesData, _ := json.Marshal(data)
  17118. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  17119. resp, _ := client.Do(req)
  17120. defer resp.Body.Close()
  17121. body, ioErr := ioutil.ReadAll(resp.Body)
  17122. if ioErr != nil {
  17123. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17125. return
  17126. }
  17127. var respJSON map[string]interface{}
  17128. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17129. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17131. return
  17132. }
  17133. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17134. userJSONBytes, _ := json.Marshal(respJSON)
  17135. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17136. utils.ErrorLog("解析失败:%v", err)
  17137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17138. return
  17139. }
  17140. } else {
  17141. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  17142. var dat map[string]interface{}
  17143. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17144. fmt.Println(dat)
  17145. } else {
  17146. fmt.Println(err)
  17147. }
  17148. userJSONBytes, _ := json.Marshal(dat)
  17149. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17150. utils.ErrorLog("解析失败:%v", err)
  17151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17152. return
  17153. }
  17154. }
  17155. if res.Infcode != 0 {
  17156. errlog := &models.HisOrderError{
  17157. UserOrgId: order.UserOrgId,
  17158. Ctime: time.Now().Unix(),
  17159. Mtime: time.Now().Unix(),
  17160. ErrMsg: res.ErrMsg + "解析失败",
  17161. Status: 1,
  17162. PatientId: order.ID,
  17163. Stage: 10485,
  17164. }
  17165. service.CreateErrMsgLog(errlog)
  17166. continue
  17167. //c.ServeSuccessJSON(map[string]interface{}{
  17168. // "failed_code": -10,
  17169. // "msg": res.ErrMsg,
  17170. //})
  17171. } else {
  17172. //order.FaPiaoNumber = zero
  17173. //order.FaPiaoCode = last_order.FaPiaoCode
  17174. //service.UpdateOrder(order)
  17175. hisFundSettleListResult := &models.HisFundSettleListResult{
  17176. Number: res.Output.SetlListId,
  17177. Status: 1,
  17178. Ctime: time.Now().Unix(),
  17179. Mtime: time.Now().Unix(),
  17180. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17181. IsUpload: 1,
  17182. OrderId: order.ID,
  17183. }
  17184. service.CreateUploadRecord(hisFundSettleListResult)
  17185. continue
  17186. }
  17187. }
  17188. }
  17189. func (c *HisApiController) GetSettleList() {
  17190. order_id, _ := c.GetInt64("order_id")
  17191. admin_user_id, _ := c.GetInt64("admin_user_id")
  17192. order, _ := service.GetHisOrderByIDTwo(order_id)
  17193. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17194. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17195. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17196. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17197. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17198. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17199. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17200. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17201. if order.ID == 0 {
  17202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  17203. return
  17204. }
  17205. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17206. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17207. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17208. //fmt.Println(count)
  17209. //var zero string
  17210. //number := count + 1
  17211. //if number >= 1000 {
  17212. // zero = "0000" + strconv.FormatInt(number, 10)
  17213. //} else if number >= 10000 {
  17214. // zero = "000" + strconv.FormatInt(number, 10)
  17215. //} else if number >= 100000 {
  17216. // zero = "00" + strconv.FormatInt(number, 10)
  17217. //} else if number >= 1000000 {
  17218. // zero = "0" + strconv.FormatInt(number, 10)
  17219. //} else {
  17220. // zero = strconv.FormatInt(number, 10)
  17221. //}
  17222. //fmt.Println(zero)
  17223. struct4101 := service.Struct4101{
  17224. PsnNo: order.PsnNo,
  17225. MdtrtId: order.MdtrtId,
  17226. SetlId: order.SetlId,
  17227. PsnName: order.PsnName,
  17228. Gend: order.Gend,
  17229. Brdy: his.Brdy,
  17230. Age: his.Age,
  17231. Naty: order.Naty,
  17232. PatnCertType: "01",
  17233. Certno: order.Certno,
  17234. Prfs: "90",
  17235. ConerName: roles[0].UserName,
  17236. PatnRlts: "99",
  17237. ConerAddr: miConfig.OrgName,
  17238. ConerTel: admin.Mobile,
  17239. HiType: order.Insutype,
  17240. Insuplc: miConfig.InsuplcAdmdvs,
  17241. MaindiagFlag: "1",
  17242. BillCode: order.SetlId,
  17243. BillNo: order.SetlId,
  17244. BizSn: order.Number,
  17245. PsnSelfPay: order.PsnPartAmt,
  17246. PsnOwnPay: order.PsnPartAmt,
  17247. AcctPay: order.AcctPay,
  17248. PsnCashpay: order.PsnCashPay,
  17249. HiPaymtd: "1",
  17250. Hsorg: miConfig.InsuplcAdmdvs,
  17251. HsorgOpter: miConfig.InsuplcAdmdvs,
  17252. MedinsFillPsn: curRoles.UserName,
  17253. MedinsFillDept: miConfig.OrgName,
  17254. IptMedType: "2",
  17255. }
  17256. struct4101.SetlBegnDate = order.SetlTime
  17257. struct4101.SetlEndDate = order.SetlTime
  17258. time_arr := strings.Split(order.SetlTime, " ")
  17259. struct4101.AdmTime = time_arr[0]
  17260. struct4101.AdmEndTime = time_arr[0]
  17261. //
  17262. //var rf []CustomFundPay
  17263. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  17264. //
  17265. //var tempFunPays []service.CustomStruct
  17266. //for _, item := range rf {
  17267. // var tempFunPay service.CustomStruct
  17268. // tempFunPay.FundPayamt = item.FundPayamt
  17269. // tempFunPay.FundPayType = item.FundPayType
  17270. // tempFunPays = append(tempFunPays, tempFunPay)
  17271. //}
  17272. //struct4101.CustomStruct = tempFunPays
  17273. var tempDiaginfos []service.DiaginfoStructTwo
  17274. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  17275. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  17276. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  17277. var config []*models.HisXtDiagnoseConfig
  17278. for _, item := range diagnosis_ids {
  17279. id, _ := strconv.ParseInt(item, 10, 64)
  17280. diagnosisConfig, _ := service.FindDiagnoseById(id)
  17281. config = append(config, &diagnosisConfig)
  17282. }
  17283. if miConfig.Code == "H15049901371" {
  17284. //for _, item := range config {
  17285. // if item.ID == 138 {
  17286. diagnosisConfig, _ := service.FindDiagnoseById(138)
  17287. var tempDiaginfo service.DiaginfoStructTwo
  17288. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  17289. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  17290. tempDiaginfo.DiagType = "1"
  17291. tempDiaginfo.MaindiagFlag = "1"
  17292. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17293. //}
  17294. //}
  17295. for _, item := range config {
  17296. if item.ID != 138 {
  17297. var tempDiaginfo service.DiaginfoStructTwo
  17298. tempDiaginfo.DiagCode = item.CountryCode
  17299. tempDiaginfo.DiagName = item.CountryContentName
  17300. tempDiaginfo.DiagType = "1"
  17301. tempDiaginfo.MaindiagFlag = "0"
  17302. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17303. }
  17304. }
  17305. } else {
  17306. for index, item := range config {
  17307. if index == 0 {
  17308. var tempDiaginfo service.DiaginfoStructTwo
  17309. tempDiaginfo.DiagCode = item.CountryCode
  17310. tempDiaginfo.DiagName = item.CountryContentName
  17311. tempDiaginfo.DiagType = "1"
  17312. tempDiaginfo.MaindiagFlag = "1"
  17313. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17314. } else {
  17315. var tempDiaginfo service.DiaginfoStructTwo
  17316. tempDiaginfo.DiagCode = item.CountryCode
  17317. tempDiaginfo.DiagName = item.CountryContentName
  17318. tempDiaginfo.DiagType = "1"
  17319. tempDiaginfo.MaindiagFlag = "0"
  17320. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17321. }
  17322. }
  17323. }
  17324. struct4101.Diseinfo = tempDiaginfos
  17325. sickConfigTwo, _ := service.FindSickById(his.SickType)
  17326. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  17327. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  17328. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  17329. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  17330. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  17331. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  17332. var iteminfo service.IteminfoStruct
  17333. var bedCostTotal float64 = 0 //床位总费
  17334. var bedCostSelfTotal float64 = 0 //床位自费
  17335. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  17336. var operationCostTotal float64 = 0 //手术费
  17337. var operationCostSelfTotal float64 = 0 //手术费
  17338. var operationCostPartSelfTotal float64 = 0 //手术费
  17339. var otherCostTotal float64 = 0 //其他费用
  17340. var otherCostSelfTotal float64 = 0 //其他费用
  17341. var otherCostPartSelfTotal float64 = 0 //其他费用
  17342. var materialCostTotal float64 = 0 //材料费
  17343. var materialCostSelfTotal float64 = 0 //材料费
  17344. var materialCostPartSelfTotal float64 = 0 //材料费
  17345. var westernMedicineCostTotal float64 = 0 //西药费
  17346. var westernMedicineCostSelfTotal float64 = 0 //西药费
  17347. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  17348. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  17349. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  17350. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  17351. var checkCostTotal float64 = 0 //检查费
  17352. var checkCostSelfTotal float64 = 0 //检查费
  17353. var checkCostPartSelfTotal float64 = 0 //检查费
  17354. var laboratoryCostTotal float64 = 0 //化验费
  17355. var laboratoryCostSelfTotal float64 = 0 //化验费
  17356. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  17357. var treatCostTotal float64 = 0 //治疗费用
  17358. var treatCostSelfTotal float64 = 0 //治疗费用
  17359. var treatCostPartSelfTotal float64 = 0 //治疗费用
  17360. decimal.DivisionPrecision = 2
  17361. var bed_fulamt_ownpay_amt float64 = 0
  17362. var operation_fulamt_ownpay_amt float64 = 0
  17363. var other_fulamt_ownpay_amt float64 = 0
  17364. var westernMedicine_fulamt_ownpay_amt float64 = 0
  17365. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  17366. var check_fulamt_ownpay_amt float64 = 0
  17367. var material_fulamt_ownpay_amt float64 = 0
  17368. var laboratory_fulamt_ownpay_amt float64 = 0
  17369. var treat_fulamt_ownpay_amt float64 = 0
  17370. var bed_claa_sunmfee float64 = 0
  17371. var bed_clab_amt float64 = 0
  17372. var bed_other_amt float64 = 0
  17373. var operation_claa_sunmfee float64 = 0
  17374. var operation_clab_amt float64 = 0
  17375. var operation_other_amt float64 = 0
  17376. var other_claa_sunmfee float64 = 0
  17377. var other_clab_amt float64 = 0
  17378. var other_other_amt float64 = 0
  17379. var westernMedicine_claa_sunmfee float64 = 0
  17380. var westernMedicine_clab_amt float64 = 0
  17381. var westernMedicine_other_amt float64 = 0
  17382. var chineseTraditional_claa_sunmfee float64 = 0
  17383. var chineseTraditional_clab_amt float64 = 0
  17384. var chineseTraditional_other_amt float64 = 0
  17385. var check_claa_sunmfee float64 = 0
  17386. var check_clab_amt float64 = 0
  17387. var check_other_amt float64 = 0
  17388. var material_claa_sunmfee float64 = 0
  17389. var material_clab_amt float64 = 0
  17390. var material_other_amt float64 = 0
  17391. var laboratory_claa_sunmfee float64 = 0
  17392. var laboratory_clab_amt float64 = 0
  17393. var laboratory_other_amt float64 = 0
  17394. var treat_claa_sunmfee float64 = 0
  17395. var treat_clab_amt float64 = 0
  17396. var treat_other_amt float64 = 0
  17397. for _, item := range order.HisOrderInfo {
  17398. if item.MedChrgitmType == "01" { //床位费
  17399. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17400. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17401. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17402. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17403. if item.ChrgitmLv == "1" {
  17404. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17405. }
  17406. if item.ChrgitmLv == "2" {
  17407. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17408. }
  17409. if item.ChrgitmLv == "3" {
  17410. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17411. }
  17412. }
  17413. if item.MedChrgitmType == "03" { //检查费
  17414. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17415. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17416. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17417. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17418. if item.ChrgitmLv == "1" {
  17419. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17420. }
  17421. if item.ChrgitmLv == "2" {
  17422. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17423. }
  17424. if item.ChrgitmLv == "3" {
  17425. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17426. }
  17427. }
  17428. if item.MedChrgitmType == "04" { //化验费
  17429. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17430. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17431. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17432. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17433. if item.ChrgitmLv == "1" {
  17434. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17435. }
  17436. if item.ChrgitmLv == "2" {
  17437. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17438. }
  17439. if item.ChrgitmLv == "3" {
  17440. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17441. }
  17442. }
  17443. if item.MedChrgitmType == "05" { //治疗费
  17444. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17445. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17446. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17447. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17448. if item.ChrgitmLv == "1" {
  17449. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17450. }
  17451. if item.ChrgitmLv == "2" {
  17452. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17453. }
  17454. if item.ChrgitmLv == "3" {
  17455. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17456. }
  17457. }
  17458. if item.MedChrgitmType == "06" { //手术费
  17459. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17460. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17461. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17462. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17463. if item.ChrgitmLv == "1" {
  17464. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17465. }
  17466. if item.ChrgitmLv == "2" {
  17467. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17468. }
  17469. if item.ChrgitmLv == "3" {
  17470. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17471. }
  17472. }
  17473. if item.MedChrgitmType == "08" { //材料费
  17474. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17475. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17476. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17477. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17478. if item.ChrgitmLv == "1" {
  17479. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17480. }
  17481. if item.ChrgitmLv == "2" {
  17482. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17483. }
  17484. if item.ChrgitmLv == "3" {
  17485. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17486. }
  17487. }
  17488. if item.MedChrgitmType == "09" { //西药费
  17489. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17490. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17491. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17492. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17493. if item.ChrgitmLv == "1" {
  17494. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17495. }
  17496. if item.ChrgitmLv == "2" {
  17497. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17498. }
  17499. if item.ChrgitmLv == "3" {
  17500. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17501. }
  17502. }
  17503. if item.MedChrgitmType == "11" { //中成费
  17504. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17505. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17506. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17507. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17508. if item.ChrgitmLv == "1" {
  17509. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17510. }
  17511. if item.ChrgitmLv == "2" {
  17512. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17513. }
  17514. if item.ChrgitmLv == "3" {
  17515. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17516. }
  17517. }
  17518. if item.MedChrgitmType == "14" { //其他费
  17519. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17520. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17521. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17522. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17523. if item.ChrgitmLv == "1" {
  17524. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17525. }
  17526. if item.ChrgitmLv == "2" {
  17527. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17528. }
  17529. if item.ChrgitmLv == "3" {
  17530. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17531. }
  17532. }
  17533. }
  17534. var iteminfoStructs []service.IteminfoStruct
  17535. if bedCostTotal != 0 {
  17536. iteminfo.MedChrgitm = "01"
  17537. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17538. iteminfo.Amt = bedCostTotal
  17539. iteminfo.ClaaSumfee = bed_claa_sunmfee
  17540. iteminfo.ClabAmt = bed_clab_amt
  17541. iteminfo.OthAmt = bed_other_amt
  17542. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17543. }
  17544. if checkCostTotal != 0 {
  17545. iteminfo.MedChrgitm = "03"
  17546. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  17547. iteminfo.Amt = checkCostTotal
  17548. iteminfo.ClaaSumfee = check_claa_sunmfee
  17549. iteminfo.ClabAmt = check_clab_amt
  17550. iteminfo.OthAmt = check_other_amt
  17551. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17552. }
  17553. if laboratoryCostTotal != 0 {
  17554. iteminfo.MedChrgitm = "04"
  17555. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  17556. iteminfo.Amt = laboratoryCostTotal
  17557. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  17558. iteminfo.ClabAmt = laboratory_clab_amt
  17559. iteminfo.OthAmt = laboratory_other_amt
  17560. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17561. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17562. }
  17563. if treatCostTotal != 0 {
  17564. iteminfo.MedChrgitm = "05"
  17565. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  17566. iteminfo.Amt = treatCostTotal
  17567. iteminfo.ClaaSumfee = treat_claa_sunmfee
  17568. iteminfo.ClabAmt = treat_clab_amt
  17569. iteminfo.OthAmt = treat_other_amt
  17570. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17571. //(struct4101.IteminfoStruct, iteminfo)
  17572. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17573. }
  17574. if operationCostTotal != 0 {
  17575. iteminfo.MedChrgitm = "06"
  17576. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17577. iteminfo.Amt = operationCostTotal
  17578. iteminfo.ClaaSumfee = operation_claa_sunmfee
  17579. iteminfo.ClabAmt = operation_clab_amt
  17580. iteminfo.OthAmt = operation_other_amt
  17581. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17582. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17583. }
  17584. if materialCostTotal != 0 {
  17585. iteminfo.MedChrgitm = "08"
  17586. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  17587. iteminfo.Amt = materialCostTotal
  17588. iteminfo.ClaaSumfee = material_claa_sunmfee
  17589. iteminfo.ClabAmt = material_clab_amt
  17590. iteminfo.OthAmt = material_other_amt
  17591. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17592. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17593. }
  17594. if westernMedicineCostTotal != 0 {
  17595. iteminfo.MedChrgitm = "09"
  17596. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  17597. iteminfo.Amt = westernMedicineCostTotal
  17598. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  17599. iteminfo.ClabAmt = westernMedicine_clab_amt
  17600. iteminfo.OthAmt = westernMedicine_other_amt
  17601. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17602. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17603. }
  17604. if chineseTraditionalMedicineCostTotal != 0 {
  17605. iteminfo.MedChrgitm = "11"
  17606. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  17607. iteminfo.Amt = westernMedicineCostTotal
  17608. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  17609. iteminfo.ClabAmt = westernMedicine_clab_amt
  17610. iteminfo.OthAmt = westernMedicine_other_amt
  17611. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17612. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17613. }
  17614. if otherCostTotal != 0 {
  17615. iteminfo.MedChrgitm = "14"
  17616. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  17617. iteminfo.Amt = otherCostTotal
  17618. iteminfo.ClaaSumfee = other_claa_sunmfee
  17619. iteminfo.ClabAmt = other_clab_amt
  17620. iteminfo.OthAmt = other_other_amt
  17621. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17622. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17623. }
  17624. struct4101.IteminfoStruct = iteminfoStructs
  17625. struct4101.Ntly = "中国"
  17626. struct4101.AdmCaty = "A03.06"
  17627. struct4101.DoctorName = doctor.UserName
  17628. struct4101.DoctorCode = doctor.DoctorNumber
  17629. var res ResultSeventeen
  17630. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17631. struct4101.BillCode = order.Number
  17632. struct4101.BillNo = order.SetlId
  17633. var resOther ResultSeventeenOther
  17634. var pp models.PublicParams
  17635. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17636. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17637. pp.FixmedinsName = miConfig.OrgName
  17638. pp.FixmedinsCode = miConfig.Code
  17639. pp.RequestUrl = miConfig.Url
  17640. pp.Cainfo = miConfig.Cainfo
  17641. pp.SecretKey = miConfig.SecretKey
  17642. pp.AccessKey = miConfig.AccessKey
  17643. pp.OpterName = curRoles.UserName
  17644. client := &http.Client{}
  17645. var req *http.Request
  17646. data := make(map[string]interface{})
  17647. data["struct4101"] = struct4101
  17648. data["pp"] = pp
  17649. bytesData, _ := json.Marshal(data)
  17650. if miConfig.MdtrtareaAdmvs == "320921" {
  17651. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  17652. } else {
  17653. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  17654. }
  17655. resp, _ := client.Do(req)
  17656. defer resp.Body.Close()
  17657. body, ioErr := ioutil.ReadAll(resp.Body)
  17658. if ioErr != nil {
  17659. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17661. return
  17662. }
  17663. var respJSON map[string]interface{}
  17664. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17665. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17667. return
  17668. }
  17669. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17670. userJSONBytes, _ := json.Marshal(respJSON)
  17671. fmt.Println("log")
  17672. fmt.Println(string(userJSONBytes))
  17673. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  17674. utils.ErrorLog("解析失败:%v", err)
  17675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17676. return
  17677. }
  17678. res.InfRefmsgid = resOther.InfRefmsgid
  17679. res.Output = resOther.Output
  17680. res.ErrMsg = resOther.ErrMsg
  17681. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  17682. res.Infcode = infocode
  17683. } else if miConfig.MdtrtareaAdmvs == "360302" {
  17684. var pp models.PublicParams
  17685. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  17686. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17687. pp.FixmedinsName = miConfig.OrgName
  17688. pp.FixmedinsCode = miConfig.Code
  17689. pp.RequestUrl = miConfig.Url
  17690. pp.Cainfo = miConfig.Cainfo
  17691. pp.SecretKey = miConfig.SecretKey
  17692. pp.AccessKey = miConfig.AccessKey
  17693. pp.OpterName = curRoles.UserName
  17694. result, _ := service.Jxyb4101(struct4101, pp)
  17695. var dat map[string]interface{}
  17696. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17697. fmt.Println(dat)
  17698. } else {
  17699. fmt.Println(err)
  17700. }
  17701. userJSONBytes, _ := json.Marshal(dat)
  17702. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17703. utils.ErrorLog("解析失败:%v", err)
  17704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17705. return
  17706. }
  17707. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17708. var pp models.PublicParams
  17709. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17710. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17711. pp.FixmedinsName = miConfig.OrgName
  17712. pp.FixmedinsCode = miConfig.Code
  17713. pp.RequestUrl = miConfig.Url
  17714. pp.Cainfo = miConfig.Cainfo
  17715. pp.SecretKey = miConfig.SecretKey
  17716. pp.AccessKey = miConfig.AccessKey
  17717. pp.OpterName = curRoles.UserName
  17718. result, _ := service.Hnyb4101(struct4101, pp)
  17719. var dat map[string]interface{}
  17720. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17721. fmt.Println(dat)
  17722. } else {
  17723. fmt.Println(err)
  17724. }
  17725. userJSONBytes, _ := json.Marshal(dat)
  17726. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17727. utils.ErrorLog("解析失败:%v", err)
  17728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17729. return
  17730. }
  17731. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17732. var resOther ResultSeventeenOther
  17733. var pp models.PublicParams
  17734. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17735. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17736. pp.FixmedinsName = miConfig.OrgName
  17737. pp.FixmedinsCode = miConfig.Code
  17738. pp.RequestUrl = miConfig.Url
  17739. pp.Cainfo = miConfig.Cainfo
  17740. pp.SecretKey = miConfig.SecretKey
  17741. pp.AccessKey = miConfig.AccessKey
  17742. pp.OpterName = curRoles.UserName
  17743. client := &http.Client{}
  17744. var req *http.Request
  17745. data := make(map[string]interface{})
  17746. data["struct4101"] = struct4101
  17747. data["pp"] = pp
  17748. bytesData, _ := json.Marshal(data)
  17749. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  17750. resp, _ := client.Do(req)
  17751. defer resp.Body.Close()
  17752. body, ioErr := ioutil.ReadAll(resp.Body)
  17753. if ioErr != nil {
  17754. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17756. return
  17757. }
  17758. var respJSON map[string]interface{}
  17759. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17760. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17762. return
  17763. }
  17764. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17765. userJSONBytes, _ := json.Marshal(respJSON)
  17766. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  17767. utils.ErrorLog("解析失败:%v", err)
  17768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17769. return
  17770. }
  17771. res.InfRefmsgid = resOther.InfRefmsgid
  17772. res.Output = resOther.Output
  17773. res.ErrMsg = resOther.ErrMsg
  17774. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  17775. res.Infcode = infocode
  17776. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17777. var pp models.PublicParams
  17778. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17779. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17780. pp.FixmedinsName = miConfig.OrgName
  17781. pp.FixmedinsCode = miConfig.Code
  17782. pp.RequestUrl = miConfig.Url
  17783. pp.Cainfo = miConfig.Cainfo
  17784. pp.SecretKey = miConfig.SecretKey
  17785. pp.AccessKey = miConfig.AccessKey
  17786. pp.OpterName = curRoles.UserName
  17787. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  17788. fmt.Println(requestLog)
  17789. fmt.Println(errMsgLog)
  17790. saveLog(result, requestLog, "4101a", "上传清单")
  17791. var dat map[string]interface{}
  17792. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17793. fmt.Println(dat)
  17794. } else {
  17795. fmt.Println(err)
  17796. }
  17797. userJSONBytes, _ := json.Marshal(dat)
  17798. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17799. utils.ErrorLog("解析失败:%v", err)
  17800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17801. return
  17802. }
  17803. } else if miConfig.MdtrtareaAdmvs == "441799" {
  17804. var pp models.PublicParams
  17805. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17806. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17807. pp.FixmedinsName = miConfig.OrgName
  17808. pp.FixmedinsCode = miConfig.Code
  17809. pp.RequestUrl = miConfig.Url
  17810. pp.Cainfo = miConfig.Cainfo
  17811. pp.SecretKey = miConfig.SecretKey
  17812. pp.AccessKey = miConfig.AccessKey
  17813. pp.OpterName = curRoles.UserName
  17814. client := &http.Client{}
  17815. var req *http.Request
  17816. data := make(map[string]interface{})
  17817. data["struct4101"] = struct4101
  17818. data["pp"] = pp
  17819. bytesData, _ := json.Marshal(data)
  17820. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  17821. resp, _ := client.Do(req)
  17822. defer resp.Body.Close()
  17823. body, ioErr := ioutil.ReadAll(resp.Body)
  17824. if ioErr != nil {
  17825. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17827. return
  17828. }
  17829. var respJSON map[string]interface{}
  17830. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17831. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17833. return
  17834. }
  17835. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17836. userJSONBytes, _ := json.Marshal(respJSON)
  17837. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17838. utils.ErrorLog("解析失败:%v", err)
  17839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17840. return
  17841. }
  17842. } else {
  17843. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  17844. var dat map[string]interface{}
  17845. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17846. fmt.Println(dat)
  17847. } else {
  17848. fmt.Println(err)
  17849. }
  17850. userJSONBytes, _ := json.Marshal(dat)
  17851. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17852. utils.ErrorLog("解析失败:%v", err)
  17853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17854. return
  17855. }
  17856. }
  17857. if res.Infcode != 0 {
  17858. c.ServeSuccessJSON(map[string]interface{}{
  17859. "failed_code": -10,
  17860. "msg": res.ErrMsg,
  17861. })
  17862. return
  17863. } else {
  17864. //order.FaPiaoNumber = zero
  17865. //order.FaPiaoCode = last_order.FaPiaoCode
  17866. //service.UpdateOrder(order)
  17867. hisFundSettleListResult := &models.HisFundSettleListResult{
  17868. Number: res.Output.SetlListId,
  17869. Status: 1,
  17870. Ctime: time.Now().Unix(),
  17871. Mtime: time.Now().Unix(),
  17872. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17873. IsUpload: 1,
  17874. OrderId: order_id,
  17875. }
  17876. service.CreateUploadRecord(hisFundSettleListResult)
  17877. c.ServeSuccessJSON(map[string]interface{}{
  17878. "msg": "上传成功",
  17879. "result": hisFundSettleListResult,
  17880. })
  17881. return
  17882. }
  17883. }
  17884. func (c *HisApiController) GetSettleListHospital() {
  17885. order_id, _ := c.GetInt64("order_id")
  17886. admin_user_id, _ := c.GetInt64("admin_user_id")
  17887. order, _ := service.GetHisOrderByIDTwo(order_id)
  17888. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17889. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  17890. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17891. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17892. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17893. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17894. if order.ID == 0 {
  17895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  17896. return
  17897. }
  17898. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17899. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17900. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17901. fmt.Println(count)
  17902. var zero string
  17903. number := count + 1
  17904. if number >= 1000 {
  17905. zero = "0000" + strconv.FormatInt(number, 10)
  17906. } else if number >= 10000 {
  17907. zero = "000" + strconv.FormatInt(number, 10)
  17908. } else if number >= 100000 {
  17909. zero = "00" + strconv.FormatInt(number, 10)
  17910. } else if number >= 1000000 {
  17911. zero = "0" + strconv.FormatInt(number, 10)
  17912. } else {
  17913. zero = strconv.FormatInt(number, 10)
  17914. }
  17915. fmt.Println(zero)
  17916. struct4101 := service.Struct4101{
  17917. PsnNo: order.PsnNo,
  17918. MdtrtId: order.MdtrtId,
  17919. SetlId: order.SetlId,
  17920. PsnName: order.PsnName,
  17921. Gend: order.Gend,
  17922. Brdy: his.Brdy,
  17923. Age: int64(order.Age),
  17924. Naty: order.Naty,
  17925. PatnCertType: "01",
  17926. Certno: order.Certno,
  17927. Prfs: "90",
  17928. ConerName: roles[0].UserName,
  17929. PatnRlts: "99",
  17930. ConerAddr: miConfig.OrgName,
  17931. ConerTel: admin.Mobile,
  17932. HiType: order.Insutype,
  17933. Insuplc: miConfig.InsuplcAdmdvs,
  17934. MaindiagFlag: "1",
  17935. BillCode: order.SetlId,
  17936. BillNo: order.SetlId,
  17937. BizSn: order.Number,
  17938. PsnSelfPay: order.PsnPartAmt,
  17939. PsnOwnPay: order.PsnPartAmt,
  17940. AcctPay: order.AcctPay,
  17941. PsnCashpay: order.PsnCashPay,
  17942. HiPaymtd: "1",
  17943. Hsorg: miConfig.InsuplcAdmdvs,
  17944. HsorgOpter: miConfig.InsuplcAdmdvs,
  17945. MedinsFillPsn: curRoles.UserName,
  17946. MedinsFillDept: depart.Name,
  17947. IptMedType: "2",
  17948. AdmTime: his.InHosptialTime,
  17949. AdmEndTime: his.OutHosptialTime,
  17950. }
  17951. struct4101.SetlBegnDate = order.SetlTime
  17952. struct4101.SetlEndDate = order.SetlTime
  17953. //var rf []CustomFundPay
  17954. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  17955. //
  17956. //var tempFunPays []service.CustomStruct
  17957. //for _, item := range rf {
  17958. // var tempFunPay service.CustomStruct
  17959. // tempFunPay.FundPayamt = item.FundPayamt
  17960. // tempFunPay.FundPayType = item.FundPayType
  17961. // tempFunPays = append(tempFunPays, tempFunPay)
  17962. //}
  17963. //struct4101.CustomStruct = tempFunPays
  17964. var tempDiaginfos []service.DiaginfoStructTwo
  17965. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  17966. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  17967. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  17968. //for _, item := range infos {
  17969. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  17970. //}
  17971. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  17972. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  17973. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  17974. fmt.Println(diagnosis_ids_arr)
  17975. if order.UserOrgId == 10210 {
  17976. var diagnosis_ids_arr_two []int64
  17977. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  17978. var config []*models.HisXtDiagnoseConfig
  17979. for _, id := range diagnosis_ids_arr_two {
  17980. //id, _ := strconv.ParseInt(item, 10, 64)
  17981. diagnosisConfig, _ := service.FindDiagnoseById(id)
  17982. if diagnosisConfig.ID > 0 {
  17983. config = append(config, &diagnosisConfig)
  17984. }
  17985. }
  17986. for index, item := range config {
  17987. if item.ID > 0 {
  17988. if index == 0 {
  17989. var tempDiaginfo service.DiaginfoStructTwo
  17990. tempDiaginfo.DiagCode = item.CountryCode
  17991. tempDiaginfo.DiagName = item.CountryContentName
  17992. tempDiaginfo.DiagType = "1"
  17993. tempDiaginfo.MaindiagFlag = "1"
  17994. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17995. } else {
  17996. var tempDiaginfo service.DiaginfoStructTwo
  17997. tempDiaginfo.DiagCode = item.CountryCode
  17998. tempDiaginfo.DiagName = item.CountryContentName
  17999. tempDiaginfo.DiagType = "1"
  18000. tempDiaginfo.MaindiagFlag = "0"
  18001. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18002. }
  18003. }
  18004. }
  18005. struct4101.Diseinfo = tempDiaginfos
  18006. } else {
  18007. var config []*models.HisXtDiagnoseConfig
  18008. for _, item := range diagnosis_ids_arr {
  18009. id, _ := strconv.ParseInt(item, 10, 64)
  18010. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18011. if diagnosisConfig.ID > 0 {
  18012. config = append(config, &diagnosisConfig)
  18013. }
  18014. }
  18015. for index, item := range config {
  18016. if item.ID > 0 {
  18017. if index == 0 {
  18018. var tempDiaginfo service.DiaginfoStructTwo
  18019. tempDiaginfo.DiagCode = item.CountryCode
  18020. tempDiaginfo.DiagName = item.CountryContentName
  18021. tempDiaginfo.DiagType = "1"
  18022. tempDiaginfo.MaindiagFlag = "1"
  18023. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18024. } else {
  18025. var tempDiaginfo service.DiaginfoStructTwo
  18026. tempDiaginfo.DiagCode = item.CountryCode
  18027. tempDiaginfo.DiagName = item.CountryContentName
  18028. tempDiaginfo.DiagType = "1"
  18029. tempDiaginfo.MaindiagFlag = "0"
  18030. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18031. }
  18032. }
  18033. }
  18034. struct4101.Diseinfo = tempDiaginfos
  18035. }
  18036. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18037. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18038. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18039. tempOpspdiseinfo2.OprnOprtCode = ""
  18040. tempOpspdiseinfo2.OprnOprtName = ""
  18041. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18042. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18043. var iteminfo service.IteminfoStruct
  18044. var bedCostTotal float64 = 0 //床位总费
  18045. var bedCostSelfTotal float64 = 0 //床位自费
  18046. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18047. var operationCostTotal float64 = 0 //手术费
  18048. var operationCostSelfTotal float64 = 0 //手术费
  18049. var operationCostPartSelfTotal float64 = 0 //手术费
  18050. var otherCostTotal float64 = 0 //其他费用
  18051. var otherCostSelfTotal float64 = 0 //其他费用
  18052. var otherCostPartSelfTotal float64 = 0 //其他费用
  18053. var materialCostTotal float64 = 0 //材料费
  18054. var materialCostSelfTotal float64 = 0 //材料费
  18055. var materialCostPartSelfTotal float64 = 0 //材料费
  18056. var westernMedicineCostTotal float64 = 0 //西药费
  18057. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18058. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18059. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18060. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18061. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18062. var checkCostTotal float64 = 0 //检查费
  18063. var checkCostSelfTotal float64 = 0 //检查费
  18064. var checkCostPartSelfTotal float64 = 0 //检查费
  18065. var laboratoryCostTotal float64 = 0 //化验费
  18066. var laboratoryCostSelfTotal float64 = 0 //化验费
  18067. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18068. var treatCostTotal float64 = 0 //治疗费用
  18069. var treatCostSelfTotal float64 = 0 //治疗费用
  18070. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18071. decimal.DivisionPrecision = 2
  18072. var bed_fulamt_ownpay_amt float64 = 0
  18073. var operation_fulamt_ownpay_amt float64 = 0
  18074. var other_fulamt_ownpay_amt float64 = 0
  18075. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18076. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18077. var check_fulamt_ownpay_amt float64 = 0
  18078. var material_fulamt_ownpay_amt float64 = 0
  18079. var laboratory_fulamt_ownpay_amt float64 = 0
  18080. var treat_fulamt_ownpay_amt float64 = 0
  18081. var bed_claa_sunmfee float64 = 0
  18082. var bed_clab_amt float64 = 0
  18083. var bed_other_amt float64 = 0
  18084. var operation_claa_sunmfee float64 = 0
  18085. var operation_clab_amt float64 = 0
  18086. var operation_other_amt float64 = 0
  18087. var other_claa_sunmfee float64 = 0
  18088. var other_clab_amt float64 = 0
  18089. var other_other_amt float64 = 0
  18090. var westernMedicine_claa_sunmfee float64 = 0
  18091. var westernMedicine_clab_amt float64 = 0
  18092. var westernMedicine_other_amt float64 = 0
  18093. var chineseTraditional_claa_sunmfee float64 = 0
  18094. var chineseTraditional_clab_amt float64 = 0
  18095. var chineseTraditional_other_amt float64 = 0
  18096. var check_claa_sunmfee float64 = 0
  18097. var check_clab_amt float64 = 0
  18098. var check_other_amt float64 = 0
  18099. var material_claa_sunmfee float64 = 0
  18100. var material_clab_amt float64 = 0
  18101. var material_other_amt float64 = 0
  18102. var laboratory_claa_sunmfee float64 = 0
  18103. var laboratory_clab_amt float64 = 0
  18104. var laboratory_other_amt float64 = 0
  18105. var treat_claa_sunmfee float64 = 0
  18106. var treat_clab_amt float64 = 0
  18107. var treat_other_amt float64 = 0
  18108. for _, item := range order.HisOrderInfo {
  18109. if item.MedChrgitmType == "01" { //床位费
  18110. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18111. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18112. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18113. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18114. if item.ChrgitmLv == "1" {
  18115. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18116. }
  18117. if item.ChrgitmLv == "2" {
  18118. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18119. }
  18120. if item.ChrgitmLv == "3" {
  18121. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18122. }
  18123. }
  18124. if item.MedChrgitmType == "03" { //检查费
  18125. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18126. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18127. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18128. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18129. if item.ChrgitmLv == "1" {
  18130. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18131. }
  18132. if item.ChrgitmLv == "2" {
  18133. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18134. }
  18135. if item.ChrgitmLv == "3" {
  18136. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18137. }
  18138. }
  18139. if item.MedChrgitmType == "04" { //化验费
  18140. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18141. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18142. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18143. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18144. if item.ChrgitmLv == "1" {
  18145. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18146. }
  18147. if item.ChrgitmLv == "2" {
  18148. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18149. }
  18150. if item.ChrgitmLv == "3" {
  18151. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18152. }
  18153. }
  18154. if item.MedChrgitmType == "05" { //治疗费
  18155. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18156. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18157. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18158. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18159. if item.ChrgitmLv == "1" {
  18160. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18161. }
  18162. if item.ChrgitmLv == "2" {
  18163. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18164. }
  18165. if item.ChrgitmLv == "3" {
  18166. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18167. }
  18168. }
  18169. if item.MedChrgitmType == "06" { //手术费
  18170. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18171. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18172. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18173. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18174. if item.ChrgitmLv == "1" {
  18175. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18176. }
  18177. if item.ChrgitmLv == "2" {
  18178. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18179. }
  18180. if item.ChrgitmLv == "3" {
  18181. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18182. }
  18183. }
  18184. if item.MedChrgitmType == "08" { //材料费
  18185. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18186. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18187. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18188. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18189. if item.ChrgitmLv == "1" {
  18190. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18191. }
  18192. if item.ChrgitmLv == "2" {
  18193. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18194. }
  18195. if item.ChrgitmLv == "3" {
  18196. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18197. }
  18198. }
  18199. if item.MedChrgitmType == "09" { //西药费
  18200. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18201. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18202. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18203. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18204. if item.ChrgitmLv == "1" {
  18205. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18206. }
  18207. if item.ChrgitmLv == "2" {
  18208. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18209. }
  18210. if item.ChrgitmLv == "3" {
  18211. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18212. }
  18213. }
  18214. if item.MedChrgitmType == "11" { //中成费
  18215. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18216. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18217. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18218. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18219. if item.ChrgitmLv == "1" {
  18220. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18221. }
  18222. if item.ChrgitmLv == "2" {
  18223. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18224. }
  18225. if item.ChrgitmLv == "3" {
  18226. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18227. }
  18228. }
  18229. if item.MedChrgitmType == "14" { //其他费
  18230. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18231. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18232. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18233. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18234. if item.ChrgitmLv == "1" {
  18235. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18236. }
  18237. if item.ChrgitmLv == "2" {
  18238. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18239. }
  18240. if item.ChrgitmLv == "3" {
  18241. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18242. }
  18243. }
  18244. }
  18245. var iteminfoStructs []service.IteminfoStruct
  18246. if bedCostTotal != 0 {
  18247. iteminfo.MedChrgitm = "01"
  18248. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18249. iteminfo.Amt = bedCostTotal
  18250. iteminfo.ClaaSumfee = bed_claa_sunmfee
  18251. iteminfo.ClabAmt = bed_clab_amt
  18252. iteminfo.OthAmt = bed_other_amt
  18253. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18254. }
  18255. if checkCostTotal != 0 {
  18256. iteminfo.MedChrgitm = "03"
  18257. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18258. iteminfo.Amt = checkCostTotal
  18259. iteminfo.ClaaSumfee = check_claa_sunmfee
  18260. iteminfo.ClabAmt = check_clab_amt
  18261. iteminfo.OthAmt = check_other_amt
  18262. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18263. }
  18264. if laboratoryCostTotal != 0 {
  18265. iteminfo.MedChrgitm = "04"
  18266. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18267. iteminfo.Amt = laboratoryCostTotal
  18268. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18269. iteminfo.ClabAmt = laboratory_clab_amt
  18270. iteminfo.OthAmt = laboratory_other_amt
  18271. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18272. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18273. }
  18274. if treatCostTotal != 0 {
  18275. iteminfo.MedChrgitm = "05"
  18276. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18277. iteminfo.Amt = treatCostTotal
  18278. iteminfo.ClaaSumfee = treat_claa_sunmfee
  18279. iteminfo.ClabAmt = treat_clab_amt
  18280. iteminfo.OthAmt = treat_other_amt
  18281. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18282. //(struct4101.IteminfoStruct, iteminfo)
  18283. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18284. }
  18285. if operationCostTotal != 0 {
  18286. iteminfo.MedChrgitm = "06"
  18287. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18288. iteminfo.Amt = operationCostTotal
  18289. iteminfo.ClaaSumfee = operation_claa_sunmfee
  18290. iteminfo.ClabAmt = operation_clab_amt
  18291. iteminfo.OthAmt = operation_other_amt
  18292. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18293. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18294. }
  18295. if materialCostTotal != 0 {
  18296. iteminfo.MedChrgitm = "08"
  18297. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18298. iteminfo.Amt = materialCostTotal
  18299. iteminfo.ClaaSumfee = material_claa_sunmfee
  18300. iteminfo.ClabAmt = material_clab_amt
  18301. iteminfo.OthAmt = material_other_amt
  18302. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18303. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18304. }
  18305. if westernMedicineCostTotal != 0 {
  18306. iteminfo.MedChrgitm = "09"
  18307. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18308. iteminfo.Amt = westernMedicineCostTotal
  18309. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18310. iteminfo.ClabAmt = westernMedicine_clab_amt
  18311. iteminfo.OthAmt = westernMedicine_other_amt
  18312. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18313. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18314. }
  18315. if chineseTraditionalMedicineCostTotal != 0 {
  18316. iteminfo.MedChrgitm = "11"
  18317. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18318. iteminfo.Amt = westernMedicineCostTotal
  18319. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18320. iteminfo.ClabAmt = westernMedicine_clab_amt
  18321. iteminfo.OthAmt = westernMedicine_other_amt
  18322. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18323. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18324. }
  18325. if otherCostTotal != 0 {
  18326. iteminfo.MedChrgitm = "14"
  18327. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18328. iteminfo.Amt = otherCostTotal
  18329. iteminfo.ClaaSumfee = other_claa_sunmfee
  18330. iteminfo.ClabAmt = other_clab_amt
  18331. iteminfo.OthAmt = other_other_amt
  18332. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18333. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18334. }
  18335. struct4101.IteminfoStruct = iteminfoStructs
  18336. struct4101.Ntly = "中国"
  18337. struct4101.AdmCaty = "A03.06"
  18338. var resOther ResultSeventeenOther
  18339. var res ResultSeventeen
  18340. if miConfig.MdtrtareaAdmvs == "150499" {
  18341. var pp models.PublicParams
  18342. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18343. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18344. pp.FixmedinsName = miConfig.OrgName
  18345. pp.FixmedinsCode = miConfig.Code
  18346. pp.RequestUrl = miConfig.Url
  18347. pp.Cainfo = miConfig.Cainfo
  18348. pp.SecretKey = miConfig.SecretKey
  18349. pp.AccessKey = miConfig.AccessKey
  18350. pp.OpterName = curRoles.UserName
  18351. client := &http.Client{}
  18352. var req *http.Request
  18353. data := make(map[string]interface{})
  18354. data["struct4101"] = struct4101
  18355. data["pp"] = pp
  18356. bytesData, _ := json.Marshal(data)
  18357. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18358. resp, _ := client.Do(req)
  18359. defer resp.Body.Close()
  18360. body, ioErr := ioutil.ReadAll(resp.Body)
  18361. if ioErr != nil {
  18362. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18364. return
  18365. }
  18366. var respJSON map[string]interface{}
  18367. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18370. return
  18371. }
  18372. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18373. userJSONBytes, _ := json.Marshal(respJSON)
  18374. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18375. utils.ErrorLog("解析失败:%v", err)
  18376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18377. return
  18378. }
  18379. res.InfRefmsgid = resOther.InfRefmsgid
  18380. res.Output = resOther.Output
  18381. res.ErrMsg = resOther.ErrMsg
  18382. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18383. res.Infcode = infocode
  18384. } else if miConfig.MdtrtareaAdmvs == "360302" {
  18385. var pp models.PublicParams
  18386. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18387. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18388. pp.FixmedinsName = miConfig.OrgName
  18389. pp.FixmedinsCode = miConfig.Code
  18390. pp.RequestUrl = miConfig.Url
  18391. pp.Cainfo = miConfig.Cainfo
  18392. pp.SecretKey = miConfig.SecretKey
  18393. pp.AccessKey = miConfig.AccessKey
  18394. pp.OpterName = curRoles.UserName
  18395. result, _ := service.Jxyb4101(struct4101, pp)
  18396. var dat map[string]interface{}
  18397. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18398. fmt.Println(dat)
  18399. } else {
  18400. fmt.Println(err)
  18401. }
  18402. userJSONBytes, _ := json.Marshal(dat)
  18403. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18404. utils.ErrorLog("解析失败:%v", err)
  18405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18406. return
  18407. }
  18408. } else {
  18409. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  18410. var dat map[string]interface{}
  18411. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18412. fmt.Println(dat)
  18413. } else {
  18414. fmt.Println(err)
  18415. }
  18416. userJSONBytes, _ := json.Marshal(dat)
  18417. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18418. utils.ErrorLog("解析失败:%v", err)
  18419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18420. return
  18421. }
  18422. }
  18423. if res.Infcode != 0 {
  18424. c.ServeSuccessJSON(map[string]interface{}{
  18425. "failed_code": -10,
  18426. "msg": res.ErrMsg,
  18427. })
  18428. return
  18429. } else {
  18430. if miConfig.MdtrtareaAdmvs != "150499" {
  18431. order.FaPiaoNumber = zero
  18432. order.FaPiaoCode = last_order.FaPiaoCode
  18433. service.UpdateOrder(order)
  18434. }
  18435. hisFundSettleListResult := &models.HisFundSettleListResult{
  18436. Number: res.Output.SetlListId,
  18437. Status: 1,
  18438. Ctime: time.Now().Unix(),
  18439. Mtime: time.Now().Unix(),
  18440. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18441. IsUpload: 1,
  18442. OrderId: order_id,
  18443. }
  18444. service.CreateUploadRecord(hisFundSettleListResult)
  18445. c.ServeSuccessJSON(map[string]interface{}{
  18446. "msg": "上传成功",
  18447. "result": hisFundSettleListResult,
  18448. })
  18449. return
  18450. }
  18451. }
  18452. //func (c *HisApiController) GetBatchSettleList() {
  18453. // orders, _ := service.GetAllHisOrder(10106)
  18454. // for _, item := range orders {
  18455. // order_id := item.ID
  18456. // order, _ := service.GetHisOrderByIDTwo(order_id)
  18457. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18458. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18459. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18460. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  18461. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18462. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18463. //
  18464. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18465. //
  18466. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18467. //
  18468. // if order.ID == 0 {
  18469. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  18470. // return
  18471. // }
  18472. // if his.BalanceAccountsType == 2 {
  18473. // continue
  18474. // }
  18475. // struct4101 := service.Struct4101{
  18476. // PsnNo: order.PsnNo,
  18477. // MdtrtId: order.MdtrtId,
  18478. // SetlId: order.SetlId,
  18479. // PsnName: order.PsnName,
  18480. // Gend: order.Gend,
  18481. // Brdy: his.Brdy,
  18482. // Age: his.Age,
  18483. // Naty: order.Naty,
  18484. // PatnCertType: "01",
  18485. // Certno: order.Certno,
  18486. // Prfs: "90",
  18487. // ConerName: roles[0].UserName,
  18488. // PatnRlts: "99",
  18489. // ConerAddr: miConfig.OrgName,
  18490. // ConerTel: admin.Mobile,
  18491. // HiType: order.Insutype,
  18492. // Insuplc: his.InsuplcAdmdvs,
  18493. // MaindiagFlag: "1",
  18494. // BillCode: order.SetlId,
  18495. // BillNo: order.SetlId,
  18496. // BizSn: order.Number,
  18497. // PsnSelfPay: order.PsnPartAmt,
  18498. // PsnOwnPay: order.PsnPartAmt,
  18499. // AcctPay: order.AcctPay,
  18500. // PsnCashpay: order.PsnCashPay,
  18501. // HiPaymtd: "1",
  18502. // Hsorg: his.InsuplcAdmdvs,
  18503. // HsorgOpter: his.InsuplcAdmdvs,
  18504. // MedinsFillPsn: curRoles.UserName,
  18505. // MedinsFillDept: depart.Name,
  18506. // IptMedType: "2",
  18507. // }
  18508. // struct4101.SetlBegnDate = order.SetlTime
  18509. // struct4101.SetlEndDate = order.SetlTime
  18510. // //if order.SettleType == 1 {
  18511. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  18512. // // dateStr := t.Format("2006-01-02")
  18513. // // struct4101.SetlBegnDate = dateStr
  18514. // // struct4101.SetlEndDate = dateStr
  18515. // //} else {
  18516. // // t := time.Unix(int64(order.SettleStartTime), 0)
  18517. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  18518. // // dateStartStr := t.Format("2006-01-02")
  18519. // // dateEndStr := t2.Format("2006-01-02")
  18520. // // struct4101.SetlBegnDate = dateStartStr
  18521. // // struct4101.SetlEndDate = dateEndStr
  18522. // //}
  18523. //
  18524. // var rf []CustomFundPay
  18525. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  18526. //
  18527. // var tempFunPays []service.CustomStruct
  18528. // var tempFunPay610100 service.CustomStruct
  18529. //
  18530. // for _, item := range rf {
  18531. // if item.FundPayType == "610100" {
  18532. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  18533. // tempFunPay610100.FundPayType = item.FundPayType
  18534. // } else {
  18535. // var tempFunPay service.CustomStruct
  18536. // tempFunPay.FundPayamt = item.FundPayamt
  18537. // tempFunPay.FundPayType = item.FundPayType
  18538. // tempFunPays = append(tempFunPays, tempFunPay)
  18539. // }
  18540. // }
  18541. // tempFunPays = append(tempFunPays, tempFunPay610100)
  18542. // struct4101.CustomStruct = tempFunPays
  18543. //
  18544. // var tempDiaginfos []service.DiaginfoStructTwo
  18545. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18546. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18547. //
  18548. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18549. // var config []*models.HisXtDiagnoseConfig
  18550. // for _, item := range diagnosis_ids {
  18551. // id, _ := strconv.ParseInt(item, 10, 64)
  18552. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  18553. // config = append(config, &diagnosisConfig)
  18554. // }
  18555. //
  18556. // for index, item := range config {
  18557. // if index == 0 {
  18558. // var tempDiaginfo service.DiaginfoStructTwo
  18559. // tempDiaginfo.DiagCode = item.CountryCode
  18560. // tempDiaginfo.DiagName = item.CountryContentName
  18561. // tempDiaginfo.DiagType = "1"
  18562. // tempDiaginfo.MaindiagFlag = "1"
  18563. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18564. // } else {
  18565. //
  18566. // var tempDiaginfo service.DiaginfoStructTwo
  18567. // tempDiaginfo.DiagCode = item.CountryCode
  18568. // tempDiaginfo.DiagName = item.CountryContentName
  18569. // tempDiaginfo.DiagType = "2"
  18570. // tempDiaginfo.MaindiagFlag = "0"
  18571. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18572. // }
  18573. // }
  18574. // struct4101.Diseinfo = tempDiaginfos
  18575. //
  18576. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  18577. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18578. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18579. // tempOpspdiseinfo2.OprnOprtCode = ""
  18580. // tempOpspdiseinfo2.OprnOprtName = ""
  18581. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18582. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18583. //
  18584. // var iteminfo service.IteminfoStruct
  18585. //
  18586. // var bedCostTotal float64 = 0 //床位总费
  18587. // var bedCostSelfTotal float64 = 0 //床位自费
  18588. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18589. //
  18590. // var examineCostTotal float64 = 0 //诊查总费
  18591. // var examineCostSelfTotal float64 = 0 //诊查自费
  18592. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  18593. //
  18594. // var nursingCostTotal float64 = 0 //护理总费
  18595. // var nursingCostSelfTotal float64 = 0 //护理自费
  18596. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  18597. //
  18598. // var chineseMedicineCostTotal float64 = 0 //中成药
  18599. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  18600. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  18601. //
  18602. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  18603. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  18604. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  18605. //
  18606. // var registerCostTotal float64 = 0 //一般诊疗费
  18607. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  18608. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  18609. //
  18610. // var operationCostTotal float64 = 0 //手术费
  18611. // var operationCostSelfTotal float64 = 0 //手术费
  18612. // var operationCostPartSelfTotal float64 = 0 //手术费
  18613. //
  18614. // var otherCostTotal float64 = 0 //其他费用
  18615. // var otherCostSelfTotal float64 = 0 //其他费用
  18616. // var otherCostPartSelfTotal float64 = 0 //其他费用
  18617. //
  18618. // var materialCostTotal float64 = 0 //材料费
  18619. // var materialCostSelfTotal float64 = 0 //材料费
  18620. // var materialCostPartSelfTotal float64 = 0 //材料费
  18621. //
  18622. // var westernMedicineCostTotal float64 = 0 //西药费
  18623. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  18624. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18625. //
  18626. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18627. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18628. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18629. //
  18630. // var checkCostTotal float64 = 0 //检查费
  18631. // var checkCostSelfTotal float64 = 0 //检查费
  18632. // var checkCostPartSelfTotal float64 = 0 //检查费
  18633. //
  18634. // var laboratoryCostTotal float64 = 0 //化验费
  18635. // var laboratoryCostSelfTotal float64 = 0 //化验费
  18636. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18637. //
  18638. // var treatCostTotal float64 = 0 //治疗费用
  18639. // var treatCostSelfTotal float64 = 0 //治疗费用
  18640. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  18641. //
  18642. // decimal.DivisionPrecision = 2
  18643. //
  18644. // var bed_fulamt_ownpay_amt float64 = 0
  18645. //
  18646. // var examine_fulamt_ownpay_amt float64 = 0
  18647. //
  18648. // var nursing_fulamt_ownpay_amt float64 = 0
  18649. //
  18650. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  18651. //
  18652. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  18653. //
  18654. // var register_fulamt_ownpay_amt float64 = 0
  18655. //
  18656. // var operation_fulamt_ownpay_amt float64 = 0
  18657. // var other_fulamt_ownpay_amt float64 = 0
  18658. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  18659. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18660. // var check_fulamt_ownpay_amt float64 = 0
  18661. // var material_fulamt_ownpay_amt float64 = 0
  18662. // var laboratory_fulamt_ownpay_amt float64 = 0
  18663. // var treat_fulamt_ownpay_amt float64 = 0
  18664. //
  18665. // var bed_claa_sunmfee float64 = 0
  18666. // var bed_clab_amt float64 = 0
  18667. // var bed_other_amt float64 = 0
  18668. //
  18669. // var examine_claa_sunmfee float64 = 0
  18670. // var examine_clab_amt float64 = 0
  18671. // var examine_other_amt float64 = 0
  18672. //
  18673. // var nursing_claa_sunmfee float64 = 0
  18674. // var nursing_clab_amt float64 = 0
  18675. // var nursing_other_amt float64 = 0
  18676. //
  18677. // var chinese_medicine_claa_sunmfee float64 = 0
  18678. // var chinese_medicine_clab_amt float64 = 0
  18679. // var chinese_medicine_other_amt float64 = 0
  18680. //
  18681. // var commonly_treatment_claa_sunmfee float64 = 0
  18682. // var commonly_treatment_clab_amt float64 = 0
  18683. // var commonly_treatment_other_amt float64 = 0
  18684. //
  18685. // var operation_claa_sunmfee float64 = 0
  18686. // var operation_clab_amt float64 = 0
  18687. // var operation_other_amt float64 = 0
  18688. //
  18689. // var other_claa_sunmfee float64 = 0
  18690. // var other_clab_amt float64 = 0
  18691. // var other_other_amt float64 = 0
  18692. //
  18693. // var westernMedicine_claa_sunmfee float64 = 0
  18694. // var westernMedicine_clab_amt float64 = 0
  18695. // var westernMedicine_other_amt float64 = 0
  18696. //
  18697. // var chineseTraditional_claa_sunmfee float64 = 0
  18698. // var chineseTraditional_clab_amt float64 = 0
  18699. // var chineseTraditional_other_amt float64 = 0
  18700. //
  18701. // var check_claa_sunmfee float64 = 0
  18702. // var check_clab_amt float64 = 0
  18703. // var check_other_amt float64 = 0
  18704. //
  18705. // var material_claa_sunmfee float64 = 0
  18706. // var material_clab_amt float64 = 0
  18707. // var material_other_amt float64 = 0
  18708. //
  18709. // var laboratory_claa_sunmfee float64 = 0
  18710. // var laboratory_clab_amt float64 = 0
  18711. // var laboratory_other_amt float64 = 0
  18712. //
  18713. // var treat_claa_sunmfee float64 = 0
  18714. // var treat_clab_amt float64 = 0
  18715. // var treat_other_amt float64 = 0
  18716. //
  18717. // var register_claa_sunmfee float64 = 0
  18718. // var register_clab_amt float64 = 0
  18719. // var register_other_amt float64 = 0
  18720. //
  18721. // for _, item := range order.HisOrderInfo {
  18722. // if item.MedChrgitmType == "01" { //床位费
  18723. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18724. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18725. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18726. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18727. // if item.ChrgitmLv == "1" {
  18728. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18729. // }
  18730. // if item.ChrgitmLv == "2" {
  18731. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18732. //
  18733. // }
  18734. // if item.ChrgitmLv == "3" {
  18735. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18736. // }
  18737. //
  18738. // }
  18739. //
  18740. // if item.MedChrgitmType == "02" { //诊查
  18741. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18742. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18743. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18744. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18745. // if item.ChrgitmLv == "1" {
  18746. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18747. // }
  18748. // if item.ChrgitmLv == "2" {
  18749. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18750. //
  18751. // }
  18752. // if item.ChrgitmLv == "3" {
  18753. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18754. // }
  18755. //
  18756. // }
  18757. //
  18758. // if item.MedChrgitmType == "03" { //检查费
  18759. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18760. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18761. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18762. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18763. // if item.ChrgitmLv == "1" {
  18764. //
  18765. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18766. //
  18767. // }
  18768. // if item.ChrgitmLv == "2" {
  18769. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18770. //
  18771. // }
  18772. // if item.ChrgitmLv == "3" {
  18773. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18774. // }
  18775. // }
  18776. //
  18777. // if item.MedChrgitmType == "04" { //化验费
  18778. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18779. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18780. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18781. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18782. // if item.ChrgitmLv == "1" {
  18783. //
  18784. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18785. //
  18786. // }
  18787. // if item.ChrgitmLv == "2" {
  18788. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18789. //
  18790. // }
  18791. // if item.ChrgitmLv == "3" {
  18792. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18793. // }
  18794. // }
  18795. //
  18796. // if item.MedChrgitmType == "05" { //治疗费
  18797. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18798. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18799. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18800. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18801. // if item.ChrgitmLv == "1" {
  18802. //
  18803. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18804. //
  18805. // }
  18806. // if item.ChrgitmLv == "2" {
  18807. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18808. //
  18809. // }
  18810. // if item.ChrgitmLv == "3" {
  18811. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18812. // }
  18813. // }
  18814. //
  18815. // if item.MedChrgitmType == "06" { //手术费
  18816. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18817. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18818. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18819. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18820. //
  18821. // if item.ChrgitmLv == "1" {
  18822. //
  18823. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18824. //
  18825. // }
  18826. // if item.ChrgitmLv == "2" {
  18827. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18828. //
  18829. // }
  18830. // if item.ChrgitmLv == "3" {
  18831. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18832. // }
  18833. // }
  18834. //
  18835. // if item.MedChrgitmType == "07" { //手术费
  18836. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18837. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18838. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18839. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18840. //
  18841. // if item.ChrgitmLv == "1" {
  18842. //
  18843. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18844. //
  18845. // }
  18846. // if item.ChrgitmLv == "2" {
  18847. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18848. //
  18849. // }
  18850. // if item.ChrgitmLv == "3" {
  18851. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18852. // }
  18853. // }
  18854. //
  18855. // if item.MedChrgitmType == "08" { //材料费
  18856. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18857. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18858. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18859. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18860. // if item.ChrgitmLv == "1" {
  18861. //
  18862. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18863. //
  18864. // }
  18865. // if item.ChrgitmLv == "2" {
  18866. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18867. //
  18868. // }
  18869. // if item.ChrgitmLv == "3" {
  18870. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18871. // }
  18872. // }
  18873. // if item.MedChrgitmType == "09" { //西药费
  18874. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18875. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18876. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18877. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18878. // if item.ChrgitmLv == "1" {
  18879. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18880. // }
  18881. // if item.ChrgitmLv == "2" {
  18882. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18883. // }
  18884. // if item.ChrgitmLv == "3" {
  18885. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18886. // }
  18887. // }
  18888. // if item.MedChrgitmType == "10" { //中药饮片
  18889. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18890. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18891. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18892. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18893. // if item.ChrgitmLv == "1" {
  18894. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18895. // }
  18896. // if item.ChrgitmLv == "2" {
  18897. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18898. // }
  18899. // if item.ChrgitmLv == "3" {
  18900. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18901. // }
  18902. // }
  18903. //
  18904. // if item.MedChrgitmType == "11" { //中成费
  18905. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18906. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18907. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18908. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18909. // if item.ChrgitmLv == "1" {
  18910. //
  18911. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18912. //
  18913. // }
  18914. // if item.ChrgitmLv == "2" {
  18915. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18916. //
  18917. // }
  18918. // if item.ChrgitmLv == "3" {
  18919. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18920. // }
  18921. // }
  18922. //
  18923. // if item.MedChrgitmType == "12" { //中成费
  18924. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18925. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18926. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18927. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18928. // if item.ChrgitmLv == "1" {
  18929. //
  18930. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18931. //
  18932. // }
  18933. // if item.ChrgitmLv == "2" {
  18934. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18935. //
  18936. // }
  18937. // if item.ChrgitmLv == "3" {
  18938. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18939. // }
  18940. // }
  18941. //
  18942. // if item.MedChrgitmType == "13" { //中成费
  18943. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18944. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18945. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18946. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18947. // if item.ChrgitmLv == "1" {
  18948. //
  18949. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18950. //
  18951. // }
  18952. // if item.ChrgitmLv == "2" {
  18953. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18954. //
  18955. // }
  18956. // if item.ChrgitmLv == "3" {
  18957. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18958. // }
  18959. // }
  18960. //
  18961. // if item.MedChrgitmType == "14" { //其他费
  18962. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18963. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18964. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18965. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18966. // if item.ChrgitmLv == "1" {
  18967. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18968. //
  18969. // }
  18970. // if item.ChrgitmLv == "2" {
  18971. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18972. //
  18973. // }
  18974. // if item.ChrgitmLv == "3" {
  18975. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18976. // }
  18977. // }
  18978. //
  18979. // }
  18980. //
  18981. // var iteminfoStructs []service.IteminfoStruct
  18982. //
  18983. // if bedCostTotal != 0 {
  18984. // iteminfo.MedChrgitm = "01"
  18985. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18986. // iteminfo.Amt = bedCostTotal
  18987. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  18988. // iteminfo.ClabAmt = bed_clab_amt
  18989. // iteminfo.OthAmt = bed_other_amt
  18990. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18991. // }
  18992. //
  18993. // if examineCostTotal != 0 {
  18994. // iteminfo.MedChrgitm = "02"
  18995. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  18996. // iteminfo.Amt = examineCostTotal
  18997. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  18998. // iteminfo.ClabAmt = examine_clab_amt
  18999. // iteminfo.OthAmt = examine_other_amt
  19000. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19001. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19002. // }
  19003. //
  19004. // if checkCostTotal != 0 {
  19005. // iteminfo.MedChrgitm = "03"
  19006. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19007. // iteminfo.Amt = checkCostTotal
  19008. // iteminfo.ClaaSumfee = check_claa_sunmfee
  19009. // iteminfo.ClabAmt = check_clab_amt
  19010. // iteminfo.OthAmt = check_other_amt
  19011. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19012. //
  19013. // }
  19014. //
  19015. // if laboratoryCostTotal != 0 {
  19016. // iteminfo.MedChrgitm = "04"
  19017. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19018. // iteminfo.Amt = laboratoryCostTotal
  19019. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19020. // iteminfo.ClabAmt = laboratory_clab_amt
  19021. // iteminfo.OthAmt = laboratory_other_amt
  19022. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19023. //
  19024. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19025. //
  19026. // }
  19027. //
  19028. // if treatCostTotal != 0 {
  19029. // iteminfo.MedChrgitm = "05"
  19030. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19031. // iteminfo.Amt = treatCostTotal
  19032. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  19033. // iteminfo.ClabAmt = treat_clab_amt
  19034. // iteminfo.OthAmt = treat_other_amt
  19035. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19036. // //(struct4101.IteminfoStruct, iteminfo)
  19037. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19038. // }
  19039. //
  19040. // if operationCostTotal != 0 {
  19041. // iteminfo.MedChrgitm = "06"
  19042. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19043. // iteminfo.Amt = operationCostTotal
  19044. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  19045. // iteminfo.ClabAmt = operation_clab_amt
  19046. // iteminfo.OthAmt = operation_other_amt
  19047. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19048. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19049. // }
  19050. //
  19051. // if nursingCostTotal != 0 {
  19052. // iteminfo.MedChrgitm = "07"
  19053. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  19054. // iteminfo.Amt = nursingCostTotal
  19055. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  19056. // iteminfo.ClabAmt = nursing_clab_amt
  19057. // iteminfo.OthAmt = nursing_other_amt
  19058. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19059. // }
  19060. //
  19061. // if materialCostTotal != 0 {
  19062. // iteminfo.MedChrgitm = "08"
  19063. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19064. // iteminfo.Amt = materialCostTotal
  19065. // iteminfo.ClaaSumfee = material_claa_sunmfee
  19066. // iteminfo.ClabAmt = material_clab_amt
  19067. // iteminfo.OthAmt = material_other_amt
  19068. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19069. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19070. // }
  19071. //
  19072. // if westernMedicineCostTotal != 0 {
  19073. // iteminfo.MedChrgitm = "09"
  19074. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19075. // iteminfo.Amt = westernMedicineCostTotal
  19076. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19077. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19078. // iteminfo.OthAmt = westernMedicine_other_amt
  19079. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19080. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19081. //
  19082. // }
  19083. //
  19084. // if chineseMedicineCostTotal != 0 {
  19085. // iteminfo.MedChrgitm = "10"
  19086. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  19087. // iteminfo.Amt = chineseMedicineCostTotal
  19088. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  19089. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  19090. // iteminfo.OthAmt = chinese_medicine_other_amt
  19091. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19092. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19093. //
  19094. // }
  19095. //
  19096. // if chineseTraditionalMedicineCostTotal != 0 {
  19097. // iteminfo.MedChrgitm = "11"
  19098. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19099. // iteminfo.Amt = westernMedicineCostTotal
  19100. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19101. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19102. // iteminfo.OthAmt = westernMedicine_other_amt
  19103. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19104. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19105. //
  19106. // }
  19107. //
  19108. // if commonlyTreatmentCostTotal != 0 {
  19109. // iteminfo.MedChrgitm = "12"
  19110. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  19111. // iteminfo.Amt = commonlyTreatmentCostTotal
  19112. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  19113. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  19114. // iteminfo.OthAmt = commonly_treatment_other_amt
  19115. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19116. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19117. //
  19118. // }
  19119. //
  19120. // if registerCostTotal != 0 {
  19121. // iteminfo.MedChrgitm = "13"
  19122. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  19123. // iteminfo.Amt = registerCostTotal
  19124. // iteminfo.ClaaSumfee = register_claa_sunmfee
  19125. // iteminfo.ClabAmt = register_clab_amt
  19126. // iteminfo.OthAmt = register_other_amt
  19127. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19128. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19129. //
  19130. // }
  19131. //
  19132. // if otherCostTotal != 0 {
  19133. // iteminfo.MedChrgitm = "14"
  19134. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19135. // iteminfo.Amt = otherCostTotal
  19136. // iteminfo.ClaaSumfee = other_claa_sunmfee
  19137. // iteminfo.ClabAmt = other_clab_amt
  19138. // iteminfo.OthAmt = other_other_amt
  19139. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19140. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19141. //
  19142. // }
  19143. // struct4101.IteminfoStruct = iteminfoStructs
  19144. // time_arr := strings.Split(order.SetlTime, " ")
  19145. // struct4101.AdmTime = time_arr[0]
  19146. // struct4101.AdmEndTime = time_arr[0]
  19147. //
  19148. // struct4101.DoctorName = doctor.UserName
  19149. // struct4101.DoctorCode = doctor.DoctorNumber
  19150. //
  19151. // struct4101.Ntly = "中国"
  19152. // struct4101.AdmCaty = "A03.06"
  19153. // var res ResultSeventeen
  19154. // if miConfig.MdtrtareaAdmvs == "421300" {
  19155. // data := make(map[string]interface{})
  19156. // data["struct4101"] = struct4101
  19157. // data["secret_key"] = miConfig.SecretKey
  19158. // data["org_name"] = miConfig.OrgName
  19159. // data["opera"] = curRoles.UserName
  19160. // data["code"] = miConfig.Code
  19161. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  19162. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19163. //
  19164. // client := &http.Client{}
  19165. // bytesData, _ := json.Marshal(data)
  19166. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  19167. // resp, _ := client.Do(req)
  19168. // defer resp.Body.Close()
  19169. // body, ioErr := ioutil.ReadAll(resp.Body)
  19170. // if ioErr != nil {
  19171. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19172. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19173. // return
  19174. // }
  19175. // var respJSON map[string]interface{}
  19176. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19177. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19178. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19179. // return
  19180. // }
  19181. //
  19182. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19183. // userJSONBytes, _ := json.Marshal(respJSON)
  19184. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19185. // utils.ErrorLog("解析失败:%v", err)
  19186. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19187. // adminUser := c.GetAdminUserInfo()
  19188. // errlog := &models.HisOrderError{
  19189. // UserOrgId: adminUser.CurrentOrgId,
  19190. // Ctime: time.Now().Unix(),
  19191. // Mtime: time.Now().Unix(),
  19192. // ErrMsg: res.ErrMsg + "解析失败",
  19193. // Status: 1,
  19194. // PatientId: order_id,
  19195. // Stage: 10088,
  19196. // }
  19197. // service.CreateErrMsgLog(errlog)
  19198. // continue
  19199. // }
  19200. //
  19201. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  19202. // data := make(map[string]interface{})
  19203. // data["struct4101"] = struct4101
  19204. // data["secret_key"] = miConfig.SecretKey
  19205. // data["org_name"] = miConfig.OrgName
  19206. // data["opera"] = curRoles.UserName
  19207. // data["code"] = miConfig.Code
  19208. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  19209. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19210. //
  19211. // client := &http.Client{}
  19212. // bytesData, _ := json.Marshal(data)
  19213. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  19214. // resp, _ := client.Do(req)
  19215. // defer resp.Body.Close()
  19216. // body, ioErr := ioutil.ReadAll(resp.Body)
  19217. // if ioErr != nil {
  19218. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19219. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19220. // return
  19221. // }
  19222. // var respJSON map[string]interface{}
  19223. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19224. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19225. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19226. // return
  19227. // }
  19228. //
  19229. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19230. // userJSONBytes, _ := json.Marshal(respJSON)
  19231. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19232. // utils.ErrorLog("解析失败:%v", err)
  19233. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19234. // adminUser := c.GetAdminUserInfo()
  19235. // errlog := &models.HisOrderError{
  19236. // UserOrgId: adminUser.CurrentOrgId,
  19237. // Ctime: time.Now().Unix(),
  19238. // Mtime: time.Now().Unix(),
  19239. // ErrMsg: res.ErrMsg + "解析失败",
  19240. // Status: 1,
  19241. // PatientId: order_id,
  19242. // Stage: 10088,
  19243. // }
  19244. // service.CreateErrMsgLog(errlog)
  19245. // continue
  19246. // }
  19247. //
  19248. // } else {
  19249. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  19250. // fmt.Println(result)
  19251. //
  19252. // var dat map[string]interface{}
  19253. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19254. // fmt.Println(dat)
  19255. // } else {
  19256. // fmt.Println(err)
  19257. // }
  19258. // userJSONBytes, _ := json.Marshal(dat)
  19259. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19260. // utils.ErrorLog("解析失败:%v", err)
  19261. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19262. // adminUser := c.GetAdminUserInfo()
  19263. // errlog := &models.HisOrderError{
  19264. // UserOrgId: adminUser.CurrentOrgId,
  19265. // Ctime: time.Now().Unix(),
  19266. // Mtime: time.Now().Unix(),
  19267. // ErrMsg: res.ErrMsg + "解析失败",
  19268. // Status: 1,
  19269. // PatientId: order_id,
  19270. // Stage: 10106,
  19271. // }
  19272. // service.CreateErrMsgLog(errlog)
  19273. // continue
  19274. // }
  19275. // }
  19276. //
  19277. // if res.Infcode != 0 {
  19278. // adminUser := c.GetAdminUserInfo()
  19279. // errlog := &models.HisOrderError{
  19280. // UserOrgId: adminUser.CurrentOrgId,
  19281. // Ctime: time.Now().Unix(),
  19282. // Mtime: time.Now().Unix(),
  19283. // ErrMsg: res.ErrMsg,
  19284. // Status: 1,
  19285. // PatientId: order_id,
  19286. // Stage: 10106,
  19287. // }
  19288. // service.CreateErrMsgLog(errlog)
  19289. // continue
  19290. // } else {
  19291. // hisFundSettleListResult := &models.HisFundSettleListResult{
  19292. // Number: res.Output.SetlListId,
  19293. // Status: 1,
  19294. // Ctime: time.Now().Unix(),
  19295. // Mtime: time.Now().Unix(),
  19296. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19297. // IsUpload: 1,
  19298. // OrderId: order_id,
  19299. // }
  19300. // service.CreateUploadRecord(hisFundSettleListResult)
  19301. // continue
  19302. // }
  19303. // }
  19304. //}
  19305. func (c *HisApiController) GetOrgInfo() {
  19306. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  19307. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  19308. }
  19309. func (c *HisApiController) GetHisPatientInfo() {
  19310. medical_insurance_card := c.GetString("medical_insurance_card")
  19311. id_card_type, _ := c.GetInt64("id_card_type")
  19312. id_card := c.GetString("id_card")
  19313. adminInfo := c.GetAdminUserInfo()
  19314. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  19315. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  19316. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  19317. IdCardNo := ""
  19318. if id_card_type == 1 {
  19319. IdCardNo = medical_insurance_card
  19320. } else if id_card_type == 2 {
  19321. IdCardNo = id_card
  19322. }
  19323. if config.IsOpen == 1 {
  19324. 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
  19325. resp, requestErr := http.Get(api)
  19326. if requestErr != nil {
  19327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19328. return
  19329. }
  19330. defer resp.Body.Close()
  19331. body, ioErr := ioutil.ReadAll(resp.Body)
  19332. if ioErr != nil {
  19333. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19335. return
  19336. }
  19337. var respJSON map[string]interface{}
  19338. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19339. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19341. return
  19342. }
  19343. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19344. userJSONBytes, _ := json.Marshal(userJSON)
  19345. var res ResultTwo
  19346. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19347. utils.ErrorLog("解析失败:%v", err)
  19348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19349. return
  19350. }
  19351. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  19352. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  19353. infoStr := string(Iinfos)
  19354. idetinfoStr := string(Idetinfos)
  19355. if res.Infcode == 0 {
  19356. his := models.VMHisPatient{
  19357. Status: 1,
  19358. Ctime: time.Now().Unix(),
  19359. Mtime: time.Now().Unix(),
  19360. PsnNo: res.Output.Baseinfo.PsnNo,
  19361. PsnCertType: res.Output.Baseinfo.PsnCertType,
  19362. Certno: res.Output.Baseinfo.Certno,
  19363. PsnName: res.Output.Baseinfo.PsnName,
  19364. Gend: res.Output.Baseinfo.Gend,
  19365. Naty: res.Output.Baseinfo.Naty,
  19366. Iinfo: infoStr,
  19367. Idetinfo: idetinfoStr,
  19368. UserOrgId: adminInfo.CurrentOrgId,
  19369. IsReturn: 1,
  19370. IdCardType: id_card_type,
  19371. }
  19372. c.ServeSuccessJSON(map[string]interface{}{
  19373. "info": his,
  19374. })
  19375. } else {
  19376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  19377. return
  19378. }
  19379. }
  19380. }
  19381. //func GetBasBaseInfo() (jsonStr string, err error) {
  19382. //
  19383. // handle := syscall.NewLazyDLL("SSCard.dll")
  19384. // add := handle.NewProc("ReadCardBas")
  19385. // str := make([]byte, 1024)
  19386. // str1 := make([]byte, 1024)
  19387. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  19388. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  19389. //
  19390. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  19391. //
  19392. // fmt.Println("> Add(4,5)的结果为:", ret)
  19393. // handle.Release()
  19394. //
  19395. // return "", nil
  19396. //
  19397. //}
  19398. //func GetQRBaseInfo() (jsonStr string, err error) {
  19399. // handle := syscall.LoadDLL("SSCard.dll")
  19400. // ReadCardBas := handle.FindProc("GetQRBase")
  19401. //
  19402. // str := make([]byte, 256)
  19403. // str1 := make([]byte, 256)
  19404. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  19405. //
  19406. // fmt.Println(string(str))
  19407. // fmt.Println(r)
  19408. // return string(str), nil
  19409. //}
  19410. //func CardInit() int {
  19411. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  19412. // add := DllTestDef.MustFindProc("Init")
  19413. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  19414. // if err != nil {
  19415. // fmt.Println("SSCard的运算结果为:", ret)
  19416. // }
  19417. // result := int(ret)
  19418. // return result
  19419. //}
  19420. //func CardInit() int {
  19421. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  19422. // if err != nil {
  19423. // fmt.Println("SSCard的运算结果为:", ret)
  19424. // }
  19425. // fmt.Println(err)
  19426. // result := int(ret)
  19427. // return result
  19428. //}
  19429. func IntPtr(n int) uintptr {
  19430. return uintptr(n)
  19431. }
  19432. func StrPtr(s string) uintptr {
  19433. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  19434. }
  19435. type Result2001 struct {
  19436. Cainfo interface{} `json:"cainfo"`
  19437. ErrMsg string `json:"err_msg"`
  19438. InfRefmsgid string `json:"inf_refmsgid"`
  19439. Infcode int64 `json:"infcode"`
  19440. Output struct {
  19441. Trtinfo struct {
  19442. PsnNo string `json:"psn_no"`
  19443. TrtChkType string `json:"trt_chk_type"`
  19444. FundPayType string `json:"fund_pay_type"`
  19445. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  19446. Begndate string `json:"begndate"`
  19447. Enddate string `json:"enddate"`
  19448. TrtChkRslt string `json:"trt_chk_rslt"`
  19449. } `json:"trtinfo"`
  19450. } `json:"output"`
  19451. RefmsgTime string `json:"refmsg_time"`
  19452. RespondTime string `json:"respond_time"`
  19453. Signtype interface{} `json:"signtype"`
  19454. WarnMsg interface{} `json:"warn_msg"`
  19455. }
  19456. type Result2001Org10265 struct {
  19457. Cainfo interface{} `json:"cainfo"`
  19458. ErrMsg string `json:"err_msg"`
  19459. InfRefmsgid string `json:"inf_refmsgid"`
  19460. Infcode string `json:"infcode"`
  19461. Output struct {
  19462. Trtinfo struct {
  19463. PsnNo string `json:"psn_no"`
  19464. TrtChkType string `json:"trt_chk_type"`
  19465. FundPayType string `json:"fund_pay_type"`
  19466. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  19467. Begndate string `json:"begndate"`
  19468. Enddate string `json:"enddate"`
  19469. TrtChkRslt string `json:"trt_chk_rslt"`
  19470. } `json:"trtinfo"`
  19471. } `json:"output"`
  19472. RefmsgTime string `json:"refmsg_time"`
  19473. RespondTime string `json:"respond_time"`
  19474. Signtype interface{} `json:"signtype"`
  19475. WarnMsg interface{} `json:"warn_msg"`
  19476. }
  19477. type ResultTwo struct {
  19478. ErrMsg string `json:"err_msg"`
  19479. InfRefmsgid string `json:"inf_refmsgid"`
  19480. Infcode int64 `json:"infcode"`
  19481. Output struct {
  19482. Baseinfo struct {
  19483. //Brdy string `json:"brdy"`
  19484. Certno string `json:"certno"`
  19485. Gend string `json:"gend"`
  19486. Naty string `json:"naty"`
  19487. PsnCertType string `json:"psn_cert_type"`
  19488. PsnName string `json:"psn_name"`
  19489. PsnNo string `json:"psn_no"`
  19490. } `json:"baseinfo"`
  19491. Idetinfo []interface{} `json:"idetinfo"`
  19492. Iinfo []struct {
  19493. Balc float64 `json:"balc"`
  19494. CvlservFlag string `json:"cvlserv_flag"`
  19495. EmpName string `json:"emp_name"`
  19496. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  19497. Insutype string `json:"insutype"`
  19498. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  19499. //PausInsuDate string `json:"paus_insu_date"`
  19500. //PsnInsuDate string `json:"psn_insu_date"`
  19501. PsnInsuStas string `json:"psn_insu_stas"`
  19502. PsnType string `json:"psn_type"`
  19503. } `json:"insuinfo"`
  19504. } `json:"output"`
  19505. RefmsgTime string `json:"refmsg_time"`
  19506. RespondTime string `json:"respond_time"`
  19507. Signtype interface{} `json:"signtype"`
  19508. WarnInfo interface{} `json:"warn_info"`
  19509. }
  19510. type ResultTwo10265 struct {
  19511. ErrMsg string `json:"err_msg"`
  19512. InfRefmsgid string `json:"inf_refmsgid"`
  19513. Infcode string `json:"infcode"`
  19514. Output struct {
  19515. Baseinfo struct {
  19516. //Brdy string `json:"brdy"`
  19517. Certno string `json:"certno"`
  19518. Gend string `json:"gend"`
  19519. Naty string `json:"naty"`
  19520. PsnCertType string `json:"psn_cert_type"`
  19521. PsnName string `json:"psn_name"`
  19522. PsnNo string `json:"psn_no"`
  19523. } `json:"baseinfo"`
  19524. Idetinfo []interface{} `json:"idetinfo"`
  19525. Iinfo []struct {
  19526. Balc float64 `json:"balc"`
  19527. CvlservFlag string `json:"cvlserv_flag"`
  19528. EmpName string `json:"emp_name"`
  19529. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  19530. Insutype string `json:"insutype"`
  19531. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  19532. PsnInsuStas string `json:"psn_insu_stas"`
  19533. PsnType string `json:"psn_type"`
  19534. } `json:"insuinfo"`
  19535. } `json:"output"`
  19536. RefmsgTime string `json:"refmsg_time"`
  19537. RespondTime string `json:"respond_time"`
  19538. Signtype interface{} `json:"signtype"`
  19539. WarnInfo interface{} `json:"warn_info"`
  19540. }
  19541. type ResultThree struct {
  19542. Cainfo interface{} `json:"cainfo"`
  19543. ErrMsg string `json:"err_msg"`
  19544. InfRefmsgid string `json:"inf_refmsgid"`
  19545. Infcode int64 `json:"infcode"`
  19546. Output struct {
  19547. Data struct {
  19548. IptOtpNo string `json:"ipt_otp_no"`
  19549. MdtrtID string `json:"mdtrt_id"`
  19550. PsnNo string `json:"psn_no"`
  19551. } `json:"data"`
  19552. } `json:"output"`
  19553. RefmsgTime string `json:"refmsg_time"`
  19554. RespondTime string `json:"respond_time"`
  19555. Signtype interface{} `json:"signtype"`
  19556. WarnMsg interface{} `json:"warn_msg"`
  19557. }
  19558. type ResultThree10265 struct {
  19559. Cainfo interface{} `json:"cainfo"`
  19560. ErrMsg string `json:"err_msg"`
  19561. InfRefmsgid string `json:"inf_refmsgid"`
  19562. Infcode string `json:"infcode"`
  19563. Output struct {
  19564. Data struct {
  19565. IptOtpNo string `json:"ipt_otp_no"`
  19566. MdtrtID string `json:"mdtrt_id"`
  19567. PsnNo string `json:"psn_no"`
  19568. } `json:"data"`
  19569. } `json:"output"`
  19570. RefmsgTime string `json:"refmsg_time"`
  19571. RespondTime string `json:"respond_time"`
  19572. Signtype interface{} `json:"signtype"`
  19573. WarnMsg interface{} `json:"warn_msg"`
  19574. }
  19575. type ResultFour struct {
  19576. Cainfo string `json:"cainfo"`
  19577. ErrMsg string `json:"err_msg"`
  19578. InfRefmsgid string `json:"inf_refmsgid"`
  19579. Infcode int64 `json:"infcode"`
  19580. Output struct {
  19581. Result []struct {
  19582. BasMednFlag string `json:"bas_medn_flag"`
  19583. ChldMedcFlag string `json:"chld_medc_flag"`
  19584. ChrgitmLv string `json:"chrgitm_lv"`
  19585. Cnt float64 `json:"cnt"`
  19586. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  19587. DrtReimFlag string `json:"drt_reim_flag"`
  19588. FeedetlSn string `json:"feedetl_sn"`
  19589. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  19590. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  19591. InscpScpAmt float64 `json:"inscp_scp_amt"`
  19592. ListSpItemFlag string `json:"list_sp_item_flag"`
  19593. LmtUsedFlag string `json:"lmt_used_flag"`
  19594. MedChrgitmType string `json:"med_chrgitm_type"`
  19595. Memo string `json:"memo"`
  19596. OverlmtAmt float64 `json:"overlmt_amt"`
  19597. PreselfpayAmt float64 `json:"preselfpay_amt"`
  19598. Pric float64 `json:"pric"`
  19599. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  19600. SelfpayProp float64 `json:"selfpay_prop"`
  19601. } `json:"result"`
  19602. } `json:"output"`
  19603. RefmsgTime string `json:"refmsg_time"`
  19604. RespondTime string `json:"respond_time"`
  19605. Signtype string `json:"signtype"`
  19606. WarnMsg string `json:"warn_msg"`
  19607. }
  19608. type ResultFour10265 struct {
  19609. Cainfo string `json:"cainfo"`
  19610. ErrMsg string `json:"err_msg"`
  19611. InfRefmsgid string `json:"inf_refmsgid"`
  19612. Infcode string `json:"infcode"`
  19613. Output struct {
  19614. Result []struct {
  19615. BasMednFlag string `json:"bas_medn_flag"`
  19616. ChldMedcFlag string `json:"chld_medc_flag"`
  19617. ChrgitmLv string `json:"chrgitm_lv"`
  19618. Cnt float64 `json:"cnt"`
  19619. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  19620. DrtReimFlag string `json:"drt_reim_flag"`
  19621. FeedetlSn string `json:"feedetl_sn"`
  19622. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  19623. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  19624. InscpScpAmt float64 `json:"inscp_scp_amt"`
  19625. ListSpItemFlag string `json:"list_sp_item_flag"`
  19626. LmtUsedFlag string `json:"lmt_used_flag"`
  19627. MedChrgitmType string `json:"med_chrgitm_type"`
  19628. Memo string `json:"memo"`
  19629. OverlmtAmt float64 `json:"overlmt_amt"`
  19630. PreselfpayAmt float64 `json:"preselfpay_amt"`
  19631. Pric float64 `json:"pric"`
  19632. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  19633. SelfpayProp float64 `json:"selfpay_prop"`
  19634. } `json:"result"`
  19635. } `json:"output"`
  19636. RefmsgTime string `json:"refmsg_time"`
  19637. RespondTime string `json:"respond_time"`
  19638. Signtype string `json:"signtype"`
  19639. WarnMsg string `json:"warn_msg"`
  19640. }
  19641. type ResultMemo struct {
  19642. InsuAdmdvs string `json:"insuAdmdvs"`
  19643. }
  19644. // [{"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}]
  19645. type ResultIDInfo struct {
  19646. Begntime string `json:"begntime"`
  19647. Endtime string `json:"endtime"`
  19648. Memo string `json:"memo"`
  19649. }
  19650. type ResultFive struct {
  19651. Balc float64 `json:"balc"`
  19652. CvlservFlag string `json:"cvlserv_flag"`
  19653. EmpName string `json:"emp_name"`
  19654. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  19655. Insutype string `json:"insutype"`
  19656. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  19657. PausInsuDate string `json:"paus_insu_date"`
  19658. PsnInsuDate string `json:"psn_insu_date"`
  19659. PsnInsuStas string `json:"psn_insu_stas"`
  19660. PsnType string `json:"psn_type"`
  19661. }
  19662. type ResultSix struct {
  19663. Cainfo interface{} `json:"cainfo"`
  19664. ErrMsg string `json:"err_msg"`
  19665. InfRefmsgid string `json:"inf_refmsgid"`
  19666. Infcode int64 `json:"infcode"`
  19667. Output struct {
  19668. } `json:"output"`
  19669. RefmsgTime string `json:"refmsg_time"`
  19670. RespondTime string `json:"respond_time"`
  19671. Signtype interface{} `json:"signtype"`
  19672. WarnMsg interface{} `json:"warn_msg"`
  19673. }
  19674. type FJ3507Result struct {
  19675. Cainfo interface{} `json:"cainfo"`
  19676. ErrMsg string `json:"err_msg"`
  19677. InfRefmsgid string `json:"inf_refmsgid"`
  19678. Infcode int64 `json:"infcode"`
  19679. Output struct {
  19680. retRslt string `json:"retRslt"`
  19681. msgRslt string `json:"msgRslt"`
  19682. } `json:"output"`
  19683. RefmsgTime string `json:"refmsg_time"`
  19684. RespondTime string `json:"respond_time"`
  19685. Signtype interface{} `json:"signtype"`
  19686. WarnMsg interface{} `json:"warn_msg"`
  19687. }
  19688. type FJ3507ResultFor10188 struct {
  19689. Cainfo interface{} `json:"cainfo"`
  19690. ErrMsg string `json:"err_msg"`
  19691. InfRefmsgid string `json:"inf_refmsgid"`
  19692. Infcode string `json:"infcode"`
  19693. RefmsgTime string `json:"refmsg_time"`
  19694. RespondTime string `json:"respond_time"`
  19695. Signtype interface{} `json:"signtype"`
  19696. WarnMsg interface{} `json:"warn_msg"`
  19697. }
  19698. type Result2406 struct {
  19699. Cainfo interface{} `json:"cainfo"`
  19700. ErrMsg string `json:"err_msg"`
  19701. InfRefmsgid string `json:"inf_refmsgid"`
  19702. Infcode int64 `json:"infcode"`
  19703. Output struct {
  19704. Result struct {
  19705. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  19706. } `json:"result"`
  19707. } `json:"output"`
  19708. RefmsgTime string `json:"refmsg_time"`
  19709. RespondTime string `json:"respond_time"`
  19710. Signtype interface{} `json:"signtype"`
  19711. WarnMsg interface{} `json:"warn_msg"`
  19712. }
  19713. type GZResultSix struct {
  19714. Cainfo interface{} `json:"cainfo"`
  19715. ErrMsg string `json:"err_msg"`
  19716. InfRefmsgid string `json:"inf_refmsgid"`
  19717. Infcode int64 `json:"infcode"`
  19718. Output string `json:"output"`
  19719. RefmsgTime string `json:"refmsg_time"`
  19720. RespondTime string `json:"respond_time"`
  19721. Signtype interface{} `json:"signtype"`
  19722. WarnMsg interface{} `json:"warn_msg"`
  19723. }
  19724. type ResultSix10265 struct {
  19725. Cainfo interface{} `json:"cainfo"`
  19726. ErrMsg string `json:"err_msg"`
  19727. InfRefmsgid string `json:"inf_refmsgid"`
  19728. Infcode string `json:"infcode"`
  19729. Output struct {
  19730. } `json:"output"`
  19731. RefmsgTime string `json:"refmsg_time"`
  19732. RespondTime string `json:"respond_time"`
  19733. Signtype interface{} `json:"signtype"`
  19734. WarnMsg interface{} `json:"warn_msg"`
  19735. }
  19736. type ResultSeven struct {
  19737. Cainfo string `json:"cainfo"`
  19738. ErrMsg string `json:"err_msg"`
  19739. InfRefmsgid string `json:"inf_refmsgid"`
  19740. Infcode int64 `json:"infcode"`
  19741. Output struct {
  19742. Setlinfo struct {
  19743. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  19744. AcctPay float64 `json:"acct_pay"`
  19745. ActPayDedc float64 `json:"act_pay_dedc"`
  19746. Age float64 `json:"age"`
  19747. Balc float64 `json:"balc"`
  19748. Certno string `json:"certno"`
  19749. ClrOptins string `json:"clr_optins"`
  19750. ClrType string `json:"clr_type"`
  19751. ClrWay string `json:"clr_way"`
  19752. CvlservFlag string `json:"cvlserv_flag"`
  19753. CvlservPay float64 `json:"cvlserv_pay"`
  19754. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  19755. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  19756. Gend string `json:"gend"`
  19757. HifesPay float64 `json:"hifes_pay"`
  19758. HifmiPay float64 `json:"hifmi_pay"`
  19759. HifpPay float64 `json:"hifp_pay"`
  19760. HospPartAmt float64 `json:"hosp_part_amt"`
  19761. InscpScpAmt float64 `json:"inscp_scp_amt"`
  19762. Insutype string `json:"insutype"`
  19763. MafPay float64 `json:"maf_pay"`
  19764. MdtrtCertType string `json:"mdtrt_cert_type"`
  19765. HifobPay float64 `json:"hifob_pay"`
  19766. MdtrtID string `json:"mdtrt_id"`
  19767. MedType string `json:"med_type"`
  19768. MedfeeSumamt float64 `json:"medfee_sumamt"`
  19769. MedinsSetlID string `json:"medins_setl_id"`
  19770. Naty string `json:"naty"`
  19771. OthPay float64 `json:"oth_pay"`
  19772. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  19773. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  19774. PreselfpayAmt float64 `json:"preselfpay_amt"`
  19775. PsnCashPay float64 `json:"psn_cash_pay"`
  19776. PsnCertType string `json:"psn_cert_type"`
  19777. PsnName string `json:"psn_name"`
  19778. PsnNo string `json:"psn_no"`
  19779. PsnPartAmt float64 `json:"psn_part_amt"`
  19780. PsnType string `json:"psn_type"`
  19781. SetlID string `json:"setl_id"`
  19782. SetlTime string `json:"setl_time"`
  19783. } `json:"setlinfo"`
  19784. Setldetail interface{} `json:"setldetail"`
  19785. } `json:"output"`
  19786. RefmsgTime string `json:"refmsg_time"`
  19787. RespondTime string `json:"respond_time"`
  19788. Signtype interface{} `json:"signtype"`
  19789. WarnMsg interface{} `json:"warn_msg"`
  19790. }
  19791. type ResultSevenAH struct {
  19792. Cainfo string `json:"cainfo"`
  19793. ErrMsg string `json:"err_msg"`
  19794. InfRefmsgid string `json:"inf_refmsgid"`
  19795. Infcode int64 `json:"infcode"`
  19796. Output struct {
  19797. Setlinfo struct {
  19798. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  19799. AcctPay float64 `json:"acct_pay"`
  19800. ActPayDedc float64 `json:"act_pay_dedc"`
  19801. Age float64 `json:"age"`
  19802. Balc float64 `json:"balc"`
  19803. Certno string `json:"certno"`
  19804. ClrOptins string `json:"clr_optins"`
  19805. ClrType string `json:"clr_type"`
  19806. ClrWay string `json:"clr_way"`
  19807. CvlservFlag string `json:"cvlserv_flag"`
  19808. CvlservPay float64 `json:"cvlserv_pay"`
  19809. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  19810. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  19811. Gend string `json:"gend"`
  19812. HifesPay float64 `json:"hifes_pay"`
  19813. HifmiPay float64 `json:"hifmi_pay"`
  19814. HifpPay float64 `json:"hifp_pay"`
  19815. HospPartAmt float64 `json:"hosp_part_amt"`
  19816. InscpScpAmt float64 `json:"inscp_scp_amt"`
  19817. Insutype string `json:"insutype"`
  19818. MafPay float64 `json:"maf_pay"`
  19819. MdtrtCertType string `json:"mdtrt_cert_type"`
  19820. HifobPay float64 `json:"hifob_pay"`
  19821. MdtrtID string `json:"mdtrt_id"`
  19822. MedType string `json:"med_type"`
  19823. MedfeeSumamt float64 `json:"medfee_sumamt"`
  19824. MedinsSetlID string `json:"medins_setl_id"`
  19825. Naty string `json:"naty"`
  19826. OthPay float64 `json:"oth_pay"`
  19827. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  19828. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  19829. PreselfpayAmt float64 `json:"preselfpay_amt"`
  19830. PsnCashPay float64 `json:"psn_cash_pay"`
  19831. PsnCertType string `json:"psn_cert_type"`
  19832. PsnName string `json:"psn_name"`
  19833. PsnNo string `json:"psn_no"`
  19834. PsnPartAmt float64 `json:"psn_part_amt"`
  19835. PsnType string `json:"psn_type"`
  19836. SetlID string `json:"setl_id"`
  19837. SetlTime int64 `json:"setl_time"`
  19838. } `json:"setlinfo"`
  19839. Setldetail interface{} `json:"setldetail"`
  19840. } `json:"output"`
  19841. RefmsgTime string `json:"refmsg_time"`
  19842. RespondTime string `json:"respond_time"`
  19843. Signtype interface{} `json:"signtype"`
  19844. WarnMsg interface{} `json:"warn_msg"`
  19845. }
  19846. type ResultSeven10265 struct {
  19847. Cainfo string `json:"cainfo"`
  19848. ErrMsg string `json:"err_msg"`
  19849. InfRefmsgid string `json:"inf_refmsgid"`
  19850. Infcode string `json:"infcode"`
  19851. Output struct {
  19852. Setlinfo struct {
  19853. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  19854. AcctPay float64 `json:"acct_pay"`
  19855. ActPayDedc float64 `json:"act_pay_dedc"`
  19856. Age float64 `json:"age"`
  19857. Balc float64 `json:"balc"`
  19858. Certno string `json:"certno"`
  19859. ClrOptins string `json:"clr_optins"`
  19860. ClrType string `json:"clr_type"`
  19861. ClrWay string `json:"clr_way"`
  19862. CvlservFlag string `json:"cvlserv_flag"`
  19863. CvlservPay float64 `json:"cvlserv_pay"`
  19864. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  19865. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  19866. Gend string `json:"gend"`
  19867. HifesPay float64 `json:"hifes_pay"`
  19868. HifmiPay float64 `json:"hifmi_pay"`
  19869. HifpPay float64 `json:"hifp_pay"`
  19870. HospPartAmt float64 `json:"hosp_part_amt"`
  19871. InscpScpAmt float64 `json:"inscp_scp_amt"`
  19872. Insutype string `json:"insutype"`
  19873. MafPay float64 `json:"maf_pay"`
  19874. MdtrtCertType string `json:"mdtrt_cert_type"`
  19875. HifobPay float64 `json:"hifob_pay"`
  19876. MdtrtID string `json:"mdtrt_id"`
  19877. MedType string `json:"med_type"`
  19878. MedfeeSumamt float64 `json:"medfee_sumamt"`
  19879. MedinsSetlID string `json:"medins_setl_id"`
  19880. Naty string `json:"naty"`
  19881. OthPay float64 `json:"oth_pay"`
  19882. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  19883. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  19884. PreselfpayAmt float64 `json:"preselfpay_amt"`
  19885. PsnCashPay float64 `json:"psn_cash_pay"`
  19886. PsnCertType string `json:"psn_cert_type"`
  19887. PsnName string `json:"psn_name"`
  19888. PsnNo string `json:"psn_no"`
  19889. PsnPartAmt float64 `json:"psn_part_amt"`
  19890. PsnType string `json:"psn_type"`
  19891. SetlID string `json:"setl_id"`
  19892. SetlTime string `json:"setl_time"`
  19893. } `json:"setlinfo"`
  19894. Setldetail interface{} `json:"setldetail"`
  19895. } `json:"output"`
  19896. RefmsgTime string `json:"refmsg_time"`
  19897. RespondTime string `json:"respond_time"`
  19898. Signtype interface{} `json:"signtype"`
  19899. WarnMsg interface{} `json:"warn_msg"`
  19900. }
  19901. type ResultSeven10265Two struct {
  19902. Cainfo string `json:"cainfo"`
  19903. ErrMsg string `json:"err_msg"`
  19904. InfRefmsgid string `json:"inf_refmsgid"`
  19905. Infcode string `json:"infcode"`
  19906. Output struct {
  19907. Setlinfo struct {
  19908. AcctMulaidPay string `json:"acct_mulaid_pay"`
  19909. AcctPay float64 `json:"acct_pay"`
  19910. ActPayDedc float64 `json:"act_pay_dedc"`
  19911. Age float64 `json:"age"`
  19912. Balc float64 `json:"balc"`
  19913. Certno string `json:"certno"`
  19914. ClrOptins string `json:"clr_optins"`
  19915. ClrType string `json:"clr_type"`
  19916. ClrWay string `json:"clr_way"`
  19917. CvlservFlag string `json:"cvlserv_flag"`
  19918. CvlservPay float64 `json:"cvlserv_pay"`
  19919. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  19920. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  19921. Gend string `json:"gend"`
  19922. HifesPay float64 `json:"hifes_pay"`
  19923. HifmiPay float64 `json:"hifmi_pay"`
  19924. HifpPay float64 `json:"hifp_pay"`
  19925. HospPartAmt string `json:"hosp_part_amt"`
  19926. InscpScpAmt float64 `json:"inscp_scp_amt"`
  19927. Insutype string `json:"insutype"`
  19928. MafPay float64 `json:"maf_pay"`
  19929. MdtrtCertType string `json:"mdtrt_cert_type"`
  19930. HifobPay float64 `json:"hifob_pay"`
  19931. MdtrtID string `json:"mdtrt_id"`
  19932. MedType string `json:"med_type"`
  19933. MedfeeSumamt float64 `json:"medfee_sumamt"`
  19934. MedinsSetlID string `json:"medins_setl_id"`
  19935. Naty string `json:"naty"`
  19936. OthPay float64 `json:"oth_pay"`
  19937. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  19938. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  19939. PreselfpayAmt float64 `json:"preselfpay_amt"`
  19940. PsnCashPay float64 `json:"psn_cash_pay"`
  19941. PsnCertType string `json:"psn_cert_type"`
  19942. PsnName string `json:"psn_name"`
  19943. PsnNo string `json:"psn_no"`
  19944. PsnPartAmt float64 `json:"psn_part_amt"`
  19945. PsnType string `json:"psn_type"`
  19946. SetlID string `json:"setl_id"`
  19947. SetlTime string `json:"setl_time"`
  19948. } `json:"setlinfo"`
  19949. Setldetail interface{} `json:"setldetail"`
  19950. } `json:"output"`
  19951. RefmsgTime string `json:"refmsg_time"`
  19952. RespondTime string `json:"respond_time"`
  19953. Signtype interface{} `json:"signtype"`
  19954. WarnMsg interface{} `json:"warn_msg"`
  19955. }
  19956. type GZResultSeven10265Two struct {
  19957. Cainfo string `json:"cainfo"`
  19958. ErrMsg string `json:"err_msg"`
  19959. InfRefmsgid string `json:"inf_refmsgid"`
  19960. Infcode int64 `json:"infcode"`
  19961. Output struct {
  19962. Setlinfo struct {
  19963. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  19964. AcctPay float64 `json:"acct_pay"`
  19965. ActPayDedc float64 `json:"act_pay_dedc"`
  19966. Age float64 `json:"age"`
  19967. Balc float64 `json:"balc"`
  19968. Certno string `json:"certno"`
  19969. ClrOptins string `json:"clr_optins"`
  19970. ClrType string `json:"clr_type"`
  19971. ClrWay string `json:"clr_way"`
  19972. CvlservFlag string `json:"cvlserv_flag"`
  19973. CvlservPay float64 `json:"cvlserv_pay"`
  19974. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  19975. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  19976. Gend string `json:"gend"`
  19977. HifesPay float64 `json:"hifes_pay"`
  19978. HifmiPay float64 `json:"hifmi_pay"`
  19979. HifpPay float64 `json:"hifp_pay"`
  19980. HospPartAmt float64 `json:"hosp_part_amt"`
  19981. InscpScpAmt float64 `json:"inscp_scp_amt"`
  19982. Insutype string `json:"insutype"`
  19983. MafPay float64 `json:"maf_pay"`
  19984. MdtrtCertType string `json:"mdtrt_cert_type"`
  19985. HifobPay float64 `json:"hifob_pay"`
  19986. MdtrtID string `json:"mdtrt_id"`
  19987. MedType string `json:"med_type"`
  19988. MedfeeSumamt float64 `json:"medfee_sumamt"`
  19989. MedinsSetlID string `json:"medins_setl_id"`
  19990. Naty string `json:"naty"`
  19991. OthPay float64 `json:"oth_pay"`
  19992. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  19993. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  19994. PreselfpayAmt float64 `json:"preselfpay_amt"`
  19995. PsnCashPay float64 `json:"psn_cash_pay"`
  19996. PsnCertType string `json:"psn_cert_type"`
  19997. PsnName string `json:"psn_name"`
  19998. PsnNo string `json:"psn_no"`
  19999. PsnPartAmt float64 `json:"psn_part_amt"`
  20000. PsnType string `json:"psn_type"`
  20001. SetlID string `json:"setl_id"`
  20002. SetlTime string `json:"setl_time"`
  20003. } `json:"setlinfo"`
  20004. Setldetail interface{} `json:"setldetail"`
  20005. } `json:"output"`
  20006. RefmsgTime string `json:"refmsg_time"`
  20007. RespondTime string `json:"respond_time"`
  20008. Signtype interface{} `json:"signtype"`
  20009. WarnMsg interface{} `json:"warn_msg"`
  20010. }
  20011. type ResultEight struct {
  20012. Cainfo string `json:"cainfo"`
  20013. ErrMsg string `json:"err_msg"`
  20014. InfRefmsgid string `json:"inf_refmsgid"`
  20015. Infcode int64 `json:"infcode"`
  20016. Output struct {
  20017. Stmtinfo struct {
  20018. SetlOptins string `json:"setl_optins"`
  20019. StmtRslt string `json:"stmt_rslt"`
  20020. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  20021. } `json:"stmtinfo"`
  20022. } `json:"output"`
  20023. RefmsgTime string `json:"refmsg_time"`
  20024. RespondTime string `json:"respond_time"`
  20025. Signtype interface{} `json:"signtype"`
  20026. WarnMsg interface{} `json:"warn_msg"`
  20027. }
  20028. type ResultEightFor10188 struct {
  20029. Cainfo string `json:"cainfo"`
  20030. ErrMsg string `json:"err_msg"`
  20031. InfRefmsgid string `json:"inf_refmsgid"`
  20032. Infcode string `json:"infcode"`
  20033. Output struct {
  20034. Stmtinfo struct {
  20035. SetlOptins string `json:"setl_optins"`
  20036. StmtRslt string `json:"stmt_rslt"`
  20037. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  20038. } `json:"stmtinfo"`
  20039. } `json:"output"`
  20040. RefmsgTime string `json:"refmsg_time"`
  20041. RespondTime string `json:"respond_time"`
  20042. Signtype interface{} `json:"signtype"`
  20043. WarnMsg interface{} `json:"warn_msg"`
  20044. }
  20045. type ResultNine struct {
  20046. Cainfo string `json:"cainfo"`
  20047. ErrMsg string `json:"err_msg"`
  20048. InfRefmsgid string `json:"inf_refmsgid"`
  20049. Infcode int64 `json:"infcode"`
  20050. Output struct {
  20051. FileQuryNo string `json:"file_qury_no"`
  20052. } `json:"output"`
  20053. RefmsgTime string `json:"refmsg_time"`
  20054. RespondTime string `json:"respond_time"`
  20055. Signtype interface{} `json:"signtype"`
  20056. WarnMsg interface{} `json:"warn_msg"`
  20057. }
  20058. type ResultTen struct {
  20059. Cainfo string `json:"cainfo"`
  20060. ErrMsg string `json:"err_msg"`
  20061. InfRefmsgid string `json:"inf_refmsgid"`
  20062. Infcode int64 `json:"infcode"`
  20063. Output struct {
  20064. Fileinfo struct {
  20065. DldEndtime string `json:"dld_endtime"`
  20066. FileQuryNo string `json:"file_qury_no"`
  20067. Filename string `json:"filename"`
  20068. } `json:"fileinfo"`
  20069. } `json:"output"`
  20070. RefmsgTime string `json:"refmsg_time"`
  20071. RespondTime string `json:"respond_time"`
  20072. Signtype interface{} `json:"signtype"`
  20073. WarnMsg interface{} `json:"warn_msg"`
  20074. }
  20075. type Result5262 struct {
  20076. ErrMsg string `json:"err_msg"`
  20077. InfRefmsgid string `json:"inf_refmsgid"`
  20078. Infcode int64 `json:"infcode"`
  20079. Output struct {
  20080. PageInfo struct {
  20081. Size int `json:"size"`
  20082. RecordCounts int `json:"record_counts"`
  20083. } `json:"page_info"`
  20084. Idetinfo []interface{} `json:"idetinfo"`
  20085. Result []struct {
  20086. SetlID string `json:"setl_id"`
  20087. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  20088. MdtrtID string `json:"mdtrt_id"`
  20089. InitSetlID string `json:"init_setl_id,omitempty"`
  20090. PsnNo string `json:"psn_no"`
  20091. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  20092. PsnName string `json:"psn_name"`
  20093. PsnCertType string `json:"psn_cert_type"`
  20094. Certno string `json:"certno"`
  20095. Gend string `json:"gend,omitempty"`
  20096. Naty string `json:"naty,omitempty"`
  20097. Brdy string `json:"brdy,omitempty"`
  20098. Age float64 `json:"age,omitempty"`
  20099. Insutype string `json:"insutype,omitempty"`
  20100. PsnType string `json:"psn_type"`
  20101. CvlservFlag string `json:"cvlserv_flag"`
  20102. CvlservLv string `json:"cvlserv_lv,omitempty"`
  20103. SpPsnType string `json:"sp_psn_type,omitempty"`
  20104. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  20105. ClctGrde string `json:"clct_grde,omitempty"`
  20106. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  20107. NwbFlag string `json:"nwb_flag,omitempty"`
  20108. InsuAdmdvs string `json:"insu_admdvs"`
  20109. EmpNo string `json:"emp_no,omitempty"`
  20110. EmpName string `json:"emp_name,omitempty"`
  20111. EmpType string `json:"emp_type,omitempty"`
  20112. EconType string `json:"econ_type,omitempty"`
  20113. AfilIndu string `json:"afil_indu,omitempty"`
  20114. AfilRlts string `json:"afil_rlts,omitempty"`
  20115. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  20116. PayLoc string `json:"pay_loc,omitempty"`
  20117. FixmedinsCode string `json:"fixmedins_code"`
  20118. FixmedinsName string `json:"fixmedins_name"`
  20119. HospLv string `json:"hosp_lv,omitempty"`
  20120. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  20121. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  20122. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  20123. Begndate string `json:"begndate"`
  20124. Enddate string `json:"enddate"`
  20125. SetlTime string `json:"setl_time"`
  20126. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  20127. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  20128. MedType string `json:"med_type"`
  20129. SetlType string `json:"setl_type,omitempty"`
  20130. ClrType string `json:"clr_type,omitempty"`
  20131. ClrWay string `json:"clr_way,omitempty"`
  20132. PsnSetlway string `json:"psn_setlway,omitempty"`
  20133. ClrOptins string `json:"clr_optins,omitempty"`
  20134. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  20135. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  20136. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  20137. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  20138. InscpAmt float64 `json:"inscp_amt,omitempty"`
  20139. DedcStd float64 `json:"dedc_std,omitempty"`
  20140. CrtDedc float64 `json:"crt_dedc,omitempty"`
  20141. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  20142. HifpPay float64 `json:"hifp_pay,omitempty"`
  20143. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  20144. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  20145. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  20146. HifesPay float64 `json:"hifes_pay,omitempty"`
  20147. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  20148. HifobPay float64 `json:"hifob_pay,omitempty"`
  20149. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  20150. MafPay float64 `json:"maf_pay,omitempty"`
  20151. OthfundPay float64 `json:"othfund_pay,omitempty"`
  20152. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  20153. PsnPay float64 `json:"psn_pay,omitempty"`
  20154. AcctPay float64 `json:"acct_pay,omitempty"`
  20155. CashPayamt float64 `json:"cash_payamt,omitempty"`
  20156. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  20157. Balc float64 `json:"balc,omitempty"`
  20158. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  20159. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  20160. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  20161. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  20162. Year string `json:"year,omitempty"`
  20163. DiseNo string `json:"dise_no,omitempty"`
  20164. DiseName string `json:"dise_name,omitempty"`
  20165. Invono string `json:"invono,omitempty"`
  20166. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  20167. ValiFlag string `json:"vali_flag,omitempty"`
  20168. Memo string `json:"memo,omitempty"`
  20169. Rid string `json:"rid"`
  20170. UpdtTime string `json:"updt_time,omitempty"`
  20171. CrterID string `json:"crter_id,omitempty"`
  20172. CrterName string `json:"crter_name,omitempty"`
  20173. CrteTime string `json:"crte_time,omitempty"`
  20174. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  20175. OpterID string `json:"opter_id,omitempty"`
  20176. OpterName string `json:"opter_name,omitempty"`
  20177. OptTime string `json:"opt_time,omitempty"`
  20178. OptinsNo string `json:"optins_no,omitempty"`
  20179. PoolareaNo string `json:"poolarea_no,omitempty"`
  20180. } `json:"result"`
  20181. } `json:"output"`
  20182. RefmsgTime string `json:"refmsg_time"`
  20183. RespondTime string `json:"respond_time"`
  20184. Signtype interface{} `json:"signtype"`
  20185. WarnInfo interface{} `json:"warn_info"`
  20186. }
  20187. type Result5267 struct {
  20188. ErrMsg string `json:"err_msg"`
  20189. InfRefmsgid string `json:"inf_refmsgid"`
  20190. Infcode int64 `json:"infcode"`
  20191. Output struct {
  20192. PageInfo struct {
  20193. Size int `json:"size"`
  20194. RecordCounts int `json:"record_counts"`
  20195. } `json:"pageinfo"`
  20196. Result []struct {
  20197. SetlID string `json:"setl_id"`
  20198. ClrOptins string `json:"clr_optins"`
  20199. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  20200. MdtrtID string `json:"mdtrt_id"`
  20201. InitSetlID string `json:"init_setl_id,omitempty"`
  20202. PsnNo string `json:"psn_no"`
  20203. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  20204. PsnName string `json:"psn_name"`
  20205. PsnCertType string `json:"psn_cert_type"`
  20206. Certno string `json:"certno"`
  20207. Gend string `json:"gend,omitempty"`
  20208. Naty string `json:"naty,omitempty"`
  20209. Brdy string `json:"brdy,omitempty"`
  20210. Age float64 `json:"age,omitempty"`
  20211. Insutype string `json:"insutype,omitempty"`
  20212. PsnType string `json:"psn_type"`
  20213. CvlservFlag string `json:"cvlserv_flag"`
  20214. CvlservLv string `json:"cvlserv_lv,omitempty"`
  20215. SpPsnType string `json:"sp_psn_type,omitempty"`
  20216. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  20217. ClctGrde string `json:"clct_grde,omitempty"`
  20218. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  20219. NwbFlag string `json:"nwb_flag,omitempty"`
  20220. InsuAdmdvs string `json:"insu_admdvs"`
  20221. EmpNo string `json:"emp_no,omitempty"`
  20222. EmpName string `json:"emp_name,omitempty"`
  20223. EmpType string `json:"emp_type,omitempty"`
  20224. EconType string `json:"econ_type,omitempty"`
  20225. AfilIndu string `json:"afil_indu,omitempty"`
  20226. AfilRlts string `json:"afil_rlts,omitempty"`
  20227. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  20228. PayLoc string `json:"pay_loc,omitempty"`
  20229. FixmedinsCode string `json:"fixmedins_code"`
  20230. FixmedinsName string `json:"fixmedins_name"`
  20231. HospLv string `json:"hosp_lv,omitempty"`
  20232. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  20233. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  20234. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  20235. Begndate string `json:"begndate,omitempty"`
  20236. Enddate string `json:"enddate,omitempty"`
  20237. SetlTime string `json:"setl_time,omitempty"`
  20238. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  20239. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  20240. MedType string `json:"med_type"`
  20241. SetlType string `json:"setl_type,omitempty"`
  20242. ClrType string `json:"clr_type,omitempty"`
  20243. ClrWay string `json:"clr_way,omitempty"`
  20244. PsnSetlway string `json:"psn_setlway,omitempty"`
  20245. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  20246. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  20247. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  20248. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  20249. InscpAmt float64 `json:"inscp_amt,omitempty"`
  20250. DedcStd float64 `json:"dedc_std,omitempty"`
  20251. CrtDedc float64 `json:"crt_dedc,omitempty"`
  20252. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  20253. HifpPay float64 `json:"hifp_pay,omitempty"`
  20254. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  20255. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  20256. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  20257. HifesPay float64 `json:"hifes_pay,omitempty"`
  20258. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  20259. HifobPay float64 `json:"hifob_pay,omitempty"`
  20260. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  20261. MafPay float64 `json:"maf_pay,omitempty"`
  20262. OthfundPay float64 `json:"othfund_pay,omitempty"`
  20263. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  20264. PsnPay float64 `json:"psn_pay,omitempty"`
  20265. AcctPay float64 `json:"acct_pay,omitempty"`
  20266. CashPayamt float64 `json:"cash_payamt,omitempty"`
  20267. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  20268. Balc float64 `json:"balc,omitempty"`
  20269. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  20270. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  20271. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  20272. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  20273. Year string `json:"year,omitempty"`
  20274. DiseNo string `json:"dise_no,omitempty"`
  20275. DiseName string `json:"dise_name,omitempty"`
  20276. Invono string `json:"invono,omitempty"`
  20277. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  20278. Memo string `json:"memo,omitempty"`
  20279. UpdtTime string `json:"updt_time,omitempty"`
  20280. OpterID string `json:"opter_id,omitempty"`
  20281. OpterName string `json:"opter_name,omitempty"`
  20282. OptTime string `json:"opt_time,omitempty"`
  20283. OptinsNo string `json:"optins_no,omitempty"`
  20284. PoolareaNo string `json:"poolarea_no,omitempty"`
  20285. } `json:"result"`
  20286. } `json:"output"`
  20287. RefmsgTime string `json:"refmsg_time"`
  20288. RespondTime string `json:"respond_time"`
  20289. Signtype interface{} `json:"signtype"`
  20290. WarnInfo interface{} `json:"warn_info"`
  20291. }
  20292. // type Autogenerated struct {
  20293. // Output struct {
  20294. // Setlinfo struct {
  20295. // SetlTime string `json:"setl_time"`
  20296. // CvlservPay float64 `json:"cvlserv_pay"`
  20297. // Year string `json:"year"`
  20298. // MedType string `json:"med_type"`
  20299. // PsnPay float64 `json:"psn_pay"`
  20300. // OpterID string `json:"opter_id"`
  20301. // Begndate string `json:"begndate"`
  20302. // FlxempeFlag string `json:"flxempe_flag"`
  20303. // HifmiPay float64 `json:"hifmi_pay"`
  20304. // PsnNo string `json:"psn_no"`
  20305. // ActPayDedc float64 `json:"act_pay_dedc"`
  20306. // MedinsSetlID interface{} `json:"medins_setl_id"`
  20307. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  20308. // ClrWay string `json:"clr_way"`
  20309. // OthPay float64 `json:"oth_pay"`
  20310. // Gend string `json:"gend"`
  20311. // MdtrtID string `json:"mdtrt_id"`
  20312. // AcctPay float64 `json:"acct_pay"`
  20313. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  20314. // Insutype string `json:"insutype"`
  20315. // Invono interface{} `json:"invono"`
  20316. // Enddate string `json:"enddate"`
  20317. // CashPayamt float64 `json:"cash_payamt"`
  20318. // PsnType string `json:"psn_type"`
  20319. // FixmedinsName string `json:"fixmedins_name"`
  20320. // HifpPay float64 `json:"hifp_pay"`
  20321. // NewFlag interface{} `json:"new_flag"`
  20322. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20323. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  20324. // PayLoc string `json:"pay_loc"`
  20325. // ClrType string `json:"clr_type"`
  20326. // RefdSetlFlag string `json:"refd_setl_flag"`
  20327. // CvlservFlag string `json:"cvlserv_flag"`
  20328. // EmpName string `json:"emp_name"`
  20329. // Brdy string `json:"brdy"`
  20330. // Naty string `json:"naty"`
  20331. // Certno string `json:"certno"`
  20332. // DiseCode string `json:"dise_code"`
  20333. // FixmedinsCode string `json:"fixmedins_code"`
  20334. // DedcHospLv string `json:"dedc_hosp_lv"`
  20335. // OpterName string `json:"opter_name"`
  20336. // Balc float64 `json:"balc"`
  20337. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  20338. // PsnCertType string `json:"psn_cert_type"`
  20339. // HifobPay float64 `json:"hifob_pay"`
  20340. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  20341. // HifesPay float64 `json:"hifes_pay"`
  20342. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20343. // OptTime string `json:"opt_time"`
  20344. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20345. // SetlID string `json:"setl_id"`
  20346. // MafPay float64 `json:"maf_pay"`
  20347. // PsnName string `json:"psn_name"`
  20348. // InsuOptins interface{} `json:"insu_optins"`
  20349. // PrefFundPay interface{} `json:"pref_fund_pay"`
  20350. // ClrOptins string `json:"clr_optins"`
  20351. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  20352. // DiseName string `json:"dise_name"`
  20353. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  20354. // Age float64 `json:"age"`
  20355. // DtrtCertType string `json:"dtrt_cert_type"`
  20356. // HospLv string `json:"hosp_lv"`
  20357. // } `json:"setlinfo"`
  20358. // Setldetail []struct {
  20359. // FundPayType string `json:"fund_pay_type"`
  20360. // FundPayamt float64 `json:"fund_payamt"`
  20361. // SetlProcInfo interface{} `json:"setl_proc_info"`
  20362. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  20363. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  20364. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  20365. // PrefFundPay interface{} `json:"pref_fund_pay"`
  20366. // } `json:"setldetail"`
  20367. // } `json:"output"`
  20368. // Infcode int `json:"infcode"`
  20369. // WarnMsg interface{} `json:"warn_msg"`
  20370. // Cainfo interface{} `json:"cainfo"`
  20371. // ErrMsg interface{} `json:"err_msg"`
  20372. // RefmsgTime string `json:"refmsg_time"`
  20373. // Signtype interface{} `json:"signtype"`
  20374. // RespondTime string `json:"respond_time"`
  20375. // InfRefmsgid string `json:"inf_refmsgid"`
  20376. // }
  20377. type Result002 struct {
  20378. Cainfo interface{} `json:"cainfo"`
  20379. ErrMsg string `json:"err_msg"`
  20380. InfRefmsgid string `json:"inf_refmsgid"`
  20381. Infcode int64 `json:"infcode"`
  20382. Output struct {
  20383. RxFile string `json:"rx_file"`
  20384. SignDigest string `json:"sign_digest"`
  20385. SignCertSn string `json:"sign_cert_sn"`
  20386. SignCertDn string `json:"sign_cert_dn"`
  20387. } `json:"output"`
  20388. RefmsgTime string `json:"refmsg_time"`
  20389. RespondTime string `json:"respond_time"`
  20390. Signtype interface{} `json:"signtype"`
  20391. WarnMsg interface{} `json:"warn_msg"`
  20392. }
  20393. type Result003 struct {
  20394. Cainfo interface{} `json:"cainfo"`
  20395. ErrMsg string `json:"err_msg"`
  20396. InfRefmsgid string `json:"inf_refmsgid"`
  20397. Infcode int64 `json:"infcode"`
  20398. Output struct {
  20399. HiRxno string `json:"hi_rxno"`
  20400. RxStasCodg string `json:"rx_stas_codg"`
  20401. RxStasName string `json:"rx_stas_name"`
  20402. } `json:"output"`
  20403. RefmsgTime string `json:"refmsg_time"`
  20404. RespondTime string `json:"respond_time"`
  20405. Signtype interface{} `json:"signtype"`
  20406. WarnMsg interface{} `json:"warn_msg"`
  20407. }
  20408. type ResultEleven struct {
  20409. Cainfo string `json:"cainfo"`
  20410. ErrMsg string `json:"err_msg"`
  20411. InfRefmsgid string `json:"inf_refmsgid"`
  20412. Infcode int64 `json:"infcode"`
  20413. Output struct {
  20414. Setlinfo struct {
  20415. SetlTime string `json:"setl_time"`
  20416. CvlservPay float64 `json:"cvlserv_pay"`
  20417. Year string `json:"year"`
  20418. MedType string `json:"med_type"`
  20419. PsnPay float64 `json:"psn_pay"`
  20420. OpterID string `json:"opter_id"`
  20421. Begndate string `json:"begndate"`
  20422. FlxempeFlag string `json:"flxempe_flag"`
  20423. HifmiPay float64 `json:"hifmi_pay"`
  20424. PsnNo string `json:"psn_no"`
  20425. ActPayDedc float64 `json:"act_pay_dedc"`
  20426. MedinsSetlID interface{} `json:"medins_setl_id"`
  20427. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  20428. ClrWay string `json:"clr_way"`
  20429. OthPay float64 `json:"oth_pay"`
  20430. Gend string `json:"gend"`
  20431. MdtrtID string `json:"mdtrt_id"`
  20432. AcctPay float64 `json:"acct_pay"`
  20433. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20434. Insutype string `json:"insutype"`
  20435. Invono interface{} `json:"invono"`
  20436. Enddate string `json:"enddate"`
  20437. CashPayamt float64 `json:"cash_payamt"`
  20438. PsnType string `json:"psn_type"`
  20439. FixmedinsName string `json:"fixmedins_name"`
  20440. HifpPay float64 `json:"hifp_pay"`
  20441. NewFlag interface{} `json:"new_flag"`
  20442. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20443. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20444. PayLoc string `json:"pay_loc"`
  20445. ClrType string `json:"clr_type"`
  20446. RefdSetlFlag string `json:"refd_setl_flag"`
  20447. CvlservFlag string `json:"cvlserv_flag"`
  20448. EmpName string `json:"emp_name"`
  20449. Brdy string `json:"brdy"`
  20450. Naty string `json:"naty"`
  20451. Certno string `json:"certno"`
  20452. DiseCode string `json:"dise_code"`
  20453. FixmedinsCode string `json:"fixmedins_code"`
  20454. DedcHospLv string `json:"dedc_hosp_lv"`
  20455. OpterName string `json:"opter_name"`
  20456. Balc float64 `json:"balc"`
  20457. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  20458. PsnCertType string `json:"psn_cert_type"`
  20459. HifobPay float64 `json:"hifob_pay"`
  20460. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20461. HifesPay float64 `json:"hifes_pay"`
  20462. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20463. OptTime string `json:"opt_time"`
  20464. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20465. SetlID string `json:"setl_id"`
  20466. MafPay float64 `json:"maf_pay"`
  20467. PsnName string `json:"psn_name"`
  20468. InsuOptins interface{} `json:"insu_optins"`
  20469. PrefFundPay interface{} `json:"pref_fund_pay"`
  20470. ClrOptins string `json:"clr_optins"`
  20471. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  20472. DiseName string `json:"dise_name"`
  20473. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  20474. Age float64 `json:"age"`
  20475. DtrtCertType string `json:"dtrt_cert_type"`
  20476. HospLv string `json:"hosp_lv"`
  20477. PsnCashPay float64 `json:"psn_cash_pay"`
  20478. } `json:"setlinfo"`
  20479. } `json:"output"`
  20480. RefmsgTime string `json:"refmsg_time"`
  20481. RespondTime string `json:"respond_time"`
  20482. Signtype interface{} `json:"signtype"`
  20483. WarnMsg interface{} `json:"warn_msg"`
  20484. }
  20485. type ResultElevenah struct {
  20486. Cainfo string `json:"cainfo"`
  20487. ErrMsg string `json:"err_msg"`
  20488. InfRefmsgid string `json:"inf_refmsgid"`
  20489. Infcode int64 `json:"infcode"`
  20490. Output struct {
  20491. Setlinfo struct {
  20492. SetlTime int64 `json:"setl_time"`
  20493. CvlservPay float64 `json:"cvlserv_pay"`
  20494. Year string `json:"year"`
  20495. MedType string `json:"med_type"`
  20496. PsnPay float64 `json:"psn_pay"`
  20497. OpterID string `json:"opter_id"`
  20498. Begndate int64 `json:"begndate"`
  20499. FlxempeFlag string `json:"flxempe_flag"`
  20500. HifmiPay float64 `json:"hifmi_pay"`
  20501. PsnNo string `json:"psn_no"`
  20502. ActPayDedc float64 `json:"act_pay_dedc"`
  20503. MedinsSetlID interface{} `json:"medins_setl_id"`
  20504. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  20505. ClrWay string `json:"clr_way"`
  20506. OthPay float64 `json:"oth_pay"`
  20507. Gend string `json:"gend"`
  20508. MdtrtID string `json:"mdtrt_id"`
  20509. AcctPay float64 `json:"acct_pay"`
  20510. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20511. Insutype string `json:"insutype"`
  20512. Invono interface{} `json:"invono"`
  20513. Enddate int64 `json:"enddate"`
  20514. CashPayamt float64 `json:"cash_payamt"`
  20515. PsnType string `json:"psn_type"`
  20516. FixmedinsName string `json:"fixmedins_name"`
  20517. HifpPay float64 `json:"hifp_pay"`
  20518. NewFlag interface{} `json:"new_flag"`
  20519. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20520. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20521. PayLoc string `json:"pay_loc"`
  20522. ClrType string `json:"clr_type"`
  20523. RefdSetlFlag string `json:"refd_setl_flag"`
  20524. CvlservFlag string `json:"cvlserv_flag"`
  20525. EmpName string `json:"emp_name"`
  20526. Brdy int64 `json:"brdy"`
  20527. Naty string `json:"naty"`
  20528. Certno string `json:"certno"`
  20529. DiseCode string `json:"dise_code"`
  20530. FixmedinsCode string `json:"fixmedins_code"`
  20531. DedcHospLv string `json:"dedc_hosp_lv"`
  20532. OpterName string `json:"opter_name"`
  20533. Balc float64 `json:"balc"`
  20534. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  20535. PsnCertType string `json:"psn_cert_type"`
  20536. HifobPay float64 `json:"hifob_pay"`
  20537. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20538. HifesPay float64 `json:"hifes_pay"`
  20539. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20540. OptTime int64 `json:"opt_time"`
  20541. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20542. SetlID string `json:"setl_id"`
  20543. MafPay float64 `json:"maf_pay"`
  20544. PsnName string `json:"psn_name"`
  20545. InsuOptins interface{} `json:"insu_optins"`
  20546. PrefFundPay interface{} `json:"pref_fund_pay"`
  20547. ClrOptins string `json:"clr_optins"`
  20548. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  20549. DiseName string `json:"dise_name"`
  20550. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  20551. Age float64 `json:"age"`
  20552. DtrtCertType string `json:"dtrt_cert_type"`
  20553. HospLv string `json:"hosp_lv"`
  20554. PsnCashPay float64 `json:"psn_cash_pay"`
  20555. } `json:"setlinfo"`
  20556. } `json:"output"`
  20557. RefmsgTime string `json:"refmsg_time"`
  20558. RespondTime string `json:"respond_time"`
  20559. Signtype interface{} `json:"signtype"`
  20560. WarnMsg interface{} `json:"warn_msg"`
  20561. }
  20562. type ResultEleven10265 struct {
  20563. Cainfo string `json:"cainfo"`
  20564. ErrMsg string `json:"err_msg"`
  20565. InfRefmsgid string `json:"inf_refmsgid"`
  20566. Infcode string `json:"infcode"`
  20567. Output struct {
  20568. Setlinfo struct {
  20569. SetlTime string `json:"setl_time"`
  20570. CvlservPay float64 `json:"cvlserv_pay"`
  20571. Year string `json:"year"`
  20572. MedType string `json:"med_type"`
  20573. PsnPay float64 `json:"psn_pay"`
  20574. OpterID string `json:"opter_id"`
  20575. Begndate string `json:"begndate"`
  20576. FlxempeFlag string `json:"flxempe_flag"`
  20577. HifmiPay float64 `json:"hifmi_pay"`
  20578. PsnNo string `json:"psn_no"`
  20579. ActPayDedc float64 `json:"act_pay_dedc"`
  20580. MedinsSetlID interface{} `json:"medins_setl_id"`
  20581. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  20582. ClrWay string `json:"clr_way"`
  20583. OthPay float64 `json:"oth_pay"`
  20584. Gend string `json:"gend"`
  20585. MdtrtID string `json:"mdtrt_id"`
  20586. AcctPay float64 `json:"acct_pay"`
  20587. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20588. Insutype string `json:"insutype"`
  20589. Invono interface{} `json:"invono"`
  20590. Enddate string `json:"enddate"`
  20591. CashPayamt float64 `json:"cash_payamt"`
  20592. PsnType string `json:"psn_type"`
  20593. FixmedinsName string `json:"fixmedins_name"`
  20594. HifpPay float64 `json:"hifp_pay"`
  20595. NewFlag interface{} `json:"new_flag"`
  20596. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20597. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20598. PayLoc string `json:"pay_loc"`
  20599. ClrType string `json:"clr_type"`
  20600. RefdSetlFlag string `json:"refd_setl_flag"`
  20601. CvlservFlag string `json:"cvlserv_flag"`
  20602. EmpName string `json:"emp_name"`
  20603. Brdy string `json:"brdy"`
  20604. Naty string `json:"naty"`
  20605. Certno string `json:"certno"`
  20606. DiseCode string `json:"dise_code"`
  20607. FixmedinsCode string `json:"fixmedins_code"`
  20608. DedcHospLv string `json:"dedc_hosp_lv"`
  20609. OpterName string `json:"opter_name"`
  20610. Balc float64 `json:"balc"`
  20611. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  20612. PsnCertType string `json:"psn_cert_type"`
  20613. HifobPay float64 `json:"hifob_pay"`
  20614. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20615. HifesPay float64 `json:"hifes_pay"`
  20616. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20617. OptTime string `json:"opt_time"`
  20618. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20619. SetlID string `json:"setl_id"`
  20620. MafPay float64 `json:"maf_pay"`
  20621. PsnName string `json:"psn_name"`
  20622. InsuOptins interface{} `json:"insu_optins"`
  20623. PrefFundPay interface{} `json:"pref_fund_pay"`
  20624. ClrOptins string `json:"clr_optins"`
  20625. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  20626. DiseName string `json:"dise_name"`
  20627. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  20628. Age float64 `json:"age"`
  20629. DtrtCertType string `json:"dtrt_cert_type"`
  20630. HospLv string `json:"hosp_lv"`
  20631. PsnCashPay float64 `json:"psn_cash_pay"`
  20632. } `json:"setlinfo"`
  20633. } `json:"output"`
  20634. RefmsgTime string `json:"refmsg_time"`
  20635. RespondTime string `json:"respond_time"`
  20636. Signtype interface{} `json:"signtype"`
  20637. WarnMsg interface{} `json:"warn_msg"`
  20638. }
  20639. type ResultTwelve struct {
  20640. Cainfo string `json:"cainfo"`
  20641. ErrMsg string `json:"err_msg"`
  20642. InfRefmsgid string `json:"inf_refmsgid"`
  20643. Infcode int64 `json:"infcode"`
  20644. Output struct {
  20645. MdtrtId string `json:"mdtrt_id"`
  20646. ChrgBchno string `json:"chrg_bchno"`
  20647. PsnNo string `json:"psn_no"`
  20648. } `json:"output"`
  20649. RefmsgTime string `json:"refmsg_time"`
  20650. RespondTime string `json:"respond_time"`
  20651. Signtype interface{} `json:"signtype"`
  20652. WarnMsg interface{} `json:"warn_msg"`
  20653. }
  20654. type ResultThirteen struct {
  20655. ErrMsg string `json:"err_msg"`
  20656. InfRefmsgid string `json:"inf_refmsgid"`
  20657. Infcode int64 `json:"infcode"`
  20658. Output struct {
  20659. Result struct {
  20660. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  20661. } `json:"result"`
  20662. } `json:"output"`
  20663. RefmsgTime string `json:"refmsg_time"`
  20664. RespondTime string `json:"respond_time"`
  20665. Signtype interface{} `json:"signtype"`
  20666. WarnInfo interface{} `json:"warn_info"`
  20667. }
  20668. type ResultThirteen10265 struct {
  20669. ErrMsg string `json:"err_msg"`
  20670. InfRefmsgid string `json:"inf_refmsgid"`
  20671. Infcode string `json:"infcode"`
  20672. Output struct {
  20673. Result struct {
  20674. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  20675. } `json:"result"`
  20676. } `json:"output"`
  20677. RefmsgTime string `json:"refmsg_time"`
  20678. RespondTime string `json:"respond_time"`
  20679. Signtype interface{} `json:"signtype"`
  20680. WarnInfo interface{} `json:"warn_info"`
  20681. }
  20682. type ResultFourteen struct {
  20683. ErrMsg string `json:"err_msg"`
  20684. InfRefmsgid string `json:"inf_refmsgid"`
  20685. Infcode int64 `json:"infcode"`
  20686. Output struct {
  20687. } `json:"output"`
  20688. RefmsgTime string `json:"refmsg_time"`
  20689. RespondTime string `json:"respond_time"`
  20690. Signtype interface{} `json:"signtype"`
  20691. WarnInfo interface{} `json:"warn_info"`
  20692. }
  20693. type ResultCFYLJG001 struct {
  20694. ErrMsg string `json:"err_msg"`
  20695. InfRefmsgid string `json:"inf_refmsgid"`
  20696. Infcode int64 `json:"infcode"`
  20697. Output struct {
  20698. RxTraceCode string `json:"rx_trace_code"`
  20699. HiRxno string `json:"hi_rxno"`
  20700. } `json:"output"`
  20701. RefmsgTime string `json:"refmsg_time"`
  20702. RespondTime string `json:"respond_time"`
  20703. Signtype interface{} `json:"signtype"`
  20704. WarnInfo interface{} `json:"warn_info"`
  20705. }
  20706. type ResultCFYLJG007 struct {
  20707. ErrMsg string `json:"err_msg"`
  20708. InfRefmsgid string `json:"inf_refmsgid"`
  20709. Infcode int64 `json:"infcode"`
  20710. Output struct {
  20711. HiRxno string `json:"hi_rxno"`
  20712. RxStasName string `json:"rx_stas_name"`
  20713. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  20714. Seltdelts []interface{} `json:"seltdelts"`
  20715. RxUsedStasName string `json:"rx_used_stas_name"`
  20716. RxStasCodg string `json:"rx_stas_codg"`
  20717. } `json:"output"`
  20718. RefmsgTime string `json:"refmsg_time"`
  20719. RespondTime string `json:"respond_time"`
  20720. Signtype interface{} `json:"signtype"`
  20721. WarnInfo interface{} `json:"warn_info"`
  20722. }
  20723. type ResultCFYLJG002 struct {
  20724. ErrMsg string `json:"err_msg"`
  20725. InfRefmsgid string `json:"inf_refmsgid"`
  20726. Infcode int64 `json:"infcode"`
  20727. Output struct {
  20728. RxFile string `json:"rx_file"`
  20729. SignDigest string `json:"sign_digest"`
  20730. SignCertSn string `json:"sign_cert_sn"`
  20731. SignCertDn string `json:"sign_cert_dn"`
  20732. } `json:"output"`
  20733. RefmsgTime string `json:"refmsg_time"`
  20734. RespondTime string `json:"respond_time"`
  20735. Signtype interface{} `json:"signtype"`
  20736. WarnInfo interface{} `json:"warn_info"`
  20737. }
  20738. type ResultCFYLJG003 struct {
  20739. ErrMsg string `json:"err_msg"`
  20740. InfRefmsgid string `json:"inf_refmsgid"`
  20741. Infcode int64 `json:"infcode"`
  20742. Output struct {
  20743. HiRxno string `json:"hi_rxno"`
  20744. RxStasCodg string `json:"rx_stas_codg"`
  20745. RxStasName string `json:"rx_stas_name"`
  20746. } `json:"output"`
  20747. RefmsgTime string `json:"refmsg_time"`
  20748. RespondTime string `json:"respond_time"`
  20749. Signtype interface{} `json:"signtype"`
  20750. WarnInfo interface{} `json:"warn_info"`
  20751. }
  20752. type ResultCFYLJG004 struct {
  20753. ErrMsg string `json:"err_msg"`
  20754. InfRefmsgid string `json:"inf_refmsgid"`
  20755. Infcode int64 `json:"infcode"`
  20756. Output struct {
  20757. HiRxno string `json:"hi_rxno"`
  20758. RxStasCodg string `json:"rx_stas_codg"`
  20759. RxStasName string `json:"rx_stas_name"`
  20760. } `json:"output"`
  20761. RefmsgTime string `json:"refmsg_time"`
  20762. RespondTime string `json:"respond_time"`
  20763. Signtype interface{} `json:"signtype"`
  20764. WarnInfo interface{} `json:"warn_info"`
  20765. }
  20766. type ResultCFYLJG008 struct {
  20767. ErrMsg string `json:"err_msg"`
  20768. InfRefmsgid string `json:"inf_refmsgid"`
  20769. Infcode int64 `json:"infcode"`
  20770. Output struct {
  20771. PoolareaNo string `json:"poolareaNo"`
  20772. AdmdvsName string `json:"admdvsName"`
  20773. Count string `json:"count"`
  20774. } `json:"output"`
  20775. RefmsgTime string `json:"refmsg_time"`
  20776. RespondTime string `json:"respond_time"`
  20777. Signtype interface{} `json:"signtype"`
  20778. WarnInfo interface{} `json:"warn_info"`
  20779. }
  20780. type ResultCFYLJG005 struct {
  20781. ErrMsg string `json:"err_msg"`
  20782. InfRefmsgid string `json:"inf_refmsgid"`
  20783. Infcode int64 `json:"infcode"`
  20784. Output struct {
  20785. HiRxNo string `json:"hi_rxno"`
  20786. FixMedinsCode string `json:"fixmedins_code"`
  20787. FixMedinsName string `json:"fixmedins_name"`
  20788. RxStasCodg string `json:"rx_stas_codg"`
  20789. RxStasName string `json:"rx_stas_name"`
  20790. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  20791. RxUserdStasName string `json:"rx_userd_stas_name"`
  20792. PrscTime string `json:"prsc_time"`
  20793. RxDrugCnt float64 `json:"rx_drug_cnt"`
  20794. RxUsedWayCodg string `json:"rx_used_way_codg"`
  20795. RxUsedWayName string `json:"rx_used_way_name"`
  20796. RxFrquCodg string `json:"rx_frqu_codg"`
  20797. RxFrquName string `json:"rx_frqu_name"`
  20798. RxDosunt string `json:"rx_dosunt"`
  20799. RxDoscnt float64 `json:"rx_doscnt"`
  20800. RxDrordDscr string `json:"rx_drord_dscr"`
  20801. ValiDays int64 `json:"vali_days"`
  20802. ValiEndTime string `json:"vali_end_time"`
  20803. ReptFlag string `json:"rept_flag"`
  20804. MaxReptCnt int64 `json:"max_rept_cnt"`
  20805. ReptdCnt int64 `json:"reptd_cnt"`
  20806. MinInrvDays int64 `json:"min_inrv_days"`
  20807. RxTypeCode string `json:"rx_type_code"`
  20808. RxTypeName string `json:"rx_type_name"`
  20809. LongRxFlag string `json:"long_rx_flag"`
  20810. RxDetlList []struct {
  20811. MedListCodg string `json:"med_list_codg"`
  20812. MedinsListCodg string `json:"medins_list_codg"`
  20813. HospPrepFlag string `json:"hosp_prep_flag"`
  20814. RxItemTypeCode string `json:"rx_item_type_code"`
  20815. RxItemTypeName string `json:"rx_item_type_name"`
  20816. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  20817. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  20818. TcmHerbFoote string `json:"tcmherb_foote"`
  20819. MednTypeCode string `json:"medn_type_code"`
  20820. MednTypeName string `json:"medn_type_name"`
  20821. MainMedcFlag string `json:"main_medc_flag"`
  20822. UrgtFlag string `json:"urgt_flag"`
  20823. BasMednFlag string `json:"bas_medn_flag"`
  20824. ImpDrugFlag string `json:"imp_drug_flag"`
  20825. ProdBarc string `json:"prod_barc"`
  20826. DrugProdname string `json:"drug_prodname"`
  20827. GennameCodg string `json:"genname_codg"`
  20828. DrugGenname string `json:"drug_genname"`
  20829. DrugDosform string `json:"drug_dosform"`
  20830. DrugSpec string `json:"drug_spec"`
  20831. PrdrName string `json:"prdr_name"`
  20832. MedcWayCodg string `json:"medc_way_codg"`
  20833. MedcWayDscr string `json:"medc_way_dscr"`
  20834. MedcBegntime string `json:"medc_begntime"`
  20835. MedcEndtime string `json:"medc_endtime"`
  20836. MedcDays float64 `json:"medc_days"`
  20837. DrugPric float64 `json:"drug_pric"`
  20838. DrugSumamt float64 `json:"drug_sumamt"`
  20839. DrugCnt float64 `json:"drug_cnt"`
  20840. DrugDosunt string `json:"drug_dosunt"`
  20841. SinDoscnt float64 `json:"sin_doscnt"`
  20842. SinDosunt string `json:"sin_dosunt"`
  20843. UsedFrquCodg string `json:"used_frqu_codg"`
  20844. UsedFrquName string `json:"used_frqu_name"`
  20845. DrugTotlcnt string `json:"drug_totlcnt"`
  20846. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  20847. DiseCodg string `json:"dise_codg"`
  20848. HospApprFlag string `json:"hosp_appr_flag"`
  20849. } `json:"rx_detl_list"`
  20850. RxOtpinfo struct {
  20851. MedType string `json:"med_type"`
  20852. IptOtpNo string `json:"ipt_otp_no"`
  20853. OtpIptFlag string `json:"otp_ipt_flag"`
  20854. PatnName string `json:"patn_name"`
  20855. PatnAge float64 `json:"patn_age"`
  20856. PatnHgt float64 `json:"patn_hgt"`
  20857. PatnWt float64 `json:"patn_wt"`
  20858. Gend string `json:"gend"`
  20859. GesoVal float64 `json:"geso_val"`
  20860. NwbFlag string `json:"nwb_flag"`
  20861. NwbAge string `json:"nwb_age"`
  20862. SuckPrdFlag string `json:"suck_prd_flag"`
  20863. AlgsHis string `json:"algs_his"`
  20864. Insutype string `json:"insutype"`
  20865. PrscDeptName string `json:"prsc_dept_name"`
  20866. PrscDrName string `json:"prsc_dr_name"`
  20867. PharName string `json:"phar_name"`
  20868. PharChkTime string `json:"phar_chk_time"`
  20869. MdtrtTime string `json:"mdtrt_time"`
  20870. DiseCodg string `json:"dise_codg"`
  20871. DiseName string `json:"dise_name"`
  20872. SpDiseFlag string `json:"sp_dise_flag"`
  20873. MaindiagCode string `json:"maindiag_code"`
  20874. MaindiagName string `json:"maindiag_name"`
  20875. DiseCondDscr string `json:"dise_cond_dscr"`
  20876. FstdiagFlag string `json:"fstdiag_flag"`
  20877. } `json:"rx_otpinfo"`
  20878. RxDiseList []struct {
  20879. DiagType string `json:"diag_type"`
  20880. MaindiagFlag string `json:"maindiag_flag"`
  20881. DiagSrtNo string `json:"diag_srt_no"`
  20882. DiagCode string `json:"diag_code"`
  20883. DiagName string `json:"diag_name"`
  20884. DiagDept string `json:"diag_dept"`
  20885. DiagDrNo string `json:"diag_dr_no"`
  20886. DiagDrName string `json:"diag_dr_name"`
  20887. DiagTime string `json:"diag_time"`
  20888. TcmDiseCode string `json:"tcm_dise_code"`
  20889. TcmDiseName string `json:"tcm_dise_name"`
  20890. TcmSympCode string `json:"tcmsymp_code"`
  20891. TcmSymp string `json:"tcmsymp"`
  20892. } `json:"rx_dise_list"`
  20893. } `json:"output"`
  20894. RefmsgTime string `json:"refmsg_time"`
  20895. RespondTime string `json:"respond_time"`
  20896. Signtype interface{} `json:"signtype"`
  20897. WarnInfo interface{} `json:"warn_info"`
  20898. }
  20899. type ResultCFYLJG006 struct {
  20900. ErrMsg string `json:"err_msg"`
  20901. InfRefmsgid string `json:"inf_refmsgid"`
  20902. Infcode int64 `json:"infcode"`
  20903. Output struct {
  20904. HiRxNo string `json:"hi_rxno"`
  20905. PharCode string `json:"phar_code"`
  20906. PharName string `json:"phar_name"`
  20907. RxChkOpnn string `json:"rx_chk_opnn"`
  20908. RxChkTime string `json:"rx_chk_time"`
  20909. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  20910. RxChkStasName string `json:"rx_chk_stas_name"`
  20911. RxStasCodg string `json:"rx_stas_codg"`
  20912. RxStasName string `json:"rx_stas_name"`
  20913. } `json:"output"`
  20914. RefmsgTime string `json:"refmsg_time"`
  20915. RespondTime string `json:"respond_time"`
  20916. Signtype interface{} `json:"signtype"`
  20917. WarnInfo interface{} `json:"warn_info"`
  20918. }
  20919. type ResultFourteen10265 struct {
  20920. ErrMsg string `json:"err_msg"`
  20921. InfRefmsgid string `json:"inf_refmsgid"`
  20922. Infcode string `json:"infcode"`
  20923. Output struct {
  20924. } `json:"output"`
  20925. RefmsgTime string `json:"refmsg_time"`
  20926. RespondTime string `json:"respond_time"`
  20927. Signtype interface{} `json:"signtype"`
  20928. WarnInfo interface{} `json:"warn_info"`
  20929. }
  20930. type ResultSixteen struct {
  20931. Cainfo string `json:"cainfo"`
  20932. ErrMsg string `json:"err_msg"`
  20933. InfRefmsgid string `json:"inf_refmsgid"`
  20934. Infcode int64 `json:"infcode"`
  20935. Output struct {
  20936. Setlinfo struct {
  20937. MdtrtID string `json:"mdtrt_id"`
  20938. SetlID string `json:"setl_id"`
  20939. ClrOptins string `json:"clr_optins"`
  20940. SetlTime string `json:"setl_time"`
  20941. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20942. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20943. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20944. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20945. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20946. ActPayDedc float64 `json:"act_pay_dedc"`
  20947. HifpPay float64 `json:"hifp_pay"`
  20948. PoolPropSe float64 `json:"pool_prop_selfpay"`
  20949. Lfpay float64 `json:"selfpay"`
  20950. CvlservPay float64 `json:"cvlserv_pay"`
  20951. HifesPay float64 `json:"hifes_pay"`
  20952. HifmiPay float64 `json:"hifmi_pay"`
  20953. HifobPay float64 `json:"hifob_pay"`
  20954. MafPay float64 `json:"maf_pay"`
  20955. OthPay float64 `json:"oth_pay"`
  20956. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20957. PsnPartAmt float64 `json:"psn_part_amt"`
  20958. AcctPay float64 `json:"acct_pay"`
  20959. Balc float64 `json:"balc"`
  20960. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  20961. HospPartAmt float64 `json:"hosp_part_amt"`
  20962. MedinsSetlID string `json:"medins_setl_id"`
  20963. PdnCashPay string `json:"pdn_cash_pay"`
  20964. } `json:"setlinfo"`
  20965. } `json:"output"`
  20966. RefmsgTime string `json:"refmsg_time"`
  20967. RespondTime string `json:"respond_time"`
  20968. Signtype interface{} `json:"signtype"`
  20969. WarnMsg interface{} `json:"warn_msg"`
  20970. }
  20971. type ResultSixteen10265 struct {
  20972. Cainfo string `json:"cainfo"`
  20973. ErrMsg string `json:"err_msg"`
  20974. InfRefmsgid string `json:"inf_refmsgid"`
  20975. Infcode string `json:"infcode"`
  20976. Output struct {
  20977. Setlinfo struct {
  20978. MdtrtID string `json:"mdtrt_id"`
  20979. SetlID string `json:"setl_id"`
  20980. ClrOptins string `json:"clr_optins"`
  20981. SetlTime string `json:"setl_time"`
  20982. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20983. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20984. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20985. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20986. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20987. ActPayDedc float64 `json:"act_pay_dedc"`
  20988. HifpPay float64 `json:"hifp_pay"`
  20989. PoolPropSe float64 `json:"pool_prop_selfpay"`
  20990. Lfpay float64 `json:"selfpay"`
  20991. CvlservPay float64 `json:"cvlserv_pay"`
  20992. HifesPay float64 `json:"hifes_pay"`
  20993. HifmiPay float64 `json:"hifmi_pay"`
  20994. HifobPay float64 `json:"hifob_pay"`
  20995. MafPay float64 `json:"maf_pay"`
  20996. OthPay float64 `json:"oth_pay"`
  20997. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20998. PsnPartAmt float64 `json:"psn_part_amt"`
  20999. AcctPay float64 `json:"acct_pay"`
  21000. Balc float64 `json:"balc"`
  21001. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21002. HospPartAmt float64 `json:"hosp_part_amt"`
  21003. MedinsSetlID string `json:"medins_setl_id"`
  21004. PdnCashPay string `json:"pdn_cash_pay"`
  21005. } `json:"setlinfo"`
  21006. } `json:"output"`
  21007. RefmsgTime string `json:"refmsg_time"`
  21008. RespondTime string `json:"respond_time"`
  21009. Signtype interface{} `json:"signtype"`
  21010. WarnMsg interface{} `json:"warn_msg"`
  21011. }
  21012. type ResultSixteen10265Two struct {
  21013. Cainfo string `json:"cainfo"`
  21014. ErrMsg string `json:"err_msg"`
  21015. InfRefmsgid string `json:"inf_refmsgid"`
  21016. Infcode string `json:"infcode"`
  21017. Output struct {
  21018. Setlinfo interface{} `json:"setlinfo"`
  21019. } `json:"output"`
  21020. RefmsgTime string `json:"refmsg_time"`
  21021. RespondTime string `json:"respond_time"`
  21022. Signtype interface{} `json:"signtype"`
  21023. WarnMsg interface{} `json:"warn_msg"`
  21024. }
  21025. type ResultgzSixteen10265Two struct {
  21026. Cainfo string `json:"cainfo"`
  21027. ErrMsg string `json:"err_msg"`
  21028. InfRefmsgid string `json:"inf_refmsgid"`
  21029. Infcode int64 `json:"infcode"`
  21030. Output struct {
  21031. Setlinfo interface{} `json:"setlinfo"`
  21032. } `json:"output"`
  21033. RefmsgTime string `json:"refmsg_time"`
  21034. RespondTime string `json:"respond_time"`
  21035. Signtype interface{} `json:"signtype"`
  21036. WarnMsg interface{} `json:"warn_msg"`
  21037. }
  21038. type ResultSeventeen struct {
  21039. ErrMsg string `json:"err_msg"`
  21040. InfRefmsgid string `json:"inf_refmsgid"`
  21041. Infcode int64 `json:"infcode"`
  21042. Output struct {
  21043. SetlListId string `json:"setl_list_id"`
  21044. } `json:"output"`
  21045. RefmsgTime string `json:"refmsg_time"`
  21046. RespondTime string `json:"respond_time"`
  21047. Signtype string `json:"signtype"`
  21048. WarnInfo string `json:"warn_info"`
  21049. }
  21050. type ResultSeventeenOther struct {
  21051. ErrMsg string `json:"err_msg"`
  21052. InfRefmsgid string `json:"inf_refmsgid"`
  21053. Infcode string `json:"infcode"`
  21054. Output struct {
  21055. SetlListId string `json:"setl_list_id"`
  21056. } `json:"output"`
  21057. RefmsgTime string `json:"refmsg_time"`
  21058. RespondTime string `json:"respond_time"`
  21059. Signtype string `json:"signtype"`
  21060. WarnInfo string `json:"warn_info"`
  21061. }
  21062. type Result90991 struct {
  21063. ErrMsg string `json:"err_msg"`
  21064. InfRefmsgid string `json:"inf_refmsgid"`
  21065. Infcode int64 `json:"infcode"`
  21066. Output struct {
  21067. Result struct {
  21068. PsnNo string `json:"psn_no"`
  21069. CardStat string `json:"card_stat"`
  21070. Certno string `json:"certno"`
  21071. PsnName string `json:"psn_name"`
  21072. CheckStat string `json:"check_stat"`
  21073. SscnoCheckStat string `json:"sscno_check_stat"`
  21074. } `json:"result"`
  21075. } `json:"output"`
  21076. RefmsgTime string `json:"refmsg_time"`
  21077. RespondTime string `json:"respond_time"`
  21078. Signtype interface{} `json:"signtype"`
  21079. WarnInfo interface{} `json:"warn_info"`
  21080. }
  21081. type Result90100 struct {
  21082. ErrMsg string `json:"err_msg"`
  21083. InfRefmsgid string `json:"inf_refmsgid"`
  21084. Infcode int64 `json:"infcode"`
  21085. Output struct {
  21086. PoolareaNo string `json:"poolarea_no"`
  21087. PoolareaNoName string `json:"poolarea_no_name"`
  21088. Insutype string `json:"insutype"`
  21089. InsutypeName string `json:"insutype_name"`
  21090. ClctType string `json:"clct_type"`
  21091. ClctTypeName string `json:"clct_type_name"`
  21092. ClctFlag string `json:"clct_flag"`
  21093. ClctFlagName string `json:"clct_flag_name"`
  21094. AccrymBegn string `json:"accrym_begn"`
  21095. AccrymEnd string `json:"accrym_end"`
  21096. ClctTime string `json:"clct_time"`
  21097. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  21098. } `json:"output"`
  21099. RefmsgTime string `json:"refmsg_time"`
  21100. RespondTime string `json:"respond_time"`
  21101. Signtype interface{} `json:"signtype"`
  21102. WarnInfo interface{} `json:"warn_info"`
  21103. }
  21104. type Custom struct {
  21105. DetItemFeeSumamt string
  21106. Cut string
  21107. FeedetlSn string
  21108. Price string
  21109. MedListCodg string
  21110. Type int64
  21111. AdviceId int64
  21112. ProjectId int64
  21113. ItemId int64
  21114. }
  21115. type Result5301 struct {
  21116. ErrMsg string `json:"err_msg"`
  21117. InfRefmsgid string `json:"inf_refmsgid"`
  21118. Infcode int64 `json:"infcode"`
  21119. Output struct {
  21120. Result []struct {
  21121. OpspDiseCode string `json:"opsp_dise_code"`
  21122. OpspDiseName string `json:"opsp_dise_name"`
  21123. Begndate string `json:"begndate"`
  21124. Enddate string `json:"enddate"`
  21125. } `json:"feedetail"`
  21126. } `json:"output"`
  21127. RefmsgTime string `json:"refmsg_time"`
  21128. RespondTime string `json:"respond_time"`
  21129. Signtype interface{} `json:"signtype"`
  21130. WarnInfo interface{} `json:"warn_info"`
  21131. }
  21132. type Result5301For10265 struct {
  21133. ErrMsg string `json:"err_msg"`
  21134. InfRefmsgid string `json:"inf_refmsgid"`
  21135. Infcode string `json:"infcode"`
  21136. Output struct {
  21137. Result []struct {
  21138. OpspDiseCode string `json:"opsp_dise_code"`
  21139. OpspDiseName string `json:"opsp_dise_name"`
  21140. Begndate string `json:"begndate"`
  21141. Enddate string `json:"enddate"`
  21142. } `json:"feedetail"`
  21143. } `json:"output"`
  21144. RefmsgTime string `json:"refmsg_time"`
  21145. RespondTime string `json:"respond_time"`
  21146. Signtype interface{} `json:"signtype"`
  21147. WarnInfo interface{} `json:"warn_info"`
  21148. }
  21149. //获取个人信息----挂号-----上传就诊信息
  21150. func (c *HisApiController) GetRegisterInfo() {
  21151. id, _ := c.GetInt64("id")
  21152. record_time := c.GetString("record_time")
  21153. settlementValue, _ := c.GetInt64("settlement_value")
  21154. medical_insurance_card := c.GetString("medical_insurance_card")
  21155. name := c.GetString("name")
  21156. id_card_type, _ := c.GetInt64("id_card_type")
  21157. certificates, _ := c.GetInt64("certificates")
  21158. medical_care, _ := c.GetInt64("medical_care")
  21159. birthday := c.GetString("birthday")
  21160. id_card := c.GetString("id_card")
  21161. register_type, _ := c.GetInt64("register")
  21162. doctor, _ := c.GetInt64("doctor")
  21163. department, _ := c.GetInt64("department")
  21164. gender, _ := c.GetInt64("sex")
  21165. registration_fee, _ := c.GetFloat("registration_fee")
  21166. medical_expenses, _ := c.GetFloat("medical_expenses")
  21167. social_type, _ := c.GetInt64("social_type")
  21168. admin_user_id, _ := c.GetInt64("admin_user_id")
  21169. insuplc_admdvs := c.GetString("insuplc_admdvs")
  21170. mdtrt_type := c.GetString("mdtrt_type")
  21171. if id_card_type == 5 {
  21172. id_card_type = 4
  21173. }
  21174. timeLayout := "2006-01-02"
  21175. loc, _ := time.LoadLocation("Local")
  21176. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  21177. birthUnix := birthdays.Unix()
  21178. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  21179. if err != nil {
  21180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21181. return
  21182. }
  21183. recordDateTime := theTime.Unix()
  21184. adminInfo := c.GetAdminUserInfo()
  21185. var patient service.Patients
  21186. if id == 0 {
  21187. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  21188. } else {
  21189. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  21190. }
  21191. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  21192. if patientPrescription.ID == 0 {
  21193. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  21194. }
  21195. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  21196. if patient.ID == 0 {
  21197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  21198. return
  21199. }
  21200. if len(patient.IdCardNo) == 0 {
  21201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  21202. return
  21203. }
  21204. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  21205. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  21206. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  21207. //就诊结算未完成,不能进行二次挂号
  21208. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  21209. if len(his) >= 1 {
  21210. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  21211. if len(his) >= 1 && order.ID == 0 {
  21212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  21213. return
  21214. }
  21215. }
  21216. //var register_log string
  21217. if config.IsOpen == 1 {
  21218. var res ResultTwo
  21219. var res10265 ResultTwo10265
  21220. var PsnNo string
  21221. var PsnCertType string
  21222. var Certno string
  21223. var PsnName string
  21224. var Gend string
  21225. var Naty string
  21226. var Brdy string
  21227. var Age float64
  21228. var infoStr string
  21229. var idetinfoStr string
  21230. var infocode int64
  21231. var verify_number string
  21232. fmt.Println(verify_number)
  21233. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  21234. psn_info, _ := service.GetPsnByPatientId(id)
  21235. PsnNo = psn_info.PsnNo
  21236. PsnCertType = psn_info.PsnCertType
  21237. Certno = psn_info.Certno
  21238. PsnName = psn_info.PsnName
  21239. Gend = psn_info.Gend
  21240. Naty = psn_info.Naty
  21241. Brdy = psn_info.Brdy
  21242. Age = psn_info.Age
  21243. infoStr = psn_info.Insuinfo
  21244. idetinfoStr = psn_info.Idetinfo
  21245. infocode = 0
  21246. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21247. psn_info, _ := service.GetPsnByPatientId(id)
  21248. PsnNo = psn_info.PsnNo
  21249. PsnCertType = psn_info.PsnCertType
  21250. Certno = psn_info.Certno
  21251. PsnName = psn_info.PsnName
  21252. Gend = psn_info.Gend
  21253. Naty = psn_info.Naty
  21254. Brdy = psn_info.Brdy
  21255. Age = psn_info.Age
  21256. infoStr = psn_info.Insuinfo
  21257. idetinfoStr = psn_info.Idetinfo
  21258. infocode = 0
  21259. verify_number = psn_info.VerifyNumber
  21260. } else if miConfig.MdtrtareaAdmvs == "150499" {
  21261. if id_card_type == 2 {
  21262. //请求内网数据
  21263. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  21264. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21265. "&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
  21266. resp, requestErr := http.Get(api)
  21267. if requestErr != nil {
  21268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21269. return
  21270. }
  21271. body, ioErr := ioutil.ReadAll(resp.Body)
  21272. if ioErr != nil {
  21273. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21275. return
  21276. }
  21277. var respJSON map[string]interface{}
  21278. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21281. return
  21282. }
  21283. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21284. result_byte, _ := json.Marshal(respJSON)
  21285. result := string(result_byte)
  21286. var dat map[string]interface{}
  21287. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21288. fmt.Println(dat)
  21289. } else {
  21290. fmt.Println(err)
  21291. }
  21292. userJSONBytes, _ := json.Marshal(dat)
  21293. var res ResultTwo
  21294. var resTwo10265 ResultTwo10265
  21295. if miConfig.Code == "H15049901371" {
  21296. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  21297. utils.ErrorLog("解析失败:%v", err)
  21298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21299. return
  21300. }
  21301. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  21302. res.Infcode = Infcode
  21303. res.ErrMsg = resTwo10265.ErrMsg
  21304. res.Output = resTwo10265.Output
  21305. res.InfRefmsgid = resTwo10265.InfRefmsgid
  21306. res.RespondTime = resTwo10265.RespondTime
  21307. res.WarnInfo = resTwo10265.WarnInfo
  21308. } else {
  21309. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21310. utils.ErrorLog("解析失败:%v", err)
  21311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21312. return
  21313. }
  21314. }
  21315. //var insutypes []string
  21316. //var insutype string
  21317. //var is390 int = 0
  21318. //var is310 int = 0
  21319. //for _, item := range res.Output.Iinfo {
  21320. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  21321. // insutypes = append(insutypes, item.Insutype)
  21322. // }
  21323. //}
  21324. //if len(insutypes) == 1 {
  21325. // insutype = insutypes[0]
  21326. //} else {
  21327. // for _, i := range insutypes {
  21328. // if i == "390" {
  21329. // is390 = 1
  21330. // }
  21331. //
  21332. // if i == "310" {
  21333. // is310 = 1
  21334. // }
  21335. // }
  21336. //}
  21337. //if is390 == 1 {
  21338. // insutype = "390"
  21339. //}
  21340. //if is310 == 1 {
  21341. // insutype = "310"
  21342. //}
  21343. //if len(insutypes) == 0 {
  21344. // insutype = "310"
  21345. //}
  21346. PsnNo = res.Output.Baseinfo.PsnNo
  21347. PsnCertType = res.Output.Baseinfo.PsnCertType
  21348. Certno = res.Output.Baseinfo.Certno
  21349. PsnName = res.Output.Baseinfo.PsnName
  21350. Gend = res.Output.Baseinfo.Gend
  21351. Naty = res.Output.Baseinfo.Naty
  21352. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21353. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21354. infoStr = string(Iinfos)
  21355. idetinfoStr = string(Idetinfos)
  21356. infocode = res.Infcode
  21357. //infocode = 0
  21358. //verify_number = psn_info.VerifyNumber
  21359. } else {
  21360. psn_info, _ := service.GetPsnByPatientId(id)
  21361. PsnNo = psn_info.PsnNo
  21362. PsnCertType = psn_info.PsnCertType
  21363. Certno = psn_info.Certno
  21364. PsnName = psn_info.PsnName
  21365. Gend = psn_info.Gend
  21366. Naty = psn_info.Naty
  21367. Brdy = psn_info.Brdy
  21368. Age = psn_info.Age
  21369. infoStr = psn_info.Insuinfo
  21370. idetinfoStr = psn_info.Idetinfo
  21371. infocode = 0
  21372. verify_number = psn_info.VerifyNumber
  21373. }
  21374. } else if miConfig.MdtrtareaAdmvs == "350500" {
  21375. if id_card_type == 1 {
  21376. psn_info, _ := service.GetPsnByPatientId(id)
  21377. PsnNo = psn_info.PsnNo
  21378. PsnCertType = psn_info.PsnCertType
  21379. Certno = psn_info.Certno
  21380. PsnName = psn_info.PsnName
  21381. Gend = psn_info.Gend
  21382. Naty = psn_info.Naty
  21383. Brdy = psn_info.Brdy
  21384. Age = psn_info.Age
  21385. infoStr = psn_info.Insuinfo
  21386. idetinfoStr = psn_info.Idetinfo
  21387. infocode = 0
  21388. verify_number = psn_info.VerifyNumber
  21389. } else if id_card_type == 2 {
  21390. 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)
  21391. fmt.Println(errMsgLog)
  21392. saveLog(result, requestLog, "1101", "人员基本信息获取")
  21393. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21394. utils.ErrorLog("解析失败:%v", err)
  21395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21396. return
  21397. }
  21398. PsnNo = res.Output.Baseinfo.PsnNo
  21399. PsnCertType = res.Output.Baseinfo.PsnCertType
  21400. Certno = res.Output.Baseinfo.Certno
  21401. PsnName = res.Output.Baseinfo.PsnName
  21402. Gend = res.Output.Baseinfo.Gend
  21403. Naty = res.Output.Baseinfo.Naty
  21404. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21405. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21406. infoStr = string(Iinfos)
  21407. idetinfoStr = string(Idetinfos)
  21408. infocode = res.Infcode
  21409. }
  21410. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21411. if id_card_type == 1 {
  21412. psn_info, _ := service.GetPsnByPatientId(id)
  21413. PsnNo = psn_info.PsnNo
  21414. PsnCertType = psn_info.PsnCertType
  21415. Certno = psn_info.Certno
  21416. PsnName = psn_info.PsnName
  21417. Gend = psn_info.Gend
  21418. Naty = psn_info.Naty
  21419. Brdy = psn_info.Brdy
  21420. Age = psn_info.Age
  21421. infoStr = psn_info.Insuinfo
  21422. idetinfoStr = psn_info.Idetinfo
  21423. infocode = 0
  21424. verify_number = psn_info.VerifyNumber
  21425. } else if id_card_type == 2 {
  21426. 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, "")
  21427. saveLog(result, requestLog, "1101", "人员基本信息获取")
  21428. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21429. utils.ErrorLog("解析失败:%v", err)
  21430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21431. return
  21432. }
  21433. PsnNo = res.Output.Baseinfo.PsnNo
  21434. PsnCertType = res.Output.Baseinfo.PsnCertType
  21435. Certno = res.Output.Baseinfo.Certno
  21436. PsnName = res.Output.Baseinfo.PsnName
  21437. Gend = res.Output.Baseinfo.Gend
  21438. Naty = res.Output.Baseinfo.Naty
  21439. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21440. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21441. infoStr = string(Iinfos)
  21442. idetinfoStr = string(Idetinfos)
  21443. infocode = res.Infcode
  21444. } else {
  21445. psn_info, _ := service.GetPsnByPatientId(id)
  21446. PsnNo = psn_info.PsnNo
  21447. PsnCertType = psn_info.PsnCertType
  21448. Certno = psn_info.Certno
  21449. PsnName = psn_info.PsnName
  21450. Gend = psn_info.Gend
  21451. Naty = psn_info.Naty
  21452. Brdy = psn_info.Brdy
  21453. Age = psn_info.Age
  21454. infoStr = psn_info.Insuinfo
  21455. idetinfoStr = psn_info.Idetinfo
  21456. infocode = 0
  21457. verify_number = psn_info.VerifyNumber
  21458. }
  21459. } else if miConfig.MdtrtareaAdmvs == "341203" {
  21460. psn_info, _ := service.GetPsnByPatientId(id)
  21461. PsnNo = psn_info.PsnNo
  21462. PsnCertType = psn_info.PsnCertType
  21463. Certno = psn_info.Certno
  21464. PsnName = psn_info.PsnName
  21465. Gend = psn_info.Gend
  21466. Naty = psn_info.Naty
  21467. Brdy = psn_info.Brdy
  21468. Age = psn_info.Age
  21469. infoStr = psn_info.Insuinfo
  21470. idetinfoStr = psn_info.Idetinfo
  21471. infocode = 0
  21472. verify_number = psn_info.VerifyNumber
  21473. } else if miConfig.MdtrtareaAdmvs == "430800" {
  21474. if id_card_type == 1 {
  21475. psn_info, _ := service.GetPsnByPatientId(id)
  21476. PsnNo = psn_info.PsnNo
  21477. PsnCertType = psn_info.PsnCertType
  21478. Certno = psn_info.Certno
  21479. PsnName = psn_info.PsnName
  21480. Gend = psn_info.Gend
  21481. Naty = psn_info.Naty
  21482. Brdy = psn_info.Brdy
  21483. Age = psn_info.Age
  21484. infoStr = psn_info.Insuinfo
  21485. idetinfoStr = psn_info.Idetinfo
  21486. infocode = 0
  21487. verify_number = psn_info.VerifyNumber
  21488. } else if id_card_type == 2 {
  21489. 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)
  21490. saveLog(result, requestLog, "1101", "人员基本信息获取")
  21491. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21492. utils.ErrorLog("解析失败:%v", err)
  21493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21494. return
  21495. }
  21496. PsnNo = res.Output.Baseinfo.PsnNo
  21497. PsnCertType = res.Output.Baseinfo.PsnCertType
  21498. Certno = res.Output.Baseinfo.Certno
  21499. PsnName = res.Output.Baseinfo.PsnName
  21500. Gend = res.Output.Baseinfo.Gend
  21501. Naty = res.Output.Baseinfo.Naty
  21502. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21503. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21504. infoStr = string(Iinfos)
  21505. idetinfoStr = string(Idetinfos)
  21506. infocode = res.Infcode
  21507. } else if id_card_type == 4 {
  21508. psn_info, _ := service.GetPsnByPatientId(id)
  21509. PsnNo = psn_info.PsnNo
  21510. PsnCertType = psn_info.PsnCertType
  21511. Certno = psn_info.Certno
  21512. PsnName = psn_info.PsnName
  21513. Gend = psn_info.Gend
  21514. Naty = psn_info.Naty
  21515. Brdy = psn_info.Brdy
  21516. Age = psn_info.Age
  21517. infoStr = psn_info.Insuinfo
  21518. idetinfoStr = psn_info.Idetinfo
  21519. infocode = 0
  21520. verify_number = psn_info.VerifyNumber
  21521. }
  21522. } else if miConfig.MdtrtareaAdmvs == "131023" {
  21523. var result string
  21524. var requestLog string
  21525. 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), "")
  21526. if id_card_type == 4 {
  21527. psn_info, _ := service.GetPsnByPatientId(id)
  21528. PsnNo = psn_info.PsnNo
  21529. PsnCertType = psn_info.PsnCertType
  21530. Certno = psn_info.Certno
  21531. PsnName = psn_info.PsnName
  21532. Gend = psn_info.Gend
  21533. Naty = psn_info.Naty
  21534. Brdy = psn_info.Brdy
  21535. Age = psn_info.Age
  21536. infoStr = psn_info.Insuinfo
  21537. idetinfoStr = psn_info.Idetinfo
  21538. infocode = 0
  21539. verify_number = psn_info.VerifyNumber
  21540. } else {
  21541. saveLog(result, requestLog, "1101", "人员基本信息获取")
  21542. if miConfig.Code == "H15049901371" {
  21543. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  21544. utils.ErrorLog("解析失败:%v", err)
  21545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21546. return
  21547. }
  21548. res.ErrMsg = res10265.ErrMsg
  21549. res.Output = res10265.Output
  21550. res.InfRefmsgid = res10265.InfRefmsgid
  21551. } else {
  21552. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21553. utils.ErrorLog("解析失败:%v", err)
  21554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21555. return
  21556. }
  21557. }
  21558. PsnNo = res.Output.Baseinfo.PsnNo
  21559. PsnCertType = res.Output.Baseinfo.PsnCertType
  21560. Certno = res.Output.Baseinfo.Certno
  21561. PsnName = res.Output.Baseinfo.PsnName
  21562. Gend = res.Output.Baseinfo.Gend
  21563. Naty = res.Output.Baseinfo.Naty
  21564. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21565. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21566. infoStr = string(Iinfos)
  21567. idetinfoStr = string(Idetinfos)
  21568. if miConfig.Code == "H15049901371" {
  21569. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  21570. } else {
  21571. infocode = res.Infcode
  21572. }
  21573. }
  21574. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21575. psn_info, _ := service.GetPsnByPatientId(id)
  21576. PsnNo = psn_info.PsnNo
  21577. PsnCertType = psn_info.PsnCertType
  21578. Certno = psn_info.Certno
  21579. PsnName = psn_info.PsnName
  21580. Gend = psn_info.Gend
  21581. Naty = psn_info.Naty
  21582. Brdy = psn_info.Brdy
  21583. Age = psn_info.Age
  21584. infoStr = psn_info.Insuinfo
  21585. idetinfoStr = psn_info.Idetinfo
  21586. infocode = 0
  21587. verify_number = psn_info.VerifyNumber
  21588. } else if miConfig.MdtrtareaAdmvs == "450721" {
  21589. psn_info, _ := service.GetPsnByPatientId(id)
  21590. PsnNo = psn_info.PsnNo
  21591. PsnCertType = psn_info.PsnCertType
  21592. Certno = psn_info.Certno
  21593. PsnName = psn_info.PsnName
  21594. Gend = psn_info.Gend
  21595. Naty = psn_info.Naty
  21596. Brdy = psn_info.Brdy
  21597. Age = psn_info.Age
  21598. infoStr = psn_info.Insuinfo
  21599. idetinfoStr = psn_info.Idetinfo
  21600. infocode = 0
  21601. verify_number = psn_info.VerifyNumber
  21602. } else {
  21603. var result string
  21604. var requestLog string
  21605. //if miConfig.UserOrgId == 10138 {
  21606. if id_card_type != 4 || id_card_type != 1 {
  21607. var insa string
  21608. if len(patient.InsuplcAdmdvs) > 0 {
  21609. insa = patient.InsuplcAdmdvs
  21610. } else {
  21611. insa = miConfig.InsuplcAdmdvs
  21612. }
  21613. //psn_info, _ := service.GetPsnByPatientId(id)
  21614. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  21615. 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)
  21616. }
  21617. //}
  21618. //else {
  21619. // var insa string
  21620. // if len(patient.InsuplcAdmdvs) > 0 {
  21621. // insa = patient.InsuplcAdmdvs
  21622. // } else {
  21623. // insa = miConfig.InsuplcAdmdvs
  21624. // }
  21625. // 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)
  21626. //}
  21627. if id_card_type == 4 || id_card_type == 1 {
  21628. psn_info, _ := service.GetPsnByPatientId(id)
  21629. PsnNo = psn_info.PsnNo
  21630. PsnCertType = psn_info.PsnCertType
  21631. Certno = psn_info.Certno
  21632. PsnName = psn_info.PsnName
  21633. Gend = psn_info.Gend
  21634. Naty = psn_info.Naty
  21635. Brdy = psn_info.Brdy
  21636. Age = psn_info.Age
  21637. infoStr = psn_info.Insuinfo
  21638. idetinfoStr = psn_info.Idetinfo
  21639. infocode = 0
  21640. verify_number = psn_info.VerifyNumber
  21641. } else {
  21642. saveLog(result, requestLog, "1101", "人员基本信息获取")
  21643. if miConfig.Code == "H15049901371" {
  21644. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  21645. utils.ErrorLog("解析失败:%v", err)
  21646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21647. return
  21648. }
  21649. res.ErrMsg = res10265.ErrMsg
  21650. res.Output = res10265.Output
  21651. res.InfRefmsgid = res10265.InfRefmsgid
  21652. } else {
  21653. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21654. utils.ErrorLog("解析失败:%v", err)
  21655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21656. return
  21657. }
  21658. }
  21659. PsnNo = res.Output.Baseinfo.PsnNo
  21660. PsnCertType = res.Output.Baseinfo.PsnCertType
  21661. Certno = res.Output.Baseinfo.Certno
  21662. PsnName = res.Output.Baseinfo.PsnName
  21663. Gend = res.Output.Baseinfo.Gend
  21664. Naty = res.Output.Baseinfo.Naty
  21665. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21666. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21667. infoStr = string(Iinfos)
  21668. idetinfoStr = string(Idetinfos)
  21669. if miConfig.Code == "H15049901371" {
  21670. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  21671. } else {
  21672. infocode = res.Infcode
  21673. }
  21674. }
  21675. }
  21676. if infocode == 0 {
  21677. his := models.VMHisPatient{
  21678. Name: name,
  21679. Gender: gender,
  21680. Birthday: birthUnix,
  21681. MedicalTreatmentType: medical_care,
  21682. IdType: certificates,
  21683. IdCardNo: id_card,
  21684. BalanceAccountsType: settlementValue,
  21685. SocialType: social_type,
  21686. MedicalInsuranceNumber: medical_insurance_card,
  21687. RegisterType: register_type,
  21688. RegisterCost: registration_fee,
  21689. TreatmentCost: medical_expenses,
  21690. Status: 1,
  21691. Ctime: time.Now().Unix(),
  21692. Mtime: time.Now().Unix(),
  21693. PsnNo: PsnNo,
  21694. PsnCertType: PsnCertType,
  21695. Certno: Certno,
  21696. PsnName: PsnName,
  21697. Gend: Gend,
  21698. Naty: Naty,
  21699. Brdy: Brdy,
  21700. Age: Age,
  21701. Iinfo: infoStr,
  21702. Idetinfo: idetinfoStr,
  21703. PatientId: patient.ID,
  21704. RecordDate: theTime.Unix(),
  21705. UserOrgId: adminInfo.CurrentOrgId,
  21706. AdminUserId: admin_user_id,
  21707. IsReturn: 1,
  21708. IdCardType: id_card_type,
  21709. Doctor: doctor,
  21710. Departments: department,
  21711. MdtrtGrpType: mdtrt_type,
  21712. }
  21713. timestamp := time.Now().Unix()
  21714. tempTime := time.Unix(timestamp, 0)
  21715. timeFormat := tempTime.Format("20060102150405")
  21716. chrgBchno := rand.Intn(100000) + 10000
  21717. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  21718. his.Number = ipt_otp_no
  21719. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  21720. department, _ := service.GetDepartMentDetail(department)
  21721. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  21722. IdCardNo := ""
  21723. if id_card_type == 1 {
  21724. // IdCardNo = medical_insurance_card
  21725. IdCardNo = patient.IdCardNo
  21726. } else {
  21727. IdCardNo = patient.IdCardNo
  21728. }
  21729. var rf []*ResultFive
  21730. json.Unmarshal([]byte(his.Iinfo), &rf)
  21731. var insutypes []*ResultFive
  21732. var insutype string
  21733. var insuplc_admdvs_temp string
  21734. var is390 int = 0
  21735. var is310 int = 0
  21736. for _, item := range rf {
  21737. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  21738. insutypes = append(insutypes, item)
  21739. }
  21740. }
  21741. if len(insutypes) == 1 {
  21742. insutype = insutypes[0].Insutype
  21743. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  21744. if insutype == "390" {
  21745. is390 = 1
  21746. }
  21747. if insutype == "310" {
  21748. is310 = 1
  21749. }
  21750. } else {
  21751. for _, i := range insutypes {
  21752. if i.Insutype == "390" {
  21753. is390 = 1
  21754. }
  21755. if i.Insutype == "310" {
  21756. is310 = 1
  21757. }
  21758. }
  21759. }
  21760. if is390 == 1 {
  21761. insutype = "390"
  21762. }
  21763. if is310 == 1 {
  21764. insutype = "310"
  21765. }
  21766. fmt.Println(social_type)
  21767. if social_type > 0 {
  21768. insutype = strconv.FormatInt(social_type, 10)
  21769. }
  21770. var infocode int64
  21771. var resThree ResultThree
  21772. var resThree10265 ResultThree10265
  21773. if len(insuplc_admdvs) == 0 {
  21774. psn_info, _ := service.GetPsnByPatientId(id)
  21775. //if len(psn_info.InsuplcAdmdvs) > 0 {
  21776. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  21777. //}
  21778. } else {
  21779. insuplc_admdvs_temp = insuplc_admdvs
  21780. }
  21781. if miConfig.MdtrtareaAdmvs == "421300" {
  21782. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  21783. psn_info, _ := service.GetPsnByPatientId(id)
  21784. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  21785. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  21786. "&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
  21787. resp, requestErr := http.Get(api)
  21788. if requestErr != nil {
  21789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21790. return
  21791. }
  21792. body, ioErr := ioutil.ReadAll(resp.Body)
  21793. if ioErr != nil {
  21794. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21796. return
  21797. }
  21798. var respJSON map[string]interface{}
  21799. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21800. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21802. return
  21803. }
  21804. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21805. result, _ := json.Marshal(respJSON)
  21806. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  21807. utils.ErrorLog("解析失败:%v", err)
  21808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21809. return
  21810. }
  21811. infocode = resThree.Infcode
  21812. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21813. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  21814. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  21815. // insuplc_admdvs_temp =
  21816. //}
  21817. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  21818. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  21819. //}
  21820. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  21821. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  21822. "&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
  21823. resp, requestErr := http.Get(api)
  21824. if requestErr != nil {
  21825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21826. return
  21827. }
  21828. body, ioErr := ioutil.ReadAll(resp.Body)
  21829. if ioErr != nil {
  21830. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21832. return
  21833. }
  21834. var respJSON map[string]interface{}
  21835. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21838. return
  21839. }
  21840. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21841. result, _ := json.Marshal(respJSON)
  21842. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  21843. utils.ErrorLog("解析失败:%v", err)
  21844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21845. return
  21846. }
  21847. infocode = resThree.Infcode
  21848. } else if miConfig.MdtrtareaAdmvs == "420902" {
  21849. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  21850. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  21851. // insuplc_admdvs_temp =
  21852. //}
  21853. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  21854. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  21855. //}
  21856. utils.ErrorLog("解析失败:%v", insutype)
  21857. utils.ErrorLog("解析失败:%v", PsnNo)
  21858. utils.ErrorLog("解析失败:%v", Certno)
  21859. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  21860. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  21861. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  21862. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  21863. utils.ErrorLog("解析失败:%v", PsnNo)
  21864. utils.ErrorLog("解析失败:%v", department.Number)
  21865. utils.ErrorLog("解析失败:%v", department.Name)
  21866. utils.ErrorLog("解析失败:%v", roles.UserName)
  21867. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  21868. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  21869. "&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
  21870. resp, requestErr := http.Get(api)
  21871. if requestErr != nil {
  21872. utils.ErrorLog("解析失败:%v", requestErr)
  21873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21874. return
  21875. }
  21876. body, ioErr := ioutil.ReadAll(resp.Body)
  21877. if ioErr != nil {
  21878. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21880. return
  21881. }
  21882. var respJSON map[string]interface{}
  21883. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21884. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21886. return
  21887. }
  21888. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21889. result, _ := json.Marshal(respJSON)
  21890. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  21891. utils.ErrorLog("解析失败:%v", err)
  21892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21893. return
  21894. }
  21895. infocode = resThree.Infcode
  21896. } else if miConfig.MdtrtareaAdmvs == "421182" {
  21897. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  21898. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  21899. // insuplc_admdvs_temp =
  21900. //}
  21901. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  21902. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  21903. //}
  21904. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  21905. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  21906. "&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
  21907. resp, requestErr := http.Get(api)
  21908. if requestErr != nil {
  21909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21910. return
  21911. }
  21912. body, ioErr := ioutil.ReadAll(resp.Body)
  21913. if ioErr != nil {
  21914. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21916. return
  21917. }
  21918. var respJSON map[string]interface{}
  21919. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21922. return
  21923. }
  21924. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21925. result, _ := json.Marshal(respJSON)
  21926. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  21927. utils.ErrorLog("解析失败:%v", err)
  21928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21929. return
  21930. }
  21931. infocode = resThree.Infcode
  21932. } else if miConfig.MdtrtareaAdmvs == "150499" {
  21933. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  21934. psn_info, _ := service.GetPsnByPatientId(id)
  21935. var verify_number string
  21936. if id_card_type == 4 {
  21937. verify_number = psn_info.VerifyNumber
  21938. } else if id_card_type == 1 {
  21939. bas := strings.Split(psn_info.CardInfo, "|")
  21940. cardNumber := bas[2]
  21941. verify_number = cardNumber
  21942. }
  21943. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  21944. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  21945. "&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
  21946. resp, requestErr := http.Get(api)
  21947. if requestErr != nil {
  21948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21949. return
  21950. }
  21951. body, ioErr := ioutil.ReadAll(resp.Body)
  21952. if ioErr != nil {
  21953. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21955. return
  21956. }
  21957. var respJSON map[string]interface{}
  21958. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21959. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21961. return
  21962. }
  21963. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21964. result, _ := json.Marshal(respJSON)
  21965. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  21966. // utils.ErrorLog("解析失败:%v", err)
  21967. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21968. // return
  21969. //}
  21970. //infocode = resThree.Infcode
  21971. //result, _ := json.Marshal(respJSON)
  21972. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  21973. utils.ErrorLog("解析失败:%v", err)
  21974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21975. return
  21976. }
  21977. resThree.ErrMsg = resThree10265.ErrMsg
  21978. resThree.Output = resThree10265.Output
  21979. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  21980. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  21981. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21982. psn_info, _ := service.GetPsnByPatientId(id)
  21983. his.PsnNo = psn_info.PsnNo
  21984. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  21985. var cert_no string
  21986. if id_card_type == 3 {
  21987. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  21988. cert_no = IdCardNo
  21989. } else if id_card_type == 4 {
  21990. cert_no = IdCardNo
  21991. psn_info.VerifyNumber = psn_info.VerifyNumber
  21992. } else {
  21993. bas := strings.Split(psn_info.CardInfo, "|")
  21994. cert_no = bas[2]
  21995. }
  21996. var hisPrescription []*models.HisPrescription
  21997. for _, item := range rf {
  21998. if item.Insutype == insutype {
  21999. //insuplc_admdvs = item.InsuplcAdmdvs
  22000. his.InsuplcAdmdvs = insuplc_admdvs
  22001. }
  22002. }
  22003. his.Insutype = insutype
  22004. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  22005. fmt.Println(res3101)
  22006. fmt.Println(res3101.Infcode)
  22007. if res3101.Infcode == "0" {
  22008. fmt.Println("33333333")
  22009. if len(res3101.Output.Result) > 0 {
  22010. fmt.Println("222222")
  22011. for _, item := range res3101.Output.Result {
  22012. if len(res3101.ErrMsg) == 0 {
  22013. res3101.ErrMsg = item.VolaCont
  22014. } else {
  22015. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  22016. }
  22017. }
  22018. c.ServeSuccessJSON(map[string]interface{}{
  22019. "failed_code": -10,
  22020. "msg": res3101.ErrMsg,
  22021. })
  22022. return
  22023. } else {
  22024. fmt.Println("11111")
  22025. var api string
  22026. if miConfig.MdtrtareaAdmvs == "320921" {
  22027. ipt_otp_no = timeFormat
  22028. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  22029. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22030. "&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
  22031. } else {
  22032. ipt_otp_no = timeFormat
  22033. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  22034. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22035. "&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
  22036. }
  22037. resp, requestErr := http.Get(api)
  22038. if requestErr != nil {
  22039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22040. return
  22041. }
  22042. body, ioErr := ioutil.ReadAll(resp.Body)
  22043. if ioErr != nil {
  22044. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22046. return
  22047. }
  22048. var respJSON map[string]interface{}
  22049. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22050. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22052. return
  22053. }
  22054. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22055. result, _ := json.Marshal(respJSON)
  22056. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22057. utils.ErrorLog("解析失败:%v", err)
  22058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22059. return
  22060. }
  22061. resThree.ErrMsg = resThree10265.ErrMsg
  22062. resThree.Output = resThree10265.Output
  22063. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22064. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22065. }
  22066. } else if res3101.Infcode != "0" {
  22067. c.ServeSuccessJSON(map[string]interface{}{
  22068. "failed_code": -10,
  22069. "msg": res3101.ErrMsg,
  22070. })
  22071. return
  22072. }
  22073. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22074. psn_info, _ := service.GetPsnByPatientId(id)
  22075. var cert_no string
  22076. if id_card_type == 1 {
  22077. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  22078. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  22079. } else if id_card_type == 4 {
  22080. cert_no = psn_info.VerifyNumber
  22081. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  22082. } else {
  22083. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  22084. cert_no = psn_info.VerifyNumber
  22085. }
  22086. 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)
  22087. saveLog(result, requestLog, "2201", "挂号")
  22088. if miConfig.Code == "H15049901371" {
  22089. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22090. utils.ErrorLog("解析失败:%v", err)
  22091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22092. return
  22093. }
  22094. resThree.ErrMsg = resThree10265.ErrMsg
  22095. resThree.Output = resThree10265.Output
  22096. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22097. } else {
  22098. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22099. utils.ErrorLog("解析失败:%v", err)
  22100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22101. return
  22102. }
  22103. }
  22104. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22105. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  22106. psn_info, _ := service.GetPsnByPatientId(id)
  22107. var result string
  22108. var requestLog string
  22109. if id_card_type == 1 {
  22110. bas := strings.Split(psn_info.CardInfo, "|")
  22111. basNumber := bas[2]
  22112. card_sn := bas[3]
  22113. 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)
  22114. saveLog(result, requestLog, "2201A", "挂号")
  22115. } else if id_card_type == 2 {
  22116. 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, "", "", "", "", "", "")
  22117. saveLog(result, requestLog, "2201A", "挂号")
  22118. } else {
  22119. 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)
  22120. saveLog(result, requestLog, "2201A", "挂号")
  22121. }
  22122. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22123. utils.ErrorLog("解析失败:%v", err)
  22124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22125. return
  22126. }
  22127. infocode = resThree.Infcode
  22128. } else if miConfig.MdtrtareaAdmvs == "341203" {
  22129. psn_info, _ := service.GetPsnByPatientId(id)
  22130. his.PsnNo = psn_info.PsnNo
  22131. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  22132. var cert_no string
  22133. if id_card_type == 1 {
  22134. bas := strings.Split(psn_info.CardInfo, "|")
  22135. cert_no = bas[2]
  22136. } else if id_card_type == 4 {
  22137. cert_no = IdCardNo
  22138. psn_info.VerifyNumber = psn_info.VerifyNumber
  22139. } else {
  22140. cert_no = IdCardNo
  22141. psn_info.VerifyNumber = cert_no
  22142. }
  22143. for _, item := range rf {
  22144. if item.Insutype == insutype {
  22145. his.InsuplcAdmdvs = insuplc_admdvs
  22146. }
  22147. }
  22148. his.Insutype = insutype
  22149. var api string
  22150. ipt_otp_no = timeFormat
  22151. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  22152. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22153. "&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
  22154. resp, requestErr := http.Get(api)
  22155. if requestErr != nil {
  22156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22157. return
  22158. }
  22159. body, ioErr := ioutil.ReadAll(resp.Body)
  22160. if ioErr != nil {
  22161. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22163. return
  22164. }
  22165. var respJSON map[string]interface{}
  22166. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22167. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22169. return
  22170. }
  22171. status := respJSON["data"].(map[string]interface{})["status"].(string)
  22172. if status == "0" {
  22173. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  22174. c.ServeSuccessJSON(map[string]interface{}{
  22175. "failed_code": -10,
  22176. "msg": err_msg,
  22177. })
  22178. return
  22179. }
  22180. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22181. result, _ := json.Marshal(respJSON)
  22182. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22183. utils.ErrorLog("解析失败:%v", err)
  22184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22185. return
  22186. }
  22187. infocode = resThree.Infcode
  22188. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22189. psn_info, _ := service.GetPsnByPatientId(id)
  22190. var result string
  22191. var requestLog string
  22192. if id_card_type == 1 {
  22193. bas := strings.Split(psn_info.CardInfo, "|")
  22194. basNumber := bas[2]
  22195. card_sn := bas[3]
  22196. 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)
  22197. saveLog(result, requestLog, "2201A", "挂号")
  22198. } else if id_card_type == 2 {
  22199. 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, "", "")
  22200. saveLog(result, requestLog, "2201A", "挂号")
  22201. } else {
  22202. 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, "", "")
  22203. saveLog(result, requestLog, "2201A", "挂号")
  22204. }
  22205. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22206. utils.ErrorLog("解析失败:%v", err)
  22207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22208. return
  22209. }
  22210. infocode = resThree.Infcode
  22211. } else if miConfig.MdtrtareaAdmvs == "131023" {
  22212. psn_info, _ := service.GetPsnByPatientId(id)
  22213. 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)
  22214. saveLog(result, requestLog, "2201A", "挂号")
  22215. if miConfig.Code == "H15049901371" {
  22216. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22217. utils.ErrorLog("解析失败:%v", err)
  22218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22219. return
  22220. }
  22221. resThree.ErrMsg = resThree10265.ErrMsg
  22222. resThree.Output = resThree10265.Output
  22223. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22224. } else {
  22225. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22226. utils.ErrorLog("解析失败:%v", err)
  22227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22228. return
  22229. }
  22230. }
  22231. if miConfig.Code == "H15049901371" {
  22232. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22233. } else {
  22234. infocode = resThree.Infcode
  22235. }
  22236. } else {
  22237. psn_info, _ := service.GetPsnByPatientId(id)
  22238. if id_card_type == 4 || id_card_type == 1 {
  22239. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  22240. }
  22241. var rf []*ResultFive
  22242. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  22243. var insutypes []*ResultFive
  22244. var insutype string
  22245. var is390 int = 0
  22246. var is310 int = 0
  22247. for _, item := range rf {
  22248. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  22249. insutypes = append(insutypes, item)
  22250. }
  22251. }
  22252. if len(insutypes) == 1 {
  22253. insutype = insutypes[0].Insutype
  22254. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  22255. } else {
  22256. for _, i := range insutypes {
  22257. if i.Insutype == "390" {
  22258. is390 = 1
  22259. }
  22260. if i.Insutype == "310" {
  22261. is310 = 1
  22262. }
  22263. }
  22264. }
  22265. if is390 == 1 {
  22266. insutype = "390"
  22267. }
  22268. if is310 == 1 {
  22269. insutype = "310"
  22270. }
  22271. fmt.Println(len(insutypes))
  22272. if len(insutypes) == 0 {
  22273. for index, item := range rf {
  22274. if index == 0 {
  22275. insutype = item.Insutype
  22276. insuplc_admdvs = item.InsuplcAdmdvs
  22277. }
  22278. }
  22279. fmt.Println(insutype)
  22280. fmt.Println(insuplc_admdvs)
  22281. }
  22282. if social_type > 0 {
  22283. insutype = strconv.FormatInt(social_type, 10)
  22284. }
  22285. fmt.Println("--------")
  22286. fmt.Println(psn_info)
  22287. fmt.Println(psn_info.PsnNo)
  22288. if miConfig.MdtrtareaAdmvs == "441202" {
  22289. var hisPrescription []*models.HisPrescription
  22290. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  22291. if res3101.Infcode == 0 {
  22292. fmt.Println("33333333")
  22293. if len(res3101.Output.Result) > 0 {
  22294. fmt.Println("222222")
  22295. for _, item := range res3101.Output.Result {
  22296. if len(res3101.ErrMsg) == 0 {
  22297. res3101.ErrMsg = item.VolaCont
  22298. } else {
  22299. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  22300. }
  22301. }
  22302. c.ServeSuccessJSON(map[string]interface{}{
  22303. "failed_code": -10,
  22304. "msg": res3101.ErrMsg,
  22305. })
  22306. return
  22307. } else {
  22308. hour := time.Now().Format("15")
  22309. min := time.Now().Format("04")
  22310. sec := time.Now().Format("05")
  22311. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  22312. fmt.Println(record_time_two)
  22313. 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)
  22314. saveLog(result, requestLog, "2201A", "挂号")
  22315. if miConfig.Code == "H15049901371" {
  22316. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22317. utils.ErrorLog("解析失败:%v", err)
  22318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22319. return
  22320. }
  22321. resThree.ErrMsg = resThree10265.ErrMsg
  22322. resThree.Output = resThree10265.Output
  22323. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22324. } else {
  22325. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22326. utils.ErrorLog("解析失败:%v", err)
  22327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22328. return
  22329. }
  22330. }
  22331. if miConfig.Code == "H15049901371" {
  22332. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22333. } else {
  22334. infocode = resThree.Infcode
  22335. }
  22336. }
  22337. } else if res3101.Infcode != 0 {
  22338. c.ServeSuccessJSON(map[string]interface{}{
  22339. "failed_code": -10,
  22340. "msg": res3101.ErrMsg,
  22341. })
  22342. return
  22343. }
  22344. } else if miConfig.MdtrtareaAdmvs == "440205" {
  22345. var hisPrescription []*models.HisPrescription
  22346. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  22347. if res3101.Infcode == 0 {
  22348. fmt.Println("33333333")
  22349. if len(res3101.Output.Result) > 0 {
  22350. fmt.Println("222222")
  22351. for _, item := range res3101.Output.Result {
  22352. if len(res3101.ErrMsg) == 0 {
  22353. res3101.ErrMsg = item.VolaCont
  22354. } else {
  22355. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  22356. }
  22357. }
  22358. c.ServeSuccessJSON(map[string]interface{}{
  22359. "failed_code": -10,
  22360. "msg": res3101.ErrMsg,
  22361. })
  22362. return
  22363. } else {
  22364. hour := time.Now().Format("15")
  22365. min := time.Now().Format("04")
  22366. sec := time.Now().Format("05")
  22367. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  22368. fmt.Println(record_time_two)
  22369. 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)
  22370. saveLog(result, requestLog, "2201A", "挂号")
  22371. if miConfig.Code == "H15049901371" {
  22372. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22373. utils.ErrorLog("解析失败:%v", err)
  22374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22375. return
  22376. }
  22377. resThree.ErrMsg = resThree10265.ErrMsg
  22378. resThree.Output = resThree10265.Output
  22379. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22380. } else {
  22381. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22382. utils.ErrorLog("解析失败:%v", err)
  22383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22384. return
  22385. }
  22386. }
  22387. if miConfig.Code == "H15049901371" {
  22388. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22389. } else {
  22390. infocode = resThree.Infcode
  22391. }
  22392. }
  22393. } else if res3101.Infcode != 0 {
  22394. c.ServeSuccessJSON(map[string]interface{}{
  22395. "failed_code": -10,
  22396. "msg": res3101.ErrMsg,
  22397. })
  22398. return
  22399. }
  22400. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22401. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  22402. psn_info, _ := service.GetPsnByPatientId(id)
  22403. var verify_number string
  22404. if id_card_type == 4 {
  22405. verify_number = psn_info.VerifyNumber
  22406. } else if id_card_type == 1 {
  22407. bas := strings.Split(psn_info.CardInfo, "|")
  22408. cardNumber := bas[2]
  22409. verify_number = cardNumber
  22410. } else {
  22411. verify_number = psn_info.Certno
  22412. }
  22413. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  22414. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22415. "&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
  22416. resp, requestErr := http.Get(api)
  22417. if requestErr != nil {
  22418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22419. return
  22420. }
  22421. body, ioErr := ioutil.ReadAll(resp.Body)
  22422. if ioErr != nil {
  22423. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22425. return
  22426. }
  22427. var respJSON map[string]interface{}
  22428. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22429. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22431. return
  22432. }
  22433. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22434. result, _ := json.Marshal(respJSON)
  22435. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22436. utils.ErrorLog("解析失败:%v", err)
  22437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22438. return
  22439. }
  22440. infocode = resThree.Infcode
  22441. } else {
  22442. hour := time.Now().Format("15")
  22443. min := time.Now().Format("04")
  22444. sec := time.Now().Format("05")
  22445. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  22446. if id_card_type == 1 {
  22447. for _, item := range rf {
  22448. if item.Insutype == strconv.FormatInt(social_type, 10) {
  22449. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  22450. insuplc_admdvs_temp = item.InsuplcAdmdvs
  22451. } else if strconv.FormatInt(social_type, 10) == "390" {
  22452. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  22453. } else {
  22454. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  22455. }
  22456. }
  22457. }
  22458. }
  22459. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  22460. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  22461. }
  22462. if id_card_type == 1 {
  22463. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  22464. bas := strings.Split(psn_info.CardInfo, "|")
  22465. basNumber := bas[1]
  22466. IdCardNo = basNumber
  22467. }
  22468. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  22469. IdCardNo = psn_info.VerifyNumber
  22470. }
  22471. if len(insuplc_admdvs_temp) == 0 {
  22472. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  22473. }
  22474. 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)
  22475. saveLog(result, requestLog, "2201A", "挂号")
  22476. if miConfig.Code == "H15049901371" {
  22477. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22478. utils.ErrorLog("解析失败:%v", err)
  22479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22480. return
  22481. }
  22482. resThree.ErrMsg = resThree10265.ErrMsg
  22483. resThree.Output = resThree10265.Output
  22484. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22485. } else {
  22486. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22487. utils.ErrorLog("解析失败:%v", err)
  22488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22489. return
  22490. }
  22491. }
  22492. if miConfig.Code == "H15049901371" {
  22493. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22494. } else {
  22495. infocode = resThree.Infcode
  22496. }
  22497. }
  22498. }
  22499. if infocode == -1 {
  22500. adminUser := c.GetAdminUserInfo()
  22501. errlog := &models.HisOrderError{
  22502. UserOrgId: adminUser.CurrentOrgId,
  22503. Ctime: time.Now().Unix(),
  22504. Mtime: time.Now().Unix(),
  22505. ErrMsg: resThree.ErrMsg,
  22506. Status: 1,
  22507. PatientId: id,
  22508. RecordTime: recordDateTime,
  22509. Stage: 2,
  22510. }
  22511. service.CreateErrMsgLog(errlog)
  22512. c.ServeSuccessJSON(map[string]interface{}{
  22513. "failed_code": -10,
  22514. "msg": resThree.ErrMsg,
  22515. })
  22516. return
  22517. }
  22518. his.Number = resThree.Output.Data.MdtrtID
  22519. his.PsnNo = resThree.Output.Data.PsnNo
  22520. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  22521. his.IdCardNo = patient.IdCardNo
  22522. his.PhoneNumber = patient.Phone
  22523. his.UserOrgId = adminInfo.CurrentOrgId
  22524. his.Insutype = insutype
  22525. his.Ctime = time.Now().Unix()
  22526. his.Mtime = time.Now().Unix()
  22527. his.InsuplcAdmdvs = insuplc_admdvs_temp
  22528. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  22529. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  22530. }
  22531. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  22532. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  22533. }
  22534. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  22535. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  22536. }
  22537. his.Status = 1
  22538. his.MdtrtGrpType = mdtrt_type
  22539. service.UpdateHisPatientStatus(&his)
  22540. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  22541. c.ServeSuccessJSON(map[string]interface{}{
  22542. "his_info": his,
  22543. })
  22544. } else {
  22545. adminUser := c.GetAdminUserInfo()
  22546. errlog := &models.HisOrderError{
  22547. UserOrgId: adminUser.CurrentOrgId,
  22548. Ctime: time.Now().Unix(),
  22549. Mtime: time.Now().Unix(),
  22550. ErrMsg: res.ErrMsg,
  22551. Status: 1,
  22552. PatientId: id,
  22553. RecordTime: recordDateTime,
  22554. Stage: 1,
  22555. }
  22556. service.CreateErrMsgLog(errlog)
  22557. c.ServeSuccessJSON(map[string]interface{}{
  22558. "failed_code": -10,
  22559. "msg": res.ErrMsg,
  22560. })
  22561. return
  22562. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  22563. }
  22564. }
  22565. }
  22566. func (c *HisApiController) GetUploadInfo() {
  22567. id, _ := c.GetInt64("id")
  22568. record_time := c.GetString("record_time")
  22569. his_patient_id, _ := c.GetInt64("his_patient_id")
  22570. order_id, _ := c.GetInt64("order_id")
  22571. pay_way, _ := c.GetInt64("pay_way")
  22572. pay_ways := c.GetString("pay_ways")
  22573. oth_desc := c.GetString("oth_desc")
  22574. pay_price, _ := c.GetFloat("pay_price")
  22575. pay_card_no := c.GetString("pay_card_no")
  22576. discount_price, _ := c.GetFloat("discount_price")
  22577. preferential_price, _ := c.GetFloat("preferential_price")
  22578. reality_price, _ := c.GetFloat("reality_price")
  22579. found_price, _ := c.GetFloat("found_price")
  22580. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  22581. private_price, _ := c.GetFloat("private_price")
  22582. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  22583. admin_user_id, _ := c.GetInt64("admin_user_id")
  22584. fapiao_code := c.GetString("fapiao_code")
  22585. fapiao_number := c.GetString("fapiao_number")
  22586. diagnosis_id := c.GetString("diagnosis")
  22587. sick_type, _ := c.GetInt64("sick_type")
  22588. reg_type, _ := c.GetInt64("p_type")
  22589. begin_time := c.GetString("begin_time")
  22590. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  22591. cash_pay := c.GetString("cash_pay")
  22592. band_card_pay := c.GetString("band_card_pay")
  22593. wechat_pay := c.GetString("wechat_pay")
  22594. ali_pay := c.GetString("ali_pay")
  22595. jifen_pay := c.GetString("jifen_pay")
  22596. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  22597. fmt.Println(acct_used_flag)
  22598. id_str := c.GetString("ids")
  22599. ids_arr := strings.Split(id_str, ",")
  22600. timeLayout := "2006-01-02"
  22601. loc, _ := time.LoadLocation("Local")
  22602. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  22603. if err != nil {
  22604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22605. return
  22606. }
  22607. recordDateTime := theTime.Unix()
  22608. adminUser := c.GetAdminUserInfo()
  22609. var tempOrder models.HisOrder
  22610. tempOrder, _ = service.GetHisOrderByID(order_id)
  22611. var prescriptions []*models.HisPrescription
  22612. var start_time int64
  22613. var end_time int64
  22614. //押金模块
  22615. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  22616. tmp_decimal := c.GetString("tmp_decimal")
  22617. var decimal float64 //本次使用的押金
  22618. var errmsg error
  22619. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  22620. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  22621. return
  22622. }
  22623. if len(tmp_decimal) > 0 {
  22624. if tmp_decimal[0] == 45 {
  22625. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  22626. return
  22627. }
  22628. }
  22629. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  22630. fmt.Println(errs)
  22631. decimal = tt
  22632. //if adminUser.CurrentOrgId == 10106{
  22633. // if len(fapiao_code) == 0{
  22634. // fapiao_code = "144072080589"
  22635. // }
  22636. // if len(fapiao_number) == 0{
  22637. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  22638. // if order.ID == 0{
  22639. // fapiao_number = "00001520"
  22640. // }else{
  22641. // //fapiao_code = "00001520"
  22642. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  22643. // var zero string
  22644. // if fpNumber >= 1000{
  22645. // zero = "0000" + strconv.Itoa(fpNumber)
  22646. // }else if fpNumber >= 10000{
  22647. // zero = "000" + strconv.Itoa(fpNumber)
  22648. // } else if fpNumber >= 100000{
  22649. // zero = "00" + strconv.Itoa(fpNumber)
  22650. // } else if fpNumber >= 1000000{
  22651. // zero = "0" + strconv.Itoa(fpNumber)
  22652. // }else {
  22653. // zero = strconv.Itoa(fpNumber)
  22654. // }
  22655. // fapiao_number = zero
  22656. // }
  22657. // }
  22658. //}
  22659. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  22660. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  22661. var patientPrescription models.HisPrescriptionInfo
  22662. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  22663. if patientPrescription.ID == 0 {
  22664. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  22665. }
  22666. //if patientPrescription.Do
  22667. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  22668. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  22669. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  22670. diagnosis_ids := strings.Split(diagnosis_id, ",")
  22671. var config []*models.HisXtDiagnoseConfig
  22672. for _, item := range diagnosis_ids {
  22673. id, _ := strconv.ParseInt(item, 10, 64)
  22674. diagnosisConfig, _ := service.FindDiagnoseById(id)
  22675. config = append(config, &diagnosisConfig)
  22676. }
  22677. sickConfig, _ := service.FindSickById(sick_type)
  22678. //if tempOrder.ID == 0 {
  22679. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  22680. //}
  22681. if tempOrder.ID == 0 {
  22682. var result string
  22683. var requestLog string
  22684. var res2 ResultSix
  22685. var res3 GZResultSix
  22686. var ressix10265 ResultSix10265
  22687. if miConfig.MdtrtareaAdmvs == "421300" {
  22688. data := make(map[string]interface{})
  22689. client := &http.Client{}
  22690. data["psn_no"] = his.PsnNo
  22691. data["mdtrt_id"] = his.Number
  22692. data["opter"] = roles.UserName
  22693. data["org_name"] = miConfig.OrgName
  22694. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22695. data["doctor_id"] = doctor_info.DoctorNumber
  22696. data["doctor_name"] = doctor_info.UserName
  22697. data["department"] = department.Name
  22698. data["fixmedins_code"] = miConfig.Code
  22699. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22700. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22701. data["secret_key"] = miConfig.SecretKey
  22702. data["sick_code"] = sickConfig.CountryCode
  22703. data["sick_name"] = sickConfig.ClassName
  22704. data["dept"] = strconv.FormatInt(department.ID, 10)
  22705. data["config"] = config
  22706. data["begin_time"] = begin_time
  22707. bytesData, _ := json.Marshal(data)
  22708. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  22709. resp, _ := client.Do(req)
  22710. defer resp.Body.Close()
  22711. body, ioErr := ioutil.ReadAll(resp.Body)
  22712. if ioErr != nil {
  22713. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22715. return
  22716. }
  22717. var respJSON map[string]interface{}
  22718. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22719. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22721. return
  22722. }
  22723. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22724. userJSONBytes, _ := json.Marshal(respJSON)
  22725. fmt.Println("log")
  22726. fmt.Println(string(userJSONBytes))
  22727. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22728. utils.ErrorLog("解析失败:%v", err)
  22729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22730. return
  22731. }
  22732. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22733. data := make(map[string]interface{})
  22734. client := &http.Client{}
  22735. data["psn_no"] = his.PsnNo
  22736. data["mdtrt_id"] = his.Number
  22737. data["opter"] = roles.UserName
  22738. data["org_name"] = miConfig.OrgName
  22739. if reg_type == 11 && his.Insutype == "390" {
  22740. data["med_type"] = "110104"
  22741. } else {
  22742. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22743. }
  22744. data["doctor_id"] = doctor_info.DoctorNumber
  22745. data["doctor_name"] = doctor_info.UserName
  22746. data["department"] = department.Name
  22747. data["fixmedins_code"] = miConfig.Code
  22748. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22749. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22750. data["secret_key"] = miConfig.SecretKey
  22751. data["sick_code"] = sickConfig.CountryCode
  22752. data["sick_name"] = sickConfig.ClassName
  22753. data["dept"] = strconv.FormatInt(department.ID, 10)
  22754. data["config"] = config
  22755. data["begin_time"] = begin_time
  22756. bytesData, _ := json.Marshal(data)
  22757. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  22758. resp, _ := client.Do(req)
  22759. defer resp.Body.Close()
  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(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. userJSONBytes, _ := json.Marshal(respJSON)
  22774. fmt.Println("log")
  22775. fmt.Println(string(userJSONBytes))
  22776. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22777. utils.ErrorLog("解析失败:%v", err)
  22778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22779. return
  22780. }
  22781. } else if miConfig.MdtrtareaAdmvs == "420902" {
  22782. data := make(map[string]interface{})
  22783. client := &http.Client{}
  22784. data["psn_no"] = his.PsnNo
  22785. data["mdtrt_id"] = his.Number
  22786. data["opter"] = roles.UserName
  22787. data["org_name"] = miConfig.OrgName
  22788. if reg_type == 11 && his.Insutype == "390" {
  22789. data["med_type"] = "110104"
  22790. } else {
  22791. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22792. }
  22793. data["doctor_id"] = doctor_info.DoctorNumber
  22794. data["doctor_name"] = doctor_info.UserName
  22795. data["department"] = department.Name
  22796. data["fixmedins_code"] = miConfig.Code
  22797. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22798. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22799. data["secret_key"] = miConfig.SecretKey
  22800. data["sick_code"] = sickConfig.CountryCode
  22801. data["sick_name"] = sickConfig.ClassName
  22802. data["dept"] = strconv.FormatInt(department.ID, 10)
  22803. data["config"] = config
  22804. data["begin_time"] = begin_time
  22805. bytesData, _ := json.Marshal(data)
  22806. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  22807. resp, _ := client.Do(req)
  22808. defer resp.Body.Close()
  22809. body, ioErr := ioutil.ReadAll(resp.Body)
  22810. if ioErr != nil {
  22811. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22813. return
  22814. }
  22815. var respJSON map[string]interface{}
  22816. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22817. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22819. return
  22820. }
  22821. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22822. userJSONBytes, _ := json.Marshal(respJSON)
  22823. fmt.Println("log")
  22824. fmt.Println(string(userJSONBytes))
  22825. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22826. utils.ErrorLog("解析失败:%v", err)
  22827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22828. return
  22829. }
  22830. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22831. data := make(map[string]interface{})
  22832. client := &http.Client{}
  22833. data["psn_no"] = his.PsnNo
  22834. data["mdtrt_id"] = his.Number
  22835. data["opter"] = roles.UserName
  22836. data["org_name"] = miConfig.OrgName
  22837. if reg_type == 11 && his.Insutype == "390" {
  22838. data["med_type"] = "110104"
  22839. } else {
  22840. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22841. }
  22842. data["doctor_id"] = doctor_info.DoctorNumber
  22843. data["doctor_name"] = doctor_info.UserName
  22844. data["department"] = department.Name
  22845. data["fixmedins_code"] = miConfig.Code
  22846. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22847. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22848. data["secret_key"] = miConfig.SecretKey
  22849. data["sick_code"] = sickConfig.CountryCode
  22850. data["sick_name"] = sickConfig.ClassName
  22851. data["dept"] = strconv.FormatInt(department.ID, 10)
  22852. data["config"] = config
  22853. data["begin_time"] = begin_time
  22854. bytesData, _ := json.Marshal(data)
  22855. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  22856. resp, _ := client.Do(req)
  22857. defer resp.Body.Close()
  22858. body, ioErr := ioutil.ReadAll(resp.Body)
  22859. if ioErr != nil {
  22860. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22862. return
  22863. }
  22864. var respJSON map[string]interface{}
  22865. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22868. return
  22869. }
  22870. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22871. userJSONBytes, _ := json.Marshal(respJSON)
  22872. fmt.Println("log")
  22873. fmt.Println(string(userJSONBytes))
  22874. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22875. utils.ErrorLog("解析失败:%v", err)
  22876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22877. return
  22878. }
  22879. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22880. data := make(map[string]interface{})
  22881. client := &http.Client{}
  22882. data["psn_no"] = his.PsnNo
  22883. data["mdtrt_id"] = his.Number
  22884. data["doctor"] = roles.UserName
  22885. data["department"] = department.Name
  22886. data["org_name"] = miConfig.OrgName
  22887. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22888. data["doctor_id"] = doctor_info.DoctorNumber
  22889. data["new_doctor_name"] = doctor_info.UserName
  22890. data["fixmedins_code"] = miConfig.Code
  22891. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22892. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22893. data["secret_key"] = miConfig.SecretKey
  22894. data["sick_code"] = sickConfig.CountryCode
  22895. data["sick_name"] = sickConfig.ClassName
  22896. data["url"] = miConfig.Url
  22897. data["ak"] = miConfig.AccessKey
  22898. data["begin_time"] = begin_time
  22899. data["cainfo"] = miConfig.Cainfo
  22900. data["dept"] = strconv.FormatInt(department.ID, 10)
  22901. data["config"] = config
  22902. bytesData, _ := json.Marshal(data)
  22903. var req *http.Request
  22904. if miConfig.MdtrtareaAdmvs == "320921" {
  22905. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  22906. //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 +
  22907. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  22908. } else {
  22909. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  22910. }
  22911. resp, _ := client.Do(req)
  22912. defer resp.Body.Close()
  22913. body, ioErr := ioutil.ReadAll(resp.Body)
  22914. if ioErr != nil {
  22915. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22917. return
  22918. }
  22919. var respJSON map[string]interface{}
  22920. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22921. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22923. return
  22924. }
  22925. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22926. userJSONBytes, _ := json.Marshal(respJSON)
  22927. fmt.Println("log")
  22928. fmt.Println(string(userJSONBytes))
  22929. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  22930. utils.ErrorLog("解析失败:%v", err)
  22931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22932. return
  22933. }
  22934. res2.InfRefmsgid = ressix10265.InfRefmsgid
  22935. res2.Output = ressix10265.Output
  22936. res2.ErrMsg = ressix10265.ErrMsg
  22937. res2.Cainfo = ressix10265.Cainfo
  22938. res2.WarnMsg = ressix10265.WarnMsg
  22939. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  22940. res2.Infcode = infocode
  22941. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22942. data := make(map[string]interface{})
  22943. client := &http.Client{}
  22944. data["psn_no"] = his.PsnNo
  22945. data["mdtrt_id"] = his.Number
  22946. data["doctor"] = roles.UserName
  22947. data["department"] = department.Name
  22948. data["org_name"] = miConfig.OrgName
  22949. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22950. data["doctor_id"] = doctor_info.DoctorNumber
  22951. data["new_doctor_name"] = doctor_info.UserName
  22952. data["fixmedins_code"] = miConfig.Code
  22953. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22954. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22955. data["secret_key"] = miConfig.SecretKey
  22956. data["sick_code"] = sickConfig.CountryCode
  22957. data["sick_name"] = sickConfig.ClassName
  22958. data["url"] = miConfig.Url
  22959. data["ak"] = miConfig.AccessKey
  22960. data["begin_time"] = begin_time
  22961. data["cainfo"] = miConfig.Cainfo
  22962. data["dept"] = strconv.FormatInt(department.ID, 10)
  22963. data["config"] = config
  22964. bytesData, _ := json.Marshal(data)
  22965. var req *http.Request
  22966. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  22967. resp, _ := client.Do(req)
  22968. defer resp.Body.Close()
  22969. body, ioErr := ioutil.ReadAll(resp.Body)
  22970. if ioErr != nil {
  22971. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22973. return
  22974. }
  22975. var respJSON map[string]interface{}
  22976. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22977. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22979. return
  22980. }
  22981. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22982. userJSONBytes, _ := json.Marshal(respJSON)
  22983. fmt.Println("log")
  22984. fmt.Println(string(userJSONBytes))
  22985. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  22986. utils.ErrorLog("解析失败:%v", err)
  22987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22988. return
  22989. }
  22990. res2.InfRefmsgid = ressix10265.InfRefmsgid
  22991. res2.Output = ressix10265.Output
  22992. res2.ErrMsg = ressix10265.ErrMsg
  22993. res2.Cainfo = ressix10265.Cainfo
  22994. res2.WarnMsg = ressix10265.WarnMsg
  22995. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  22996. res2.Infcode = infocode
  22997. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22998. 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)
  22999. saveLog(result, requestLog, "2203", "上传就诊信息")
  23000. var respJSON2 map[string]interface{}
  23001. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  23002. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23004. return
  23005. }
  23006. userJSONBytes2, _ := json.Marshal(respJSON2)
  23007. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  23008. utils.ErrorLog("解析失败:%v", err)
  23009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23010. return
  23011. }
  23012. 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)
  23013. fmt.Println(result2)
  23014. fmt.Println(src_request)
  23015. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23016. data := make(map[string]interface{})
  23017. client := &http.Client{}
  23018. data["psn_no"] = his.PsnNo
  23019. data["mdtrt_id"] = his.Number
  23020. data["doctor"] = roles.UserName
  23021. data["department"] = department.Name
  23022. data["org_name"] = miConfig.OrgName
  23023. data["med_type"] = strconv.FormatInt(reg_type, 10)
  23024. data["doctor_id"] = doctor_info.DoctorNumber
  23025. data["new_doctor_name"] = doctor_info.UserName
  23026. data["fixmedins_code"] = miConfig.Code
  23027. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  23028. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  23029. data["secret_key"] = miConfig.SecretKey
  23030. data["sick_code"] = sickConfig.CountryCode
  23031. data["sick_name"] = sickConfig.ClassName
  23032. data["url"] = miConfig.Url
  23033. data["ak"] = miConfig.AccessKey
  23034. data["begin_time"] = begin_time
  23035. data["cainfo"] = miConfig.Cainfo
  23036. data["dept"] = strconv.FormatInt(department.ID, 10)
  23037. data["config"] = config
  23038. bytesData, _ := json.Marshal(data)
  23039. var req *http.Request
  23040. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  23041. resp, _ := client.Do(req)
  23042. defer resp.Body.Close()
  23043. body, ioErr := ioutil.ReadAll(resp.Body)
  23044. if ioErr != nil {
  23045. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23047. return
  23048. }
  23049. var respJSON map[string]interface{}
  23050. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23051. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23053. return
  23054. }
  23055. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23056. userJSONBytes, _ := json.Marshal(respJSON)
  23057. fmt.Println("log")
  23058. fmt.Println(string(userJSONBytes))
  23059. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23060. utils.ErrorLog("解析失败:%v", err)
  23061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23062. return
  23063. }
  23064. } else {
  23065. if miConfig.MdtrtareaAdmvs == "440781" { //
  23066. 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)
  23067. } else {
  23068. if miConfig.Code == "H15049901371" {
  23069. //赤峰地区国家医保医疗类别
  23070. //职工透析:医疗类别选特殊情况门诊990502
  23071. //居民定额血透门慢: 医疗类别选门诊慢病140104
  23072. var med_type string
  23073. if his.Insutype == "390" {
  23074. if reg_type == 14 {
  23075. med_type = "9933"
  23076. } else if reg_type == 11 {
  23077. med_type = "11"
  23078. }
  23079. } else if his.Insutype == "310" {
  23080. if reg_type == 14 {
  23081. med_type = "990502"
  23082. } else if reg_type == 11 {
  23083. med_type = "11"
  23084. }
  23085. }
  23086. 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)
  23087. } else {
  23088. 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)
  23089. }
  23090. }
  23091. saveLog(result, requestLog, "2203", "上传就诊信息")
  23092. var respJSON2 map[string]interface{}
  23093. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  23094. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23096. return
  23097. }
  23098. userJSONBytes2, _ := json.Marshal(respJSON2)
  23099. if miConfig.Code == "H15049901371" {
  23100. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  23101. utils.ErrorLog("解析失败:%v", err)
  23102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23103. return
  23104. }
  23105. res2.InfRefmsgid = ressix10265.InfRefmsgid
  23106. res2.Output = ressix10265.Output
  23107. res2.ErrMsg = ressix10265.ErrMsg
  23108. res2.Cainfo = ressix10265.Cainfo
  23109. res2.WarnMsg = ressix10265.WarnMsg
  23110. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  23111. res2.Infcode = infocode
  23112. } else {
  23113. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23114. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  23115. utils.ErrorLog("解析失败:%v", err)
  23116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23117. return
  23118. }
  23119. res2.Infcode = res3.Infcode
  23120. } else {
  23121. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  23122. utils.ErrorLog("解析失败:%v", err)
  23123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23124. return
  23125. }
  23126. }
  23127. }
  23128. }
  23129. if res2.Infcode == -1 {
  23130. adminUser := c.GetAdminUserInfo()
  23131. errlog := &models.HisOrderError{
  23132. UserOrgId: adminUser.CurrentOrgId,
  23133. Ctime: time.Now().Unix(),
  23134. Mtime: time.Now().Unix(),
  23135. ErrMsg: res2.ErrMsg,
  23136. Status: 1,
  23137. PatientId: id,
  23138. RecordTime: recordDateTime,
  23139. Stage: 3,
  23140. }
  23141. service.CreateErrMsgLog(errlog)
  23142. c.ServeSuccessJSON(map[string]interface{}{
  23143. "failed_code": -10,
  23144. "msg": res2.ErrMsg,
  23145. })
  23146. return
  23147. } else {
  23148. his.Diagnosis = diagnosis_id
  23149. his.SickType = sickConfig.ID
  23150. //var p_type int64
  23151. //if reg_type == 1111 || reg_type == 1112 {
  23152. // p_type = 11
  23153. //
  23154. //}
  23155. his.PType = fmt.Sprintf("%d", reg_type)
  23156. service.UpdateHisPatientThree(&his)
  23157. data := make(map[string]interface{})
  23158. if settle_accounts_type == 1 { //日结
  23159. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  23160. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  23161. } else {
  23162. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  23163. }
  23164. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  23165. data["pre"] = prescriptions
  23166. } else { //月结
  23167. start_time_str := c.GetString("start_time")
  23168. end_time_str := c.GetString("end_time")
  23169. timeLayout := "2006-01-02"
  23170. loc, _ := time.LoadLocation("Local")
  23171. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  23172. if err != nil {
  23173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23174. return
  23175. }
  23176. recordStartTime := theStartTime.Unix()
  23177. start_time = recordStartTime
  23178. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  23179. if err != nil {
  23180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23181. return
  23182. }
  23183. recordEndTime := theEndTime.Unix()
  23184. end_time = recordEndTime
  23185. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  23186. data["pre"] = prescriptions
  23187. }
  23188. timestamp := time.Now().Unix()
  23189. tempTime := time.Unix(timestamp, 0)
  23190. timeFormat := tempTime.Format("20060102150405")
  23191. chrgBchno := rand.Intn(100000) + 10000
  23192. new_chrg_bchno := ""
  23193. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  23194. new_chrg_bchno = chrg_bchno
  23195. strconv.FormatInt(his.PatientId, 10)
  23196. client := &http.Client{}
  23197. if adminUser.CurrentOrgId == 10265 {
  23198. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  23199. new_chrg_bchno = "0000"
  23200. }
  23201. }
  23202. data["psn_no"] = his.PsnNo
  23203. data["mdtrt_id"] = his.Number
  23204. data["chrg_bchno"] = new_chrg_bchno
  23205. data["org_name"] = miConfig.OrgName
  23206. data["doctor"] = doctor_info.UserName
  23207. data["doctor_id"] = doctor_info.DoctorNumber
  23208. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  23209. data["fixmedins_code"] = miConfig.Code
  23210. data["dept_code"] = department.Number
  23211. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  23212. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  23213. data["secret_key"] = miConfig.SecretKey
  23214. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  23215. data["url"] = miConfig.Url
  23216. data["ak"] = miConfig.AccessKey
  23217. data["new_doctor_name"] = patientPrescription.Doctor
  23218. data["diag_code"] = sickConfig.CountryCode
  23219. data["cainfo"] = miConfig.Cainfo
  23220. data["opter"] = roles.UserName
  23221. var ids []int64
  23222. for _, item := range prescriptions {
  23223. ids = append(ids, item.ID)
  23224. }
  23225. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  23226. if config.IsOpen == 1 { //对接了医保,走医保流程
  23227. var res ResultFour
  23228. var resFour10265 ResultFour10265
  23229. if miConfig.MdtrtareaAdmvs == "421300" {
  23230. bytesData, _ := json.Marshal(data)
  23231. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  23232. resp, _ := client.Do(req)
  23233. defer resp.Body.Close()
  23234. body, ioErr := ioutil.ReadAll(resp.Body)
  23235. if ioErr != nil {
  23236. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23238. return
  23239. }
  23240. var respJSON map[string]interface{}
  23241. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23242. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23244. return
  23245. }
  23246. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23247. userJSONBytes, _ := json.Marshal(respJSON)
  23248. fmt.Println("log")
  23249. fmt.Println(string(userJSONBytes))
  23250. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23251. utils.ErrorLog("解析失败:%v", err)
  23252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23253. return
  23254. }
  23255. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23256. bytesData, _ := json.Marshal(data)
  23257. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  23258. resp, _ := client.Do(req)
  23259. defer resp.Body.Close()
  23260. body, ioErr := ioutil.ReadAll(resp.Body)
  23261. if ioErr != nil {
  23262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23264. return
  23265. }
  23266. var respJSON map[string]interface{}
  23267. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23270. return
  23271. }
  23272. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23273. userJSONBytes, _ := json.Marshal(respJSON)
  23274. fmt.Println("log")
  23275. fmt.Println(string(userJSONBytes))
  23276. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23277. utils.ErrorLog("解析失败:%v", err)
  23278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23279. return
  23280. }
  23281. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23282. bytesData, _ := json.Marshal(data)
  23283. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  23284. resp, _ := client.Do(req)
  23285. defer resp.Body.Close()
  23286. body, ioErr := ioutil.ReadAll(resp.Body)
  23287. if ioErr != nil {
  23288. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23290. return
  23291. }
  23292. var respJSON map[string]interface{}
  23293. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23294. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23296. return
  23297. }
  23298. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23299. userJSONBytes, _ := json.Marshal(respJSON)
  23300. fmt.Println("log")
  23301. fmt.Println(string(userJSONBytes))
  23302. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23303. utils.ErrorLog("解析失败:%v", err)
  23304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23305. return
  23306. }
  23307. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23308. bytesData, _ := json.Marshal(data)
  23309. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  23310. resp, _ := client.Do(req)
  23311. defer resp.Body.Close()
  23312. body, ioErr := ioutil.ReadAll(resp.Body)
  23313. if ioErr != nil {
  23314. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23316. return
  23317. }
  23318. var respJSON map[string]interface{}
  23319. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23322. return
  23323. }
  23324. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23325. userJSONBytes, _ := json.Marshal(respJSON)
  23326. fmt.Println("log")
  23327. fmt.Println(string(userJSONBytes))
  23328. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23329. utils.ErrorLog("解析失败:%v", err)
  23330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23331. return
  23332. }
  23333. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23334. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  23335. if result3101.Infcode == "0" {
  23336. if len(result3101.Output.Result) > 0 {
  23337. var errMsgs []string
  23338. for _, item := range result3101.Output.Result {
  23339. errMsgs = append(errMsgs, item.VolaCont)
  23340. }
  23341. c.ServeSuccessJSON(map[string]interface{}{
  23342. "failed_code": -10,
  23343. "msg": errMsgs,
  23344. })
  23345. return
  23346. }
  23347. }
  23348. bytesData, _ := json.Marshal(data)
  23349. var req *http.Request
  23350. if miConfig.MdtrtareaAdmvs == "320921" {
  23351. data["diag_code"] = sickConfig.CountryCode
  23352. fmt.Println(data)
  23353. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23354. } else {
  23355. data["diag_code"] = sickConfig.CountryCode
  23356. fmt.Println(data)
  23357. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23358. }
  23359. resp, _ := client.Do(req)
  23360. defer resp.Body.Close()
  23361. body, ioErr := ioutil.ReadAll(resp.Body)
  23362. if ioErr != nil {
  23363. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23365. return
  23366. }
  23367. var respJSON map[string]interface{}
  23368. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23371. return
  23372. }
  23373. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23374. userJSONBytes, _ := json.Marshal(respJSON)
  23375. fmt.Println("log")
  23376. fmt.Println(string(userJSONBytes))
  23377. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  23378. utils.ErrorLog("解析失败:%v", err)
  23379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23380. return
  23381. }
  23382. res.InfRefmsgid = resFour10265.InfRefmsgid
  23383. res.Output = resFour10265.Output
  23384. res.ErrMsg = resFour10265.ErrMsg
  23385. res.Cainfo = resFour10265.Cainfo
  23386. res.WarnMsg = resFour10265.WarnMsg
  23387. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  23388. res.Infcode = infocode
  23389. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23390. var pagesize int = 2
  23391. var start int = 1
  23392. var stop int
  23393. var pagecount int
  23394. var curpage int
  23395. var isSuccess bool = true
  23396. data["doctor_id"] = doctor_info.DoctorNumber
  23397. //总页数,向上取整,注意除之前要先转换类型为float64
  23398. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  23399. for curpage = 1; curpage <= pagecount; curpage++ {
  23400. if curpage == 1 {
  23401. start = 1
  23402. } else {
  23403. start = (curpage-1)*pagesize + 1
  23404. }
  23405. stop = curpage * pagesize
  23406. if stop > len(prescriptions) {
  23407. stop = len(prescriptions)
  23408. }
  23409. //var requestLog string
  23410. data["pre"] = prescriptions[start-1 : stop]
  23411. fmt.Println(data["pre"])
  23412. bytesData, _ := json.Marshal(data)
  23413. var req *http.Request
  23414. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  23415. resp, _ := client.Do(req)
  23416. defer resp.Body.Close()
  23417. body, ioErr := ioutil.ReadAll(resp.Body)
  23418. if ioErr != nil {
  23419. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23421. return
  23422. }
  23423. var respJSON map[string]interface{}
  23424. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23425. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23427. return
  23428. }
  23429. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23430. userJSONBytes, _ := json.Marshal(respJSON)
  23431. fmt.Println("log")
  23432. fmt.Println(string(userJSONBytes))
  23433. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  23434. utils.ErrorLog("解析失败:%v", err)
  23435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23436. return
  23437. }
  23438. res.InfRefmsgid = resFour10265.InfRefmsgid
  23439. res.Output = resFour10265.Output
  23440. res.ErrMsg = resFour10265.ErrMsg
  23441. res.Cainfo = resFour10265.Cainfo
  23442. res.WarnMsg = resFour10265.WarnMsg
  23443. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  23444. res.Infcode = infocode
  23445. if infocode == 0 {
  23446. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  23447. } else {
  23448. isSuccess = false
  23449. errlog := &models.HisOrderError{
  23450. UserOrgId: adminUser.CurrentOrgId,
  23451. Ctime: time.Now().Unix(),
  23452. Mtime: time.Now().Unix(),
  23453. Number: chrg_bchno,
  23454. ErrMsg: "",
  23455. Status: 1,
  23456. PatientId: id,
  23457. RecordTime: recordDateTime,
  23458. Stage: 4,
  23459. }
  23460. service.CreateErrMsgLog(errlog)
  23461. c.ServeSuccessJSON(map[string]interface{}{
  23462. "failed_code": -10,
  23463. "msg": res.ErrMsg,
  23464. })
  23465. return
  23466. }
  23467. }
  23468. if isSuccess {
  23469. res.Infcode = 0
  23470. }
  23471. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23472. 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)
  23473. var dat map[string]interface{}
  23474. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23475. fmt.Println(dat)
  23476. } else {
  23477. fmt.Println(err)
  23478. }
  23479. saveLog(result, request_log, "2204", "上传费用明细")
  23480. userJSONBytes, _ := json.Marshal(dat)
  23481. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  23482. utils.ErrorLog("解析失败:%v", err)
  23483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23484. return
  23485. }
  23486. res.InfRefmsgid = resFour10265.InfRefmsgid
  23487. res.Output = resFour10265.Output
  23488. res.ErrMsg = resFour10265.ErrMsg
  23489. res.Cainfo = resFour10265.Cainfo
  23490. res.WarnMsg = resFour10265.WarnMsg
  23491. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  23492. res.Infcode = infocode
  23493. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23494. bytesData, _ := json.Marshal(data)
  23495. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  23496. resp, _ := client.Do(req)
  23497. defer resp.Body.Close()
  23498. body, ioErr := ioutil.ReadAll(resp.Body)
  23499. if ioErr != nil {
  23500. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23502. return
  23503. }
  23504. var respJSON map[string]interface{}
  23505. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23508. return
  23509. }
  23510. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23511. userJSONBytes, _ := json.Marshal(respJSON)
  23512. fmt.Println("log")
  23513. fmt.Println(string(userJSONBytes))
  23514. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23515. utils.ErrorLog("解析失败:%v", err)
  23516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23517. return
  23518. }
  23519. } else {
  23520. if miConfig.Code == "H15049901371" {
  23521. 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)
  23522. var dat map[string]interface{}
  23523. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23524. fmt.Println(dat)
  23525. } else {
  23526. fmt.Println(err)
  23527. }
  23528. saveLog(result, request_log, "2204", "上传费用明细")
  23529. userJSONBytes, _ := json.Marshal(dat)
  23530. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  23531. utils.ErrorLog("解析失败:%v", err)
  23532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23533. return
  23534. }
  23535. res.InfRefmsgid = resFour10265.InfRefmsgid
  23536. res.Output = resFour10265.Output
  23537. res.ErrMsg = resFour10265.ErrMsg
  23538. res.Cainfo = resFour10265.Cainfo
  23539. res.WarnMsg = resFour10265.WarnMsg
  23540. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  23541. res.Infcode = infocode
  23542. } else {
  23543. 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)
  23544. var dat map[string]interface{}
  23545. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23546. fmt.Println(dat)
  23547. } else {
  23548. fmt.Println(err)
  23549. }
  23550. saveLog(result, request_log, "2204", "上传费用明细")
  23551. userJSONBytes, _ := json.Marshal(dat)
  23552. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23553. utils.ErrorLog("解析失败:%v", err)
  23554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23555. return
  23556. }
  23557. }
  23558. }
  23559. if res.Infcode == 0 {
  23560. order := &models.HisOrder{
  23561. UserOrgId: adminUser.CurrentOrgId,
  23562. HisPatientId: his.ID,
  23563. PatientId: his.PatientId,
  23564. SettleAccountsDate: recordDateTime,
  23565. MdtrtId: his.Number,
  23566. PsnNo: his.PsnNo,
  23567. MedType: strconv.FormatInt(reg_type, 10),
  23568. Ctime: time.Now().Unix(),
  23569. Mtime: time.Now().Unix(),
  23570. Status: 1,
  23571. Number: chrg_bchno,
  23572. Infcode: res.Infcode,
  23573. WarnMsg: res.WarnMsg,
  23574. Cainfo: res.Cainfo,
  23575. ErrMsg: res.ErrMsg,
  23576. RespondTime: res.RefmsgTime,
  23577. InfRefmsgid: res.InfRefmsgid,
  23578. OrderStatus: 1,
  23579. PayWay: pay_way,
  23580. PayWays: pay_ways,
  23581. OthDesc: oth_desc,
  23582. PayPrice: pay_price,
  23583. PayCardNo: pay_card_no,
  23584. DiscountPrice: discount_price,
  23585. PreferentialPrice: preferential_price,
  23586. RealityPrice: reality_price,
  23587. FoundPrice: found_price,
  23588. MedicalInsurancePrice: medical_insurance_price,
  23589. PrivatePrice: private_price,
  23590. IsMedicineInsurance: 1,
  23591. SettleType: settle_accounts_type,
  23592. SettleStartTime: start_time,
  23593. SettleEndTime: end_time,
  23594. Creator: roles.AdminUserId,
  23595. Modify: roles.AdminUserId,
  23596. FaPiaoNumber: fapiao_number,
  23597. FaPiaoCode: fapiao_code,
  23598. PType: 2,
  23599. Diagnosis: diagnosis_id,
  23600. CashPay: cash_pay,
  23601. WechatPay: wechat_pay,
  23602. AliPay: ali_pay,
  23603. JifenPay: jifen_pay,
  23604. BandCardPay: band_card_pay,
  23605. }
  23606. err = service.CreateOrder(order)
  23607. if err != nil {
  23608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  23609. return
  23610. }
  23611. for _, item := range res.Output.Result {
  23612. temp := strings.Split(item.FeedetlSn, "-")
  23613. var advice_id int64 = 0
  23614. var project_id int64 = 0
  23615. var types int64 = 0
  23616. id, _ := strconv.ParseInt(temp[2], 10, 64)
  23617. types, _ = strconv.ParseInt(temp[1], 10, 64)
  23618. if temp[1] == "1" {
  23619. advice_id = id
  23620. project_id = 0
  23621. } else if temp[1] == "2" {
  23622. advice_id = 0
  23623. project_id = id
  23624. }
  23625. if item.MedChrgitmType == "9" {
  23626. item.MedChrgitmType = "09"
  23627. }
  23628. info := &models.HisOrderInfo{
  23629. OrderNumber: order.Number,
  23630. FeedetlSn: item.FeedetlSn,
  23631. UploadDate: time.Now().Unix(),
  23632. AdviceId: advice_id,
  23633. DetItemFeeSumamt: item.DetItemFeeSumamt,
  23634. Cnt: item.Cnt,
  23635. Pric: float64(item.Pric),
  23636. PatientId: his.PatientId,
  23637. PricUplmtAmt: item.PricUplmtAmt,
  23638. SelfpayProp: item.SelfpayProp,
  23639. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  23640. OverlmtAmt: item.OverlmtAmt,
  23641. PreselfpayAmt: item.PreselfpayAmt,
  23642. BasMednFlag: item.BasMednFlag,
  23643. MedChrgitmType: item.MedChrgitmType,
  23644. HiNegoDrugFlag: item.HiNegoDrugFlag,
  23645. Status: 1,
  23646. Memo: item.Memo,
  23647. Mtime: time.Now().Unix(),
  23648. InscpScpAmt: item.InscpScpAmt,
  23649. DrtReimFlag: item.DrtReimFlag,
  23650. Ctime: time.Now().Unix(),
  23651. ListSpItemFlag: item.ListSpItemFlag,
  23652. ChldMedcFlag: item.ChldMedcFlag,
  23653. LmtUsedFlag: item.LmtUsedFlag,
  23654. ChrgitmLv: item.ChrgitmLv,
  23655. UserOrgId: adminUser.CurrentOrgId,
  23656. HisPatientId: his.ID,
  23657. OrderId: order.ID,
  23658. ProjectId: project_id,
  23659. Type: types,
  23660. }
  23661. service.CreateOrderInfo(info)
  23662. }
  23663. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  23664. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  23665. var total float64
  23666. for _, item := range prescriptions {
  23667. if item.Type == 1 { //药品
  23668. for _, subItem := range item.HisDoctorAdviceInfo {
  23669. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  23670. total_one := price * subItem.PrescribingNumber
  23671. total = total + total_one
  23672. }
  23673. }
  23674. if item.Type == 2 { //项目
  23675. for _, subItem := range item.HisPrescriptionProject {
  23676. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  23677. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  23678. total_one := price * cnt
  23679. total = total + total_one
  23680. }
  23681. }
  23682. }
  23683. allTotal := fmt.Sprintf("%.2f", total)
  23684. //if adminUser.CurrentOrgId == 9919 {
  23685. //
  23686. // allTotal = fmt.Sprintf("%.2f", total)
  23687. //
  23688. //} else {
  23689. //
  23690. // allTotal = fmt.Sprintf("%.2f", total)
  23691. //
  23692. //}
  23693. if res.Infcode == 0 {
  23694. var rf []*ResultFive
  23695. json.Unmarshal([]byte(his.Iinfo), &rf)
  23696. chrg_bchno := chrg_bchno
  23697. cert_no := his.Certno
  23698. var insutypes []string
  23699. var insutype string
  23700. var is390 int = 0
  23701. var is310 int = 0
  23702. for _, item := range rf {
  23703. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23704. insutypes = append(insutypes, item.Insutype)
  23705. }
  23706. }
  23707. if len(insutypes) == 1 {
  23708. insutype = insutypes[0]
  23709. } else {
  23710. for _, i := range insutypes {
  23711. if i == "390" {
  23712. is390 = 1
  23713. }
  23714. if i == "310" {
  23715. is310 = 1
  23716. }
  23717. }
  23718. }
  23719. if is390 == 1 {
  23720. insutype = "390"
  23721. }
  23722. if is310 == 1 {
  23723. insutype = "310"
  23724. }
  23725. if len(insutypes) == 0 {
  23726. insutype = "310"
  23727. }
  23728. if len(insutypes) == 2 {
  23729. insutype = strconv.FormatInt(his.SocialType, 10)
  23730. }
  23731. insutype = strconv.FormatInt(his.SocialType, 10)
  23732. //insutype = "390"
  23733. if his.IdCardType == 1 {
  23734. // cert_no = his.MedicalInsuranceNumber
  23735. cert_no = his.Certno
  23736. } else {
  23737. cert_no = his.Certno
  23738. }
  23739. var res ResultSeven
  23740. var resSeven10265 ResultSeven10265
  23741. var gzresSeven10265Two GZResultSeven10265Two
  23742. var src_resquest string
  23743. var result2 string
  23744. if miConfig.MdtrtareaAdmvs == "421300" {
  23745. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23746. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23747. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23748. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23749. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23750. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23751. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  23752. resp, requestErr := http.Get(api)
  23753. if requestErr != nil {
  23754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23755. return
  23756. }
  23757. body, ioErr := ioutil.ReadAll(resp.Body)
  23758. if ioErr != nil {
  23759. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23761. return
  23762. }
  23763. var respJSON map[string]interface{}
  23764. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23765. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23767. return
  23768. }
  23769. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23770. result, _ := json.Marshal(respJSON)
  23771. if miConfig.Code == "H15049901371" {
  23772. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  23773. utils.ErrorLog("解析失败:%v", err)
  23774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23775. return
  23776. }
  23777. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23778. res.Output = resSeven10265.Output
  23779. res.ErrMsg = resSeven10265.ErrMsg
  23780. res.Cainfo = resSeven10265.Cainfo
  23781. res.WarnMsg = resSeven10265.WarnMsg
  23782. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23783. res.Infcode = infocode
  23784. } else {
  23785. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23786. utils.ErrorLog("解析失败:%v", err)
  23787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23788. return
  23789. }
  23790. }
  23791. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23792. if reg_type == 11 && his.Insutype == "390" {
  23793. reg_type = 110104
  23794. }
  23795. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23796. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23797. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23798. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23799. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23800. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23801. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  23802. resp, requestErr := http.Get(api)
  23803. if requestErr != nil {
  23804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23805. return
  23806. }
  23807. body, ioErr := ioutil.ReadAll(resp.Body)
  23808. if ioErr != nil {
  23809. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23811. return
  23812. }
  23813. var respJSON map[string]interface{}
  23814. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23815. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23817. return
  23818. }
  23819. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23820. result, _ := json.Marshal(respJSON)
  23821. if miConfig.Code == "H15049901371" {
  23822. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  23823. utils.ErrorLog("解析失败:%v", err)
  23824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23825. return
  23826. }
  23827. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23828. res.Output = resSeven10265.Output
  23829. res.ErrMsg = resSeven10265.ErrMsg
  23830. res.Cainfo = resSeven10265.Cainfo
  23831. res.WarnMsg = resSeven10265.WarnMsg
  23832. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23833. res.Infcode = infocode
  23834. } else {
  23835. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23836. utils.ErrorLog("解析失败:%v", err)
  23837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23838. return
  23839. }
  23840. }
  23841. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23842. if reg_type == 11 && his.Insutype == "390" {
  23843. reg_type = 110104
  23844. }
  23845. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23846. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23847. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23848. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23849. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23850. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23851. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  23852. resp, requestErr := http.Get(api)
  23853. if requestErr != nil {
  23854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23855. return
  23856. }
  23857. body, ioErr := ioutil.ReadAll(resp.Body)
  23858. if ioErr != nil {
  23859. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23861. return
  23862. }
  23863. var respJSON map[string]interface{}
  23864. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23867. return
  23868. }
  23869. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23870. result, _ := json.Marshal(respJSON)
  23871. if miConfig.Code == "H15049901371" {
  23872. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  23873. utils.ErrorLog("解析失败:%v", err)
  23874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23875. return
  23876. }
  23877. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23878. res.Output = resSeven10265.Output
  23879. res.ErrMsg = resSeven10265.ErrMsg
  23880. res.Cainfo = resSeven10265.Cainfo
  23881. res.WarnMsg = resSeven10265.WarnMsg
  23882. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23883. res.Infcode = infocode
  23884. } else {
  23885. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23886. utils.ErrorLog("解析失败:%v", err)
  23887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23888. return
  23889. }
  23890. }
  23891. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23892. if reg_type == 11 && his.Insutype == "390" {
  23893. reg_type = 110104
  23894. }
  23895. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23896. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23897. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23898. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23899. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23900. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23901. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  23902. resp, requestErr := http.Get(api)
  23903. if requestErr != nil {
  23904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23905. return
  23906. }
  23907. body, ioErr := ioutil.ReadAll(resp.Body)
  23908. if ioErr != nil {
  23909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23911. return
  23912. }
  23913. var respJSON map[string]interface{}
  23914. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23917. return
  23918. }
  23919. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23920. result, _ := json.Marshal(respJSON)
  23921. if miConfig.Code == "H15049901371" {
  23922. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  23923. utils.ErrorLog("解析失败:%v", err)
  23924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23925. return
  23926. }
  23927. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23928. res.Output = resSeven10265.Output
  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 {
  23935. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23936. utils.ErrorLog("解析失败:%v", err)
  23937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23938. return
  23939. }
  23940. }
  23941. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23942. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  23943. if result3101.Infcode == "0" {
  23944. if len(result3101.Output.Result) > 0 {
  23945. var errMsgs []string
  23946. for _, item := range result3101.Output.Result {
  23947. errMsgs = append(errMsgs, item.VolaCont)
  23948. }
  23949. c.ServeSuccessJSON(map[string]interface{}{
  23950. "failed_code": -10,
  23951. "msg": errMsgs,
  23952. })
  23953. return
  23954. } else {
  23955. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23956. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23957. bas := strings.Split(psn_info.CardInfo, "|")
  23958. if his.IdCardType == 1 {
  23959. cert_no = bas[2]
  23960. } else if his.IdCardType == 3 {
  23961. cert_no = his.Certno
  23962. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  23963. } else if his.IdCardType == 4 {
  23964. cert_no = his.Certno
  23965. psn_info.VerifyNumber = psn_info.VerifyNumber
  23966. }
  23967. var api string
  23968. if miConfig.MdtrtareaAdmvs == "320921" {
  23969. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23970. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23971. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23972. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23973. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23974. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23975. "&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
  23976. } else {
  23977. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23978. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23979. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23980. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23981. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23982. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23983. "&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
  23984. }
  23985. resp, requestErr := http.Get(api)
  23986. if requestErr != nil {
  23987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23988. return
  23989. }
  23990. body, ioErr := ioutil.ReadAll(resp.Body)
  23991. if ioErr != nil {
  23992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23994. return
  23995. }
  23996. var respJSON map[string]interface{}
  23997. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24000. return
  24001. }
  24002. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24003. result, _ := json.Marshal(respJSON)
  24004. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  24005. utils.ErrorLog("解析失败:%v", err)
  24006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24007. return
  24008. }
  24009. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24010. res.Output = resSeven10265.Output
  24011. res.ErrMsg = resSeven10265.ErrMsg
  24012. res.Cainfo = resSeven10265.Cainfo
  24013. res.WarnMsg = resSeven10265.WarnMsg
  24014. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24015. res.Infcode = infocode
  24016. }
  24017. }
  24018. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24019. psn_info, _ := service.GetPsnByPatientId(id)
  24020. var verify_number string
  24021. if psn_info.IdCardType == 4 {
  24022. verify_number = psn_info.VerifyNumber
  24023. } else if psn_info.IdCardType == 1 {
  24024. bas := strings.Split(psn_info.CardInfo, "|")
  24025. cardNumber := bas[2]
  24026. verify_number = cardNumber
  24027. } else {
  24028. psn_info.IdCardType = 2
  24029. verify_number = psn_info.Certno
  24030. }
  24031. var api string
  24032. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24033. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24034. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24035. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24036. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24037. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24038. "&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
  24039. resp, requestErr := http.Get(api)
  24040. if requestErr != nil {
  24041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24042. return
  24043. }
  24044. body, ioErr := ioutil.ReadAll(resp.Body)
  24045. if ioErr != nil {
  24046. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24048. return
  24049. }
  24050. var respJSON map[string]interface{}
  24051. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24052. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24054. return
  24055. }
  24056. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24057. result, _ := json.Marshal(respJSON)
  24058. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  24059. utils.ErrorLog("解析失败:%v", err)
  24060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24061. return
  24062. }
  24063. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24064. res.Output = resSeven10265.Output
  24065. res.ErrMsg = resSeven10265.ErrMsg
  24066. res.Cainfo = resSeven10265.Cainfo
  24067. res.WarnMsg = resSeven10265.WarnMsg
  24068. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24069. res.Infcode = infocode
  24070. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24071. var cert_no string
  24072. if his.IdCardType == 4 {
  24073. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24074. cert_no = psn_info.VerifyNumber
  24075. 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)
  24076. } else if his.IdCardType == 1 {
  24077. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24078. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  24079. 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)
  24080. }
  24081. //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)
  24082. var dat map[string]interface{}
  24083. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24084. fmt.Println(dat)
  24085. } else {
  24086. fmt.Println(err)
  24087. }
  24088. saveLog(result2, src_resquest, "2207", "结算")
  24089. userJSONBytes, _ := json.Marshal(dat)
  24090. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  24091. utils.ErrorLog("解析失败:%v", err)
  24092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24093. return
  24094. }
  24095. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24096. res.Output = resSeven10265.Output
  24097. res.ErrMsg = resSeven10265.ErrMsg
  24098. res.Cainfo = resSeven10265.Cainfo
  24099. res.WarnMsg = resSeven10265.WarnMsg
  24100. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24101. res.Infcode = infocode
  24102. } else if miConfig.MdtrtareaAdmvs == "450721" {
  24103. res2 := c.GetoleInfo()
  24104. if res2.Infcode == 0 {
  24105. var result string
  24106. var request_log string
  24107. var result_log string
  24108. if res2.Output.MdtrtCertType == "02" {
  24109. 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)
  24110. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24111. } else if res2.Output.MdtrtCertType == "01" {
  24112. 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)
  24113. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24114. } else {
  24115. 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)
  24116. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24117. }
  24118. var dat map[string]interface{}
  24119. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24120. fmt.Println(dat)
  24121. } else {
  24122. fmt.Println(err)
  24123. }
  24124. userJSONBytes, _ := json.Marshal(dat)
  24125. var res5 ResultTwo
  24126. //var resTwo10265 ResultTwo10265
  24127. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  24128. utils.ErrorLog("解析失败:%v", err)
  24129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24130. return
  24131. }
  24132. if res5.Infcode == -1 {
  24133. c.ServeSuccessJSON(map[string]interface{}{
  24134. "failed_code": -10,
  24135. "msg": res5.ErrMsg,
  24136. })
  24137. return
  24138. }
  24139. var insutypes []string
  24140. var insutype string
  24141. var is390 int = 0
  24142. var is310 int = 0
  24143. for _, item := range res5.Output.Iinfo {
  24144. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24145. insutypes = append(insutypes, item.Insutype)
  24146. }
  24147. }
  24148. if len(insutypes) == 1 {
  24149. insutype = insutypes[0]
  24150. } else {
  24151. for _, i := range insutypes {
  24152. if i == "390" {
  24153. is390 = 1
  24154. }
  24155. if i == "310" {
  24156. is310 = 1
  24157. }
  24158. }
  24159. }
  24160. if is390 == 1 {
  24161. insutype = "390"
  24162. }
  24163. if is310 == 1 {
  24164. insutype = "310"
  24165. }
  24166. if len(insutypes) == 0 {
  24167. insutype = "310"
  24168. }
  24169. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  24170. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  24171. infoStr := string(Iinfos)
  24172. idetinfoStr := string(Idetinfos)
  24173. psn := &models.HisPsn{
  24174. PsnNo: res5.Output.Baseinfo.PsnNo,
  24175. PatientId: id,
  24176. Certno: res5.Output.Baseinfo.Certno,
  24177. Gend: res5.Output.Baseinfo.Gend,
  24178. Naty: res5.Output.Baseinfo.Naty,
  24179. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  24180. PsnName: res5.Output.Baseinfo.PsnName,
  24181. Idetinfo: idetinfoStr,
  24182. Insuinfo: infoStr,
  24183. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  24184. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  24185. VerifyNumber: res2.Output.EcToken,
  24186. }
  24187. if res2.Output.MdtrtCertType == "01" {
  24188. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24189. psn.VerifyNumber = res2.Output.EcToken
  24190. } else if res2.Output.MdtrtCertType == "02" {
  24191. psn.VerifyNumber = res2.Output.CardNo
  24192. } else {
  24193. psn.VerifyNumber = res2.Output.MdtrtCertNo
  24194. }
  24195. service.CreateHisPsn(psn)
  24196. if res2.Output.MdtrtCertType == "01" {
  24197. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24198. token := res2.Output.EcToken
  24199. 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)
  24200. } else if res2.Output.MdtrtCertType == "02" {
  24201. 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)
  24202. } else {
  24203. 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)
  24204. }
  24205. var dat2 map[string]interface{}
  24206. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  24207. fmt.Println(dat2)
  24208. } else {
  24209. fmt.Println(err)
  24210. }
  24211. userJSONBytes3, _ := json.Marshal(dat2)
  24212. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24213. utils.ErrorLog("解析失败:%v", err)
  24214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24215. return
  24216. }
  24217. saveLog(result2, src_resquest, "2207", "结算")
  24218. } else {
  24219. c.ServeSuccessJSON(map[string]interface{}{
  24220. "failed_code": -10,
  24221. "msg": res2.ErrMsg,
  24222. })
  24223. return
  24224. }
  24225. } else {
  24226. if miConfig.Code == "H15049901371" {
  24227. //赤峰地区国家医保医疗类别
  24228. //职工透析:医疗类别选特殊情况门诊990502
  24229. //居民定额血透门慢: 医疗类别选门诊慢病140104
  24230. var med_type string
  24231. if his.Insutype == "390" {
  24232. if reg_type == 14 {
  24233. med_type = "9933"
  24234. } else if reg_type == 11 {
  24235. med_type = "11"
  24236. }
  24237. } else if his.Insutype == "310" {
  24238. if reg_type == 14 {
  24239. med_type = "990502"
  24240. } else if reg_type == 11 {
  24241. med_type = "11"
  24242. }
  24243. }
  24244. 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)
  24245. } else {
  24246. if his.IdCardType == 4 {
  24247. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24248. var token string
  24249. token = psn_info.VerifyNumber
  24250. 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)
  24251. } else {
  24252. if his.IdCardType == 1 {
  24253. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24254. bas := strings.Split(psn_info.CardInfo, "|")
  24255. basNumber := bas[2]
  24256. cert_no = basNumber
  24257. }
  24258. 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)
  24259. }
  24260. }
  24261. //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)
  24262. var dat map[string]interface{}
  24263. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24264. fmt.Println(dat)
  24265. } else {
  24266. fmt.Println(err)
  24267. }
  24268. saveLog(result2, src_resquest, "2207", "结算")
  24269. userJSONBytes, _ := json.Marshal(dat)
  24270. if miConfig.Code == "H15049901371" {
  24271. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  24272. utils.ErrorLog("解析失败:%v", err)
  24273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24274. return
  24275. }
  24276. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24277. res.Output = resSeven10265.Output
  24278. res.ErrMsg = resSeven10265.ErrMsg
  24279. res.Cainfo = resSeven10265.Cainfo
  24280. res.WarnMsg = resSeven10265.WarnMsg
  24281. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24282. res.Infcode = infocode
  24283. } else {
  24284. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24285. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  24286. utils.ErrorLog("解析失败:%v", err)
  24287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24288. return
  24289. }
  24290. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  24291. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  24292. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  24293. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  24294. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  24295. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  24296. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  24297. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  24298. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  24299. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24300. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24301. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24302. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24303. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  24304. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  24305. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  24306. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  24307. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  24308. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  24309. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  24310. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  24311. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  24312. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  24313. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  24314. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  24315. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  24316. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  24317. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  24318. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  24319. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  24320. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  24321. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  24322. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  24323. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  24324. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  24325. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  24326. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  24327. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  24328. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24329. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  24330. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  24331. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  24332. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  24333. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  24334. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  24335. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  24336. res.ErrMsg = gzresSeven10265Two.ErrMsg
  24337. res.Cainfo = gzresSeven10265Two.Cainfo
  24338. res.WarnMsg = gzresSeven10265Two.WarnMsg
  24339. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  24340. //res.Infcode = infocode
  24341. } else {
  24342. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24343. utils.ErrorLog("解析失败:%v", err)
  24344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24345. return
  24346. }
  24347. }
  24348. }
  24349. }
  24350. if res.Infcode == -1 {
  24351. errlog := &models.HisOrderError{
  24352. UserOrgId: adminUser.CurrentOrgId,
  24353. Ctime: time.Now().Unix(),
  24354. Mtime: time.Now().Unix(),
  24355. Number: chrg_bchno,
  24356. ErrMsg: res.ErrMsg,
  24357. Status: 1,
  24358. PatientId: id,
  24359. RecordTime: recordDateTime,
  24360. Stage: 6,
  24361. }
  24362. service.CreateErrMsgLog(errlog)
  24363. c.ServeSuccessJSON(map[string]interface{}{
  24364. "failed_code": -10,
  24365. "msg": res.ErrMsg,
  24366. })
  24367. return
  24368. } else {
  24369. sickConfig, _ := service.FindSickById(his.SickType)
  24370. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  24371. order.OrderStatus = 2
  24372. order.Status = 1
  24373. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  24374. order.SetlId = res.Output.Setlinfo.SetlID
  24375. order.PsnNo = res.Output.Setlinfo.PsnNo
  24376. order.PsnName = res.Output.Setlinfo.PsnName
  24377. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  24378. order.Certno = res.Output.Setlinfo.Certno
  24379. order.Gend = res.Output.Setlinfo.Gend
  24380. order.Naty = res.Output.Setlinfo.Naty
  24381. order.Age = res.Output.Setlinfo.Age
  24382. order.Insutype = res.Output.Setlinfo.Insutype
  24383. order.PsnType = res.Output.Setlinfo.PsnType
  24384. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  24385. order.SetlTime = res.Output.Setlinfo.SetlTime
  24386. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  24387. if res.Output.Setlinfo.MedType == "140101" {
  24388. order.MedType = "14"
  24389. } else {
  24390. if res.Output.Setlinfo.MedType == "110104" {
  24391. order.MedType = "11"
  24392. } else {
  24393. order.MedType = res.Output.Setlinfo.MedType
  24394. }
  24395. }
  24396. if reg_type == 1112 {
  24397. order.MedType = "1112"
  24398. }
  24399. if reg_type == 1111 {
  24400. order.MedType = "1111"
  24401. }
  24402. order.ClrType = res.Output.Setlinfo.ClrType
  24403. if adminUser.CurrentOrgId == 10480 {
  24404. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  24405. order.ClrType = "11"
  24406. } else {
  24407. order.ClrType = "9903"
  24408. }
  24409. }
  24410. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  24411. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  24412. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  24413. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  24414. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  24415. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  24416. order.HifpPay = res.Output.Setlinfo.HifpPay
  24417. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  24418. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  24419. order.HifesPay = res.Output.Setlinfo.HifesPay
  24420. order.HifobPay = res.Output.Setlinfo.HifobPay
  24421. order.MafPay = res.Output.Setlinfo.MafPay
  24422. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  24423. order.OthPay = res.Output.Setlinfo.OthPay
  24424. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  24425. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  24426. order.AcctPay = res.Output.Setlinfo.AcctPay
  24427. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  24428. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  24429. order.Balc = res.Output.Setlinfo.Balc
  24430. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  24431. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  24432. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  24433. //order.ClrType = res.Output.Setlinfo.ClrType
  24434. order.ClrWay = res.Output.Setlinfo.ClrWay
  24435. order.Creator = order.Creator
  24436. order.Modify = roles.AdminUserId
  24437. order.RequestLog = src_resquest
  24438. order.FaPiaoNumber = fapiao_number
  24439. order.FaPiaoCode = fapiao_code
  24440. order.SickName = sickConfig.ClassName
  24441. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  24442. //detailStr := string(setlDetail)
  24443. //order.SetlDetail = detailStr
  24444. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  24445. err = service.UpDateOrder(order)
  24446. if err == nil {
  24447. //判断是否使用了押金
  24448. if dec_way == "true" {
  24449. tmpstring := strconv.FormatInt(order.ID, 10)
  24450. order.Decimal = decimal
  24451. service.UpDateOrder(order)
  24452. //扣押金
  24453. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  24454. if errmsg != nil {
  24455. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  24456. return
  24457. }
  24458. }
  24459. c.ServeSuccessJSON(map[string]interface{}{
  24460. "msg": "结算成功",
  24461. })
  24462. } else {
  24463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  24464. return
  24465. }
  24466. }
  24467. } else {
  24468. adminUser := c.GetAdminUserInfo()
  24469. errlog := &models.HisOrderError{
  24470. UserOrgId: adminUser.CurrentOrgId,
  24471. Ctime: time.Now().Unix(),
  24472. Mtime: time.Now().Unix(),
  24473. ErrMsg: res.ErrMsg,
  24474. Status: 1,
  24475. PatientId: id,
  24476. RecordTime: recordDateTime,
  24477. Stage: 4,
  24478. }
  24479. service.CreateErrMsgLog(errlog)
  24480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  24481. return
  24482. }
  24483. } else {
  24484. adminUser := c.GetAdminUserInfo()
  24485. errlog := &models.HisOrderError{
  24486. UserOrgId: adminUser.CurrentOrgId,
  24487. Ctime: time.Now().Unix(),
  24488. Mtime: time.Now().Unix(),
  24489. ErrMsg: res.ErrMsg,
  24490. Status: 1,
  24491. PatientId: id,
  24492. RecordTime: recordDateTime,
  24493. Stage: 4,
  24494. }
  24495. service.CreateErrMsgLog(errlog)
  24496. c.ServeSuccessJSON(map[string]interface{}{
  24497. "failed_code": -10,
  24498. "msg": res.ErrMsg,
  24499. })
  24500. return
  24501. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  24502. //return
  24503. }
  24504. }
  24505. }
  24506. } else if tempOrder.ID > 0 {
  24507. if tempOrder.IsPre == 1 {
  24508. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  24509. var rf []*ResultFive
  24510. json.Unmarshal([]byte(his.Iinfo), &rf)
  24511. chrg_bchno := tempOrder.Number
  24512. cert_no := his.Certno
  24513. var insutypes []string
  24514. var insutype string
  24515. var is390 int = 0
  24516. var is310 int = 0
  24517. for _, item := range rf {
  24518. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24519. insutypes = append(insutypes, item.Insutype)
  24520. }
  24521. }
  24522. if len(insutypes) == 1 {
  24523. insutype = insutypes[0]
  24524. } else {
  24525. for _, i := range insutypes {
  24526. if i == "390" {
  24527. is390 = 1
  24528. }
  24529. if i == "310" {
  24530. is310 = 1
  24531. }
  24532. }
  24533. }
  24534. if is390 == 1 {
  24535. insutype = "390"
  24536. }
  24537. if is310 == 1 {
  24538. insutype = "310"
  24539. }
  24540. if len(insutypes) == 0 {
  24541. insutype = "310"
  24542. }
  24543. if len(insutypes) == 2 {
  24544. insutype = strconv.FormatInt(his.SocialType, 10)
  24545. }
  24546. //insutype = "390"
  24547. if his.IdCardType == 1 {
  24548. // cert_no = his.MedicalInsuranceNumber
  24549. cert_no = his.Certno
  24550. } else {
  24551. cert_no = his.Certno
  24552. }
  24553. var res ResultSeven
  24554. var ahres ResultSevenAH
  24555. var resSeven10265 ResultSeven10265
  24556. var gzresSeven10265Two GZResultSeven10265Two
  24557. var src_resquest string
  24558. var result2 string
  24559. if miConfig.MdtrtareaAdmvs == "450721" {
  24560. res2 := c.GetoleInfo()
  24561. if res2.Infcode == 0 {
  24562. var result string
  24563. var request_log string
  24564. var result_log string
  24565. if res2.Output.MdtrtCertType == "02" {
  24566. 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)
  24567. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24568. } else if res2.Output.MdtrtCertType == "01" {
  24569. 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)
  24570. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24571. } else {
  24572. 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)
  24573. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24574. }
  24575. var dat map[string]interface{}
  24576. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24577. fmt.Println(dat)
  24578. } else {
  24579. fmt.Println(err)
  24580. }
  24581. userJSONBytes, _ := json.Marshal(dat)
  24582. var res5 ResultTwo
  24583. //var resTwo10265 ResultTwo10265
  24584. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  24585. utils.ErrorLog("解析失败:%v", err)
  24586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24587. return
  24588. }
  24589. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  24590. if res5.Infcode == -1 {
  24591. c.ServeSuccessJSON(map[string]interface{}{
  24592. "failed_code": -10,
  24593. "msg": res5.ErrMsg,
  24594. })
  24595. return
  24596. }
  24597. var insutypes []string
  24598. var insutype string
  24599. var is390 int = 0
  24600. var is310 int = 0
  24601. for _, item := range res5.Output.Iinfo {
  24602. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24603. insutypes = append(insutypes, item.Insutype)
  24604. }
  24605. }
  24606. if len(insutypes) == 1 {
  24607. insutype = insutypes[0]
  24608. } else {
  24609. for _, i := range insutypes {
  24610. if i == "390" {
  24611. is390 = 1
  24612. }
  24613. if i == "310" {
  24614. is310 = 1
  24615. }
  24616. }
  24617. }
  24618. if is390 == 1 {
  24619. insutype = "390"
  24620. }
  24621. if is310 == 1 {
  24622. insutype = "310"
  24623. }
  24624. if len(insutypes) == 0 {
  24625. insutype = "310"
  24626. }
  24627. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  24628. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  24629. infoStr := string(Iinfos)
  24630. idetinfoStr := string(Idetinfos)
  24631. psn := &models.HisPsn{
  24632. PsnNo: res5.Output.Baseinfo.PsnNo,
  24633. PatientId: id,
  24634. Certno: res5.Output.Baseinfo.Certno,
  24635. Gend: res5.Output.Baseinfo.Gend,
  24636. Naty: res5.Output.Baseinfo.Naty,
  24637. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  24638. PsnName: res5.Output.Baseinfo.PsnName,
  24639. Idetinfo: idetinfoStr,
  24640. Insuinfo: infoStr,
  24641. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  24642. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  24643. VerifyNumber: res2.Output.EcToken,
  24644. }
  24645. service.CreateHisPsn(psn)
  24646. if res2.Output.MdtrtCertType == "01" {
  24647. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24648. token := res2.Output.EcToken
  24649. 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)
  24650. } else if res2.Output.MdtrtCertType == "02" {
  24651. 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)
  24652. } else {
  24653. 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)
  24654. }
  24655. var dat2 map[string]interface{}
  24656. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  24657. fmt.Println(dat2)
  24658. } else {
  24659. fmt.Println(err)
  24660. }
  24661. userJSONBytes3, _ := json.Marshal(dat2)
  24662. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24663. utils.ErrorLog("解析失败:%v", err)
  24664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24665. return
  24666. }
  24667. saveLog(result2, src_resquest, "2207", "结算")
  24668. } else {
  24669. c.ServeSuccessJSON(map[string]interface{}{
  24670. "failed_code": -10,
  24671. "msg": res2.ErrMsg,
  24672. })
  24673. return
  24674. }
  24675. } else if miConfig.MdtrtareaAdmvs == "421300" {
  24676. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24677. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24678. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24679. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24680. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24681. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24682. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  24683. resp, requestErr := http.Get(api)
  24684. if requestErr != nil {
  24685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24686. return
  24687. }
  24688. body, ioErr := ioutil.ReadAll(resp.Body)
  24689. if ioErr != nil {
  24690. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24692. return
  24693. }
  24694. var respJSON map[string]interface{}
  24695. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24696. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24698. return
  24699. }
  24700. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24701. result, _ := json.Marshal(respJSON)
  24702. fmt.Println("log")
  24703. fmt.Println(string(result))
  24704. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24705. utils.ErrorLog("解析失败:%v", err)
  24706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24707. return
  24708. }
  24709. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24710. if reg_type == 11 && his.Insutype == "390" {
  24711. reg_type = 110104
  24712. }
  24713. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24714. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24715. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24716. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24717. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24718. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24719. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  24720. resp, requestErr := http.Get(api)
  24721. if requestErr != nil {
  24722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24723. return
  24724. }
  24725. body, ioErr := ioutil.ReadAll(resp.Body)
  24726. if ioErr != nil {
  24727. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24729. return
  24730. }
  24731. var respJSON map[string]interface{}
  24732. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24733. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24735. return
  24736. }
  24737. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24738. result, _ := json.Marshal(respJSON)
  24739. fmt.Println("log")
  24740. fmt.Println(string(result))
  24741. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24742. utils.ErrorLog("解析失败:%v", err)
  24743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24744. return
  24745. }
  24746. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24747. if reg_type == 11 && his.Insutype == "390" {
  24748. reg_type = 110104
  24749. }
  24750. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24751. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24752. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24753. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24754. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24755. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24756. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  24757. resp, requestErr := http.Get(api)
  24758. if requestErr != nil {
  24759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24760. return
  24761. }
  24762. body, ioErr := ioutil.ReadAll(resp.Body)
  24763. if ioErr != nil {
  24764. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24766. return
  24767. }
  24768. var respJSON map[string]interface{}
  24769. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24770. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24772. return
  24773. }
  24774. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24775. result, _ := json.Marshal(respJSON)
  24776. fmt.Println("log")
  24777. fmt.Println(string(result))
  24778. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24779. utils.ErrorLog("解析失败:%v", err)
  24780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24781. return
  24782. }
  24783. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24784. if reg_type == 11 && his.Insutype == "390" {
  24785. reg_type = 110104
  24786. }
  24787. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24788. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24789. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24790. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24791. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24792. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24793. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  24794. resp, requestErr := http.Get(api)
  24795. if requestErr != nil {
  24796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24797. return
  24798. }
  24799. body, ioErr := ioutil.ReadAll(resp.Body)
  24800. if ioErr != nil {
  24801. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24803. return
  24804. }
  24805. var respJSON map[string]interface{}
  24806. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24807. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24809. return
  24810. }
  24811. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24812. result, _ := json.Marshal(respJSON)
  24813. fmt.Println("log")
  24814. fmt.Println(string(result))
  24815. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24816. utils.ErrorLog("解析失败:%v", err)
  24817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24818. return
  24819. }
  24820. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24821. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  24822. if result3101.Infcode == "0" {
  24823. if len(result3101.Output.Result) > 0 {
  24824. var errMsgs []string
  24825. for _, item := range result3101.Output.Result {
  24826. errMsgs = append(errMsgs, item.VolaCont)
  24827. }
  24828. c.ServeSuccessJSON(map[string]interface{}{
  24829. "failed_code": -10,
  24830. "msg": errMsgs,
  24831. })
  24832. return
  24833. } else {
  24834. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24835. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24836. bas := strings.Split(psn_info.CardInfo, "|")
  24837. if his.IdCardType == 1 {
  24838. cert_no = bas[2]
  24839. } else if his.IdCardType == 3 {
  24840. cert_no = his.Certno
  24841. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  24842. } else if his.IdCardType == 4 {
  24843. cert_no = his.Certno
  24844. psn_info.VerifyNumber = psn_info.VerifyNumber
  24845. }
  24846. //江苏地区国家医保医疗类别
  24847. //职工透析:医疗类别选特殊情况门诊9933
  24848. //居民血透门慢: 医疗类别选门诊慢病1402
  24849. //var med_type string
  24850. //if his.Insutype == "310" {
  24851. // if reg_type == 14 {
  24852. // med_type = "9933"
  24853. // } else if reg_type == 11 {
  24854. // med_type = "11"
  24855. //
  24856. // }
  24857. //} else if his.Insutype == "390" {
  24858. // if reg_type == 14 {
  24859. // med_type = "1402"
  24860. // } else if reg_type == 11 {
  24861. // med_type = "11"
  24862. // }
  24863. //}
  24864. var api string
  24865. if miConfig.MdtrtareaAdmvs == "320921" {
  24866. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24867. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24868. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24869. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24870. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24871. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24872. "&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
  24873. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24874. } else {
  24875. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24876. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24877. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24878. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24879. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24880. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24881. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24882. "&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
  24883. }
  24884. resp, requestErr := http.Get(api)
  24885. if requestErr != nil {
  24886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24887. return
  24888. }
  24889. body, ioErr := ioutil.ReadAll(resp.Body)
  24890. if ioErr != nil {
  24891. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24893. return
  24894. }
  24895. var respJSON map[string]interface{}
  24896. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24897. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24899. return
  24900. }
  24901. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24902. result, _ := json.Marshal(respJSON)
  24903. fmt.Println("log")
  24904. fmt.Println(string(result))
  24905. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  24906. utils.ErrorLog("解析失败:%v", err)
  24907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24908. return
  24909. }
  24910. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24911. res.Output = resSeven10265.Output
  24912. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24913. res.ErrMsg = resSeven10265.ErrMsg
  24914. res.Cainfo = resSeven10265.Cainfo
  24915. res.WarnMsg = resSeven10265.WarnMsg
  24916. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24917. res.Infcode = infocode
  24918. }
  24919. }
  24920. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24921. psn_info, _ := service.GetPsnByPatientId(id)
  24922. var verify_number string
  24923. if psn_info.IdCardType == 4 {
  24924. verify_number = psn_info.VerifyNumber
  24925. } else if psn_info.IdCardType == 1 {
  24926. bas := strings.Split(psn_info.CardInfo, "|")
  24927. cardNumber := bas[2]
  24928. verify_number = cardNumber
  24929. } else {
  24930. verify_number = psn_info.Certno
  24931. psn_info.IdCardType = 2
  24932. }
  24933. var api string
  24934. new_chrg_bchno := chrg_bchno
  24935. if adminUser.CurrentOrgId == 10265 {
  24936. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  24937. new_chrg_bchno = "0000"
  24938. }
  24939. }
  24940. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24941. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  24942. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24943. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24944. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  24945. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24946. "&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
  24947. resp, requestErr := http.Get(api)
  24948. if requestErr != nil {
  24949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24950. return
  24951. }
  24952. body, ioErr := ioutil.ReadAll(resp.Body)
  24953. if ioErr != nil {
  24954. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24956. return
  24957. }
  24958. var respJSON map[string]interface{}
  24959. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24960. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24962. return
  24963. }
  24964. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24965. result, _ := json.Marshal(respJSON)
  24966. fmt.Println("log")
  24967. fmt.Println(string(result))
  24968. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  24969. utils.ErrorLog("解析失败:%v", err)
  24970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24971. return
  24972. }
  24973. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24974. res.Output = resSeven10265.Output
  24975. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24976. res.ErrMsg = resSeven10265.ErrMsg
  24977. res.Cainfo = resSeven10265.Cainfo
  24978. res.WarnMsg = resSeven10265.WarnMsg
  24979. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24980. res.Infcode = infocode
  24981. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24982. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24983. var cert_no string
  24984. if his.IdCardType == 1 {
  24985. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  24986. } else {
  24987. cert_no = psn_info.VerifyNumber
  24988. }
  24989. 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)
  24990. var dat map[string]interface{}
  24991. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24992. fmt.Println(dat)
  24993. } else {
  24994. fmt.Println(err)
  24995. }
  24996. saveLog(result2, src_resquest, "2207", "结算")
  24997. userJSONBytes, _ := json.Marshal(dat)
  24998. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24999. utils.ErrorLog("解析失败:%v", err)
  25000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25001. return
  25002. }
  25003. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25004. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25005. var cert_no string
  25006. var card_sn string
  25007. if his.IdCardType == 1 {
  25008. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25009. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25010. bas := strings.Split(psn_info.CardInfo, "|")
  25011. card_sn = bas[3]
  25012. } else if his.IdCardType == 2 {
  25013. cert_no = his.IdCardNo
  25014. } else {
  25015. cert_no = psn_info.VerifyNumber
  25016. }
  25017. var rf []*ResultFive
  25018. json.Unmarshal([]byte(his.Iinfo), &rf)
  25019. var psn_type string
  25020. for _, item := range rf {
  25021. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  25022. psn_type = item.PsnType
  25023. }
  25024. }
  25025. 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)
  25026. var dat map[string]interface{}
  25027. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25028. fmt.Println(dat)
  25029. } else {
  25030. fmt.Println(err)
  25031. }
  25032. saveLog(result2, src_resquest, "2207", "结算")
  25033. userJSONBytes, _ := json.Marshal(dat)
  25034. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25035. utils.ErrorLog("解析失败:%v", err)
  25036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25037. return
  25038. }
  25039. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25040. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25041. if his.IdCardType == 1 {
  25042. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25043. bas := strings.Split(psn_info.CardInfo, "|")
  25044. cert_no = bas[2]
  25045. } else if his.IdCardType == 3 {
  25046. cert_no = his.Certno
  25047. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  25048. } else if his.IdCardType == 4 {
  25049. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25050. cert_no = his.Certno
  25051. psn_info.VerifyNumber = psn_info.VerifyNumber
  25052. } else {
  25053. cert_no = his.Certno
  25054. psn_info.VerifyNumber = his.Certno
  25055. }
  25056. var api string
  25057. var med_type string
  25058. if his.Insutype == "390" {
  25059. if reg_type == 992102 {
  25060. med_type = "992102"
  25061. }
  25062. if reg_type == 140104 {
  25063. med_type = "140104"
  25064. }
  25065. if reg_type == 14 {
  25066. med_type = "14"
  25067. }
  25068. } else if his.Insutype == "310" {
  25069. if reg_type == 992102 {
  25070. med_type = "992102"
  25071. }
  25072. if reg_type == 14 {
  25073. med_type = "14"
  25074. }
  25075. }
  25076. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25077. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25078. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25079. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25080. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25081. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25082. "&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
  25083. resp, requestErr := http.Get(api)
  25084. if requestErr != nil {
  25085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25086. return
  25087. }
  25088. body, ioErr := ioutil.ReadAll(resp.Body)
  25089. if ioErr != nil {
  25090. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25092. return
  25093. }
  25094. var respJSON map[string]interface{}
  25095. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25096. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25098. return
  25099. }
  25100. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25101. if status == "0" {
  25102. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25103. c.ServeSuccessJSON(map[string]interface{}{
  25104. "failed_code": -10,
  25105. "msg": err_msg,
  25106. })
  25107. return
  25108. }
  25109. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25110. result, _ := json.Marshal(respJSON)
  25111. fmt.Println("log")
  25112. fmt.Println(string(result))
  25113. if err := json.Unmarshal(result, &ahres); err != nil {
  25114. utils.ErrorLog("解析失败:%v", err)
  25115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25116. return
  25117. }
  25118. res.InfRefmsgid = ahres.InfRefmsgid
  25119. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  25120. // 创建对应的Time类型
  25121. t := time.UnixMilli(timestamp)
  25122. // 格式化成指定的日期字符串
  25123. str := t.Format("2006-01-02 15:04:05")
  25124. res.Output.Setlinfo.SetlTime = str
  25125. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  25126. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  25127. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  25128. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  25129. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  25130. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  25131. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  25132. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  25133. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  25134. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  25135. res.Output.Setlinfo.ClrType = "11"
  25136. } else {
  25137. res.Output.Setlinfo.ClrType = "9903"
  25138. }
  25139. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  25140. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  25141. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  25142. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  25143. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  25144. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  25145. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  25146. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  25147. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  25148. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  25149. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  25150. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  25151. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  25152. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  25153. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  25154. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  25155. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  25156. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  25157. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  25158. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  25159. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  25160. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  25161. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  25162. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  25163. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  25164. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  25165. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  25166. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  25167. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  25168. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  25169. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  25170. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  25171. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  25172. res.Output.Setldetail = ahres.Output.Setldetail
  25173. res.ErrMsg = ahres.ErrMsg
  25174. res.Cainfo = ahres.Cainfo
  25175. res.WarnMsg = ahres.WarnMsg
  25176. res.Infcode = ahres.Infcode
  25177. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25178. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25179. var cert_no string
  25180. if his.IdCardType == 1 {
  25181. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25182. } else if his.IdCardType == 2 {
  25183. cert_no = his.IdCardNo
  25184. } else {
  25185. cert_no = psn_info.VerifyNumber
  25186. }
  25187. 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, "")
  25188. var dat map[string]interface{}
  25189. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25190. fmt.Println(dat)
  25191. } else {
  25192. fmt.Println(err)
  25193. }
  25194. saveLog(result2, src_resquest, "2207", "结算")
  25195. userJSONBytes, _ := json.Marshal(dat)
  25196. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25197. utils.ErrorLog("解析失败:%v", err)
  25198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25199. return
  25200. }
  25201. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25202. psn_info, _ := service.GetPsnByPatientId(id)
  25203. var verify_number string
  25204. if psn_info.IdCardType == 4 {
  25205. verify_number = psn_info.VerifyNumber
  25206. } else if psn_info.IdCardType == 1 {
  25207. bas := strings.Split(psn_info.CardInfo, "|")
  25208. cardNumber := bas[2]
  25209. verify_number = cardNumber
  25210. } else {
  25211. verify_number = psn_info.Certno
  25212. psn_info.IdCardType = 2
  25213. }
  25214. var api string
  25215. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25216. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25217. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25218. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25219. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  25220. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25221. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  25222. resp, requestErr := http.Get(api)
  25223. if requestErr != nil {
  25224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25225. return
  25226. }
  25227. body, ioErr := ioutil.ReadAll(resp.Body)
  25228. if ioErr != nil {
  25229. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25231. return
  25232. }
  25233. var respJSON map[string]interface{}
  25234. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25235. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25237. return
  25238. }
  25239. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25240. result, _ := json.Marshal(respJSON)
  25241. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25242. utils.ErrorLog("解析失败:%v", err)
  25243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25244. return
  25245. }
  25246. } else {
  25247. var src_resquest string
  25248. if miConfig.Code == "H15049901371" {
  25249. //赤峰地区国家医保医疗类别
  25250. //职工透析:医疗类别选特殊情况门诊990502
  25251. //居民定额血透门慢: 医疗类别选门诊慢病140104
  25252. var med_type string
  25253. if his.Insutype == "390" {
  25254. if reg_type == 14 {
  25255. med_type = "9933"
  25256. } else if reg_type == 11 {
  25257. med_type = "11"
  25258. }
  25259. } else if his.Insutype == "310" {
  25260. if reg_type == 14 {
  25261. med_type = "990502"
  25262. } else if reg_type == 11 {
  25263. med_type = "11"
  25264. }
  25265. }
  25266. 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)
  25267. } else {
  25268. if his.IdCardType == 4 {
  25269. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25270. token := psn_info.VerifyNumber
  25271. 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)
  25272. } else {
  25273. 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)
  25274. }
  25275. }
  25276. var dat map[string]interface{}
  25277. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25278. fmt.Println(dat)
  25279. } else {
  25280. fmt.Println(err)
  25281. }
  25282. saveLog(result2, src_resquest, "2207", "结算")
  25283. userJSONBytes, _ := json.Marshal(dat)
  25284. if miConfig.Code == "H15049901371" {
  25285. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  25286. utils.ErrorLog("解析失败:%v", err)
  25287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25288. return
  25289. }
  25290. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25291. res.Output = resSeven10265.Output
  25292. res.ErrMsg = resSeven10265.ErrMsg
  25293. res.Cainfo = resSeven10265.Cainfo
  25294. res.WarnMsg = resSeven10265.WarnMsg
  25295. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25296. res.Infcode = infocode
  25297. } else {
  25298. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25299. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  25300. utils.ErrorLog("解析失败:%v", err)
  25301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25302. return
  25303. }
  25304. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  25305. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  25306. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  25307. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  25308. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  25309. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  25310. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  25311. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  25312. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  25313. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25314. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25315. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25316. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25317. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  25318. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  25319. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  25320. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  25321. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  25322. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  25323. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  25324. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  25325. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  25326. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  25327. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  25328. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  25329. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  25330. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  25331. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  25332. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  25333. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  25334. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  25335. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  25336. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  25337. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  25338. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  25339. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  25340. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  25341. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  25342. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25343. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  25344. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  25345. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  25346. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  25347. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  25348. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  25349. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  25350. res.ErrMsg = gzresSeven10265Two.ErrMsg
  25351. res.Cainfo = gzresSeven10265Two.Cainfo
  25352. res.WarnMsg = gzresSeven10265Two.WarnMsg
  25353. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  25354. //res.Infcode = infocode
  25355. } else {
  25356. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25357. utils.ErrorLog("解析失败:%v", err)
  25358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25359. return
  25360. }
  25361. }
  25362. }
  25363. }
  25364. if res.Infcode == -1 {
  25365. errlog := &models.HisOrderError{
  25366. UserOrgId: adminUser.CurrentOrgId,
  25367. Ctime: time.Now().Unix(),
  25368. Mtime: time.Now().Unix(),
  25369. Number: chrg_bchno,
  25370. ErrMsg: res.ErrMsg,
  25371. Status: 1,
  25372. PatientId: id,
  25373. RecordTime: recordDateTime,
  25374. Stage: 6,
  25375. }
  25376. service.CreateErrMsgLog(errlog)
  25377. c.ServeSuccessJSON(map[string]interface{}{
  25378. "failed_code": -10,
  25379. "msg": res.ErrMsg,
  25380. })
  25381. return
  25382. } else {
  25383. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  25384. order.OrderStatus = 2
  25385. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  25386. order.SetlId = res.Output.Setlinfo.SetlID
  25387. order.PsnNo = res.Output.Setlinfo.PsnNo
  25388. order.PsnName = res.Output.Setlinfo.PsnName
  25389. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  25390. order.Certno = res.Output.Setlinfo.Certno
  25391. order.Gend = res.Output.Setlinfo.Gend
  25392. order.Naty = res.Output.Setlinfo.Naty
  25393. order.Age = res.Output.Setlinfo.Age
  25394. order.Insutype = res.Output.Setlinfo.Insutype
  25395. order.PsnType = res.Output.Setlinfo.PsnType
  25396. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  25397. order.SetlTime = res.Output.Setlinfo.SetlTime
  25398. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  25399. order.PayWays = pay_ways
  25400. order.AcctUsedFlag = acct_used_flag
  25401. order.WechatPay = wechat_pay
  25402. order.AliPay = ali_pay
  25403. order.JifenPay = jifen_pay
  25404. order.BandCardPay = band_card_pay
  25405. order.CashPay = cash_pay
  25406. order.OthDesc = oth_desc
  25407. //order.MedType = res.Output.Setlinfo.MedType
  25408. if reg_type == 1112 {
  25409. order.MedType = "1112"
  25410. }
  25411. if reg_type == 1111 {
  25412. order.MedType = "1111"
  25413. }
  25414. order.ClrType = res.Output.Setlinfo.ClrType
  25415. if adminUser.CurrentOrgId == 10480 {
  25416. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  25417. order.ClrType = "11"
  25418. } else {
  25419. order.ClrType = "9903"
  25420. }
  25421. }
  25422. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  25423. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  25424. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  25425. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  25426. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  25427. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  25428. order.HifpPay = res.Output.Setlinfo.HifpPay
  25429. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  25430. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  25431. order.HifesPay = res.Output.Setlinfo.HifesPay
  25432. order.HifobPay = res.Output.Setlinfo.HifobPay
  25433. order.MafPay = res.Output.Setlinfo.MafPay
  25434. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  25435. order.OthPay = res.Output.Setlinfo.OthPay
  25436. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  25437. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  25438. order.AcctPay = res.Output.Setlinfo.AcctPay
  25439. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  25440. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  25441. order.Balc = res.Output.Setlinfo.Balc
  25442. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  25443. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  25444. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  25445. order.ClrWay = res.Output.Setlinfo.ClrWay
  25446. order.Creator = order.Creator
  25447. order.Modify = roles.AdminUserId
  25448. order.RequestLog = src_resquest
  25449. order.Diagnosis = diagnosis_id
  25450. order.FaPiaoNumber = fapiao_number
  25451. order.FaPiaoCode = fapiao_code
  25452. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  25453. detailStr := string(setlDetail)
  25454. order.SetlDetail = detailStr
  25455. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  25456. err = service.UpDateOrder(order)
  25457. if err == nil {
  25458. //判断是否使用了押金
  25459. if dec_way == "true" {
  25460. tmpstring := strconv.FormatInt(order.ID, 10)
  25461. //扣押金
  25462. order.Decimal = decimal
  25463. service.UpDateOrder(order)
  25464. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  25465. if errmsg != nil {
  25466. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  25467. return
  25468. }
  25469. }
  25470. c.ServeSuccessJSON(map[string]interface{}{
  25471. "msg": "结算成功",
  25472. })
  25473. } else {
  25474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  25475. return
  25476. }
  25477. }
  25478. }
  25479. }
  25480. }
  25481. // 上传明细-预结算-
  25482. func (c *HisApiController) GetPreUploadInfo() {
  25483. id, _ := c.GetInt64("id")
  25484. record_time := c.GetString("record_time")
  25485. his_patient_id, _ := c.GetInt64("his_patient_id")
  25486. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  25487. admin_user_id, _ := c.GetInt64("admin_user_id")
  25488. diagnosis_id := c.GetString("diagnosis")
  25489. sick_type, _ := c.GetInt64("sick_type")
  25490. reg_type, _ := c.GetInt64("p_type")
  25491. begin_time := c.GetString("begin_time")
  25492. acct_used_flag := c.GetString("acct_used_flag")
  25493. id_str := c.GetString("ids")
  25494. ids_arr := strings.Split(id_str, ",")
  25495. timeLayout := "2006-01-02"
  25496. loc, _ := time.LoadLocation("Local")
  25497. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  25498. if err != nil {
  25499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25500. return
  25501. }
  25502. recordDateTime := theTime.Unix()
  25503. adminUser := c.GetAdminUserInfo()
  25504. diagnosis_ids := strings.Split(diagnosis_id, ",")
  25505. var config []*models.HisXtDiagnoseConfig
  25506. for _, item := range diagnosis_ids {
  25507. id, _ := strconv.ParseInt(item, 10, 64)
  25508. diagnosisConfig, _ := service.FindDiagnoseById(id)
  25509. config = append(config, &diagnosisConfig)
  25510. }
  25511. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  25512. sickConfig, _ := service.FindSickById(sick_type)
  25513. var prescriptions []*models.HisPrescription
  25514. var start_time int64
  25515. var end_time int64
  25516. var isSuccess bool = true
  25517. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25518. fmt.Println(his_patient_id)
  25519. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  25520. timestamp := time.Now().Unix()
  25521. tempTime := time.Unix(timestamp, 0)
  25522. timeFormat := tempTime.Format("20060102150405")
  25523. chrgBchno := rand.Intn(100000) + 10000
  25524. new_chrg_bchno := ""
  25525. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  25526. new_chrg_bchno = chrg_bchno
  25527. if adminUser.CurrentOrgId == 10265 {
  25528. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  25529. new_chrg_bchno = "0000"
  25530. }
  25531. }
  25532. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25533. var patientPrescription models.HisPrescriptionInfo
  25534. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  25535. if patientPrescription.ID == 0 {
  25536. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  25537. }
  25538. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25539. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  25540. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  25541. strconv.FormatInt(his.PatientId, 10)
  25542. var res2406 Result2406
  25543. //安徽单病种处理
  25544. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  25545. data := make(map[string]interface{})
  25546. client := &http.Client{}
  25547. data["psn_no"] = his.PsnNo
  25548. data["mdtrt_id"] = his.Number
  25549. data["operator"] = roles.UserName
  25550. data["cert_no"] = his.IdCardNo
  25551. data["org_name"] = miConfig.OrgName
  25552. data["psn_name"] = his.Name
  25553. data["ipt_otp_no"] = his.IptOtpNo
  25554. data["ipt_psn_sp_flag_type"] = "0901"
  25555. data["ipt_psn_sp_flag"] = "1"
  25556. data["fixmedins_code"] = miConfig.Code
  25557. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25558. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25559. data["url"] = miConfig.Url
  25560. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  25561. bytesData, _ := json.Marshal(data)
  25562. var req *http.Request
  25563. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  25564. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  25565. resp, _ := client.Do(req)
  25566. defer resp.Body.Close()
  25567. body, ioErr := ioutil.ReadAll(resp.Body)
  25568. if ioErr != nil {
  25569. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25571. return
  25572. }
  25573. var respJSON map[string]interface{}
  25574. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25577. return
  25578. }
  25579. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25580. if status == "0" {
  25581. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25582. c.ServeSuccessJSON(map[string]interface{}{
  25583. "failed_code": -10,
  25584. "msg": err_msg,
  25585. })
  25586. return
  25587. }
  25588. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25589. userJSONBytes, _ := json.Marshal(respJSON)
  25590. fmt.Println("log")
  25591. fmt.Println(string(userJSONBytes))
  25592. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  25593. utils.ErrorLog("解析失败:%v", err)
  25594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25595. return
  25596. }
  25597. }
  25598. if res2406.Infcode != 0 {
  25599. adminUser := c.GetAdminUserInfo()
  25600. errlog := &models.HisOrderError{
  25601. UserOrgId: adminUser.CurrentOrgId,
  25602. Ctime: time.Now().Unix(),
  25603. Mtime: time.Now().Unix(),
  25604. ErrMsg: res2406.ErrMsg,
  25605. Status: 1,
  25606. PatientId: id,
  25607. RecordTime: recordDateTime,
  25608. Stage: 3,
  25609. }
  25610. service.CreateErrMsgLog(errlog)
  25611. c.ServeSuccessJSON(map[string]interface{}{
  25612. "failed_code": -10,
  25613. "msg": res2406.ErrMsg,
  25614. })
  25615. return
  25616. }
  25617. var res2 ResultSix
  25618. var res3 GZResultSix
  25619. var resSix10265 ResultSix10265
  25620. //var time_stamp string
  25621. if miConfig.MdtrtareaAdmvs == "421300" {
  25622. data := make(map[string]interface{})
  25623. client := &http.Client{}
  25624. data["psn_no"] = his.PsnNo
  25625. data["mdtrt_id"] = his.Number
  25626. data["department"] = department.Name
  25627. data["org_name"] = miConfig.OrgName
  25628. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25629. data["doctor_id"] = doctor_info.DoctorNumber
  25630. data["doctor_name"] = roles.UserName
  25631. data["fixmedins_code"] = miConfig.Code
  25632. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25633. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25634. data["secret_key"] = miConfig.SecretKey
  25635. data["sick_code"] = sickConfig.CountryCode
  25636. data["sick_name"] = sickConfig.ClassName
  25637. data["begin_time"] = begin_time
  25638. data["dept"] = strconv.FormatInt(department.ID, 10)
  25639. data["config"] = config
  25640. data["opter"] = roles.UserName
  25641. fmt.Println(data)
  25642. bytesData, _ := json.Marshal(data)
  25643. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  25644. resp, _ := client.Do(req)
  25645. defer resp.Body.Close()
  25646. body, ioErr := ioutil.ReadAll(resp.Body)
  25647. if ioErr != nil {
  25648. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25650. return
  25651. }
  25652. var respJSON map[string]interface{}
  25653. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25654. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25656. return
  25657. }
  25658. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25659. userJSONBytes, _ := json.Marshal(respJSON)
  25660. fmt.Println("log")
  25661. fmt.Println(string(userJSONBytes))
  25662. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25663. utils.ErrorLog("解析失败:%v", err)
  25664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25665. return
  25666. }
  25667. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25668. data := make(map[string]interface{})
  25669. client := &http.Client{}
  25670. data["psn_no"] = his.PsnNo
  25671. data["mdtrt_id"] = his.Number
  25672. data["department"] = department.Name
  25673. data["org_name"] = miConfig.OrgName
  25674. if reg_type == 11 && his.Insutype == "390" {
  25675. data["med_type"] = "110104"
  25676. } else {
  25677. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25678. }
  25679. data["doctor_id"] = doctor_info.DoctorNumber
  25680. data["doctor_name"] = roles.UserName
  25681. data["fixmedins_code"] = miConfig.Code
  25682. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25683. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25684. data["secret_key"] = miConfig.SecretKey
  25685. data["sick_code"] = sickConfig.CountryCode
  25686. data["sick_name"] = sickConfig.ClassName
  25687. data["begin_time"] = begin_time
  25688. data["dept"] = strconv.FormatInt(department.ID, 10)
  25689. data["config"] = config
  25690. data["opter"] = roles.UserName
  25691. fmt.Println(data)
  25692. bytesData, _ := json.Marshal(data)
  25693. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  25694. resp, _ := client.Do(req)
  25695. defer resp.Body.Close()
  25696. body, ioErr := ioutil.ReadAll(resp.Body)
  25697. if ioErr != nil {
  25698. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25700. return
  25701. }
  25702. var respJSON map[string]interface{}
  25703. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25706. return
  25707. }
  25708. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25709. userJSONBytes, _ := json.Marshal(respJSON)
  25710. fmt.Println("log")
  25711. fmt.Println(string(userJSONBytes))
  25712. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25713. utils.ErrorLog("解析失败:%v", err)
  25714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25715. return
  25716. }
  25717. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25718. data := make(map[string]interface{})
  25719. client := &http.Client{}
  25720. data["psn_no"] = his.PsnNo
  25721. data["mdtrt_id"] = his.Number
  25722. data["department"] = department.Name
  25723. data["org_name"] = miConfig.OrgName
  25724. if reg_type == 11 && his.Insutype == "390" {
  25725. data["med_type"] = "110104"
  25726. } else {
  25727. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25728. }
  25729. data["doctor_id"] = doctor_info.DoctorNumber
  25730. data["doctor_name"] = roles.UserName
  25731. data["fixmedins_code"] = miConfig.Code
  25732. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25733. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25734. data["secret_key"] = miConfig.SecretKey
  25735. data["sick_code"] = sickConfig.CountryCode
  25736. data["sick_name"] = sickConfig.ClassName
  25737. data["begin_time"] = begin_time
  25738. data["dept"] = strconv.FormatInt(department.ID, 10)
  25739. data["config"] = config
  25740. data["opter"] = roles.UserName
  25741. fmt.Println(data)
  25742. bytesData, _ := json.Marshal(data)
  25743. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25744. resp, _ := client.Do(req)
  25745. defer resp.Body.Close()
  25746. body, ioErr := ioutil.ReadAll(resp.Body)
  25747. if ioErr != nil {
  25748. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25750. return
  25751. }
  25752. var respJSON map[string]interface{}
  25753. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25756. return
  25757. }
  25758. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25759. userJSONBytes, _ := json.Marshal(respJSON)
  25760. fmt.Println("log")
  25761. fmt.Println(string(userJSONBytes))
  25762. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25763. utils.ErrorLog("解析失败:%v", err)
  25764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25765. return
  25766. }
  25767. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25768. data := make(map[string]interface{})
  25769. client := &http.Client{}
  25770. data["psn_no"] = his.PsnNo
  25771. data["mdtrt_id"] = his.Number
  25772. data["department"] = department.Name
  25773. data["org_name"] = miConfig.OrgName
  25774. if reg_type == 11 && his.Insutype == "390" {
  25775. data["med_type"] = "110104"
  25776. } else {
  25777. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25778. }
  25779. data["doctor_id"] = doctor_info.DoctorNumber
  25780. data["doctor_name"] = roles.UserName
  25781. data["fixmedins_code"] = miConfig.Code
  25782. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25783. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25784. data["secret_key"] = miConfig.SecretKey
  25785. data["sick_code"] = sickConfig.CountryCode
  25786. data["sick_name"] = sickConfig.ClassName
  25787. data["begin_time"] = begin_time
  25788. data["dept"] = strconv.FormatInt(department.ID, 10)
  25789. data["config"] = config
  25790. data["opter"] = roles.UserName
  25791. fmt.Println(data)
  25792. bytesData, _ := json.Marshal(data)
  25793. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25794. resp, _ := client.Do(req)
  25795. defer resp.Body.Close()
  25796. body, ioErr := ioutil.ReadAll(resp.Body)
  25797. if ioErr != nil {
  25798. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25800. return
  25801. }
  25802. var respJSON map[string]interface{}
  25803. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25804. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25806. return
  25807. }
  25808. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25809. userJSONBytes, _ := json.Marshal(respJSON)
  25810. fmt.Println("log")
  25811. fmt.Println(string(userJSONBytes))
  25812. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25813. utils.ErrorLog("解析失败:%v", err)
  25814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25815. return
  25816. }
  25817. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25818. data := make(map[string]interface{})
  25819. client := &http.Client{}
  25820. data["psn_no"] = his.PsnNo
  25821. data["mdtrt_id"] = his.Number
  25822. data["doctor"] = roles.UserName
  25823. data["department"] = department.Name
  25824. data["org_name"] = miConfig.OrgName
  25825. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25826. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  25827. data["fixmedins_code"] = miConfig.Code
  25828. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25829. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25830. data["secret_key"] = miConfig.SecretKey
  25831. data["sick_code"] = sickConfig.CountryCode
  25832. data["sick_name"] = sickConfig.ClassName
  25833. data["begin_time"] = begin_time
  25834. data["dept"] = strconv.FormatInt(department.ID, 10)
  25835. data["config"] = config
  25836. data["url"] = miConfig.Url
  25837. data["ak"] = miConfig.AccessKey
  25838. data["cainfo"] = miConfig.Cainfo
  25839. bytesData, _ := json.Marshal(data)
  25840. var req *http.Request
  25841. if miConfig.MdtrtareaAdmvs == "320921" {
  25842. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25843. } else {
  25844. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25845. }
  25846. resp, _ := client.Do(req)
  25847. defer resp.Body.Close()
  25848. body, ioErr := ioutil.ReadAll(resp.Body)
  25849. if ioErr != nil {
  25850. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25852. return
  25853. }
  25854. var respJSON map[string]interface{}
  25855. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25856. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25858. return
  25859. }
  25860. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  25861. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  25862. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  25863. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25864. userJSONBytes, _ := json.Marshal(respJSON)
  25865. fmt.Println("log")
  25866. fmt.Println(string(userJSONBytes))
  25867. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  25868. utils.ErrorLog("解析失败:%v", err)
  25869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25870. return
  25871. }
  25872. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25873. res2.Output = resSix10265.Output
  25874. res2.ErrMsg = resSix10265.ErrMsg
  25875. res2.Cainfo = resSix10265.Cainfo
  25876. res2.WarnMsg = resSix10265.WarnMsg
  25877. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25878. res2.Infcode = infocode
  25879. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25880. data := make(map[string]interface{})
  25881. client := &http.Client{}
  25882. data["psn_no"] = his.PsnNo
  25883. data["mdtrt_id"] = his.Number
  25884. data["doctor"] = roles.UserName
  25885. data["department"] = department.Name
  25886. data["org_name"] = miConfig.OrgName
  25887. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25888. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  25889. data["fixmedins_code"] = miConfig.Code
  25890. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25891. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25892. data["secret_key"] = miConfig.SecretKey
  25893. data["sick_code"] = sickConfig.CountryCode
  25894. data["sick_name"] = sickConfig.ClassName
  25895. data["begin_time"] = begin_time
  25896. data["dept"] = strconv.FormatInt(department.ID, 10)
  25897. data["config"] = config
  25898. //data["url"] = miConfig.Url
  25899. //data["ak"] = miConfig.AccessKey
  25900. data["cainfo"] = miConfig.Cainfo
  25901. fmt.Println(data)
  25902. bytesData, _ := json.Marshal(data)
  25903. var req *http.Request
  25904. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  25905. resp, _ := client.Do(req)
  25906. defer resp.Body.Close()
  25907. body, ioErr := ioutil.ReadAll(resp.Body)
  25908. if ioErr != nil {
  25909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25911. return
  25912. }
  25913. var respJSON map[string]interface{}
  25914. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25917. return
  25918. }
  25919. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  25920. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  25921. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  25922. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25923. userJSONBytes, _ := json.Marshal(respJSON)
  25924. fmt.Println("log")
  25925. fmt.Println(string(userJSONBytes))
  25926. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  25927. utils.ErrorLog("解析失败:%v", err)
  25928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25929. return
  25930. }
  25931. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25932. res2.Output = resSix10265.Output
  25933. res2.ErrMsg = resSix10265.ErrMsg
  25934. res2.Cainfo = resSix10265.Cainfo
  25935. res2.WarnMsg = resSix10265.WarnMsg
  25936. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25937. res2.Infcode = infocode
  25938. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25939. 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)
  25940. saveLog(result, requestLog, "2203", "上传就诊信息")
  25941. var respJSON2 map[string]interface{}
  25942. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25943. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25945. return
  25946. }
  25947. userJSONBytes2, _ := json.Marshal(respJSON2)
  25948. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25949. utils.ErrorLog("解析失败:%v", err)
  25950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25951. return
  25952. }
  25953. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25954. var result string
  25955. var requestLog string
  25956. 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, "")
  25957. saveLog(result, requestLog, "2203", "上传就诊信息")
  25958. var respJSON2 map[string]interface{}
  25959. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25960. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25962. return
  25963. }
  25964. userJSONBytes2, _ := json.Marshal(respJSON2)
  25965. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25966. utils.ErrorLog("解析失败:%v", err)
  25967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25968. return
  25969. }
  25970. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25971. data := make(map[string]interface{})
  25972. client := &http.Client{}
  25973. data["psn_no"] = his.PsnNo
  25974. data["mdtrt_id"] = his.Number
  25975. data["operator"] = roles.UserName
  25976. data["department"] = department.Name
  25977. data["org_name"] = miConfig.OrgName
  25978. var med_type string
  25979. if his.Insutype == "390" {
  25980. if reg_type == 992102 {
  25981. med_type = "992102"
  25982. data["sick_code"] = "ZDZ940"
  25983. data["sick_name"] = "慢性肾衰竭"
  25984. }
  25985. if reg_type == 140104 {
  25986. med_type = "140104"
  25987. data["sick_code"] = sickConfig.CountryCode
  25988. data["sick_name"] = sickConfig.ClassName
  25989. }
  25990. if reg_type == 14 {
  25991. med_type = "140104"
  25992. data["sick_code"] = sickConfig.CountryCode
  25993. data["sick_name"] = sickConfig.ClassName
  25994. }
  25995. } else if his.Insutype == "310" {
  25996. if reg_type == 992102 {
  25997. med_type = "992102"
  25998. data["sick_code"] = "ZDZ940"
  25999. data["sick_name"] = "慢性肾衰竭"
  26000. }
  26001. if reg_type == 140104 {
  26002. med_type = "140104"
  26003. data["sick_code"] = sickConfig.CountryCode
  26004. data["sick_name"] = sickConfig.ClassName
  26005. }
  26006. if reg_type == 14 {
  26007. med_type = "14"
  26008. data["sick_code"] = sickConfig.CountryCode
  26009. data["sick_name"] = sickConfig.ClassName
  26010. }
  26011. }
  26012. data["med_type"] = med_type
  26013. data["doctor_number"] = doctor_info.DoctorNumber
  26014. data["doctor_name"] = doctor_info.UserName
  26015. data["fixmedins_code"] = miConfig.Code
  26016. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26017. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26018. data["secret_key"] = miConfig.SecretKey
  26019. data["begin_time"] = begin_time
  26020. data["dept"] = strconv.FormatInt(department.ID, 10)
  26021. data["config"] = config
  26022. data["url"] = miConfig.Url
  26023. data["ak"] = miConfig.AccessKey
  26024. data["cainfo"] = miConfig.Cainfo
  26025. bytesData, _ := json.Marshal(data)
  26026. var req *http.Request
  26027. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  26028. resp, _ := client.Do(req)
  26029. defer resp.Body.Close()
  26030. body, ioErr := ioutil.ReadAll(resp.Body)
  26031. if ioErr != nil {
  26032. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26034. return
  26035. }
  26036. var respJSON map[string]interface{}
  26037. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26038. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26040. return
  26041. }
  26042. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26043. if status == "0" {
  26044. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26045. c.ServeSuccessJSON(map[string]interface{}{
  26046. "failed_code": -10,
  26047. "msg": err_msg,
  26048. })
  26049. return
  26050. }
  26051. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26052. userJSONBytes, _ := json.Marshal(respJSON)
  26053. fmt.Println("log")
  26054. fmt.Println(string(userJSONBytes))
  26055. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26056. utils.ErrorLog("解析失败:%v", err)
  26057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26058. return
  26059. }
  26060. } else if miConfig.MdtrtareaAdmvs == "430800" {
  26061. var result string
  26062. var requestLog string
  26063. 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, "")
  26064. saveLog(result, requestLog, "2203", "上传就诊信息")
  26065. var respJSON2 map[string]interface{}
  26066. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26067. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26069. return
  26070. }
  26071. userJSONBytes2, _ := json.Marshal(respJSON2)
  26072. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26073. utils.ErrorLog("解析失败:%v", err)
  26074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26075. return
  26076. }
  26077. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26078. data := make(map[string]interface{})
  26079. client := &http.Client{}
  26080. data["psn_no"] = his.PsnNo
  26081. data["mdtrt_id"] = his.Number
  26082. data["doctor"] = roles.UserName
  26083. data["department"] = department.Name
  26084. data["org_name"] = miConfig.OrgName
  26085. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26086. data["doctor_id"] = doctor_info.DoctorNumber
  26087. data["fixmedins_code"] = miConfig.Code
  26088. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26089. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26090. data["secret_key"] = miConfig.SecretKey
  26091. data["sick_code"] = sickConfig.CountryCode
  26092. data["sick_name"] = sickConfig.ClassName
  26093. data["begin_time"] = begin_time
  26094. data["new_doctor_name"] = doctor_info.UserName
  26095. data["dept"] = strconv.FormatInt(department.ID, 10)
  26096. data["config"] = config
  26097. bytesData, _ := json.Marshal(data)
  26098. var req *http.Request
  26099. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  26100. resp, _ := client.Do(req)
  26101. defer resp.Body.Close()
  26102. body, ioErr := ioutil.ReadAll(resp.Body)
  26103. if ioErr != nil {
  26104. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26106. return
  26107. }
  26108. var respJSON map[string]interface{}
  26109. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26110. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26112. return
  26113. }
  26114. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26115. userJSONBytes, _ := json.Marshal(respJSON)
  26116. fmt.Println("log")
  26117. fmt.Println(string(userJSONBytes))
  26118. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26119. utils.ErrorLog("解析失败:%v", err)
  26120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26121. return
  26122. }
  26123. } else {
  26124. var result string
  26125. var requestLog string
  26126. if miConfig.MdtrtareaAdmvs == "440781" { //
  26127. 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)
  26128. } else {
  26129. if miConfig.Code == "H15049901371" {
  26130. //赤峰地区国家医保医疗类别
  26131. //职工透析:医疗类别选特殊情况门诊990502
  26132. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26133. var med_type string
  26134. if his.Insutype == "390" {
  26135. if reg_type == 14 {
  26136. med_type = "9933"
  26137. } else if reg_type == 11 {
  26138. med_type = "11"
  26139. }
  26140. } else if his.Insutype == "310" {
  26141. if reg_type == 14 {
  26142. med_type = "990502"
  26143. } else if reg_type == 11 {
  26144. med_type = "11"
  26145. }
  26146. }
  26147. 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)
  26148. } else {
  26149. 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)
  26150. }
  26151. saveLog(result, requestLog, "2203", "上传就诊信息")
  26152. var respJSON2 map[string]interface{}
  26153. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26154. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26156. return
  26157. }
  26158. userJSONBytes2, _ := json.Marshal(respJSON2)
  26159. if miConfig.Code == "H15049901371" {
  26160. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  26161. utils.ErrorLog("解析失败:%v", err)
  26162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26163. return
  26164. }
  26165. res2.InfRefmsgid = resSix10265.InfRefmsgid
  26166. res2.Output = resSix10265.Output
  26167. res2.ErrMsg = resSix10265.ErrMsg
  26168. res2.Cainfo = resSix10265.Cainfo
  26169. res2.WarnMsg = resSix10265.WarnMsg
  26170. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  26171. res2.Infcode = infocode
  26172. } else {
  26173. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26174. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  26175. utils.ErrorLog("解析失败:%v", err)
  26176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26177. return
  26178. }
  26179. res2.Infcode = res3.Infcode
  26180. } else {
  26181. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26182. utils.ErrorLog("解析失败:%v", err)
  26183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26184. return
  26185. }
  26186. }
  26187. }
  26188. }
  26189. }
  26190. if res2.Infcode == -1 {
  26191. adminUser := c.GetAdminUserInfo()
  26192. errlog := &models.HisOrderError{
  26193. UserOrgId: adminUser.CurrentOrgId,
  26194. Ctime: time.Now().Unix(),
  26195. Mtime: time.Now().Unix(),
  26196. ErrMsg: res2.ErrMsg,
  26197. Status: 1,
  26198. PatientId: id,
  26199. RecordTime: recordDateTime,
  26200. Stage: 3,
  26201. }
  26202. service.CreateErrMsgLog(errlog)
  26203. c.ServeSuccessJSON(map[string]interface{}{
  26204. "failed_code": -10,
  26205. "msg": res2.ErrMsg,
  26206. })
  26207. return
  26208. }
  26209. if res2.Infcode != 0 {
  26210. adminUser := c.GetAdminUserInfo()
  26211. errlog := &models.HisOrderError{
  26212. UserOrgId: adminUser.CurrentOrgId,
  26213. Ctime: time.Now().Unix(),
  26214. Mtime: time.Now().Unix(),
  26215. ErrMsg: res2.ErrMsg,
  26216. Status: 1,
  26217. PatientId: id,
  26218. RecordTime: recordDateTime,
  26219. Stage: 3,
  26220. }
  26221. service.CreateErrMsgLog(errlog)
  26222. c.ServeSuccessJSON(map[string]interface{}{
  26223. "failed_code": -10,
  26224. "msg": res2.ErrMsg,
  26225. })
  26226. return
  26227. } else {
  26228. his.Diagnosis = diagnosis_id
  26229. his.SickType = sickConfig.ID
  26230. his.PType = fmt.Sprintf("%d", reg_type)
  26231. service.UpdateHisPatientThree(&his)
  26232. data := make(map[string]interface{})
  26233. if settle_accounts_type == 1 { //日结
  26234. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  26235. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  26236. } else {
  26237. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  26238. }
  26239. data["pre"] = prescriptions
  26240. } else { //月结
  26241. start_time_str := c.GetString("start_time")
  26242. end_time_str := c.GetString("end_time")
  26243. timeLayout := "2006-01-02"
  26244. loc, _ := time.LoadLocation("Local")
  26245. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  26246. if err != nil {
  26247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26248. return
  26249. }
  26250. recordStartTime := theStartTime.Unix()
  26251. start_time = recordStartTime
  26252. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  26253. if err != nil {
  26254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26255. return
  26256. }
  26257. recordEndTime := theEndTime.Unix()
  26258. end_time = recordEndTime
  26259. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  26260. data["pre"] = prescriptions
  26261. }
  26262. client := &http.Client{}
  26263. data["psn_no"] = his.PsnNo
  26264. data["mdtrt_id"] = his.Number
  26265. data["chrg_bchno"] = new_chrg_bchno
  26266. data["org_name"] = miConfig.OrgName
  26267. data["doctor"] = doctor_info.UserName
  26268. data["doctor_id"] = doctor_info.DoctorNumber
  26269. data["dept"] = department.Name
  26270. data["fixmedins_code"] = miConfig.Code
  26271. data["opter"] = roles.UserName
  26272. data["dept_code"] = department.Number
  26273. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26274. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26275. data["secret_key"] = miConfig.SecretKey
  26276. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  26277. data["url"] = miConfig.Url
  26278. data["ak"] = miConfig.AccessKey
  26279. data["new_doctor_name"] = patientPrescription.Doctor
  26280. if his.Insutype == "390" {
  26281. if reg_type == 992102 {
  26282. data["diag_code"] = "ZDZ940"
  26283. }
  26284. if reg_type == 140104 {
  26285. data["diag_code"] = sickConfig.CountryCode
  26286. }
  26287. if reg_type == 14 {
  26288. data["diag_code"] = sickConfig.CountryCode
  26289. }
  26290. } else if his.Insutype == "310" {
  26291. if reg_type == 992102 {
  26292. data["diag_code"] = "ZDZ940"
  26293. }
  26294. if reg_type == 14 {
  26295. data["diag_code"] = sickConfig.CountryCode
  26296. }
  26297. }
  26298. data["cainfo"] = miConfig.Cainfo
  26299. data["opter"] = roles.UserName
  26300. var ids []int64
  26301. for _, item := range prescriptions {
  26302. ids = append(ids, item.ID)
  26303. }
  26304. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26305. if config.IsOpen == 1 { //对接了医保,走医保流程
  26306. var res ResultFour
  26307. var resFour10265 ResultFour10265
  26308. if miConfig.MdtrtareaAdmvs == "421300" {
  26309. bytesData, _ := json.Marshal(data)
  26310. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  26311. resp, _ := client.Do(req)
  26312. defer resp.Body.Close()
  26313. body, ioErr := ioutil.ReadAll(resp.Body)
  26314. if ioErr != nil {
  26315. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26317. return
  26318. }
  26319. var respJSON map[string]interface{}
  26320. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26323. return
  26324. }
  26325. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26326. userJSONBytes, _ := json.Marshal(respJSON)
  26327. fmt.Println("log")
  26328. fmt.Println(string(userJSONBytes))
  26329. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26330. utils.ErrorLog("解析失败:%v", err)
  26331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26332. return
  26333. }
  26334. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26335. bytesData, _ := json.Marshal(data)
  26336. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  26337. resp, _ := client.Do(req)
  26338. defer resp.Body.Close()
  26339. body, ioErr := ioutil.ReadAll(resp.Body)
  26340. if ioErr != nil {
  26341. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26343. return
  26344. }
  26345. var respJSON map[string]interface{}
  26346. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26347. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26349. return
  26350. }
  26351. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26352. userJSONBytes, _ := json.Marshal(respJSON)
  26353. fmt.Println("log")
  26354. fmt.Println(string(userJSONBytes))
  26355. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26356. utils.ErrorLog("解析失败:%v", err)
  26357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26358. return
  26359. }
  26360. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26361. bytesData, _ := json.Marshal(data)
  26362. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  26363. resp, _ := client.Do(req)
  26364. defer resp.Body.Close()
  26365. body, ioErr := ioutil.ReadAll(resp.Body)
  26366. if ioErr != nil {
  26367. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26369. return
  26370. }
  26371. var respJSON map[string]interface{}
  26372. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26373. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26375. return
  26376. }
  26377. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26378. userJSONBytes, _ := json.Marshal(respJSON)
  26379. fmt.Println("log")
  26380. fmt.Println(string(userJSONBytes))
  26381. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26382. utils.ErrorLog("解析失败:%v", err)
  26383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26384. return
  26385. }
  26386. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26387. bytesData, _ := json.Marshal(data)
  26388. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  26389. resp, _ := client.Do(req)
  26390. defer resp.Body.Close()
  26391. body, ioErr := ioutil.ReadAll(resp.Body)
  26392. if ioErr != nil {
  26393. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26395. return
  26396. }
  26397. var respJSON map[string]interface{}
  26398. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26401. return
  26402. }
  26403. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26404. userJSONBytes, _ := json.Marshal(respJSON)
  26405. fmt.Println("log")
  26406. fmt.Println(string(userJSONBytes))
  26407. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26408. utils.ErrorLog("解析失败:%v", err)
  26409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26410. return
  26411. }
  26412. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26413. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26414. if result3101.Infcode == "0" {
  26415. if len(result3101.Output.Result) > 0 {
  26416. var errMsgs []string
  26417. for _, item := range result3101.Output.Result {
  26418. errMsgs = append(errMsgs, item.VolaCont)
  26419. }
  26420. c.ServeSuccessJSON(map[string]interface{}{
  26421. "failed_code": -10,
  26422. "msg": errMsgs,
  26423. })
  26424. return
  26425. } else {
  26426. if miConfig.MdtrtareaAdmvs == "320921" {
  26427. data["doctor_id"] = "D320923012139"
  26428. } else {
  26429. data["doctor_id"] = "D371621008686"
  26430. }
  26431. bytesData, _ := json.Marshal(data)
  26432. var req *http.Request
  26433. if miConfig.MdtrtareaAdmvs == "320921" {
  26434. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26435. } else {
  26436. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26437. }
  26438. resp, _ := client.Do(req)
  26439. defer resp.Body.Close()
  26440. body, ioErr := ioutil.ReadAll(resp.Body)
  26441. if ioErr != nil {
  26442. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26444. return
  26445. }
  26446. var respJSON map[string]interface{}
  26447. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26448. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26450. return
  26451. }
  26452. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26453. userJSONBytes, _ := json.Marshal(respJSON)
  26454. fmt.Println("log")
  26455. fmt.Println(string(userJSONBytes))
  26456. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26457. utils.ErrorLog("解析失败:%v", err)
  26458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26459. return
  26460. }
  26461. res.InfRefmsgid = resFour10265.InfRefmsgid
  26462. res.Output = resFour10265.Output
  26463. res.ErrMsg = resFour10265.ErrMsg
  26464. res.Cainfo = resFour10265.Cainfo
  26465. res.WarnMsg = resFour10265.WarnMsg
  26466. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26467. res.Infcode = infocode
  26468. }
  26469. }
  26470. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26471. var pagesize int = 5
  26472. var start int = 1
  26473. var stop int
  26474. var pagecount int
  26475. var curpage int
  26476. data["doctor_id"] = doctor_info.DoctorNumber
  26477. var res2 ResultFour
  26478. //var result res.
  26479. //总页数,向上取整,注意除之前要先转换类型为float64
  26480. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  26481. for curpage = 1; curpage <= pagecount; curpage++ {
  26482. if curpage == 1 {
  26483. start = 1
  26484. } else {
  26485. start = (curpage-1)*pagesize + 1
  26486. }
  26487. stop = curpage * pagesize
  26488. if stop > len(prescriptions) {
  26489. stop = len(prescriptions)
  26490. }
  26491. //var requestLog string
  26492. data["pre"] = prescriptions[start-1 : stop]
  26493. fmt.Println(data["pre"])
  26494. bytesData, _ := json.Marshal(data)
  26495. var req *http.Request
  26496. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  26497. resp, _ := client.Do(req)
  26498. defer resp.Body.Close()
  26499. body, ioErr := ioutil.ReadAll(resp.Body)
  26500. if ioErr != nil {
  26501. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26503. return
  26504. }
  26505. var respJSON map[string]interface{}
  26506. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26509. return
  26510. }
  26511. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26512. userJSONBytes, _ := json.Marshal(respJSON)
  26513. fmt.Println("log")
  26514. fmt.Println(string(userJSONBytes))
  26515. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26516. utils.ErrorLog("解析失败:%v", err)
  26517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26518. return
  26519. }
  26520. res.InfRefmsgid = resFour10265.InfRefmsgid
  26521. res.Output = resFour10265.Output
  26522. res.ErrMsg = resFour10265.ErrMsg
  26523. res.Cainfo = resFour10265.Cainfo
  26524. res.WarnMsg = resFour10265.WarnMsg
  26525. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26526. res.Infcode = infocode
  26527. if infocode == 0 {
  26528. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  26529. } else {
  26530. isSuccess = false
  26531. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  26532. res.Infcode = -1
  26533. res.ErrMsg = resFour10265.ErrMsg
  26534. errlog := &models.HisOrderError{
  26535. UserOrgId: adminUser.CurrentOrgId,
  26536. Ctime: time.Now().Unix(),
  26537. Mtime: time.Now().Unix(),
  26538. Number: chrg_bchno,
  26539. ErrMsg: "",
  26540. Status: 1,
  26541. PatientId: id,
  26542. RecordTime: recordDateTime,
  26543. Stage: 4,
  26544. }
  26545. service.CreateErrMsgLog(errlog)
  26546. }
  26547. }
  26548. if isSuccess {
  26549. res.Infcode = 0
  26550. res.Output.Result = res2.Output.Result
  26551. } else {
  26552. order := &models.HisOrder{
  26553. UserOrgId: adminUser.CurrentOrgId,
  26554. HisPatientId: his.ID,
  26555. PatientId: his.PatientId,
  26556. SettleAccountsDate: recordDateTime,
  26557. Ctime: time.Now().Unix(),
  26558. Mtime: time.Now().Unix(),
  26559. MdtrtId: his.Number,
  26560. PsnNo: his.PsnNo,
  26561. MedType: strconv.FormatInt(reg_type, 10),
  26562. Status: 1,
  26563. Number: chrg_bchno,
  26564. Infcode: res.Infcode,
  26565. WarnMsg: res.WarnMsg,
  26566. Cainfo: res.Cainfo,
  26567. ErrMsg: res.ErrMsg,
  26568. RespondTime: res.RefmsgTime,
  26569. InfRefmsgid: res.InfRefmsgid,
  26570. OrderStatus: 1,
  26571. IsMedicineInsurance: 1,
  26572. SettleType: settle_accounts_type,
  26573. SettleStartTime: start_time,
  26574. SettleEndTime: end_time,
  26575. Creator: roles.AdminUserId,
  26576. Modify: roles.AdminUserId,
  26577. PType: 2,
  26578. Diagnosis: diagnosis_id,
  26579. }
  26580. err = service.CreateOrder(order)
  26581. if err != nil {
  26582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  26583. return
  26584. }
  26585. c.ServeSuccessJSON(map[string]interface{}{
  26586. "failed_code": -10,
  26587. "msg": res2.ErrMsg,
  26588. })
  26589. return
  26590. }
  26591. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26592. 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)
  26593. var dat map[string]interface{}
  26594. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26595. fmt.Println(dat)
  26596. } else {
  26597. fmt.Println(err)
  26598. }
  26599. saveLog(result, request_log, "2204", "上传费用明细")
  26600. userJSONBytes, _ := json.Marshal(dat)
  26601. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26602. utils.ErrorLog("解析失败:%v", err)
  26603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26604. return
  26605. }
  26606. } else if miConfig.MdtrtareaAdmvs == "360302" {
  26607. 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, "", "")
  26608. var dat map[string]interface{}
  26609. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26610. fmt.Println(dat)
  26611. } else {
  26612. fmt.Println(err)
  26613. }
  26614. saveLog(result, request_log, "2204", "上传费用明细")
  26615. userJSONBytes, _ := json.Marshal(dat)
  26616. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26617. utils.ErrorLog("解析失败:%v", err)
  26618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26619. return
  26620. }
  26621. } else if miConfig.MdtrtareaAdmvs == "341203" {
  26622. bytesData, _ := json.Marshal(data)
  26623. var req *http.Request
  26624. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  26625. resp, _ := client.Do(req)
  26626. defer resp.Body.Close()
  26627. body, ioErr := ioutil.ReadAll(resp.Body)
  26628. if ioErr != nil {
  26629. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26631. return
  26632. }
  26633. var respJSON map[string]interface{}
  26634. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26635. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26637. return
  26638. }
  26639. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26640. if status == "0" {
  26641. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26642. c.ServeSuccessJSON(map[string]interface{}{
  26643. "failed_code": -10,
  26644. "msg": err_msg,
  26645. })
  26646. return
  26647. }
  26648. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26649. userJSONBytes, _ := json.Marshal(respJSON)
  26650. fmt.Println("log")
  26651. fmt.Println(string(userJSONBytes))
  26652. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26653. utils.ErrorLog("解析失败:%v", err)
  26654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26655. return
  26656. }
  26657. } else if miConfig.MdtrtareaAdmvs == "430800" {
  26658. 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, "", "")
  26659. var dat map[string]interface{}
  26660. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26661. fmt.Println(dat)
  26662. } else {
  26663. fmt.Println(err)
  26664. }
  26665. saveLog(result, request_log, "2204", "上传费用明细")
  26666. userJSONBytes, _ := json.Marshal(dat)
  26667. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26668. utils.ErrorLog("解析失败:%v", err)
  26669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26670. return
  26671. }
  26672. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26673. bytesData, _ := json.Marshal(data)
  26674. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  26675. resp, _ := client.Do(req)
  26676. defer resp.Body.Close()
  26677. body, ioErr := ioutil.ReadAll(resp.Body)
  26678. if ioErr != nil {
  26679. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26681. return
  26682. }
  26683. var respJSON map[string]interface{}
  26684. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26685. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26687. return
  26688. }
  26689. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26690. userJSONBytes, _ := json.Marshal(respJSON)
  26691. fmt.Println("log")
  26692. fmt.Println(string(userJSONBytes))
  26693. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26694. utils.ErrorLog("解析失败:%v", err)
  26695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26696. return
  26697. }
  26698. } else {
  26699. if miConfig.MdtrtareaAdmvs == "441202" {
  26700. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26701. if result3101.Infcode == 0 {
  26702. if len(result3101.Output.Result) > 0 {
  26703. var errMsgs []string
  26704. for _, item := range result3101.Output.Result {
  26705. errMsgs = append(errMsgs, item.VolaCont)
  26706. }
  26707. c.ServeSuccessJSON(map[string]interface{}{
  26708. "failed_code": -10,
  26709. "msg": errMsgs,
  26710. })
  26711. return
  26712. } else {
  26713. 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)
  26714. var dat map[string]interface{}
  26715. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26716. fmt.Println(dat)
  26717. } else {
  26718. fmt.Println(err)
  26719. }
  26720. saveLog(result, request_log, "2204", "上传费用明细")
  26721. userJSONBytes, _ := json.Marshal(dat)
  26722. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26723. utils.ErrorLog("解析失败:%v", err)
  26724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26725. return
  26726. }
  26727. }
  26728. } else {
  26729. c.ServeSuccessJSON(map[string]interface{}{
  26730. "failed_code": -10,
  26731. "msg": result3101.ErrMsg,
  26732. })
  26733. return
  26734. }
  26735. } else if miConfig.MdtrtareaAdmvs == "440205" {
  26736. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26737. if result3101.Infcode == 0 {
  26738. if len(result3101.Output.Result) > 0 {
  26739. var errMsgs []string
  26740. for _, item := range result3101.Output.Result {
  26741. errMsgs = append(errMsgs, item.VolaCont)
  26742. }
  26743. c.ServeSuccessJSON(map[string]interface{}{
  26744. "failed_code": -10,
  26745. "msg": errMsgs,
  26746. })
  26747. return
  26748. } else {
  26749. 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)
  26750. var dat map[string]interface{}
  26751. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26752. fmt.Println(dat)
  26753. } else {
  26754. fmt.Println(err)
  26755. }
  26756. saveLog(result, request_log, "2204", "上传费用明细")
  26757. userJSONBytes, _ := json.Marshal(dat)
  26758. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26759. utils.ErrorLog("解析失败:%v", err)
  26760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26761. return
  26762. }
  26763. }
  26764. } else {
  26765. c.ServeSuccessJSON(map[string]interface{}{
  26766. "failed_code": -10,
  26767. "msg": result3101.ErrMsg,
  26768. })
  26769. return
  26770. }
  26771. } else {
  26772. if miConfig.Code == "H15049901371" {
  26773. 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)
  26774. var dat map[string]interface{}
  26775. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26776. fmt.Println(dat)
  26777. } else {
  26778. fmt.Println(err)
  26779. }
  26780. saveLog(result, request_log, "2204", "上传费用明细")
  26781. userJSONBytes, _ := json.Marshal(dat)
  26782. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26783. utils.ErrorLog("解析失败:%v", err)
  26784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26785. return
  26786. }
  26787. res.InfRefmsgid = resFour10265.InfRefmsgid
  26788. res.Output = resFour10265.Output
  26789. res.ErrMsg = resFour10265.ErrMsg
  26790. res.Cainfo = resFour10265.Cainfo
  26791. res.WarnMsg = resFour10265.WarnMsg
  26792. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26793. res.Infcode = infocode
  26794. } else {
  26795. 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)
  26796. var dat map[string]interface{}
  26797. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26798. fmt.Println(dat)
  26799. } else {
  26800. fmt.Println(err)
  26801. }
  26802. saveLog(result, request_log, "2204", "上传费用明细")
  26803. userJSONBytes, _ := json.Marshal(dat)
  26804. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26805. utils.ErrorLog("解析失败:%v", err)
  26806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26807. return
  26808. }
  26809. }
  26810. }
  26811. }
  26812. var total_two float64
  26813. if res.Infcode == -1 {
  26814. errlog := &models.HisOrderError{
  26815. UserOrgId: adminUser.CurrentOrgId,
  26816. Ctime: time.Now().Unix(),
  26817. Mtime: time.Now().Unix(),
  26818. Number: chrg_bchno,
  26819. ErrMsg: res.ErrMsg,
  26820. Status: 1,
  26821. PatientId: id,
  26822. RecordTime: recordDateTime,
  26823. Stage: 4,
  26824. }
  26825. service.CreateErrMsgLog(errlog)
  26826. c.ServeSuccessJSON(map[string]interface{}{
  26827. "failed_code": -10,
  26828. "msg": res.ErrMsg,
  26829. })
  26830. return
  26831. }
  26832. if res.Infcode == 0 {
  26833. order := &models.HisOrder{
  26834. UserOrgId: adminUser.CurrentOrgId,
  26835. HisPatientId: his.ID,
  26836. PatientId: his.PatientId,
  26837. SettleAccountsDate: recordDateTime,
  26838. Ctime: time.Now().Unix(),
  26839. Mtime: time.Now().Unix(),
  26840. MdtrtId: his.Number,
  26841. PsnNo: his.PsnNo,
  26842. MedType: strconv.FormatInt(reg_type, 10),
  26843. Status: 1,
  26844. Number: chrg_bchno,
  26845. Infcode: res.Infcode,
  26846. WarnMsg: res.WarnMsg,
  26847. Cainfo: res.Cainfo,
  26848. ErrMsg: res.ErrMsg,
  26849. RespondTime: res.RefmsgTime,
  26850. InfRefmsgid: res.InfRefmsgid,
  26851. OrderStatus: 1,
  26852. IsMedicineInsurance: 1,
  26853. SettleType: settle_accounts_type,
  26854. SettleStartTime: start_time,
  26855. SettleEndTime: end_time,
  26856. Creator: roles.AdminUserId,
  26857. Modify: roles.AdminUserId,
  26858. PType: 2,
  26859. Diagnosis: diagnosis_id,
  26860. }
  26861. err = service.CreateOrder(order)
  26862. if err != nil {
  26863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  26864. return
  26865. }
  26866. for _, item := range res.Output.Result {
  26867. temp := strings.Split(item.FeedetlSn, "-")
  26868. var advice_id int64 = 0
  26869. var project_id int64 = 0
  26870. var types int64 = 0
  26871. id, _ := strconv.ParseInt(temp[2], 10, 64)
  26872. types, _ = strconv.ParseInt(temp[1], 10, 64)
  26873. if temp[1] == "1" {
  26874. advice_id = id
  26875. project_id = 0
  26876. } else if temp[1] == "2" {
  26877. advice_id = 0
  26878. project_id = id
  26879. }
  26880. total_two = total_two + item.DetItemFeeSumamt
  26881. info := &models.HisOrderInfo{
  26882. OrderNumber: order.Number,
  26883. FeedetlSn: item.FeedetlSn,
  26884. UploadDate: time.Now().Unix(),
  26885. AdviceId: advice_id,
  26886. DetItemFeeSumamt: item.DetItemFeeSumamt,
  26887. Cnt: item.Cnt,
  26888. Pric: float64(item.Pric),
  26889. PatientId: his.PatientId,
  26890. PricUplmtAmt: item.PricUplmtAmt,
  26891. SelfpayProp: item.SelfpayProp,
  26892. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  26893. OverlmtAmt: item.OverlmtAmt,
  26894. PreselfpayAmt: item.PreselfpayAmt,
  26895. BasMednFlag: item.BasMednFlag,
  26896. MedChrgitmType: item.MedChrgitmType,
  26897. HiNegoDrugFlag: item.HiNegoDrugFlag,
  26898. Status: 1,
  26899. Memo: item.Memo,
  26900. Mtime: time.Now().Unix(),
  26901. InscpScpAmt: item.InscpScpAmt,
  26902. DrtReimFlag: item.DrtReimFlag,
  26903. Ctime: time.Now().Unix(),
  26904. ListSpItemFlag: item.ListSpItemFlag,
  26905. ChldMedcFlag: item.ChldMedcFlag,
  26906. LmtUsedFlag: item.LmtUsedFlag,
  26907. ChrgitmLv: item.ChrgitmLv,
  26908. UserOrgId: adminUser.CurrentOrgId,
  26909. HisPatientId: his.ID,
  26910. OrderId: order.ID,
  26911. ProjectId: project_id,
  26912. Type: types,
  26913. }
  26914. service.CreateOrderInfo(info)
  26915. }
  26916. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  26917. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  26918. var total float64
  26919. for _, item := range prescriptions {
  26920. if item.Type == 1 { //药品
  26921. for _, subItem := range item.HisDoctorAdviceInfo {
  26922. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  26923. total_one := price * subItem.PrescribingNumber
  26924. fmt.Println("subItem")
  26925. fmt.Println(subItem.Price)
  26926. fmt.Println("price")
  26927. fmt.Println(price)
  26928. fmt.Println("total_one")
  26929. fmt.Println(total_one)
  26930. total = total + total_one
  26931. fmt.Println(total)
  26932. }
  26933. }
  26934. if item.Type == 2 { //项目
  26935. for _, subItem := range item.HisPrescriptionProject {
  26936. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  26937. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  26938. total_one := price * cnt
  26939. total = total + total_one
  26940. }
  26941. }
  26942. }
  26943. allTotal := fmt.Sprintf("%.2f", total)
  26944. if res.Infcode == 0 {
  26945. var rf []*ResultFive
  26946. json.Unmarshal([]byte(his.Iinfo), &rf)
  26947. chrg_bchno := chrg_bchno
  26948. cert_no := his.Certno
  26949. var insutypes []string
  26950. var insutype string
  26951. var is390 int = 0
  26952. var is310 int = 0
  26953. for _, item := range rf {
  26954. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26955. insutypes = append(insutypes, item.Insutype)
  26956. }
  26957. }
  26958. if len(insutypes) == 1 {
  26959. insutype = insutypes[0]
  26960. } else {
  26961. for _, i := range insutypes {
  26962. if i == "390" {
  26963. is390 = 1
  26964. }
  26965. if i == "310" {
  26966. is310 = 1
  26967. }
  26968. }
  26969. }
  26970. if is390 == 1 {
  26971. insutype = "390"
  26972. }
  26973. if is310 == 1 {
  26974. insutype = "310"
  26975. }
  26976. if len(insutypes) == 0 {
  26977. insutype = "390"
  26978. }
  26979. if len(insutypes) == 2 {
  26980. insutype = strconv.FormatInt(his.SocialType, 10)
  26981. }
  26982. //insutype = "390"
  26983. if his.IdCardType == 1 {
  26984. cert_no = his.MedicalInsuranceNumber
  26985. } else {
  26986. cert_no = his.Certno
  26987. }
  26988. var res ResultSeven
  26989. var ahres ResultSevenAH
  26990. var resSeven10265 ResultSeven10265
  26991. var resSeven10265Two ResultSeven10265Two
  26992. var gzresSeven10265Two GZResultSeven10265Two
  26993. if miConfig.MdtrtareaAdmvs == "421300" {
  26994. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  26995. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26996. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26997. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26998. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26999. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27000. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27001. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  27002. resp, requestErr := http.Get(api)
  27003. if requestErr != nil {
  27004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27005. return
  27006. }
  27007. body, ioErr := ioutil.ReadAll(resp.Body)
  27008. if ioErr != nil {
  27009. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27011. return
  27012. }
  27013. var respJSON map[string]interface{}
  27014. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27017. return
  27018. }
  27019. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27020. result, _ := json.Marshal(respJSON)
  27021. fmt.Println("log")
  27022. fmt.Println(string(result))
  27023. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27024. utils.ErrorLog("解析失败:%v", err)
  27025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27026. return
  27027. }
  27028. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27029. if reg_type == 11 && his.Insutype == "390" {
  27030. reg_type = 110104
  27031. }
  27032. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27033. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27034. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27035. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27036. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27037. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27038. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  27039. resp, requestErr := http.Get(api)
  27040. if requestErr != nil {
  27041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27042. return
  27043. }
  27044. body, ioErr := ioutil.ReadAll(resp.Body)
  27045. if ioErr != nil {
  27046. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27048. return
  27049. }
  27050. var respJSON map[string]interface{}
  27051. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27052. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27054. return
  27055. }
  27056. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27057. result, _ := json.Marshal(respJSON)
  27058. fmt.Println("log")
  27059. fmt.Println(string(result))
  27060. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27061. utils.ErrorLog("解析失败:%v", err)
  27062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27063. return
  27064. }
  27065. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27066. if reg_type == 11 && his.Insutype == "390" {
  27067. reg_type = 110104
  27068. }
  27069. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27070. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27071. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27072. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27073. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27074. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27075. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  27076. resp, requestErr := http.Get(api)
  27077. if requestErr != nil {
  27078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27079. return
  27080. }
  27081. body, ioErr := ioutil.ReadAll(resp.Body)
  27082. if ioErr != nil {
  27083. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27085. return
  27086. }
  27087. var respJSON map[string]interface{}
  27088. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27089. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27091. return
  27092. }
  27093. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27094. result, _ := json.Marshal(respJSON)
  27095. fmt.Println("log")
  27096. fmt.Println(string(result))
  27097. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27098. utils.ErrorLog("解析失败:%v", err)
  27099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27100. return
  27101. }
  27102. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27103. if reg_type == 11 && his.Insutype == "390" {
  27104. reg_type = 110104
  27105. }
  27106. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27107. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27108. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27109. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27110. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27111. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27112. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  27113. resp, requestErr := http.Get(api)
  27114. if requestErr != nil {
  27115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27116. return
  27117. }
  27118. body, ioErr := ioutil.ReadAll(resp.Body)
  27119. if ioErr != nil {
  27120. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27122. return
  27123. }
  27124. var respJSON map[string]interface{}
  27125. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27128. return
  27129. }
  27130. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27131. result, _ := json.Marshal(respJSON)
  27132. fmt.Println("log")
  27133. fmt.Println(string(result))
  27134. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27135. utils.ErrorLog("解析失败:%v", err)
  27136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27137. return
  27138. }
  27139. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27140. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  27141. if result3101.Infcode == "0" {
  27142. if len(result3101.Output.Result) > 0 {
  27143. var errMsgs []string
  27144. for _, item := range result3101.Output.Result {
  27145. errMsgs = append(errMsgs, item.VolaCont)
  27146. }
  27147. c.ServeSuccessJSON(map[string]interface{}{
  27148. "failed_code": -10,
  27149. "msg": errMsgs,
  27150. })
  27151. return
  27152. } else {
  27153. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27154. if his.IdCardType != 4 {
  27155. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27156. bas := strings.Split(psn_info.CardInfo, "|")
  27157. if his.IdCardType == 1 {
  27158. cert_no = bas[2]
  27159. } else {
  27160. cert_no = bas[1]
  27161. }
  27162. } else {
  27163. cert_no = his.Certno
  27164. }
  27165. //江苏地区国家医保医疗类别
  27166. //职工透析:医疗类别选特殊情况门诊9933
  27167. //居民血透门慢: 医疗类别选门诊慢病1402
  27168. //var med_type string
  27169. //if his.Insutype == "310" {
  27170. // if reg_type == 14 {
  27171. // med_type = "9933"
  27172. // } else if reg_type == 11 {
  27173. // med_type = "11"
  27174. //
  27175. // }
  27176. //} else if his.Insutype == "390" {
  27177. // if reg_type == 14 {
  27178. // med_type = "1402"
  27179. // } else if reg_type == 11 {
  27180. // med_type = "11"
  27181. // }
  27182. //}
  27183. var api string
  27184. if miConfig.MdtrtareaAdmvs == "320921" {
  27185. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27186. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27187. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27188. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27189. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27190. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27191. "&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
  27192. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27193. } else {
  27194. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27195. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27196. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27197. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27198. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27199. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27200. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27201. "&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
  27202. }
  27203. resp, requestErr := http.Get(api)
  27204. if requestErr != nil {
  27205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27206. return
  27207. }
  27208. body, ioErr := ioutil.ReadAll(resp.Body)
  27209. if ioErr != nil {
  27210. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27212. return
  27213. }
  27214. var respJSON map[string]interface{}
  27215. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27218. return
  27219. }
  27220. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27221. result, _ := json.Marshal(respJSON)
  27222. fmt.Println("log")
  27223. fmt.Println(string(result))
  27224. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  27225. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27226. utils.ErrorLog("解析失败:%v", err)
  27227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27228. return
  27229. }
  27230. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27231. res.Output = resSeven10265.Output
  27232. res.ErrMsg = resSeven10265.ErrMsg
  27233. res.Cainfo = resSeven10265.Cainfo
  27234. res.WarnMsg = resSeven10265.WarnMsg
  27235. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27236. res.Infcode = infocode
  27237. } else {
  27238. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  27239. utils.ErrorLog("解析失败:%v", err)
  27240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27241. return
  27242. }
  27243. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  27244. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  27245. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  27246. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  27247. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  27248. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  27249. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  27250. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  27251. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  27252. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  27253. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  27254. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  27255. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  27256. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  27257. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  27258. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27259. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  27260. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  27261. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  27262. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  27263. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  27264. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27265. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  27266. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  27267. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  27268. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  27269. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  27270. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  27271. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  27272. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  27273. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27274. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  27275. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  27276. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  27277. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27278. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27279. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27280. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27281. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  27282. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  27283. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  27284. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  27285. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  27286. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  27287. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  27288. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  27289. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  27290. res.ErrMsg = resSeven10265Two.ErrMsg
  27291. res.Cainfo = resSeven10265Two.Cainfo
  27292. res.WarnMsg = resSeven10265Two.WarnMsg
  27293. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27294. res.Infcode = infocode
  27295. }
  27296. }
  27297. }
  27298. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27299. psn_info, _ := service.GetPsnByPatientId(id)
  27300. var verify_number string
  27301. if psn_info.IdCardType == 4 {
  27302. verify_number = psn_info.VerifyNumber
  27303. } else if psn_info.IdCardType == 1 {
  27304. bas := strings.Split(psn_info.CardInfo, "|")
  27305. cardNumber := bas[2]
  27306. verify_number = cardNumber
  27307. } else {
  27308. psn_info.IdCardType = 2
  27309. verify_number = psn_info.Certno
  27310. }
  27311. var api string
  27312. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27313. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  27314. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27315. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27316. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27317. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27318. "&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
  27319. resp, requestErr := http.Get(api)
  27320. if requestErr != nil {
  27321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27322. return
  27323. }
  27324. body, ioErr := ioutil.ReadAll(resp.Body)
  27325. if ioErr != nil {
  27326. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27328. return
  27329. }
  27330. var respJSON map[string]interface{}
  27331. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27332. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27334. return
  27335. }
  27336. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27337. result, _ := json.Marshal(respJSON)
  27338. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27339. utils.ErrorLog("解析失败:%v", err)
  27340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27341. return
  27342. }
  27343. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27344. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  27345. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  27346. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  27347. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  27348. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  27349. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  27350. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  27351. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  27352. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  27353. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  27354. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  27355. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  27356. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  27357. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  27358. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  27359. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  27360. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  27361. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  27362. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  27363. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27364. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  27365. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  27366. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  27367. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  27368. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  27369. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  27370. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  27371. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  27372. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  27373. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  27374. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  27375. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  27376. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  27377. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27378. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  27379. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  27380. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  27381. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  27382. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  27383. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  27384. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  27385. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  27386. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  27387. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  27388. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  27389. res.ErrMsg = resSeven10265.ErrMsg
  27390. res.Cainfo = resSeven10265.Cainfo
  27391. res.WarnMsg = resSeven10265.WarnMsg
  27392. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27393. res.Infcode = infocode
  27394. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27395. acct_used_flag := "1"
  27396. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  27397. var result string
  27398. var request_log string
  27399. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  27400. 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)
  27401. } else {
  27402. 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)
  27403. }
  27404. var dat map[string]interface{}
  27405. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27406. fmt.Println(dat)
  27407. } else {
  27408. fmt.Println(err)
  27409. }
  27410. saveLog(result, request_log, "2206", "预结算")
  27411. userJSONBytes, _ := json.Marshal(dat)
  27412. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27413. utils.ErrorLog("解析失败:%v", err)
  27414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27415. return
  27416. }
  27417. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27418. var result string
  27419. var request_log string
  27420. if his.IdCardType == 2 {
  27421. 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, "")
  27422. } else if his.IdCardType == 1 {
  27423. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27424. bas := strings.Split(psn_info.CardInfo, "|")
  27425. basNumber := bas[2]
  27426. card_sn := bas[3]
  27427. var rf []*ResultFive
  27428. json.Unmarshal([]byte(his.Iinfo), &rf)
  27429. var psn_type string
  27430. for _, item := range rf {
  27431. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27432. psn_type = item.PsnType
  27433. }
  27434. }
  27435. 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)
  27436. } else {
  27437. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27438. //bas := strings.Split(psn_info.CardInfo, "|")
  27439. //basNumber := bas[2]
  27440. //card_sn := bas[3]
  27441. var rf []*ResultFive
  27442. json.Unmarshal([]byte(his.Iinfo), &rf)
  27443. var psn_type string
  27444. for _, item := range rf {
  27445. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27446. psn_type = item.PsnType
  27447. }
  27448. }
  27449. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27450. 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)
  27451. }
  27452. var dat map[string]interface{}
  27453. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27454. fmt.Println(dat)
  27455. } else {
  27456. fmt.Println(err)
  27457. }
  27458. saveLog(result, request_log, "2206", "预结算")
  27459. userJSONBytes, _ := json.Marshal(dat)
  27460. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27461. utils.ErrorLog("解析失败:%v", err)
  27462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27463. return
  27464. }
  27465. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27466. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27467. if his.IdCardType == 4 {
  27468. psn_info.VerifyNumber = psn_info.VerifyNumber
  27469. cert_no = psn_info.Certno
  27470. } else if his.IdCardType == 2 {
  27471. cert_no = psn_info.Certno
  27472. psn_info.VerifyNumber = psn_info.Certno
  27473. } else {
  27474. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27475. bas := strings.Split(psn_info.CardInfo, "|")
  27476. if his.IdCardType == 1 {
  27477. cert_no = bas[2]
  27478. } else {
  27479. cert_no = bas[1]
  27480. }
  27481. }
  27482. var api string
  27483. var med_type string
  27484. if his.Insutype == "390" {
  27485. if reg_type == 992102 {
  27486. med_type = "992102"
  27487. }
  27488. if reg_type == 140104 {
  27489. med_type = "140104"
  27490. }
  27491. if reg_type == 14 {
  27492. med_type = "140104"
  27493. }
  27494. } else if his.Insutype == "310" {
  27495. if reg_type == 992102 {
  27496. med_type = "992102"
  27497. }
  27498. if reg_type == 14 {
  27499. med_type = "14"
  27500. }
  27501. }
  27502. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27503. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27504. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27505. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27506. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27507. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27508. "&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
  27509. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27510. resp, requestErr := http.Get(api)
  27511. if requestErr != nil {
  27512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27513. return
  27514. }
  27515. body, ioErr := ioutil.ReadAll(resp.Body)
  27516. if ioErr != nil {
  27517. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27519. return
  27520. }
  27521. var respJSON map[string]interface{}
  27522. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27523. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27525. return
  27526. }
  27527. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27528. if status == "0" {
  27529. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27530. c.ServeSuccessJSON(map[string]interface{}{
  27531. "failed_code": -10,
  27532. "msg": err_msg,
  27533. })
  27534. return
  27535. }
  27536. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27537. result, _ := json.Marshal(respJSON)
  27538. fmt.Println("log")
  27539. fmt.Println(string(result))
  27540. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  27541. utils.ErrorLog("解析失败:%v", err)
  27542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27543. return
  27544. }
  27545. res.InfRefmsgid = ahres.InfRefmsgid
  27546. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27547. // 创建对应的Time类型
  27548. t := time.UnixMilli(timestamp)
  27549. // 格式化成指定的日期字符串
  27550. str := t.Format("2006-01-02 15:04:05")
  27551. res.Output.Setlinfo.SetlTime = str
  27552. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27553. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27554. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27555. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27556. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27557. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27558. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27559. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27560. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27561. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  27562. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27563. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27564. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27565. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27566. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27567. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27568. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27569. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27570. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27571. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27572. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27573. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27574. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27575. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27576. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27577. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27578. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27579. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27580. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27581. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27582. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27583. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27584. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27585. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27586. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27587. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27588. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27589. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27590. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27591. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27592. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27593. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27594. //res.Output.Setldetail = ahres.Output.Setldetail
  27595. res.ErrMsg = ahres.ErrMsg
  27596. res.Cainfo = ahres.Cainfo
  27597. res.WarnMsg = ahres.WarnMsg
  27598. res.Infcode = ahres.Infcode
  27599. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27600. var result string
  27601. var request_log string
  27602. if his.IdCardType == 2 {
  27603. 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")
  27604. } else if his.IdCardType == 1 {
  27605. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27606. bas := strings.Split(psn_info.CardInfo, "|")
  27607. basNumber := bas[2]
  27608. card_sn := bas[3]
  27609. 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")
  27610. } else {
  27611. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27612. 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")
  27613. }
  27614. var dat map[string]interface{}
  27615. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27616. fmt.Println(dat)
  27617. } else {
  27618. fmt.Println(err)
  27619. }
  27620. saveLog(result, request_log, "2206", "预结算")
  27621. userJSONBytes, _ := json.Marshal(dat)
  27622. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27623. utils.ErrorLog("解析失败:%v", err)
  27624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27625. return
  27626. }
  27627. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27628. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27629. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27630. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27631. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27632. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27633. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27634. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  27635. resp, requestErr := http.Get(api)
  27636. if requestErr != nil {
  27637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27638. return
  27639. }
  27640. body, ioErr := ioutil.ReadAll(resp.Body)
  27641. if ioErr != nil {
  27642. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27644. return
  27645. }
  27646. var respJSON map[string]interface{}
  27647. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27648. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27650. return
  27651. }
  27652. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27653. result, _ := json.Marshal(respJSON)
  27654. fmt.Println("log")
  27655. fmt.Println(string(result))
  27656. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27657. utils.ErrorLog("解析失败:%v", err)
  27658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27659. return
  27660. }
  27661. } else {
  27662. if miConfig.MdtrtareaAdmvs == "441202" {
  27663. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  27664. if result3101.Infcode == 0 {
  27665. if len(result3101.Output.Result) > 0 {
  27666. var errMsgs []string
  27667. for _, item := range result3101.Output.Result {
  27668. errMsgs = append(errMsgs, item.VolaCont)
  27669. }
  27670. c.ServeSuccessJSON(map[string]interface{}{
  27671. "failed_code": -10,
  27672. "msg": errMsgs,
  27673. })
  27674. return
  27675. } else {
  27676. var result string
  27677. var request_log string
  27678. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27679. allTotal = fmt.Sprintf("%.2f", total_two)
  27680. if his.IdCardType == 4 {
  27681. 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)
  27682. } else {
  27683. 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)
  27684. }
  27685. var dat map[string]interface{}
  27686. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27687. fmt.Println(dat)
  27688. } else {
  27689. fmt.Println(err)
  27690. }
  27691. saveLog(result, request_log, "2206", "预结算")
  27692. //userJSONBytes, _ := json.Marshal(dat)
  27693. //
  27694. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27695. // utils.ErrorLog("解析失败:%v", err)
  27696. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27697. // return
  27698. //}
  27699. userJSONBytes, _ := json.Marshal(dat)
  27700. if miConfig.Code == "H15049901371" {
  27701. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27702. utils.ErrorLog("解析失败:%v", err)
  27703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27704. return
  27705. }
  27706. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27707. res.Output = resSeven10265.Output
  27708. res.ErrMsg = resSeven10265.ErrMsg
  27709. res.Cainfo = resSeven10265.Cainfo
  27710. res.WarnMsg = resSeven10265.WarnMsg
  27711. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27712. res.Infcode = infocode
  27713. } else {
  27714. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27715. utils.ErrorLog("解析失败:%v", err)
  27716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27717. return
  27718. }
  27719. }
  27720. }
  27721. } else {
  27722. c.ServeSuccessJSON(map[string]interface{}{
  27723. "failed_code": -10,
  27724. "msg": result3101.ErrMsg,
  27725. })
  27726. return
  27727. }
  27728. } else if miConfig.MdtrtareaAdmvs == "440205" {
  27729. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  27730. if result3101.Infcode == 0 {
  27731. if len(result3101.Output.Result) > 0 {
  27732. var errMsgs []string
  27733. for _, item := range result3101.Output.Result {
  27734. errMsgs = append(errMsgs, item.VolaCont)
  27735. }
  27736. c.ServeSuccessJSON(map[string]interface{}{
  27737. "failed_code": -10,
  27738. "msg": errMsgs,
  27739. })
  27740. return
  27741. } else {
  27742. var result string
  27743. var request_log string
  27744. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27745. allTotal = fmt.Sprintf("%.2f", total_two)
  27746. if his.IdCardType == 4 {
  27747. 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)
  27748. } else {
  27749. 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)
  27750. }
  27751. var dat map[string]interface{}
  27752. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27753. fmt.Println(dat)
  27754. } else {
  27755. fmt.Println(err)
  27756. }
  27757. saveLog(result, request_log, "2206", "预结算")
  27758. //userJSONBytes, _ := json.Marshal(dat)
  27759. //
  27760. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27761. // utils.ErrorLog("解析失败:%v", err)
  27762. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27763. // return
  27764. //}
  27765. userJSONBytes, _ := json.Marshal(dat)
  27766. if miConfig.Code == "H15049901371" {
  27767. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27768. utils.ErrorLog("解析失败:%v", err)
  27769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27770. return
  27771. }
  27772. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27773. res.Output = resSeven10265.Output
  27774. res.ErrMsg = resSeven10265.ErrMsg
  27775. res.Cainfo = resSeven10265.Cainfo
  27776. res.WarnMsg = resSeven10265.WarnMsg
  27777. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27778. res.Infcode = infocode
  27779. } else {
  27780. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27781. utils.ErrorLog("解析失败:%v", err)
  27782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27783. return
  27784. }
  27785. }
  27786. }
  27787. } else {
  27788. c.ServeSuccessJSON(map[string]interface{}{
  27789. "failed_code": -10,
  27790. "msg": result3101.ErrMsg,
  27791. })
  27792. return
  27793. }
  27794. } else {
  27795. var result string
  27796. var request_log string
  27797. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27798. allTotal = fmt.Sprintf("%.2f", total_two)
  27799. if his.IdCardType == 4 {
  27800. 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)
  27801. } else {
  27802. 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)
  27803. }
  27804. var dat map[string]interface{}
  27805. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27806. fmt.Println(dat)
  27807. } else {
  27808. fmt.Println(err)
  27809. }
  27810. saveLog(result, request_log, "2206", "预结算")
  27811. //userJSONBytes, _ := json.Marshal(dat)
  27812. //
  27813. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27814. // utils.ErrorLog("解析失败:%v", err)
  27815. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27816. // return
  27817. //}
  27818. userJSONBytes, _ := json.Marshal(dat)
  27819. if miConfig.Code == "H15049901371" {
  27820. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27821. utils.ErrorLog("解析失败:%v", err)
  27822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27823. return
  27824. }
  27825. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27826. res.Output = resSeven10265.Output
  27827. res.ErrMsg = resSeven10265.ErrMsg
  27828. res.Cainfo = resSeven10265.Cainfo
  27829. res.WarnMsg = resSeven10265.WarnMsg
  27830. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27831. res.Infcode = infocode
  27832. } else {
  27833. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27834. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27835. utils.ErrorLog("解析失败:%v", err)
  27836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27837. return
  27838. }
  27839. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27840. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27841. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27842. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27843. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27844. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27845. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27846. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27847. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27848. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27849. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27850. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27851. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27852. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27853. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27854. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27855. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27856. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27857. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27858. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27859. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27860. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27861. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27862. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27863. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27864. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27865. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27866. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27867. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27868. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27869. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27870. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27871. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27872. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27873. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27874. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27875. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27876. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27877. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27878. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27879. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27880. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27881. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27882. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27883. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27884. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27885. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27886. res.Cainfo = gzresSeven10265Two.Cainfo
  27887. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27888. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27889. //res.Infcode = infocode
  27890. } else {
  27891. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27892. utils.ErrorLog("解析失败:%v", err)
  27893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27894. return
  27895. }
  27896. }
  27897. }
  27898. }
  27899. }
  27900. utils.ErrorLog("解析失败:%v", res.Infcode)
  27901. if res.Infcode == -1 {
  27902. errlog := &models.HisOrderError{
  27903. UserOrgId: adminUser.CurrentOrgId,
  27904. Ctime: time.Now().Unix(),
  27905. Mtime: time.Now().Unix(),
  27906. Number: chrg_bchno,
  27907. ErrMsg: res.ErrMsg,
  27908. Status: 1,
  27909. PatientId: id,
  27910. RecordTime: recordDateTime,
  27911. Stage: 20,
  27912. }
  27913. service.CreateErrMsgLog(errlog)
  27914. c.ServeSuccessJSON(map[string]interface{}{
  27915. "failed_code": -10,
  27916. "msg": res.ErrMsg,
  27917. })
  27918. return
  27919. }
  27920. if res.Infcode != 0 {
  27921. errlog := &models.HisOrderError{
  27922. UserOrgId: adminUser.CurrentOrgId,
  27923. Ctime: time.Now().Unix(),
  27924. Mtime: time.Now().Unix(),
  27925. Number: chrg_bchno,
  27926. ErrMsg: res.ErrMsg,
  27927. Status: 1,
  27928. PatientId: id,
  27929. RecordTime: recordDateTime,
  27930. Stage: 20,
  27931. }
  27932. service.CreateErrMsgLog(errlog)
  27933. c.ServeSuccessJSON(map[string]interface{}{
  27934. "failed_code": -10,
  27935. "msg": res.ErrMsg,
  27936. })
  27937. return
  27938. } else {
  27939. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27940. order.OrderStatus = 1
  27941. order.IsPre = 1
  27942. order.Status = 1
  27943. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27944. order.SetlId = res.Output.Setlinfo.SetlID
  27945. order.PsnNo = res.Output.Setlinfo.PsnNo
  27946. order.PsnName = res.Output.Setlinfo.PsnName
  27947. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27948. order.Certno = res.Output.Setlinfo.Certno
  27949. order.Gend = res.Output.Setlinfo.Gend
  27950. order.Naty = res.Output.Setlinfo.Naty
  27951. order.Age = res.Output.Setlinfo.Age
  27952. order.Insutype = res.Output.Setlinfo.Insutype
  27953. order.PsnType = res.Output.Setlinfo.PsnType
  27954. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  27955. order.SetlTime = res.Output.Setlinfo.SetlTime
  27956. order.AcctUsedFlag = acct_used_flag
  27957. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  27958. if res.Output.Setlinfo.MedType == "140101" {
  27959. order.MedType = "14"
  27960. } else {
  27961. if res.Output.Setlinfo.MedType == "110104" {
  27962. order.MedType = "11"
  27963. } else {
  27964. order.MedType = res.Output.Setlinfo.MedType
  27965. }
  27966. }
  27967. if res.Output.Setlinfo.MedType == "992102" {
  27968. order.MedType = "992102"
  27969. }
  27970. if res.Output.Setlinfo.MedType == "140104" {
  27971. order.MedType = "140104"
  27972. }
  27973. if res.Output.Setlinfo.MedType == "14" {
  27974. order.MedType = "14"
  27975. }
  27976. if reg_type == 1112 {
  27977. order.MedType = "1112"
  27978. }
  27979. if reg_type == 1111 {
  27980. order.MedType = "1111"
  27981. }
  27982. order.ClrType = res.Output.Setlinfo.ClrType
  27983. if adminUser.CurrentOrgId == 10480 {
  27984. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27985. order.ClrType = "11"
  27986. } else {
  27987. order.ClrType = "9903"
  27988. }
  27989. }
  27990. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  27991. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  27992. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  27993. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  27994. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  27995. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  27996. order.HifpPay = res.Output.Setlinfo.HifpPay
  27997. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  27998. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  27999. order.HifesPay = res.Output.Setlinfo.HifesPay
  28000. order.HifobPay = res.Output.Setlinfo.HifobPay
  28001. order.MafPay = res.Output.Setlinfo.MafPay
  28002. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  28003. order.OthPay = res.Output.Setlinfo.OthPay
  28004. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  28005. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  28006. order.AcctPay = res.Output.Setlinfo.AcctPay
  28007. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  28008. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  28009. order.Balc = res.Output.Setlinfo.Balc
  28010. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  28011. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  28012. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  28013. order.ClrWay = res.Output.Setlinfo.ClrWay
  28014. order.Creator = order.Creator
  28015. order.Modify = roles.AdminUserId
  28016. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  28017. //detailStr := string(setlDetail)
  28018. //order.SetlDetail = detailStr
  28019. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  28020. err = service.UpDateOrder(order)
  28021. if err == nil {
  28022. c.ServeSuccessJSON(map[string]interface{}{
  28023. "msg": "预结算成功",
  28024. })
  28025. } else {
  28026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  28027. return
  28028. }
  28029. }
  28030. } else {
  28031. adminUser := c.GetAdminUserInfo()
  28032. errlog := &models.HisOrderError{
  28033. UserOrgId: adminUser.CurrentOrgId,
  28034. Ctime: time.Now().Unix(),
  28035. Mtime: time.Now().Unix(),
  28036. ErrMsg: res.ErrMsg,
  28037. Status: 1,
  28038. PatientId: id,
  28039. RecordTime: recordDateTime,
  28040. Stage: 4,
  28041. }
  28042. service.CreateErrMsgLog(errlog)
  28043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  28044. return
  28045. }
  28046. } else {
  28047. if miConfig.MdtrtareaAdmvs == "150499" {
  28048. order := &models.HisOrder{
  28049. UserOrgId: adminUser.CurrentOrgId,
  28050. HisPatientId: his.ID,
  28051. PatientId: his.PatientId,
  28052. SettleAccountsDate: recordDateTime,
  28053. Ctime: time.Now().Unix(),
  28054. Mtime: time.Now().Unix(),
  28055. MdtrtId: his.Number,
  28056. PsnNo: his.PsnNo,
  28057. MedType: strconv.FormatInt(reg_type, 10),
  28058. Status: 1,
  28059. Number: chrg_bchno,
  28060. Infcode: res.Infcode,
  28061. WarnMsg: res.WarnMsg,
  28062. Cainfo: res.Cainfo,
  28063. ErrMsg: res.ErrMsg,
  28064. RespondTime: res.RefmsgTime,
  28065. InfRefmsgid: res.InfRefmsgid,
  28066. OrderStatus: 1,
  28067. IsMedicineInsurance: 1,
  28068. SettleType: settle_accounts_type,
  28069. SettleStartTime: start_time,
  28070. SettleEndTime: end_time,
  28071. Creator: roles.AdminUserId,
  28072. Modify: roles.AdminUserId,
  28073. PType: 2,
  28074. Diagnosis: diagnosis_id,
  28075. }
  28076. err = service.CreateOrder(order)
  28077. if err != nil {
  28078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  28079. return
  28080. }
  28081. }
  28082. adminUser := c.GetAdminUserInfo()
  28083. errlog := &models.HisOrderError{
  28084. UserOrgId: adminUser.CurrentOrgId,
  28085. Ctime: time.Now().Unix(),
  28086. Mtime: time.Now().Unix(),
  28087. ErrMsg: res.ErrMsg,
  28088. Status: 1,
  28089. PatientId: id,
  28090. RecordTime: recordDateTime,
  28091. Stage: 4,
  28092. }
  28093. service.CreateErrMsgLog(errlog)
  28094. c.ServeSuccessJSON(map[string]interface{}{
  28095. "failed_code": -10,
  28096. "msg": res.ErrMsg,
  28097. })
  28098. return
  28099. }
  28100. }
  28101. }
  28102. }
  28103. // 退款
  28104. func (c *HisApiController) Refund() {
  28105. order_id, _ := c.GetInt64("order_id")
  28106. admin_user_id, _ := c.GetInt64("admin_user_id")
  28107. adminUser := c.GetAdminUserInfo()
  28108. var order models.HisOrder
  28109. order, _ = service.GetHisOrderByID(order_id)
  28110. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  28111. if fapiao.ID > 0 {
  28112. c.ServeSuccessJSON(map[string]interface{}{
  28113. "failed_code": -10,
  28114. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  28115. })
  28116. return
  28117. }
  28118. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28119. if order.ID == 0 {
  28120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28121. return
  28122. }
  28123. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  28124. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28125. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28126. if config.IsOpen == 1 { //对接了医保,走医保流程
  28127. var res ResultSixteen
  28128. var ahres ResultSevenAH
  28129. var resSixteen10265 ResultSixteen10265
  28130. var resSixteen10265Two ResultSixteen10265Two
  28131. var gz ResultgzSixteen10265Two
  28132. var src_resquest string
  28133. var result string
  28134. if miConfig.MdtrtareaAdmvs == "421300" {
  28135. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  28136. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28137. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28138. resp3, requestErr3 := http.Get(api3)
  28139. if requestErr3 != nil {
  28140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28141. return
  28142. }
  28143. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28144. if ioErr3 != nil {
  28145. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28147. return
  28148. }
  28149. var respJSON3 map[string]interface{}
  28150. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28151. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28153. return
  28154. }
  28155. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28156. userJSONBytes3, _ := json.Marshal(respJSON3)
  28157. fmt.Println("log")
  28158. fmt.Println(string(userJSONBytes3))
  28159. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28160. utils.ErrorLog("解析失败:%v", err)
  28161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28162. return
  28163. }
  28164. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28165. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  28166. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28167. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28168. resp3, requestErr3 := http.Get(api3)
  28169. if requestErr3 != nil {
  28170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28171. return
  28172. }
  28173. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28174. if ioErr3 != nil {
  28175. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28177. return
  28178. }
  28179. var respJSON3 map[string]interface{}
  28180. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28181. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28183. return
  28184. }
  28185. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28186. userJSONBytes3, _ := json.Marshal(respJSON3)
  28187. fmt.Println("log")
  28188. fmt.Println(string(userJSONBytes3))
  28189. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28190. utils.ErrorLog("解析失败:%v", err)
  28191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28192. return
  28193. }
  28194. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28195. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  28196. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28197. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28198. resp3, requestErr3 := http.Get(api3)
  28199. if requestErr3 != nil {
  28200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28201. return
  28202. }
  28203. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28204. if ioErr3 != nil {
  28205. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28207. return
  28208. }
  28209. var respJSON3 map[string]interface{}
  28210. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28211. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28213. return
  28214. }
  28215. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28216. userJSONBytes3, _ := json.Marshal(respJSON3)
  28217. fmt.Println("log")
  28218. fmt.Println(string(userJSONBytes3))
  28219. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28220. utils.ErrorLog("解析失败:%v", err)
  28221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28222. return
  28223. }
  28224. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28225. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  28226. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28227. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28228. resp3, requestErr3 := http.Get(api3)
  28229. if requestErr3 != nil {
  28230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28231. return
  28232. }
  28233. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28234. if ioErr3 != nil {
  28235. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28237. return
  28238. }
  28239. var respJSON3 map[string]interface{}
  28240. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28241. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28243. return
  28244. }
  28245. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28246. userJSONBytes3, _ := json.Marshal(respJSON3)
  28247. fmt.Println("log")
  28248. fmt.Println(string(userJSONBytes3))
  28249. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28250. utils.ErrorLog("解析失败:%v", err)
  28251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28252. return
  28253. }
  28254. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28255. var api3 string
  28256. if miConfig.MdtrtareaAdmvs == "320921" {
  28257. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  28258. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28259. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28260. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28261. } else {
  28262. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28263. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  28264. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28265. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28266. }
  28267. resp3, requestErr3 := http.Get(api3)
  28268. if requestErr3 != nil {
  28269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28270. return
  28271. }
  28272. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28273. if ioErr3 != nil {
  28274. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28276. return
  28277. }
  28278. var respJSON3 map[string]interface{}
  28279. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28280. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28282. return
  28283. }
  28284. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28285. userJSONBytes3, _ := json.Marshal(respJSON3)
  28286. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  28287. utils.ErrorLog("解析失败:%v", err)
  28288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28289. return
  28290. }
  28291. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  28292. res.Output = resSixteen10265.Output
  28293. res.ErrMsg = resSixteen10265.ErrMsg
  28294. res.Cainfo = resSixteen10265.Cainfo
  28295. res.WarnMsg = resSixteen10265.WarnMsg
  28296. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  28297. res.Infcode = infocode
  28298. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28299. var api3 string
  28300. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  28301. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28302. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28303. resp3, requestErr3 := http.Get(api3)
  28304. if requestErr3 != nil {
  28305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28306. return
  28307. }
  28308. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28309. if ioErr3 != nil {
  28310. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28312. return
  28313. }
  28314. var respJSON3 map[string]interface{}
  28315. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28318. return
  28319. }
  28320. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28321. userJSONBytes3, _ := json.Marshal(respJSON3)
  28322. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  28323. utils.ErrorLog("解析失败:%v", err)
  28324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28325. return
  28326. }
  28327. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  28328. res.Output = resSixteen10265.Output
  28329. res.ErrMsg = resSixteen10265.ErrMsg
  28330. res.Cainfo = resSixteen10265.Cainfo
  28331. res.WarnMsg = resSixteen10265.WarnMsg
  28332. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  28333. res.Infcode = infocode
  28334. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28335. 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)
  28336. var dat map[string]interface{}
  28337. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28338. fmt.Println(dat)
  28339. } else {
  28340. fmt.Println(err)
  28341. }
  28342. saveLog(result, src_resquest, "2208", "退费")
  28343. userJSONBytes, _ := json.Marshal(dat)
  28344. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28345. utils.ErrorLog("解析失败:%v", err)
  28346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28347. return
  28348. }
  28349. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28350. 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, "")
  28351. var dat map[string]interface{}
  28352. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28353. fmt.Println(dat)
  28354. } else {
  28355. fmt.Println(err)
  28356. }
  28357. saveLog(result, src_resquest, "2208", "退费")
  28358. userJSONBytes, _ := json.Marshal(dat)
  28359. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28360. utils.ErrorLog("解析失败:%v", err)
  28361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28362. return
  28363. }
  28364. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28365. var api3 string
  28366. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  28367. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28368. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28369. resp3, requestErr3 := http.Get(api3)
  28370. if requestErr3 != nil {
  28371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28372. return
  28373. }
  28374. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28375. if ioErr3 != nil {
  28376. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28378. return
  28379. }
  28380. var respJSON3 map[string]interface{}
  28381. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28382. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28384. return
  28385. }
  28386. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  28387. if status == "0" {
  28388. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  28389. c.ServeSuccessJSON(map[string]interface{}{
  28390. "failed_code": -10,
  28391. "msg": err_msg,
  28392. })
  28393. return
  28394. }
  28395. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28396. userJSONBytes3, _ := json.Marshal(respJSON3)
  28397. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28398. // utils.ErrorLog("解析失败:%v", err)
  28399. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28400. // return
  28401. //}
  28402. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  28403. utils.ErrorLog("解析失败:%v", err)
  28404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28405. return
  28406. }
  28407. res.InfRefmsgid = ahres.InfRefmsgid
  28408. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28409. // 创建对应的Time类型
  28410. t := time.UnixMilli(timestamp)
  28411. // 格式化成指定的日期字符串
  28412. str := t.Format("2006-01-02 15:04:05")
  28413. res.Output.Setlinfo.SetlTime = str
  28414. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  28415. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  28416. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28417. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  28418. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  28419. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  28420. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28421. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  28422. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  28423. //
  28424. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  28425. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  28426. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  28427. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28428. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  28429. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  28430. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  28431. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  28432. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  28433. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  28434. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28435. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  28436. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  28437. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  28438. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  28439. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  28440. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  28441. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  28442. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  28443. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  28444. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  28445. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  28446. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  28447. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  28448. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  28449. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  28450. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  28451. //res.Output.Setldetail = ahres.Output.Setldetail
  28452. res.ErrMsg = ahres.ErrMsg
  28453. res.Cainfo = ahres.Cainfo
  28454. res.WarnMsg = ahres.WarnMsg
  28455. res.Infcode = ahres.Infcode
  28456. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28457. 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, "")
  28458. var dat map[string]interface{}
  28459. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28460. fmt.Println(dat)
  28461. } else {
  28462. fmt.Println(err)
  28463. }
  28464. saveLog(result, src_resquest, "2208", "退费")
  28465. userJSONBytes, _ := json.Marshal(dat)
  28466. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28467. utils.ErrorLog("解析失败:%v", err)
  28468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28469. return
  28470. }
  28471. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28472. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  28473. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28474. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28475. resp3, requestErr3 := http.Get(api3)
  28476. if requestErr3 != nil {
  28477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28478. return
  28479. }
  28480. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28481. if ioErr3 != nil {
  28482. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28484. return
  28485. }
  28486. var respJSON3 map[string]interface{}
  28487. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28488. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28490. return
  28491. }
  28492. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28493. userJSONBytes3, _ := json.Marshal(respJSON3)
  28494. fmt.Println("log")
  28495. fmt.Println(string(userJSONBytes3))
  28496. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28497. utils.ErrorLog("解析失败:%v", err)
  28498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28499. return
  28500. }
  28501. } else {
  28502. if miConfig.Code == "H15049901371" {
  28503. 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)
  28504. var dat map[string]interface{}
  28505. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28506. fmt.Println(dat)
  28507. } else {
  28508. fmt.Println(err)
  28509. }
  28510. saveLog(result, src_resquest, "2208", "退费")
  28511. if strings.Contains(result, "Post") {
  28512. res.Infcode = -1
  28513. res.ErrMsg = result
  28514. }
  28515. userJSONBytes, _ := json.Marshal(dat)
  28516. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  28517. utils.ErrorLog("解析失败:%v", err)
  28518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28519. return
  28520. }
  28521. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  28522. res.Output = resSixteen10265.Output
  28523. res.ErrMsg = resSixteen10265.ErrMsg
  28524. res.Cainfo = resSixteen10265.Cainfo
  28525. res.WarnMsg = resSixteen10265.WarnMsg
  28526. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  28527. res.Infcode = infocode
  28528. } else {
  28529. 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)
  28530. var dat map[string]interface{}
  28531. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28532. fmt.Println(dat)
  28533. } else {
  28534. fmt.Println(err)
  28535. }
  28536. saveLog(result, src_resquest, "2208", "退费")
  28537. userJSONBytes, _ := json.Marshal(dat)
  28538. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28539. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  28540. utils.ErrorLog("解析失败:%v", err)
  28541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28542. return
  28543. }
  28544. res.Infcode = gz.Infcode
  28545. } else {
  28546. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28547. utils.ErrorLog("解析失败:%v", err)
  28548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28549. return
  28550. }
  28551. }
  28552. if strings.Contains(result, "Post") {
  28553. res.Infcode = -1
  28554. res.ErrMsg = result
  28555. }
  28556. }
  28557. }
  28558. if res.Infcode == -1 {
  28559. c.ServeSuccessJSON(map[string]interface{}{
  28560. "failed_code": -10,
  28561. "msg": res.ErrMsg,
  28562. })
  28563. return
  28564. }
  28565. if res.Infcode != -1 {
  28566. var res2 ResultSix
  28567. var resSix10265 ResultSix10265
  28568. if miConfig.MdtrtareaAdmvs == "421300" {
  28569. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  28570. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28571. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28572. resp3, requestErr3 := http.Get(api3)
  28573. if requestErr3 != nil {
  28574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28575. return
  28576. }
  28577. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28578. if ioErr3 != nil {
  28579. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28581. return
  28582. }
  28583. var respJSON3 map[string]interface{}
  28584. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28587. return
  28588. }
  28589. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28590. userJSONBytes3, _ := json.Marshal(respJSON3)
  28591. fmt.Println("log")
  28592. fmt.Println(string(userJSONBytes3))
  28593. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28594. utils.ErrorLog("解析失败:%v", err)
  28595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28596. return
  28597. }
  28598. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28599. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  28600. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28601. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28602. resp3, requestErr3 := http.Get(api3)
  28603. if requestErr3 != nil {
  28604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28605. return
  28606. }
  28607. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28608. if ioErr3 != nil {
  28609. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28611. return
  28612. }
  28613. var respJSON3 map[string]interface{}
  28614. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28615. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  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. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28629. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  28630. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28631. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28632. resp3, requestErr3 := http.Get(api3)
  28633. if requestErr3 != nil {
  28634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28635. return
  28636. }
  28637. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28638. if ioErr3 != nil {
  28639. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28641. return
  28642. }
  28643. var respJSON3 map[string]interface{}
  28644. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28645. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28647. return
  28648. }
  28649. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28650. userJSONBytes3, _ := json.Marshal(respJSON3)
  28651. fmt.Println("log")
  28652. fmt.Println(string(userJSONBytes3))
  28653. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28654. utils.ErrorLog("解析失败:%v", err)
  28655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28656. return
  28657. }
  28658. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28659. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  28660. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28661. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28662. resp3, requestErr3 := http.Get(api3)
  28663. if requestErr3 != nil {
  28664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28665. return
  28666. }
  28667. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28668. if ioErr3 != nil {
  28669. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28671. return
  28672. }
  28673. var respJSON3 map[string]interface{}
  28674. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28675. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28677. return
  28678. }
  28679. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28680. userJSONBytes3, _ := json.Marshal(respJSON3)
  28681. fmt.Println("log")
  28682. fmt.Println(string(userJSONBytes3))
  28683. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28684. utils.ErrorLog("解析失败:%v", err)
  28685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28686. return
  28687. }
  28688. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28689. var api3 string
  28690. if miConfig.MdtrtareaAdmvs == "320921" {
  28691. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  28692. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28693. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28694. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28695. } else {
  28696. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28697. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  28698. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28699. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28700. }
  28701. resp3, requestErr3 := http.Get(api3)
  28702. if requestErr3 != nil {
  28703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28704. return
  28705. }
  28706. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28707. if ioErr3 != nil {
  28708. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28710. return
  28711. }
  28712. var respJSON3 map[string]interface{}
  28713. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28714. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28716. return
  28717. }
  28718. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28719. userJSONBytes3, _ := json.Marshal(respJSON3)
  28720. fmt.Println("log")
  28721. fmt.Println(string(userJSONBytes3))
  28722. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  28723. utils.ErrorLog("解析失败:%v", err)
  28724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28725. return
  28726. }
  28727. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28728. res2.Output = resSix10265.Output
  28729. res2.ErrMsg = resSix10265.ErrMsg
  28730. res2.Cainfo = resSix10265.Cainfo
  28731. res2.WarnMsg = resSix10265.WarnMsg
  28732. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28733. res2.Infcode = infocode
  28734. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28735. var api3 string
  28736. new_chrg_bchno := order.Number
  28737. if adminUser.CurrentOrgId == 10265 {
  28738. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  28739. new_chrg_bchno = "0000"
  28740. }
  28741. }
  28742. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  28743. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28744. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28745. resp3, requestErr3 := http.Get(api3)
  28746. if requestErr3 != nil {
  28747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28748. return
  28749. }
  28750. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28751. if ioErr3 != nil {
  28752. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28754. return
  28755. }
  28756. var respJSON3 map[string]interface{}
  28757. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28758. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28760. return
  28761. }
  28762. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28763. userJSONBytes3, _ := json.Marshal(respJSON3)
  28764. fmt.Println("log")
  28765. fmt.Println(string(userJSONBytes3))
  28766. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  28767. utils.ErrorLog("解析失败:%v", err)
  28768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28769. return
  28770. }
  28771. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28772. res2.Output = resSix10265.Output
  28773. res2.ErrMsg = resSix10265.ErrMsg
  28774. res2.Cainfo = resSix10265.Cainfo
  28775. res2.WarnMsg = resSix10265.WarnMsg
  28776. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28777. res2.Infcode = infocode
  28778. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28779. 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)
  28780. var dat map[string]interface{}
  28781. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28782. fmt.Println(dat)
  28783. } else {
  28784. fmt.Println(err)
  28785. }
  28786. saveLog(result2, src_request, "2205", "撤销明细")
  28787. userJSONBytes, _ := json.Marshal(dat)
  28788. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28789. utils.ErrorLog("解析失败:%v", err)
  28790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28791. return
  28792. }
  28793. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28794. 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, "")
  28795. var dat map[string]interface{}
  28796. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28797. fmt.Println(dat)
  28798. } else {
  28799. fmt.Println(err)
  28800. }
  28801. saveLog(result2, src_request, "2205", "撤销明细")
  28802. userJSONBytes, _ := json.Marshal(dat)
  28803. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28804. utils.ErrorLog("解析失败:%v", err)
  28805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28806. return
  28807. }
  28808. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28809. var api3 string
  28810. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  28811. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28812. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28813. resp3, requestErr3 := http.Get(api3)
  28814. if requestErr3 != nil {
  28815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28816. return
  28817. }
  28818. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28819. if ioErr3 != nil {
  28820. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28822. return
  28823. }
  28824. var respJSON3 map[string]interface{}
  28825. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28826. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28828. return
  28829. }
  28830. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  28831. if status == "0" {
  28832. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  28833. c.ServeSuccessJSON(map[string]interface{}{
  28834. "failed_code": -10,
  28835. "msg": err_msg,
  28836. })
  28837. return
  28838. }
  28839. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28840. userJSONBytes3, _ := json.Marshal(respJSON3)
  28841. fmt.Println("log")
  28842. fmt.Println(string(userJSONBytes3))
  28843. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28844. utils.ErrorLog("解析失败:%v", err)
  28845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28846. return
  28847. }
  28848. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28849. 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, "")
  28850. var dat map[string]interface{}
  28851. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28852. fmt.Println(dat)
  28853. } else {
  28854. fmt.Println(err)
  28855. }
  28856. saveLog(result2, src_request, "2205", "撤销明细")
  28857. userJSONBytes, _ := json.Marshal(dat)
  28858. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28859. utils.ErrorLog("解析失败:%v", err)
  28860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28861. return
  28862. }
  28863. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28864. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  28865. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28866. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28867. resp3, requestErr3 := http.Get(api3)
  28868. if requestErr3 != nil {
  28869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28870. return
  28871. }
  28872. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28873. if ioErr3 != nil {
  28874. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28876. return
  28877. }
  28878. var respJSON3 map[string]interface{}
  28879. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28880. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28882. return
  28883. }
  28884. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28885. userJSONBytes3, _ := json.Marshal(respJSON3)
  28886. fmt.Println("log")
  28887. fmt.Println(string(userJSONBytes3))
  28888. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28889. utils.ErrorLog("解析失败:%v", err)
  28890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28891. return
  28892. }
  28893. } else {
  28894. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28895. res2.Infcode = 0
  28896. } else {
  28897. 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)
  28898. var dat map[string]interface{}
  28899. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28900. fmt.Println(dat)
  28901. } else {
  28902. fmt.Println(err)
  28903. }
  28904. saveLog(result2, src_request, "2205", "撤销明细")
  28905. userJSONBytes, _ := json.Marshal(dat)
  28906. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28907. utils.ErrorLog("解析失败:%v", err)
  28908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28909. return
  28910. }
  28911. }
  28912. }
  28913. if res2.Infcode == -1 {
  28914. c.ServeSuccessJSON(map[string]interface{}{
  28915. "failed_code": -10,
  28916. "msg": res2.ErrMsg,
  28917. })
  28918. return
  28919. }
  28920. if res2.Infcode == 0 {
  28921. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  28922. if err == nil {
  28923. //当押金不为零时产生退费记录
  28924. if order.Decimal != 0 {
  28925. tmp := strconv.FormatInt(order.ID, 10)
  28926. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  28927. if err != nil {
  28928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28929. return
  28930. }
  28931. }
  28932. c.ServeSuccessJSON(map[string]interface{}{
  28933. "msg": "退费成功",
  28934. })
  28935. } else {
  28936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28937. return
  28938. }
  28939. } else {
  28940. c.ServeSuccessJSON(map[string]interface{}{
  28941. "failed_code": -10,
  28942. "msg": res2.ErrMsg,
  28943. })
  28944. }
  28945. } else {
  28946. c.ServeSuccessJSON(map[string]interface{}{
  28947. "failed_code": -10,
  28948. "msg": res.ErrMsg,
  28949. })
  28950. }
  28951. }
  28952. }
  28953. func (c *HisApiController) RefundNumber() {
  28954. record_time := c.GetString("record_time")
  28955. //patient_id, _ := c.GetInt64("patient_id")
  28956. admin_user_id, _ := c.GetInt64("admin_user_id")
  28957. his_patient_id, _ := c.GetInt64("id")
  28958. timeLayout := "2006-01-02"
  28959. loc, _ := time.LoadLocation("Local")
  28960. adminUser := c.GetAdminUserInfo()
  28961. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  28962. fmt.Println(err)
  28963. if err != nil {
  28964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28965. return
  28966. }
  28967. recordDateTime := theTime.Unix()
  28968. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  28969. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  28970. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  28971. //order, _ := service.GetHisOrderByID(order_id)
  28972. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28973. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28974. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28975. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  28976. if count > 0 {
  28977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  28978. return
  28979. }
  28980. if config.IsOpen == 1 { //对接了医保,走医保流程
  28981. var res2 ResultSix
  28982. var res3 GZResultSix
  28983. var resSix10265 ResultSix10265
  28984. if miConfig.MdtrtareaAdmvs == "421300" {
  28985. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  28986. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28987. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28988. resp3, requestErr3 := http.Get(api3)
  28989. if requestErr3 != nil {
  28990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28991. return
  28992. }
  28993. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28994. if ioErr3 != nil {
  28995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28997. return
  28998. }
  28999. var respJSON3 map[string]interface{}
  29000. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29003. return
  29004. }
  29005. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29006. userJSONBytes3, _ := json.Marshal(respJSON3)
  29007. fmt.Println("log")
  29008. fmt.Println(string(userJSONBytes3))
  29009. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29010. utils.ErrorLog("解析失败:%v", err)
  29011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29012. return
  29013. }
  29014. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29015. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  29016. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29017. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29018. resp3, requestErr3 := http.Get(api3)
  29019. if requestErr3 != nil {
  29020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29021. return
  29022. }
  29023. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29024. if ioErr3 != nil {
  29025. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29027. return
  29028. }
  29029. var respJSON3 map[string]interface{}
  29030. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29031. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29033. return
  29034. }
  29035. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29036. userJSONBytes3, _ := json.Marshal(respJSON3)
  29037. fmt.Println("log")
  29038. fmt.Println(string(userJSONBytes3))
  29039. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29040. utils.ErrorLog("解析失败:%v", err)
  29041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29042. return
  29043. }
  29044. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29045. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  29046. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29047. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29048. resp3, requestErr3 := http.Get(api3)
  29049. if requestErr3 != nil {
  29050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29051. return
  29052. }
  29053. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29054. if ioErr3 != nil {
  29055. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29057. return
  29058. }
  29059. var respJSON3 map[string]interface{}
  29060. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29061. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29063. return
  29064. }
  29065. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29066. userJSONBytes3, _ := json.Marshal(respJSON3)
  29067. fmt.Println("log")
  29068. fmt.Println(string(userJSONBytes3))
  29069. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29070. utils.ErrorLog("解析失败:%v", err)
  29071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29072. return
  29073. }
  29074. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29075. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  29076. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29077. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29078. resp3, requestErr3 := http.Get(api3)
  29079. if requestErr3 != nil {
  29080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29081. return
  29082. }
  29083. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29084. if ioErr3 != nil {
  29085. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29087. return
  29088. }
  29089. var respJSON3 map[string]interface{}
  29090. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29091. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29093. return
  29094. }
  29095. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29096. userJSONBytes3, _ := json.Marshal(respJSON3)
  29097. fmt.Println("log")
  29098. fmt.Println(string(userJSONBytes3))
  29099. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29100. utils.ErrorLog("解析失败:%v", err)
  29101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29102. return
  29103. }
  29104. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29105. var api3 string
  29106. if miConfig.MdtrtareaAdmvs == "320921" {
  29107. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  29108. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29109. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29110. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29111. } else {
  29112. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29113. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  29114. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29115. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29116. }
  29117. resp3, requestErr3 := http.Get(api3)
  29118. if requestErr3 != nil {
  29119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29120. return
  29121. }
  29122. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29123. if ioErr3 != nil {
  29124. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29126. return
  29127. }
  29128. var respJSON3 map[string]interface{}
  29129. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29130. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29132. return
  29133. }
  29134. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29135. userJSONBytes3, _ := json.Marshal(respJSON3)
  29136. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  29137. utils.ErrorLog("解析失败:%v", err)
  29138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29139. return
  29140. }
  29141. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29142. res2.Output = resSix10265.Output
  29143. res2.ErrMsg = resSix10265.ErrMsg
  29144. res2.Cainfo = resSix10265.Cainfo
  29145. res2.WarnMsg = resSix10265.WarnMsg
  29146. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29147. res2.Infcode = infocode
  29148. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29149. var api3 string
  29150. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  29151. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29152. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29153. resp3, requestErr3 := http.Get(api3)
  29154. if requestErr3 != nil {
  29155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29156. return
  29157. }
  29158. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29159. if ioErr3 != nil {
  29160. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29162. return
  29163. }
  29164. var respJSON3 map[string]interface{}
  29165. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29168. return
  29169. }
  29170. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29171. userJSONBytes3, _ := json.Marshal(respJSON3)
  29172. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  29173. utils.ErrorLog("解析失败:%v", err)
  29174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29175. return
  29176. }
  29177. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29178. res2.Output = resSix10265.Output
  29179. res2.ErrMsg = resSix10265.ErrMsg
  29180. res2.Cainfo = resSix10265.Cainfo
  29181. res2.WarnMsg = resSix10265.WarnMsg
  29182. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29183. res2.Infcode = infocode
  29184. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29185. 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)
  29186. var dat map[string]interface{}
  29187. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29188. fmt.Println(dat)
  29189. } else {
  29190. fmt.Println(err)
  29191. }
  29192. saveLog(result, request, "2202", "退号")
  29193. userJSONBytes, _ := json.Marshal(dat)
  29194. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29195. utils.ErrorLog("解析失败:%v", err)
  29196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29197. return
  29198. }
  29199. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29200. 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, "")
  29201. var dat map[string]interface{}
  29202. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29203. fmt.Println(dat)
  29204. } else {
  29205. fmt.Println(err)
  29206. }
  29207. saveLog(result, request, "2202", "退号")
  29208. userJSONBytes, _ := json.Marshal(dat)
  29209. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29210. utils.ErrorLog("解析失败:%v", err)
  29211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29212. return
  29213. }
  29214. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29215. var api3 string
  29216. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  29217. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29218. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29219. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29220. resp3, requestErr3 := http.Get(api3)
  29221. if requestErr3 != nil {
  29222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29223. return
  29224. }
  29225. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29226. if ioErr3 != nil {
  29227. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29229. return
  29230. }
  29231. var respJSON3 map[string]interface{}
  29232. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29233. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29235. return
  29236. }
  29237. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  29238. if status == "0" {
  29239. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  29240. c.ServeSuccessJSON(map[string]interface{}{
  29241. "failed_code": -10,
  29242. "msg": err_msg,
  29243. })
  29244. return
  29245. }
  29246. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29247. userJSONBytes3, _ := json.Marshal(respJSON3)
  29248. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29249. utils.ErrorLog("解析失败:%v", err)
  29250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29251. return
  29252. }
  29253. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  29254. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29255. 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, "")
  29256. var dat map[string]interface{}
  29257. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29258. fmt.Println(dat)
  29259. } else {
  29260. fmt.Println(err)
  29261. }
  29262. saveLog(result, request, "2202", "退号")
  29263. userJSONBytes, _ := json.Marshal(dat)
  29264. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29265. utils.ErrorLog("解析失败:%v", err)
  29266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29267. return
  29268. }
  29269. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29270. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  29271. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29272. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  29273. resp3, requestErr3 := http.Get(api3)
  29274. if requestErr3 != nil {
  29275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29276. return
  29277. }
  29278. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29279. if ioErr3 != nil {
  29280. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29282. return
  29283. }
  29284. var respJSON3 map[string]interface{}
  29285. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29286. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29288. return
  29289. }
  29290. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29291. userJSONBytes3, _ := json.Marshal(respJSON3)
  29292. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29293. utils.ErrorLog("解析失败:%v", err)
  29294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29295. return
  29296. }
  29297. } else {
  29298. var api3 string
  29299. if miConfig.Code == "H15049901371" {
  29300. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  29301. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29302. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29303. } else {
  29304. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  29305. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29306. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  29307. }
  29308. resp3, requestErr3 := http.Get(api3)
  29309. if requestErr3 != nil {
  29310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29311. return
  29312. }
  29313. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29314. if ioErr3 != nil {
  29315. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29317. return
  29318. }
  29319. var respJSON3 map[string]interface{}
  29320. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29323. return
  29324. }
  29325. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29326. userJSONBytes3, _ := json.Marshal(respJSON3)
  29327. if miConfig.Code == "H15049901371" {
  29328. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  29329. utils.ErrorLog("解析失败:%v", err)
  29330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29331. return
  29332. }
  29333. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29334. res2.Output = resSix10265.Output
  29335. res2.ErrMsg = resSix10265.ErrMsg
  29336. res2.Cainfo = resSix10265.Cainfo
  29337. res2.WarnMsg = resSix10265.WarnMsg
  29338. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29339. res2.Infcode = infocode
  29340. } else {
  29341. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  29342. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  29343. utils.ErrorLog("解析失败:%v", err)
  29344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29345. return
  29346. }
  29347. res2.Infcode = res3.Infcode
  29348. } else {
  29349. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29350. utils.ErrorLog("解析失败:%v", err)
  29351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29352. return
  29353. }
  29354. }
  29355. }
  29356. }
  29357. if res2.Infcode == -1 {
  29358. c.ServeSuccessJSON(map[string]interface{}{
  29359. "failed_code": -10,
  29360. "msg": res2.ErrMsg,
  29361. })
  29362. return
  29363. }
  29364. if res2.Infcode == 0 {
  29365. if err == nil {
  29366. c.ServeSuccessJSON(map[string]interface{}{
  29367. "msg": "退号成功",
  29368. })
  29369. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  29370. } else {
  29371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29372. return
  29373. }
  29374. }
  29375. } else {
  29376. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  29377. //if err == nil {
  29378. // c.ServeSuccessJSON(map[string]interface{}{
  29379. // "msg": "退费成功",
  29380. // })
  29381. //} else {
  29382. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29383. // return
  29384. //}
  29385. }
  29386. }
  29387. func (c *HisApiController) RefundDetail() {
  29388. order_id, _ := c.GetInt64("order_id")
  29389. admin_user_id, _ := c.GetInt64("admin_user_id")
  29390. //his_patient_id, _ := c.GetInt64("his_patient_id")
  29391. number := c.GetString("number")
  29392. record_time := c.GetString("record_time")
  29393. patient_id, _ := c.GetInt64("patient_id")
  29394. //med_type, _ := c.GetInt64("med_type")
  29395. timeLayout := "2006-01-02"
  29396. loc, _ := time.LoadLocation("Local")
  29397. adminUser := c.GetAdminUserInfo()
  29398. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29399. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  29400. fmt.Println(err)
  29401. if err != nil {
  29402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29403. return
  29404. }
  29405. recordDateTime := theTime.Unix()
  29406. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29407. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  29408. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29409. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29410. var order models.HisOrder
  29411. order, _ = service.GetHisOrderByID(order_id)
  29412. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  29413. if config.IsOpen == 1 { //对接了医保,走医保流程
  29414. var res2 ResultSix
  29415. if miConfig.MdtrtareaAdmvs == "421300" {
  29416. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  29417. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29418. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29419. resp3, requestErr3 := http.Get(api3)
  29420. if requestErr3 != nil {
  29421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29422. return
  29423. }
  29424. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29425. if ioErr3 != nil {
  29426. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29428. return
  29429. }
  29430. var respJSON3 map[string]interface{}
  29431. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29432. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29434. return
  29435. }
  29436. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29437. userJSONBytes3, _ := json.Marshal(respJSON3)
  29438. fmt.Println("log")
  29439. fmt.Println(string(userJSONBytes3))
  29440. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29441. utils.ErrorLog("解析失败:%v", err)
  29442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29443. return
  29444. }
  29445. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29446. if err == nil {
  29447. c.ServeSuccessJSON(map[string]interface{}{
  29448. "msg": "撤销明细成功",
  29449. })
  29450. return
  29451. } else {
  29452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29453. return
  29454. }
  29455. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29456. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  29457. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29458. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29459. resp3, requestErr3 := http.Get(api3)
  29460. if requestErr3 != nil {
  29461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29462. return
  29463. }
  29464. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29465. if ioErr3 != nil {
  29466. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29468. return
  29469. }
  29470. var respJSON3 map[string]interface{}
  29471. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29474. return
  29475. }
  29476. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29477. userJSONBytes3, _ := json.Marshal(respJSON3)
  29478. fmt.Println("log")
  29479. fmt.Println(string(userJSONBytes3))
  29480. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29481. utils.ErrorLog("解析失败:%v", err)
  29482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29483. return
  29484. }
  29485. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29486. if err == nil {
  29487. c.ServeSuccessJSON(map[string]interface{}{
  29488. "msg": "撤销明细成功",
  29489. })
  29490. return
  29491. } else {
  29492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29493. return
  29494. }
  29495. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29496. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  29497. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29498. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29499. resp3, requestErr3 := http.Get(api3)
  29500. if requestErr3 != nil {
  29501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29502. return
  29503. }
  29504. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29505. if ioErr3 != nil {
  29506. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29508. return
  29509. }
  29510. var respJSON3 map[string]interface{}
  29511. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29512. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29514. return
  29515. }
  29516. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29517. userJSONBytes3, _ := json.Marshal(respJSON3)
  29518. fmt.Println("log")
  29519. fmt.Println(string(userJSONBytes3))
  29520. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29521. utils.ErrorLog("解析失败:%v", err)
  29522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29523. return
  29524. }
  29525. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29526. if err == nil {
  29527. c.ServeSuccessJSON(map[string]interface{}{
  29528. "msg": "撤销明细成功",
  29529. })
  29530. return
  29531. } else {
  29532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29533. return
  29534. }
  29535. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29536. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  29537. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29538. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29539. resp3, requestErr3 := http.Get(api3)
  29540. if requestErr3 != nil {
  29541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29542. return
  29543. }
  29544. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29545. if ioErr3 != nil {
  29546. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29548. return
  29549. }
  29550. var respJSON3 map[string]interface{}
  29551. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29554. return
  29555. }
  29556. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29557. userJSONBytes3, _ := json.Marshal(respJSON3)
  29558. fmt.Println("log")
  29559. fmt.Println(string(userJSONBytes3))
  29560. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29561. utils.ErrorLog("解析失败:%v", err)
  29562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29563. return
  29564. }
  29565. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29566. if err == nil {
  29567. c.ServeSuccessJSON(map[string]interface{}{
  29568. "msg": "撤销明细成功",
  29569. })
  29570. return
  29571. } else {
  29572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29573. return
  29574. }
  29575. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29576. var resSix10265 ResultSix10265
  29577. var api3 string
  29578. if miConfig.MdtrtareaAdmvs == "320921" {
  29579. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  29580. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29581. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29582. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29583. } else {
  29584. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29585. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  29586. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29587. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29588. }
  29589. resp3, requestErr3 := http.Get(api3)
  29590. utils.ErrorLog("接口: %v", requestErr3)
  29591. if requestErr3 != nil {
  29592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29593. return
  29594. }
  29595. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29596. if ioErr3 != nil {
  29597. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29599. return
  29600. }
  29601. var respJSON3 map[string]interface{}
  29602. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29603. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29605. return
  29606. }
  29607. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29608. userJSONBytes3, _ := json.Marshal(respJSON3)
  29609. fmt.Println("log")
  29610. fmt.Println(string(userJSONBytes3))
  29611. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  29612. utils.ErrorLog("解析失败:%v", err)
  29613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29614. return
  29615. }
  29616. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29617. res2.Output = resSix10265.Output
  29618. res2.ErrMsg = resSix10265.ErrMsg
  29619. res2.Cainfo = resSix10265.Cainfo
  29620. res2.WarnMsg = resSix10265.WarnMsg
  29621. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29622. res2.Infcode = infocode
  29623. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29624. if err == nil {
  29625. c.ServeSuccessJSON(map[string]interface{}{
  29626. "msg": "撤销明细成功",
  29627. })
  29628. return
  29629. } else {
  29630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29631. return
  29632. }
  29633. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29634. var api3 string
  29635. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  29636. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29637. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29638. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29639. resp3, requestErr3 := http.Get(api3)
  29640. utils.ErrorLog("接口: %v", requestErr3)
  29641. if requestErr3 != nil {
  29642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29643. return
  29644. }
  29645. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29646. if ioErr3 != nil {
  29647. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29649. return
  29650. }
  29651. var respJSON3 map[string]interface{}
  29652. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29653. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29655. return
  29656. }
  29657. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  29658. if status == "0" {
  29659. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  29660. c.ServeSuccessJSON(map[string]interface{}{
  29661. "failed_code": -10,
  29662. "msg": err_msg,
  29663. })
  29664. return
  29665. }
  29666. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29667. userJSONBytes3, _ := json.Marshal(respJSON3)
  29668. fmt.Println("log")
  29669. fmt.Println(string(userJSONBytes3))
  29670. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29671. utils.ErrorLog("解析失败:%v", err)
  29672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29673. return
  29674. }
  29675. fmt.Println(res2.Infcode)
  29676. if res2.Infcode == -1 {
  29677. c.ServeSuccessJSON(map[string]interface{}{
  29678. "failed_code": -10,
  29679. "msg": res2.ErrMsg,
  29680. })
  29681. return
  29682. }
  29683. if res2.Infcode == 0 {
  29684. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29685. if err == nil {
  29686. c.ServeSuccessJSON(map[string]interface{}{
  29687. "msg": "撤销明细成功",
  29688. })
  29689. return
  29690. } else {
  29691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29692. return
  29693. }
  29694. } else {
  29695. c.ServeSuccessJSON(map[string]interface{}{
  29696. "failed_code": -10,
  29697. "msg": res2.ErrMsg,
  29698. })
  29699. }
  29700. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29701. if err == nil {
  29702. c.ServeSuccessJSON(map[string]interface{}{
  29703. "msg": "撤销明细成功",
  29704. })
  29705. return
  29706. } else {
  29707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29708. return
  29709. }
  29710. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29711. var resSix10265 ResultSix10265
  29712. new_chrg_bchno := order.Number
  29713. if adminUser.CurrentOrgId == 10265 {
  29714. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  29715. new_chrg_bchno = "0000"
  29716. }
  29717. }
  29718. var api3 string
  29719. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  29720. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29721. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29722. resp3, requestErr3 := http.Get(api3)
  29723. if requestErr3 != nil {
  29724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29725. return
  29726. }
  29727. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29728. if ioErr3 != nil {
  29729. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29731. return
  29732. }
  29733. var respJSON3 map[string]interface{}
  29734. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29735. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29737. return
  29738. }
  29739. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29740. userJSONBytes3, _ := json.Marshal(respJSON3)
  29741. fmt.Println("log")
  29742. fmt.Println(string(userJSONBytes3))
  29743. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  29744. utils.ErrorLog("解析失败:%v", err)
  29745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29746. return
  29747. }
  29748. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29749. res2.Output = resSix10265.Output
  29750. res2.ErrMsg = resSix10265.ErrMsg
  29751. res2.Cainfo = resSix10265.Cainfo
  29752. res2.WarnMsg = resSix10265.WarnMsg
  29753. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29754. res2.Infcode = infocode
  29755. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29756. if err == nil {
  29757. c.ServeSuccessJSON(map[string]interface{}{
  29758. "msg": "撤销明细成功",
  29759. })
  29760. return
  29761. } else {
  29762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29763. return
  29764. }
  29765. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29766. 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)
  29767. var dat map[string]interface{}
  29768. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29769. fmt.Println(dat)
  29770. } else {
  29771. fmt.Println(err)
  29772. }
  29773. saveLog(result2, src_request, "2205", "撤销明细")
  29774. userJSONBytes, _ := json.Marshal(dat)
  29775. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29776. utils.ErrorLog("解析失败:%v", err)
  29777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29778. return
  29779. }
  29780. if res2.Infcode == 0 {
  29781. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29782. if err == nil {
  29783. c.ServeSuccessJSON(map[string]interface{}{
  29784. "msg": "撤销明细成功",
  29785. })
  29786. return
  29787. } else {
  29788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29789. return
  29790. }
  29791. } else {
  29792. c.ServeSuccessJSON(map[string]interface{}{
  29793. "failed_code": -10,
  29794. "msg": res2.ErrMsg,
  29795. })
  29796. }
  29797. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29798. 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, "")
  29799. var dat map[string]interface{}
  29800. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29801. fmt.Println(dat)
  29802. } else {
  29803. fmt.Println(err)
  29804. }
  29805. saveLog(result2, src_request, "2205", "撤销明细")
  29806. userJSONBytes, _ := json.Marshal(dat)
  29807. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29808. utils.ErrorLog("解析失败:%v", err)
  29809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29810. return
  29811. }
  29812. if res2.Infcode == 0 {
  29813. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29814. if err == nil {
  29815. c.ServeSuccessJSON(map[string]interface{}{
  29816. "msg": "撤销明细成功",
  29817. })
  29818. return
  29819. } else {
  29820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29821. return
  29822. }
  29823. } else {
  29824. c.ServeSuccessJSON(map[string]interface{}{
  29825. "failed_code": -10,
  29826. "msg": res2.ErrMsg,
  29827. })
  29828. }
  29829. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29830. 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, "")
  29831. var dat map[string]interface{}
  29832. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29833. fmt.Println(dat)
  29834. } else {
  29835. fmt.Println(err)
  29836. }
  29837. saveLog(result2, src_request, "2205", "撤销明细")
  29838. userJSONBytes, _ := json.Marshal(dat)
  29839. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29840. utils.ErrorLog("解析失败:%v", err)
  29841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29842. return
  29843. }
  29844. if res2.Infcode == 0 {
  29845. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29846. if err == nil {
  29847. c.ServeSuccessJSON(map[string]interface{}{
  29848. "msg": "撤销明细成功",
  29849. })
  29850. return
  29851. } else {
  29852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29853. return
  29854. }
  29855. } else {
  29856. c.ServeSuccessJSON(map[string]interface{}{
  29857. "failed_code": -10,
  29858. "msg": res2.ErrMsg,
  29859. })
  29860. }
  29861. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29862. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  29863. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29864. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29865. resp2, requestErr2 := http.Get(api2)
  29866. if requestErr2 != nil {
  29867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29868. return
  29869. }
  29870. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  29871. if ioErr2 != nil {
  29872. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  29873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29874. return
  29875. }
  29876. var respJSON2 map[string]interface{}
  29877. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  29878. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29880. return
  29881. }
  29882. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29883. userJSONBytes3, _ := json.Marshal(respJSON2)
  29884. fmt.Println("log")
  29885. fmt.Println(string(userJSONBytes3))
  29886. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29887. utils.ErrorLog("解析失败:%v", err)
  29888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29889. return
  29890. }
  29891. if res2.Infcode == 0 {
  29892. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29893. if err == nil {
  29894. c.ServeSuccessJSON(map[string]interface{}{
  29895. "msg": "撤销明细成功",
  29896. })
  29897. return
  29898. } else {
  29899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29900. return
  29901. }
  29902. } else {
  29903. c.ServeSuccessJSON(map[string]interface{}{
  29904. "failed_code": -10,
  29905. "msg": res2.ErrMsg,
  29906. })
  29907. }
  29908. } else {
  29909. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  29910. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29911. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  29912. resp2, requestErr2 := http.Get(api2)
  29913. if requestErr2 != nil {
  29914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29915. return
  29916. }
  29917. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  29918. if ioErr2 != nil {
  29919. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  29920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29921. return
  29922. }
  29923. var respJSON2 map[string]interface{}
  29924. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  29925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29927. return
  29928. }
  29929. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29930. userJSONBytes3, _ := json.Marshal(respJSON2)
  29931. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29932. utils.ErrorLog("解析失败:%v", err)
  29933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29934. return
  29935. }
  29936. if res2.Infcode == -1 {
  29937. c.ServeSuccessJSON(map[string]interface{}{
  29938. "failed_code": -10,
  29939. "msg": res2.ErrMsg,
  29940. })
  29941. return
  29942. } else {
  29943. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29944. if err == nil {
  29945. c.ServeSuccessJSON(map[string]interface{}{
  29946. "msg": "撤销明细成功",
  29947. })
  29948. return
  29949. } else {
  29950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29951. return
  29952. }
  29953. }
  29954. }
  29955. } else {
  29956. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29957. if err == nil {
  29958. c.ServeSuccessJSON(map[string]interface{}{
  29959. "msg": "退费成功",
  29960. })
  29961. } else {
  29962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29963. return
  29964. }
  29965. }
  29966. }
  29967. // 对账
  29968. func (c *HisApiController) GetCheckAccount() {
  29969. start_time := c.GetString("start_time")
  29970. end_time := c.GetString("end_time")
  29971. insutype := c.GetString("insutype")
  29972. clr_type := c.GetString("clr_type")
  29973. clr_org := c.GetString("clr_optins")
  29974. admin_user_id, _ := c.GetInt64("admin_user_id")
  29975. adminUser := c.GetAdminUserInfo()
  29976. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29977. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29978. if len(clr_org) == 0 {
  29979. clr_org = miConfig.InsuplcAdmdvs
  29980. }
  29981. timeLayout := "2006-01-02"
  29982. loc, _ := time.LoadLocation("Local")
  29983. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  29984. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  29985. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  29986. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  29987. fixmedins_setl_cnt := int64(len(orders))
  29988. var medfee_sumamt float64
  29989. var acct_pay float64
  29990. var fund_pay_sumamt float64
  29991. for _, item := range orders {
  29992. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  29993. acct_pay = acct_pay + item.AcctPay
  29994. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  29995. }
  29996. var user_name string
  29997. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29998. if role.ID == 0 {
  29999. user_name = "xxx"
  30000. } else {
  30001. user_name = role.UserName
  30002. }
  30003. var res ResultEight
  30004. var res10188 ResultEightFor10188
  30005. if config.IsOpen == 1 {
  30006. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  30007. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  30008. "insutype=" + insutype +
  30009. "&clr_type=" + clr_type +
  30010. "&setl_optins=" + clr_org +
  30011. "&stmt_begndate=" + start_time +
  30012. "&stm_enddate=" + end_time +
  30013. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  30014. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  30015. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  30016. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  30017. "&fixmedins_code=" + miConfig.Code +
  30018. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30019. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30020. "&secret_key=" + miConfig.SecretKey +
  30021. "&org_name=" + miConfig.OrgName +
  30022. "&doctor=" + user_name +
  30023. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30024. fmt.Println(api)
  30025. resp, requestErr := http.Get(api)
  30026. if requestErr != nil {
  30027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30028. return
  30029. }
  30030. body, ioErr := ioutil.ReadAll(resp.Body)
  30031. fmt.Println(body)
  30032. if ioErr != nil {
  30033. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30035. return
  30036. }
  30037. var respJSON map[string]interface{}
  30038. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30039. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30041. return
  30042. }
  30043. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30044. userJSONBytes, _ := json.Marshal(respJSON)
  30045. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30046. utils.ErrorLog("解析失败:%v", err)
  30047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30048. return
  30049. }
  30050. res.InfRefmsgid = res10188.InfRefmsgid
  30051. res.Output = res10188.Output
  30052. res.ErrMsg = res10188.ErrMsg
  30053. res.Cainfo = res10188.Cainfo
  30054. res.WarnMsg = res10188.WarnMsg
  30055. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  30056. res.Infcode = infocode
  30057. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30058. if clr_type != "9903" {
  30059. clr_type = "99" // 就诊 ID(来自2201接口返回)
  30060. }
  30061. if clr_type == "9903" {
  30062. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  30063. }
  30064. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  30065. "insutype=" + insutype +
  30066. "&clr_type=" + clr_type +
  30067. "&setl_optins=" + clr_org +
  30068. "&stmt_begndate=" + start_time +
  30069. "&stm_enddate=" + end_time +
  30070. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  30071. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  30072. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  30073. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  30074. "&fixmedins_code=" + miConfig.Code +
  30075. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30076. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30077. "&secret_key=" + miConfig.SecretKey +
  30078. "&org_name=" + miConfig.OrgName +
  30079. "&doctor=" + user_name
  30080. resp, requestErr := http.Get(api)
  30081. if requestErr != nil {
  30082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30083. return
  30084. }
  30085. body, ioErr := ioutil.ReadAll(resp.Body)
  30086. if ioErr != nil {
  30087. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30089. return
  30090. }
  30091. var respJSON map[string]interface{}
  30092. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30093. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30095. return
  30096. }
  30097. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30098. result, _ := json.Marshal(respJSON)
  30099. fmt.Println("log")
  30100. fmt.Println(string(result))
  30101. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  30102. utils.ErrorLog("解析失败:%v", err)
  30103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30104. return
  30105. }
  30106. res.InfRefmsgid = res10188.InfRefmsgid
  30107. res.Output = res10188.Output
  30108. res.ErrMsg = res10188.ErrMsg
  30109. res.Cainfo = res10188.Cainfo
  30110. res.WarnMsg = res10188.WarnMsg
  30111. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  30112. res.Infcode = infocode
  30113. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30114. var baseParams models.BaseParams
  30115. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  30116. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  30117. baseParams.SecretKey = miConfig.SecretKey
  30118. baseParams.OrgName = miConfig.OrgName
  30119. baseParams.FixmedinsCode = miConfig.Code
  30120. baseParams.EncKey = miConfig.EncKey
  30121. baseParams.AppSecret = miConfig.AppSecret
  30122. baseParams.SignKey = miConfig.SignKey
  30123. baseParams.AppID = miConfig.Code
  30124. baseParams.Doctor = role.UserName
  30125. baseParams.RequestUrl = miConfig.Url
  30126. businessParams := models.BusinessParams{
  30127. Insutype: insutype,
  30128. ClrType: clr_type,
  30129. SetlOptins: clr_org,
  30130. StmtBegndate: start_time,
  30131. StmtEnddate: end_time,
  30132. MedfeeSumamt: medfee_sumamt,
  30133. FundPaySumamt: fund_pay_sumamt,
  30134. AcctPay: acct_pay,
  30135. FixmedinsSetlCnt: fixmedins_setl_cnt,
  30136. }
  30137. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  30138. fmt.Println(requestLog)
  30139. fmt.Println(result)
  30140. fmt.Println(err_msg)
  30141. var dat map[string]interface{}
  30142. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30143. fmt.Println(dat)
  30144. } else {
  30145. fmt.Println(err)
  30146. }
  30147. userJSONBytes, _ := json.Marshal(dat)
  30148. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30149. utils.ErrorLog("解析失败:%v", err)
  30150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30151. return
  30152. }
  30153. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30154. var baseParams models.BaseParams
  30155. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  30156. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  30157. baseParams.SecretKey = miConfig.SecretKey
  30158. baseParams.OrgName = miConfig.OrgName
  30159. baseParams.FixmedinsCode = miConfig.Code
  30160. baseParams.EncKey = miConfig.EncKey
  30161. baseParams.AppSecret = miConfig.AppSecret
  30162. baseParams.SignKey = miConfig.SignKey
  30163. baseParams.AppID = miConfig.Code
  30164. baseParams.Doctor = role.UserName
  30165. baseParams.RequestUrl = miConfig.Url
  30166. baseParams.AccessKey = miConfig.AccessKey
  30167. businessParams := models.BusinessParams{
  30168. Insutype: insutype,
  30169. ClrType: clr_type,
  30170. SetlOptins: "430822",
  30171. StmtBegndate: start_time,
  30172. StmtEnddate: end_time,
  30173. MedfeeSumamt: medfee_sumamt,
  30174. FundPaySumamt: fund_pay_sumamt,
  30175. AcctPay: acct_pay,
  30176. FixmedinsSetlCnt: fixmedins_setl_cnt,
  30177. }
  30178. 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)
  30179. fmt.Println(requestLog)
  30180. fmt.Println(result)
  30181. var dat map[string]interface{}
  30182. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30183. fmt.Println(dat)
  30184. } else {
  30185. fmt.Println(err)
  30186. }
  30187. userJSONBytes, _ := json.Marshal(dat)
  30188. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30189. utils.ErrorLog("解析失败:%v", err)
  30190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30191. return
  30192. }
  30193. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30194. var baseParams models.BaseParams
  30195. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  30196. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  30197. baseParams.SecretKey = miConfig.SecretKey
  30198. baseParams.OrgName = miConfig.OrgName
  30199. baseParams.FixmedinsCode = miConfig.Code
  30200. baseParams.EncKey = miConfig.EncKey
  30201. baseParams.AppSecret = miConfig.AppSecret
  30202. baseParams.SignKey = miConfig.SignKey
  30203. baseParams.AppID = miConfig.Code
  30204. baseParams.Doctor = role.UserName
  30205. baseParams.RequestUrl = miConfig.Url
  30206. businessParams := models.BusinessParams{
  30207. Insutype: insutype,
  30208. ClrType: clr_type,
  30209. SetlOptins: clr_org,
  30210. StmtBegndate: start_time,
  30211. StmtEnddate: end_time,
  30212. MedfeeSumamt: medfee_sumamt,
  30213. FundPaySumamt: fund_pay_sumamt,
  30214. AcctPay: acct_pay,
  30215. FixmedinsSetlCnt: fixmedins_setl_cnt,
  30216. }
  30217. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  30218. fmt.Println(requestLog)
  30219. fmt.Println(result)
  30220. fmt.Println(err_msg)
  30221. var dat map[string]interface{}
  30222. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30223. fmt.Println(dat)
  30224. } else {
  30225. fmt.Println(err)
  30226. }
  30227. userJSONBytes, _ := json.Marshal(dat)
  30228. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30229. utils.ErrorLog("解析失败:%v", err)
  30230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30231. return
  30232. }
  30233. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30234. if len(clr_type) == 0 {
  30235. clr_type = "11"
  30236. }
  30237. api := miConfig.Url + "gdyb/ten?" +
  30238. "insutype=" + insutype +
  30239. "&clr_type=" + clr_type +
  30240. "&setl_optins=" + clr_org +
  30241. "&stmt_begndate=" + start_time +
  30242. "&stm_enddate=" + end_time +
  30243. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  30244. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  30245. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  30246. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  30247. "&fixmedins_code=" + miConfig.Code +
  30248. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30249. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30250. "&secret_key=" + miConfig.SecretKey +
  30251. "&org_name=" + miConfig.OrgName +
  30252. "&doctor=" + user_name
  30253. fmt.Println(api)
  30254. resp, requestErr := http.Get(api)
  30255. if requestErr != nil {
  30256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30257. return
  30258. }
  30259. body, ioErr := ioutil.ReadAll(resp.Body)
  30260. fmt.Println(body)
  30261. if ioErr != nil {
  30262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30264. return
  30265. }
  30266. var respJSON map[string]interface{}
  30267. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30270. return
  30271. }
  30272. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30273. userJSONBytes, _ := json.Marshal(respJSON)
  30274. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30275. utils.ErrorLog("解析失败:%v", err)
  30276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30277. return
  30278. }
  30279. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30280. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  30281. fixmedins_setl_cnt := int64(len(orders_two))
  30282. var medfee_sumamt float64
  30283. var acct_pay float64
  30284. var fund_pay_sumamt float64
  30285. for _, item := range orders_two {
  30286. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30287. acct_pay = acct_pay + item.AcctPay
  30288. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  30289. }
  30290. var baseParams models.BaseParams
  30291. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  30292. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  30293. baseParams.SecretKey = miConfig.SecretKey
  30294. baseParams.OrgName = miConfig.OrgName
  30295. baseParams.FixmedinsCode = miConfig.Code
  30296. baseParams.EncKey = miConfig.EncKey
  30297. baseParams.AppSecret = miConfig.AppSecret
  30298. baseParams.SignKey = miConfig.SignKey
  30299. baseParams.AppID = miConfig.Code
  30300. baseParams.Doctor = role.UserName
  30301. baseParams.RequestUrl = miConfig.Url
  30302. if clr_type == "9903" {
  30303. clr_type = "9994"
  30304. }
  30305. businessParams := models.BusinessParams{
  30306. Insutype: insutype,
  30307. ClrType: clr_type,
  30308. SetlOptins: "360302",
  30309. StmtBegndate: start_time,
  30310. StmtEnddate: end_time,
  30311. MedfeeSumamt: 0,
  30312. FundPaySumamt: 0,
  30313. AcctPay: 0,
  30314. FixmedinsSetlCnt: fixmedins_setl_cnt,
  30315. }
  30316. 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))
  30317. fmt.Println(requestLog)
  30318. fmt.Println(result)
  30319. var dat map[string]interface{}
  30320. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30321. fmt.Println(dat)
  30322. } else {
  30323. fmt.Println(err)
  30324. }
  30325. userJSONBytes, _ := json.Marshal(dat)
  30326. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30327. utils.ErrorLog("解析失败:%v", err)
  30328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30329. return
  30330. }
  30331. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30332. var api string
  30333. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  30334. "&clr_type=" + clr_type +
  30335. "&setl_optins=" + clr_org +
  30336. "&stmt_begndate=" + start_time +
  30337. "&stm_enddate=" + end_time +
  30338. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  30339. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  30340. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  30341. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  30342. "&fixmedins_code=" + miConfig.Code +
  30343. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30344. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30345. "&secret_key=" + miConfig.SecretKey +
  30346. "&org_name=" + miConfig.OrgName +
  30347. "&doctor=" + user_name + "&url=" + miConfig.Url
  30348. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30349. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30350. resp, requestErr := http.Get(api)
  30351. if requestErr != nil {
  30352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30353. return
  30354. }
  30355. body, ioErr := ioutil.ReadAll(resp.Body)
  30356. if ioErr != nil {
  30357. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30359. return
  30360. }
  30361. var respJSON map[string]interface{}
  30362. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30363. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30365. return
  30366. }
  30367. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30368. if status == "0" {
  30369. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30370. c.ServeSuccessJSON(map[string]interface{}{
  30371. "failed_code": -10,
  30372. "msg": err_msg,
  30373. })
  30374. return
  30375. }
  30376. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30377. userJSONBytes, _ := json.Marshal(respJSON)
  30378. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30379. utils.ErrorLog("解析失败:%v", err)
  30380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30381. return
  30382. }
  30383. } else {
  30384. if len(clr_type) == 0 {
  30385. clr_type = "11"
  30386. }
  30387. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  30388. "insutype=" + insutype +
  30389. "&clr_type=" + clr_type +
  30390. "&setl_optins=" + clr_org +
  30391. "&stmt_begndate=" + start_time +
  30392. "&stm_enddate=" + end_time +
  30393. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  30394. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  30395. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  30396. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  30397. "&fixmedins_code=" + miConfig.Code +
  30398. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30399. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30400. "&secret_key=" + miConfig.SecretKey +
  30401. "&org_name=" + miConfig.OrgName +
  30402. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  30403. fmt.Println(api)
  30404. resp, requestErr := http.Get(api)
  30405. if requestErr != nil {
  30406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30407. return
  30408. }
  30409. body, ioErr := ioutil.ReadAll(resp.Body)
  30410. fmt.Println(body)
  30411. if ioErr != nil {
  30412. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30414. return
  30415. }
  30416. var respJSON map[string]interface{}
  30417. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30418. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30420. return
  30421. }
  30422. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30423. userJSONBytes, _ := json.Marshal(respJSON)
  30424. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30425. utils.ErrorLog("解析失败:%v", err)
  30426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30427. return
  30428. }
  30429. }
  30430. if res.Infcode == 0 {
  30431. if res.Output.Stmtinfo.StmtRslt == "0" {
  30432. micc := &models.MedicalInsuranceCostCompare{
  30433. StartTime: startime.Unix(),
  30434. EndTime: endtime.Unix(),
  30435. Insutype: insutype,
  30436. CheckType: 1,
  30437. Num: fixmedins_setl_cnt,
  30438. Mtime: time.Now().Unix(),
  30439. Status: 1,
  30440. UserOrgId: adminUser.CurrentOrgId,
  30441. CostTotal: medfee_sumamt,
  30442. FuncTotal: fund_pay_sumamt,
  30443. PsnPay: acct_pay,
  30444. Creator: admin_user_id,
  30445. Ctime: time.Now().Unix(),
  30446. ClrType: clr_type,
  30447. }
  30448. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  30449. if err == nil {
  30450. c.ServeSuccessJSON(map[string]interface{}{
  30451. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  30452. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  30453. })
  30454. } else {
  30455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30456. }
  30457. } else {
  30458. c.ServeSuccessJSON(map[string]interface{}{
  30459. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  30460. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  30461. })
  30462. }
  30463. } else {
  30464. c.ServeSuccessJSON(map[string]interface{}{
  30465. "failed_code": -10,
  30466. "msg": res.ErrMsg,
  30467. })
  30468. }
  30469. }
  30470. }
  30471. func (c *HisApiController) Check310() {
  30472. adminUser := c.GetAdminUserInfo()
  30473. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30474. var user_name string
  30475. user_name = "高慧裕"
  30476. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  30477. "insutype=" + "310" +
  30478. "&clr_type=" + "" +
  30479. "&setl_optins=" + "441202" +
  30480. "&stmt_begndate=" + "2022-03-01" +
  30481. "&stm_enddate=" + "2022-03-31" +
  30482. "&medfee_sumamt=" + "194930.12" +
  30483. "&fund_pay_sumamt=" + "188741.46" +
  30484. "&acct_pay=" + "0" +
  30485. "&fixmedins_setl_cnt=" + "452" +
  30486. "&fixmedins_code=" + miConfig.Code +
  30487. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30488. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30489. "&secret_key=" + miConfig.SecretKey +
  30490. "&org_name=" + miConfig.OrgName +
  30491. "&doctor=" + user_name
  30492. fmt.Println(api)
  30493. resp, requestErr := http.Get(api)
  30494. if requestErr != nil {
  30495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30496. return
  30497. }
  30498. body, ioErr := ioutil.ReadAll(resp.Body)
  30499. fmt.Println(body)
  30500. if ioErr != nil {
  30501. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30503. return
  30504. }
  30505. var respJSON map[string]interface{}
  30506. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30509. return
  30510. }
  30511. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30512. userJSONBytes, _ := json.Marshal(respJSON)
  30513. var res ResultEight
  30514. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30515. utils.ErrorLog("解析失败:%v", err)
  30516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30517. return
  30518. }
  30519. }
  30520. func (c *HisApiController) Check390() {
  30521. adminUser := c.GetAdminUserInfo()
  30522. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30523. var user_name string
  30524. user_name = "高慧裕"
  30525. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  30526. "insutype=" + "390" +
  30527. "&clr_type=" + "" +
  30528. "&setl_optins=" + "441202" +
  30529. "&stmt_begndate=" + "2022-03-01" +
  30530. "&stm_enddate=" + "2022-03-31" +
  30531. "&medfee_sumamt=" + "1068448.89" +
  30532. "&fund_pay_sumamt=" + "1014677.62" +
  30533. "&acct_pay=" + "0" +
  30534. "&fixmedins_setl_cnt=" + "1950" +
  30535. "&fixmedins_code=" + miConfig.Code +
  30536. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30537. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30538. "&secret_key=" + miConfig.SecretKey +
  30539. "&org_name=" + miConfig.OrgName +
  30540. "&doctor=" + user_name
  30541. fmt.Println(api)
  30542. resp, requestErr := http.Get(api)
  30543. if requestErr != nil {
  30544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30545. return
  30546. }
  30547. body, ioErr := ioutil.ReadAll(resp.Body)
  30548. fmt.Println(body)
  30549. if ioErr != nil {
  30550. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30552. return
  30553. }
  30554. var respJSON map[string]interface{}
  30555. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30556. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30558. return
  30559. }
  30560. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30561. userJSONBytes, _ := json.Marshal(respJSON)
  30562. var res ResultEight
  30563. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30564. utils.ErrorLog("解析失败:%v", err)
  30565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30566. return
  30567. }
  30568. }
  30569. // 对账明细
  30570. func (c *HisApiController) GetCheckDetailAccount() {
  30571. start_time := c.GetString("start_time")
  30572. end_time := c.GetString("end_time")
  30573. admin_user_id, _ := c.GetInt64("admin_user_id")
  30574. adminUser := c.GetAdminUserInfo()
  30575. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30576. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30577. timeLayout := "2006-01-02"
  30578. loc, _ := time.LoadLocation("Local")
  30579. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  30580. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30581. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30582. rand.Seed(time.Now().UnixNano())
  30583. num := rand.Intn(30000)
  30584. Mkdir(miConfig.OrgName)
  30585. file := strconv.FormatInt(int64(num), 10)
  30586. file_name := file + ".txt"
  30587. zip_name := file + ".zip"
  30588. zip_path := miConfig.OrgName + "/" + zip_name
  30589. file_path := miConfig.OrgName + "/" + file_name
  30590. decimal.DivisionPrecision = 2
  30591. var medfee_sumamt float64
  30592. var psn_cash_pay float64
  30593. var fund_pay_sumamt float64
  30594. fixmedins_setl_cnt := int64(len(orders))
  30595. for _, item := range orders {
  30596. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30597. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  30598. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  30599. }
  30600. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  30601. defer f.Close()
  30602. if err != nil {
  30603. fmt.Println(err.Error())
  30604. } else {
  30605. for _, item := range orders {
  30606. var refd_setl_flag string
  30607. if item.OrderStatus == 2 {
  30608. refd_setl_flag = "0"
  30609. var str string
  30610. str = item.SetlId + " " +
  30611. item.MdtrtId + " " +
  30612. item.PsnNo + " " +
  30613. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  30614. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  30615. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  30616. _, err = f.Write([]byte(str))
  30617. }
  30618. if item.OrderStatus == 3 {
  30619. var str string
  30620. str = item.SetlId + " " +
  30621. item.MdtrtId + " " +
  30622. item.PsnNo + " " +
  30623. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  30624. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  30625. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  30626. _, err = f.Write([]byte(str))
  30627. var str2 string
  30628. str2 = item.SetlId + " " +
  30629. item.MdtrtId + " " +
  30630. item.PsnNo + " " +
  30631. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  30632. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  30633. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  30634. _, err = f.Write([]byte(str2))
  30635. }
  30636. }
  30637. }
  30638. Zip(file_path, zip_path)
  30639. fmt.Println(ReadFile(zip_path))
  30640. fmt.Println(string(ReadFile(zip_path)))
  30641. if config.IsOpen == 1 {
  30642. var user_name string
  30643. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30644. if role.ID == 0 {
  30645. user_name = "管理员"
  30646. } else {
  30647. user_name = role.UserName
  30648. }
  30649. baseParams := models.BaseParams{
  30650. SecretKey: miConfig.SecretKey,
  30651. FixmedinsCode: miConfig.Code,
  30652. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  30653. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  30654. OrgName: miConfig.OrgName,
  30655. Doctor: user_name,
  30656. }
  30657. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  30658. var dat map[string]interface{}
  30659. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30660. fmt.Println(dat)
  30661. } else {
  30662. fmt.Println(err)
  30663. }
  30664. userJSONBytes, _ := json.Marshal(dat)
  30665. var res ResultNine
  30666. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30667. utils.ErrorLog("解析失败:%v", err)
  30668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30669. return
  30670. }
  30671. if res.Infcode == 0 {
  30672. fileNo := res.Output.FileQuryNo
  30673. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  30674. "file_qury_no=" + fileNo +
  30675. "&setl_optins=" + "定点医保中心" +
  30676. "&stmt_begndate=" + start_time +
  30677. "&stm_enddate=" + end_time +
  30678. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  30679. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  30680. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  30681. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  30682. "&fixmedins_code=" + miConfig.Code +
  30683. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30684. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30685. "&secret_key=" + miConfig.SecretKey +
  30686. "&org_name=" + miConfig.OrgName +
  30687. "&doctor=" + user_name
  30688. resp, requestErr := http.Get(api)
  30689. if requestErr != nil {
  30690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30691. return
  30692. }
  30693. body, ioErr := ioutil.ReadAll(resp.Body)
  30694. if ioErr != nil {
  30695. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30697. return
  30698. }
  30699. var respJSON map[string]interface{}
  30700. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30703. return
  30704. }
  30705. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30706. userJSONBytes, _ := json.Marshal(respJSON)
  30707. var res ResultTen
  30708. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30709. utils.ErrorLog("解析失败:%v", err)
  30710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30711. return
  30712. }
  30713. if res.Infcode == 0 {
  30714. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  30715. micc := &models.MedicalInsuranceCostCompare{
  30716. StartTime: startime.Unix(),
  30717. EndTime: endtime.Unix(),
  30718. Insutype: "0",
  30719. CheckType: 2,
  30720. Num: fixmedins_setl_cnt,
  30721. Mtime: time.Now().Unix(),
  30722. Status: 1,
  30723. UserOrgId: adminUser.CurrentOrgId,
  30724. CostTotal: medfee_sumamt,
  30725. FuncTotal: fund_pay_sumamt,
  30726. PsnPay: psn_cash_pay,
  30727. Creator: admin_user_id,
  30728. Ctime: time.Now().Unix(),
  30729. }
  30730. service.CreateMedicalInsuranceCostCompareRecord(micc)
  30731. c.ServeSuccessJSON(map[string]interface{}{
  30732. "msg": "明细对账成功",
  30733. })
  30734. }
  30735. } else {
  30736. }
  30737. }
  30738. }
  30739. type CustomOrderInfo struct {
  30740. Name string
  30741. Spec string
  30742. Unit string
  30743. Count float64
  30744. Price float64
  30745. Total float64
  30746. }
  30747. func (c *HisApiController) GetBatchSettleAccounts() {
  30748. admin_user_id, _ := c.GetInt64("admin_user_id")
  30749. order_ids := c.GetString("order_ids")
  30750. order_ids_arr := strings.Split(order_ids, ",")
  30751. data3 := []map[string]interface{}{}
  30752. for _, item := range order_ids_arr {
  30753. id, _ := strconv.ParseInt(item, 10, 64)
  30754. order_id := id
  30755. adminUser := c.GetAdminUserInfo()
  30756. order, _ := service.GetHisOrderByID(order_id)
  30757. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  30758. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  30759. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  30760. orderInfos = append(orderInfos, orderInfos_two...)
  30761. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  30762. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  30763. var diagnosis_ids []string
  30764. if his.ID > 0 {
  30765. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  30766. } else {
  30767. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  30768. }
  30769. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  30770. var dia_config []*models.HisXtDiagnoseConfig
  30771. var name string
  30772. for _, item := range diagnosis_ids {
  30773. id, _ := strconv.ParseInt(item, 10, 64)
  30774. diagnosisConfig, _ := service.FindDiagnoseById(id)
  30775. dia_config = append(dia_config, &diagnosisConfig)
  30776. if len(name) == 0 {
  30777. name = diagnosisConfig.ClassName
  30778. }
  30779. //} else {
  30780. // name = name + "," + diagnosisConfig.ClassName
  30781. //}
  30782. }
  30783. var bedCostTotal float64 = 0 //床位总费
  30784. var bedCostSelfTotal float64 = 0 //床位自费
  30785. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  30786. var bedSelfTotal float64 = 0 //床位部分项目自费
  30787. var bedInscpTotal float64 = 0 //床位部分项目自费
  30788. var operationCostTotal float64 = 0 //手术费
  30789. var operationCostSelfTotal float64 = 0 //手术费
  30790. var operationCostPartSelfTotal float64 = 0 //手术费
  30791. var operationSelfTotal float64 = 0 //床位部分项目自费
  30792. var operationInscpTotal float64 = 0 //床位部分项目自费
  30793. var otherCostTotal float64 = 0 //其他费用
  30794. var otherCostSelfTotal float64 = 0 //其他费用
  30795. var otherCostPartSelfTotal float64 = 0 //其他费用
  30796. var otherSelfTotal float64 = 0 //床位部分项目自费
  30797. var otherInscpTotal float64 = 0 //床位部分项目自费
  30798. var materialCostTotal float64 = 0 //材料费
  30799. var materialCostSelfTotal float64 = 0 //材料费
  30800. var materialCostPartSelfTotal float64 = 0 //材料费
  30801. var materialSelfTotal float64 = 0 //床位部分项目自费
  30802. var materialInscpTotal float64 = 0 //床位部分项目自费
  30803. var westernMedicineCostTotal float64 = 0 //西药费
  30804. var westernMedicineCostSelfTotal float64 = 0 //西药费
  30805. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  30806. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  30807. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  30808. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  30809. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  30810. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  30811. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  30812. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  30813. var checkCostTotal float64 = 0 //检查费
  30814. var checkCostSelfTotal float64 = 0 //检查费
  30815. var checkCostPartSelfTotal float64 = 0 //检查费
  30816. var checkSelfTotal float64 = 0 //床位部分项目自费
  30817. var checkInscpTotal float64 = 0 //床位部分项目自费
  30818. var laboratoryCostTotal float64 = 0 //化验费
  30819. var laboratoryCostSelfTotal float64 = 0 //化验费
  30820. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  30821. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  30822. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  30823. var treatCostTotal float64 = 0 //治疗费用
  30824. var treatCostSelfTotal float64 = 0 //治疗费用
  30825. var treatCostPartSelfTotal float64 = 0 //治疗费用
  30826. var treatSelfTotal float64 = 0 //床位部分项目自费
  30827. var treatInscpTotal float64 = 0 //床位部分项目自费
  30828. decimal.DivisionPrecision = 2
  30829. for _, item := range orderInfos {
  30830. if item.MedChrgitmType == "01" { //床位费
  30831. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30832. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30833. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30834. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30835. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30836. }
  30837. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  30838. if item.MedChrgitmType == "03" { //检查费
  30839. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30840. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30841. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30842. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30843. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30844. }
  30845. } else {
  30846. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  30847. fmt.Println("------------")
  30848. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30849. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30850. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30851. }
  30852. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  30853. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30854. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30855. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30856. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30857. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30858. }
  30859. }
  30860. if item.MedChrgitmType == "04" { //化验费
  30861. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30862. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30863. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30864. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30865. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30866. }
  30867. if item.MedChrgitmType == "05" { //治疗费
  30868. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30869. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30870. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30871. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30872. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30873. }
  30874. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  30875. fmt.Println("------------")
  30876. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30877. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30878. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30879. }
  30880. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  30881. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30882. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30883. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30884. }
  30885. //if item.MedChrgitmType == "06" { //手术费
  30886. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30887. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30888. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30889. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30890. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30891. //
  30892. //}
  30893. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  30894. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30895. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30896. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30897. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30898. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30899. }
  30900. if item.MedChrgitmType == "09" { //西药费
  30901. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30902. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30903. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30904. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30905. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30906. }
  30907. if item.MedChrgitmType == "11" { //中成费
  30908. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30909. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30910. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30911. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30912. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30913. }
  30914. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  30915. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30916. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30917. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30918. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30919. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30920. }
  30921. }
  30922. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30923. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30924. var user_name string
  30925. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30926. if role.ID == 0 {
  30927. user_name = "管理员"
  30928. } else {
  30929. user_name = role.UserName
  30930. }
  30931. baseParams := models.BaseParams{
  30932. SecretKey: miConfig.SecretKey,
  30933. FixmedinsCode: miConfig.Code,
  30934. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  30935. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  30936. OrgName: miConfig.OrgName,
  30937. Doctor: user_name,
  30938. RequestUrl: miConfig.Url,
  30939. AccessKey: miConfig.AccessKey,
  30940. }
  30941. businessParams := models.BusinessParams{
  30942. PsnNo: order.PsnNo,
  30943. MdtrtId: order.MdtrtId,
  30944. SetlId: order.SetlId,
  30945. }
  30946. var res ResultEleven
  30947. var resEleven10265 ResultEleven10265
  30948. if config.IsOpen == 1 {
  30949. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  30950. result := service.Gdyb5203(baseParams, businessParams)
  30951. service.Gdyb5204(baseParams, businessParams)
  30952. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  30953. var dat map[string]interface{}
  30954. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30955. fmt.Println(dat)
  30956. } else {
  30957. fmt.Println(err)
  30958. }
  30959. userJSONBytes, _ := json.Marshal(dat)
  30960. if miConfig.Code == "H15049901371" {
  30961. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  30962. utils.ErrorLog("解析失败:%v", err)
  30963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30964. return
  30965. }
  30966. res.InfRefmsgid = resEleven10265.InfRefmsgid
  30967. res.Output = resEleven10265.Output
  30968. res.ErrMsg = resEleven10265.ErrMsg
  30969. res.Cainfo = resEleven10265.Cainfo
  30970. res.WarnMsg = resEleven10265.WarnMsg
  30971. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  30972. res.Infcode = infocode
  30973. } else {
  30974. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30975. utils.ErrorLog("解析失败:%v", err)
  30976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30977. return
  30978. }
  30979. }
  30980. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30981. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  30982. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  30983. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  30984. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  30985. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30986. var doctor_name string
  30987. if roles.ID == 0 {
  30988. doctor_name = "管理员"
  30989. } else {
  30990. doctor_name = roles.UserName
  30991. }
  30992. yiliao_leibie := ""
  30993. switch order.MedType {
  30994. case "11":
  30995. yiliao_leibie = "普通门诊"
  30996. break
  30997. case "12":
  30998. yiliao_leibie = "门诊挂号"
  30999. break
  31000. case "13":
  31001. yiliao_leibie = "急诊"
  31002. break
  31003. case "14":
  31004. yiliao_leibie = "门诊特殊病"
  31005. break
  31006. case "15":
  31007. yiliao_leibie = "门诊统筹"
  31008. break
  31009. case "16":
  31010. yiliao_leibie = "门诊慢性病"
  31011. break
  31012. case "21":
  31013. yiliao_leibie = "普通住院"
  31014. break
  31015. }
  31016. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  31017. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  31018. if res.Infcode == 0 {
  31019. data2 := map[string]interface{}{
  31020. "diagnosis": name,
  31021. "order_infos": orderInfos,
  31022. "number": order.MdtrtId,
  31023. "date": order.SettleAccountsDate,
  31024. "charge_admin": charge_admin,
  31025. "printor_admin": printor_admin,
  31026. "info": res.Output.Setlinfo,
  31027. "order": order,
  31028. "bedCostTotal": bedCostTotal,
  31029. "bedCostSelfTotal": bedCostSelfTotal,
  31030. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  31031. "bedSelfTotal": bedSelfTotal,
  31032. "bedInscpTotal": bedInscpTotal,
  31033. "operationCostTotal": operationCostTotal,
  31034. "operationCostSelfTotal": operationCostSelfTotal,
  31035. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  31036. "operationSelfTotal": operationSelfTotal,
  31037. "operationInscpTotal": operationInscpTotal,
  31038. "otherCostTotal": otherCostTotal,
  31039. "otherCostSelfTotal": otherCostSelfTotal,
  31040. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  31041. "otherSelfTotal": otherSelfTotal,
  31042. "otherInscpTotal": otherInscpTotal,
  31043. "materialCostTotal": materialCostTotal,
  31044. "materialCostSelfTotal": materialCostSelfTotal,
  31045. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  31046. "materialSelfTotal": materialSelfTotal,
  31047. "materialInscpTotal": materialInscpTotal,
  31048. "westernMedicineCostTotal": westernMedicineCostTotal,
  31049. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  31050. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  31051. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  31052. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  31053. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  31054. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  31055. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  31056. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  31057. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  31058. "checkCostTotal": checkCostTotal,
  31059. "checkCostSelfTotal": checkCostSelfTotal,
  31060. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  31061. "checkSelfTotal": checkSelfTotal,
  31062. "checkInscpTotal": checkInscpTotal,
  31063. "laboratoryCostTotal": laboratoryCostTotal,
  31064. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  31065. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  31066. "laboratorySelfTotal": laboratorySelfTotal,
  31067. "laboratoryInscpTotal": laboratoryInscpTotal,
  31068. "treatCostTotal": treatCostTotal,
  31069. "treatCostSelfTotal": treatCostSelfTotal,
  31070. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  31071. "treatSelfTotal": treatSelfTotal,
  31072. "treatInscpTotal": treatInscpTotal,
  31073. "doctor_info": doctor_info,
  31074. "doctor_code": adminRole_two.DoctorCode,
  31075. "doctor_name": doctor_name,
  31076. "health_card_no": order.PsnNo,
  31077. "department": departments.Name,
  31078. "yiliao_leibie": yiliao_leibie,
  31079. "after_money": order.AccountPrice,
  31080. "patient": patient,
  31081. "org_name": miConfig.OrgName,
  31082. "org_code": miConfig.Code,
  31083. "order_number": order.Number,
  31084. "his_hospital": his_hospital,
  31085. "his": his,
  31086. "dia_config": dia_config,
  31087. "psn_cash_pay": order.PsnCashPay,
  31088. //"check_order_info": cus_slice,
  31089. }
  31090. data3 = append(data3, data2)
  31091. }
  31092. }
  31093. }
  31094. c.ServeSuccessJSON(map[string]interface{}{
  31095. "infos": data3,
  31096. })
  31097. }
  31098. func (c *HisApiController) GetSettleAccounts() {
  31099. //id, _ := c.GetInt64("id")
  31100. //record_time := c.GetString("record_time")
  31101. order_id, _ := c.GetInt64("order_id")
  31102. admin_user_id, _ := c.GetInt64("admin_user_id")
  31103. //timeLayout := "2006-01-02"
  31104. //loc, _ := time.LoadLocation("Local")
  31105. //
  31106. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  31107. //if err != nil {
  31108. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31109. // return
  31110. //}Hbyb5203
  31111. //recordDateTime := theTime.Unix()
  31112. adminUser := c.GetAdminUserInfo()
  31113. order, _ := service.GetHisOrderByID(order_id)
  31114. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  31115. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  31116. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  31117. orderInfos = append(orderInfos, orderInfos_two...)
  31118. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  31119. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  31120. var diagnosis_ids []string
  31121. if his.ID > 0 {
  31122. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  31123. } else {
  31124. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  31125. }
  31126. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  31127. var dia_config []*models.HisXtDiagnoseConfig
  31128. var name string
  31129. for _, item := range diagnosis_ids {
  31130. id, _ := strconv.ParseInt(item, 10, 64)
  31131. diagnosisConfig, _ := service.FindDiagnoseById(id)
  31132. dia_config = append(dia_config, &diagnosisConfig)
  31133. if len(name) == 0 {
  31134. name = diagnosisConfig.ClassName
  31135. } else {
  31136. name = name + "," + diagnosisConfig.ClassName
  31137. }
  31138. }
  31139. if patient.UserOrgId == 10215 {
  31140. name = "慢性肾功能不全(血透治疗)"
  31141. }
  31142. var bedCostTotal float64 = 0 //床位总费
  31143. var bedCostSelfTotal float64 = 0 //床位自费
  31144. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  31145. var bedSelfTotal float64 = 0 //床位部分项目自费
  31146. var bedInscpTotal float64 = 0 //床位部分项目自费
  31147. var operationCostTotal float64 = 0 //手术费
  31148. var operationCostSelfTotal float64 = 0 //手术费
  31149. var operationCostPartSelfTotal float64 = 0 //手术费
  31150. var operationSelfTotal float64 = 0 //床位部分项目自费
  31151. var operationInscpTotal float64 = 0 //床位部分项目自费
  31152. var otherCostTotal float64 = 0 //其他费用
  31153. var otherCostSelfTotal float64 = 0 //其他费用
  31154. var otherCostPartSelfTotal float64 = 0 //其他费用
  31155. var otherSelfTotal float64 = 0 //床位部分项目自费
  31156. var otherInscpTotal float64 = 0 //床位部分项目自费
  31157. var materialCostTotal float64 = 0 //材料费
  31158. var materialCostSelfTotal float64 = 0 //材料费
  31159. var materialCostPartSelfTotal float64 = 0 //材料费
  31160. var materialSelfTotal float64 = 0 //床位部分项目自费
  31161. var materialInscpTotal float64 = 0 //床位部分项目自费
  31162. var westernMedicineCostTotal float64 = 0 //西药费
  31163. var westernMedicineCostSelfTotal float64 = 0 //西药费
  31164. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  31165. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  31166. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  31167. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  31168. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  31169. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  31170. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  31171. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  31172. var checkCostTotal float64 = 0 //检查费
  31173. var checkCostSelfTotal float64 = 0 //检查费
  31174. var checkCostPartSelfTotal float64 = 0 //检查费
  31175. var checkSelfTotal float64 = 0 //床位部分项目自费
  31176. var checkInscpTotal float64 = 0 //床位部分项目自费
  31177. var laboratoryCostTotal float64 = 0 //化验费
  31178. var laboratoryCostSelfTotal float64 = 0 //化验费
  31179. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  31180. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  31181. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  31182. var treatCostTotal float64 = 0 //治疗费用
  31183. var treatCostSelfTotal float64 = 0 //治疗费用
  31184. var treatCostPartSelfTotal float64 = 0 //治疗费用
  31185. var treatSelfTotal float64 = 0 //床位部分项目自费
  31186. var treatInscpTotal float64 = 0 //床位部分项目自费
  31187. var zcCostTotal float64 = 0 //治疗费用
  31188. var zcCostSelfTotal float64 = 0 //治疗费用
  31189. var zcCostPartSelfTotal float64 = 0 //治疗费用
  31190. var zcSelfTotal float64 = 0 //床位部分项目自费
  31191. var zcInscpTotal float64 = 0 //床位部分项目自费
  31192. var huliCostTotal float64 = 0 //治疗费用
  31193. var huliCostSelfTotal float64 = 0 //治疗费用
  31194. var huliCostPartSelfTotal float64 = 0 //治疗费用
  31195. var huliSelfTotal float64 = 0 //床位部分项目自费
  31196. var huliInscpTotal float64 = 0 //床位部分项目自费
  31197. decimal.DivisionPrecision = 2
  31198. for _, item := range orderInfos {
  31199. if item.MedChrgitmType == "01" { //床位费
  31200. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31201. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31202. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31203. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31204. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31205. }
  31206. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  31207. if item.MedChrgitmType == "03" { //检查费
  31208. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31209. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31210. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31211. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31212. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31213. }
  31214. } else {
  31215. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  31216. fmt.Println("------------")
  31217. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31218. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31219. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31220. }
  31221. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  31222. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31223. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31224. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31225. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31226. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31227. }
  31228. }
  31229. if item.MedChrgitmType == "04" { //化验费
  31230. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31231. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31232. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31233. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31234. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31235. }
  31236. if item.MedChrgitmType == "05" { //治疗费
  31237. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31238. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31239. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31240. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31241. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31242. }
  31243. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  31244. fmt.Println("------------")
  31245. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31246. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31247. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31248. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31249. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31250. }
  31251. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  31252. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31253. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31254. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31255. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31256. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31257. }
  31258. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  31259. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31260. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31261. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31262. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31263. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31264. }
  31265. if item.MedChrgitmType == "09" { //西药费
  31266. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31267. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31268. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31269. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31270. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31271. }
  31272. if item.MedChrgitmType == "11" { //中成费
  31273. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31274. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31275. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31276. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31277. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31278. }
  31279. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  31280. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31281. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31282. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31283. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31284. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31285. }
  31286. if item.MedChrgitmType == "02" { //其他费
  31287. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31288. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31289. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31290. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31291. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31292. }
  31293. if item.MedChrgitmType == "07" { //其他费
  31294. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31295. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31296. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31297. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31298. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31299. }
  31300. }
  31301. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31302. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31303. var user_name string
  31304. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31305. if role.ID == 0 {
  31306. user_name = "管理员"
  31307. } else {
  31308. user_name = role.UserName
  31309. }
  31310. baseParams := models.BaseParams{
  31311. SecretKey: miConfig.SecretKey,
  31312. FixmedinsCode: miConfig.Code,
  31313. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  31314. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  31315. OrgName: miConfig.OrgName,
  31316. Doctor: user_name,
  31317. RequestUrl: miConfig.Url,
  31318. AccessKey: miConfig.AccessKey,
  31319. }
  31320. businessParams := models.BusinessParams{
  31321. PsnNo: order.PsnNo,
  31322. MdtrtId: order.MdtrtId,
  31323. SetlId: order.SetlId,
  31324. }
  31325. var res ResultEleven
  31326. var resah ResultElevenah
  31327. var resEleven10265 ResultEleven10265
  31328. if config.IsOpen == 1 {
  31329. if miConfig.MdtrtareaAdmvs == "421300" {
  31330. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31331. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31332. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31333. resp, requestErr := http.Get(api)
  31334. if requestErr != nil {
  31335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31336. return
  31337. }
  31338. body, ioErr := ioutil.ReadAll(resp.Body)
  31339. if ioErr != nil {
  31340. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31342. return
  31343. }
  31344. var respJSON map[string]interface{}
  31345. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31346. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31348. return
  31349. }
  31350. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31351. result, _ := json.Marshal(respJSON)
  31352. fmt.Println("log")
  31353. fmt.Println(string(result))
  31354. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31355. utils.ErrorLog("解析失败:%v", err)
  31356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31357. return
  31358. }
  31359. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31360. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31361. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31362. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31363. resp, requestErr := http.Get(api)
  31364. if requestErr != nil {
  31365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31366. return
  31367. }
  31368. body, ioErr := ioutil.ReadAll(resp.Body)
  31369. if ioErr != nil {
  31370. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31372. return
  31373. }
  31374. var respJSON map[string]interface{}
  31375. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31376. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31378. return
  31379. }
  31380. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31381. result, _ := json.Marshal(respJSON)
  31382. fmt.Println("log")
  31383. fmt.Println(string(result))
  31384. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31385. utils.ErrorLog("解析失败:%v", err)
  31386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31387. return
  31388. }
  31389. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31390. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31391. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31392. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31393. resp, requestErr := http.Get(api)
  31394. if requestErr != nil {
  31395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31396. return
  31397. }
  31398. body, ioErr := ioutil.ReadAll(resp.Body)
  31399. if ioErr != nil {
  31400. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31402. return
  31403. }
  31404. var respJSON map[string]interface{}
  31405. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31406. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31408. return
  31409. }
  31410. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31411. result, _ := json.Marshal(respJSON)
  31412. fmt.Println("log")
  31413. fmt.Println(string(result))
  31414. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31415. utils.ErrorLog("解析失败:%v", err)
  31416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31417. return
  31418. }
  31419. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31420. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31421. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31422. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  31423. resp, requestErr := http.Get(api)
  31424. if requestErr != nil {
  31425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31426. return
  31427. }
  31428. body, ioErr := ioutil.ReadAll(resp.Body)
  31429. if ioErr != nil {
  31430. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31432. return
  31433. }
  31434. var respJSON map[string]interface{}
  31435. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31436. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31438. return
  31439. }
  31440. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31441. result, _ := json.Marshal(respJSON)
  31442. fmt.Println("log")
  31443. fmt.Println(string(result))
  31444. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31445. utils.ErrorLog("解析失败:%v", err)
  31446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31447. return
  31448. }
  31449. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31450. var api string
  31451. if miConfig.MdtrtareaAdmvs == "320921" {
  31452. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31453. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31454. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31455. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31456. } else {
  31457. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31458. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31459. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31460. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31461. }
  31462. resp, requestErr := http.Get(api)
  31463. if requestErr != nil {
  31464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31465. return
  31466. }
  31467. body, ioErr := ioutil.ReadAll(resp.Body)
  31468. if ioErr != nil {
  31469. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31471. return
  31472. }
  31473. var respJSON map[string]interface{}
  31474. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31475. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31477. return
  31478. }
  31479. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31480. result, _ := json.Marshal(respJSON)
  31481. fmt.Println("log")
  31482. fmt.Println(string(result))
  31483. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  31484. utils.ErrorLog("解析失败:%v", err)
  31485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31486. return
  31487. }
  31488. res.InfRefmsgid = resEleven10265.InfRefmsgid
  31489. res.Output = resEleven10265.Output
  31490. res.ErrMsg = resEleven10265.ErrMsg
  31491. res.Cainfo = resEleven10265.Cainfo
  31492. res.WarnMsg = resEleven10265.WarnMsg
  31493. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  31494. res.Infcode = infocode
  31495. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31496. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  31497. saveLog(result, requestLog, "5203", "结算单")
  31498. var dat map[string]interface{}
  31499. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31500. fmt.Println(dat)
  31501. } else {
  31502. fmt.Println(err)
  31503. }
  31504. userJSONBytes, _ := json.Marshal(dat)
  31505. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31506. utils.ErrorLog("解析失败:%v", err)
  31507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31508. return
  31509. }
  31510. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31511. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  31512. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  31513. fmt.Println(result3)
  31514. fmt.Println(requestLog3)
  31515. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  31516. fmt.Println(result2)
  31517. fmt.Println(requestLog2)
  31518. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  31519. saveLog(result, requestLog, "5203", "结算单")
  31520. var dat map[string]interface{}
  31521. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31522. fmt.Println(dat)
  31523. } else {
  31524. fmt.Println(err)
  31525. }
  31526. userJSONBytes, _ := json.Marshal(dat)
  31527. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31528. utils.ErrorLog("解析失败:%v", err)
  31529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31530. return
  31531. }
  31532. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31533. var api string
  31534. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31535. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31536. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31537. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31538. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31539. resp, requestErr := http.Get(api)
  31540. if requestErr != nil {
  31541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31542. return
  31543. }
  31544. body, ioErr := ioutil.ReadAll(resp.Body)
  31545. if ioErr != nil {
  31546. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31548. return
  31549. }
  31550. var respJSON map[string]interface{}
  31551. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31554. return
  31555. }
  31556. status := respJSON["data"].(map[string]interface{})["status"].(string)
  31557. if status == "0" {
  31558. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  31559. c.ServeSuccessJSON(map[string]interface{}{
  31560. "failed_code": -10,
  31561. "msg": err_msg,
  31562. })
  31563. return
  31564. }
  31565. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31566. result, _ := json.Marshal(respJSON)
  31567. fmt.Println("log")
  31568. fmt.Println(string(result))
  31569. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  31570. utils.ErrorLog("解析失败:%v", err)
  31571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31572. return
  31573. }
  31574. res.InfRefmsgid = resah.InfRefmsgid
  31575. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31576. // 创建对应的Time类型
  31577. t := time.UnixMilli(timestamp)
  31578. // 格式化成指定的日期字符串
  31579. str := t.Format("2006-01-02 15:04:05")
  31580. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31581. // 创建对应的Time类型
  31582. t3 := time.UnixMilli(timestamp2)
  31583. // 格式化成指定的日期字符串
  31584. str2 := t3.Format("2006-01-02 15:04:05")
  31585. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  31586. // 创建对应的Time类型
  31587. t4 := time.UnixMilli(timestamp3)
  31588. // 格式化成指定的日期字符串
  31589. str3 := t4.Format("2006-01-02 15:04:05")
  31590. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  31591. // 创建对应的Time类型
  31592. t5 := time.UnixMilli(timestamp4)
  31593. // 格式化成指定的日期字符串
  31594. str5 := t5.Format("2006-01-02 15:04:05")
  31595. res.Output.Setlinfo.Brdy = str2
  31596. res.Output.Setlinfo.SetlTime = str
  31597. res.Output.Setlinfo.Begndate = str3
  31598. res.Output.Setlinfo.Enddate = str5
  31599. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  31600. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  31601. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  31602. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  31603. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  31604. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  31605. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  31606. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  31607. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  31608. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  31609. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  31610. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  31611. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31612. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  31613. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  31614. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  31615. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  31616. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  31617. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  31618. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  31619. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  31620. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  31621. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  31622. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  31623. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  31624. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31625. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  31626. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  31627. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  31628. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  31629. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31630. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  31631. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  31632. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  31633. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  31634. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  31635. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  31636. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  31637. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  31638. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  31639. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  31640. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  31641. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  31642. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  31643. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  31644. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31645. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  31646. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  31647. //res.Output.Setldetail = resah.Output.Setldetail
  31648. res.ErrMsg = resah.ErrMsg
  31649. res.Cainfo = resah.Cainfo
  31650. res.WarnMsg = resah.WarnMsg
  31651. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31652. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  31653. saveLog(result, requestLog, "5203", "结算单")
  31654. var dat map[string]interface{}
  31655. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31656. fmt.Println(dat)
  31657. } else {
  31658. fmt.Println(err)
  31659. }
  31660. userJSONBytes, _ := json.Marshal(dat)
  31661. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31662. utils.ErrorLog("解析失败:%v", err)
  31663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31664. return
  31665. }
  31666. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31667. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31668. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31669. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31670. resp, requestErr := http.Get(api)
  31671. if requestErr != nil {
  31672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31673. return
  31674. }
  31675. body, ioErr := ioutil.ReadAll(resp.Body)
  31676. if ioErr != nil {
  31677. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31679. return
  31680. }
  31681. var respJSON map[string]interface{}
  31682. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31683. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31685. return
  31686. }
  31687. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31688. result, _ := json.Marshal(respJSON)
  31689. fmt.Println("log")
  31690. fmt.Println(string(result))
  31691. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  31692. utils.ErrorLog("解析失败:%v", err)
  31693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31694. return
  31695. }
  31696. res.InfRefmsgid = resEleven10265.InfRefmsgid
  31697. res.Output = resEleven10265.Output
  31698. res.ErrMsg = resEleven10265.ErrMsg
  31699. res.Cainfo = resEleven10265.Cainfo
  31700. res.WarnMsg = resEleven10265.WarnMsg
  31701. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  31702. res.Infcode = infocode
  31703. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31704. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31705. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31706. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31707. resp, requestErr := http.Get(api)
  31708. if requestErr != nil {
  31709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31710. return
  31711. }
  31712. body, ioErr := ioutil.ReadAll(resp.Body)
  31713. if ioErr != nil {
  31714. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31716. return
  31717. }
  31718. var respJSON map[string]interface{}
  31719. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31722. return
  31723. }
  31724. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31725. result, _ := json.Marshal(respJSON)
  31726. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31727. utils.ErrorLog("解析失败:%v", err)
  31728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31729. return
  31730. }
  31731. } else if miConfig.MdtrtareaAdmvs == "450721" {
  31732. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  31733. //return
  31734. } else {
  31735. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  31736. if len(his.InsuplcAdmdvs) == 0 {
  31737. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  31738. } else {
  31739. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  31740. }
  31741. result := service.Gdyb5203(baseParams, businessParams)
  31742. //service.Gdyb5204(baseParams, businessParams)
  31743. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  31744. var dat map[string]interface{}
  31745. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31746. fmt.Println(dat)
  31747. } else {
  31748. fmt.Println(err)
  31749. }
  31750. userJSONBytes, _ := json.Marshal(dat)
  31751. if miConfig.Code == "H15049901371" {
  31752. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  31753. utils.ErrorLog("解析失败:%v", err)
  31754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31755. return
  31756. }
  31757. res.InfRefmsgid = resEleven10265.InfRefmsgid
  31758. res.Output = resEleven10265.Output
  31759. res.ErrMsg = resEleven10265.ErrMsg
  31760. res.Cainfo = resEleven10265.Cainfo
  31761. res.WarnMsg = resEleven10265.WarnMsg
  31762. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  31763. res.Infcode = infocode
  31764. } else {
  31765. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31766. utils.ErrorLog("解析失败:%v", err)
  31767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31768. return
  31769. }
  31770. }
  31771. }
  31772. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31773. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  31774. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  31775. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  31776. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  31777. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31778. var doctor_name string
  31779. if roles.ID == 0 {
  31780. doctor_name = "管理员"
  31781. } else {
  31782. doctor_name = roles.UserName
  31783. }
  31784. yiliao_leibie := ""
  31785. switch order.MedType {
  31786. case "11":
  31787. yiliao_leibie = "普通门诊"
  31788. break
  31789. case "12":
  31790. yiliao_leibie = "门诊挂号"
  31791. break
  31792. case "13":
  31793. yiliao_leibie = "急诊"
  31794. break
  31795. case "14":
  31796. yiliao_leibie = "门诊特殊病"
  31797. break
  31798. case "15":
  31799. yiliao_leibie = "门诊统筹"
  31800. break
  31801. case "16":
  31802. yiliao_leibie = "门诊慢性病"
  31803. break
  31804. case "21":
  31805. yiliao_leibie = "普通住院"
  31806. break
  31807. }
  31808. //var rf []CustomFundPay
  31809. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  31810. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  31811. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  31812. if res.Infcode == 0 {
  31813. 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 {
  31814. c.ServeSuccessJSON(map[string]interface{}{
  31815. "diagnosis": name,
  31816. "order_infos": orderInfos,
  31817. "number": order.MdtrtId,
  31818. "date": order.SettleAccountsDate,
  31819. "charge_admin": charge_admin,
  31820. "printor_admin": printor_admin,
  31821. "info": res.Output.Setlinfo,
  31822. "order": order,
  31823. "bedCostTotal": bedCostTotal,
  31824. "bedCostSelfTotal": bedCostSelfTotal,
  31825. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  31826. "bedSelfTotal": bedSelfTotal,
  31827. "bedInscpTotal": bedInscpTotal,
  31828. "operationCostTotal": operationCostTotal,
  31829. "operationCostSelfTotal": operationCostSelfTotal,
  31830. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  31831. "operationSelfTotal": operationSelfTotal,
  31832. "operationInscpTotal": operationInscpTotal,
  31833. "otherCostTotal": otherCostTotal,
  31834. "otherCostSelfTotal": otherCostSelfTotal,
  31835. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  31836. "otherSelfTotal": otherSelfTotal,
  31837. "otherInscpTotal": otherInscpTotal,
  31838. "materialCostTotal": materialCostTotal,
  31839. "materialCostSelfTotal": materialCostSelfTotal,
  31840. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  31841. "materialSelfTotal": materialSelfTotal,
  31842. "materialInscpTotal": materialInscpTotal,
  31843. "westernMedicineCostTotal": westernMedicineCostTotal,
  31844. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  31845. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  31846. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  31847. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  31848. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  31849. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  31850. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  31851. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  31852. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  31853. "checkCostTotal": checkCostTotal,
  31854. "checkCostSelfTotal": checkCostSelfTotal,
  31855. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  31856. "checkSelfTotal": checkSelfTotal,
  31857. "checkInscpTotal": checkInscpTotal,
  31858. "laboratoryCostTotal": laboratoryCostTotal,
  31859. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  31860. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  31861. "laboratorySelfTotal": laboratorySelfTotal,
  31862. "laboratoryInscpTotal": laboratoryInscpTotal,
  31863. "treatCostTotal": treatCostTotal,
  31864. "treatCostSelfTotal": treatCostSelfTotal,
  31865. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  31866. "treatSelfTotal": treatSelfTotal,
  31867. "treatInscpTotal": treatInscpTotal,
  31868. "doctor_info": doctor_info,
  31869. "doctor_code": adminRole_two.DoctorCode,
  31870. "doctor_name": doctor_name,
  31871. "health_card_no": order.PsnNo,
  31872. "department": departments.Name,
  31873. "yiliao_leibie": yiliao_leibie,
  31874. "after_money": order.AccountPrice,
  31875. "patient": patient,
  31876. "org_name": miConfig.OrgName,
  31877. "org_code": miConfig.Code,
  31878. "order_number": order.Number,
  31879. "his_hospital": his_hospital,
  31880. "his": his,
  31881. "dia_config": dia_config,
  31882. "psn_cash_pay": order.PsnCashPay,
  31883. "zcCostTotal": zcCostTotal,
  31884. "zcCostSelfTotal": zcCostSelfTotal,
  31885. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  31886. "zcSelfTotal": zcSelfTotal,
  31887. "zcInscpTotal": zcInscpTotal,
  31888. "huliCostTotal": huliCostTotal,
  31889. "huliCostSelfTotal": huliCostSelfTotal,
  31890. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  31891. "huliSelfTotal": huliSelfTotal,
  31892. "huliInscpTotal": huliInscpTotal,
  31893. //"funds": rf,
  31894. //"check_order_info": cus_slice,
  31895. })
  31896. } else {
  31897. c.ServeSuccessJSON(map[string]interface{}{
  31898. "diagnosis": name,
  31899. "order_infos": orderInfos,
  31900. "number": order.MdtrtId,
  31901. "date": order.SettleAccountsDate,
  31902. "charge_admin": charge_admin,
  31903. "printor_admin": printor_admin,
  31904. "info": order,
  31905. "order": order,
  31906. "bedCostTotal": bedCostTotal,
  31907. "bedCostSelfTotal": bedCostSelfTotal,
  31908. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  31909. "bedSelfTotal": bedSelfTotal,
  31910. "bedInscpTotal": bedInscpTotal,
  31911. "operationCostTotal": operationCostTotal,
  31912. "operationCostSelfTotal": operationCostSelfTotal,
  31913. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  31914. "operationSelfTotal": operationSelfTotal,
  31915. "operationInscpTotal": operationInscpTotal,
  31916. "otherCostTotal": otherCostTotal,
  31917. "otherCostSelfTotal": otherCostSelfTotal,
  31918. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  31919. "otherSelfTotal": otherSelfTotal,
  31920. "otherInscpTotal": otherInscpTotal,
  31921. "materialCostTotal": materialCostTotal,
  31922. "materialCostSelfTotal": materialCostSelfTotal,
  31923. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  31924. "materialSelfTotal": materialSelfTotal,
  31925. "materialInscpTotal": materialInscpTotal,
  31926. "westernMedicineCostTotal": westernMedicineCostTotal,
  31927. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  31928. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  31929. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  31930. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  31931. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  31932. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  31933. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  31934. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  31935. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  31936. "checkCostTotal": checkCostTotal,
  31937. "checkCostSelfTotal": checkCostSelfTotal,
  31938. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  31939. "checkSelfTotal": checkSelfTotal,
  31940. "checkInscpTotal": checkInscpTotal,
  31941. "laboratoryCostTotal": laboratoryCostTotal,
  31942. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  31943. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  31944. "laboratorySelfTotal": laboratorySelfTotal,
  31945. "laboratoryInscpTotal": laboratoryInscpTotal,
  31946. "treatCostTotal": treatCostTotal,
  31947. "treatCostSelfTotal": treatCostSelfTotal,
  31948. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  31949. "treatSelfTotal": treatSelfTotal,
  31950. "treatInscpTotal": treatInscpTotal,
  31951. "doctor_info": doctor_info,
  31952. "doctor_code": adminRole_two.DoctorCode,
  31953. "doctor_name": doctor_name,
  31954. "health_card_no": order.PsnNo,
  31955. "department": departments.Name,
  31956. "yiliao_leibie": yiliao_leibie,
  31957. "after_money": order.AccountPrice,
  31958. "patient": patient,
  31959. "org_name": miConfig.OrgName,
  31960. "org_code": miConfig.Code,
  31961. "order_number": order.Number,
  31962. "his_hospital": his_hospital,
  31963. "his": his,
  31964. "dia_config": dia_config,
  31965. "psn_cash_pay": order.PsnCashPay,
  31966. "zcCostTotal": zcCostTotal,
  31967. "zcCostSelfTotal": zcCostSelfTotal,
  31968. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  31969. "zcSelfTotal": zcSelfTotal,
  31970. "zcInscpTotal": zcInscpTotal,
  31971. "huliCostTotal": huliCostTotal,
  31972. "huliCostSelfTotal": huliCostSelfTotal,
  31973. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  31974. "huliSelfTotal": huliSelfTotal,
  31975. "huliInscpTotal": huliInscpTotal,
  31976. //"funds": rf,
  31977. //"check_order_info": cus_slice,
  31978. })
  31979. }
  31980. }
  31981. }
  31982. }
  31983. //func (c *HisApiController) CheckTreatment() {
  31984. // patient_id, _ := c.GetInt64("patient_id")
  31985. // id_card_no := c.GetString("id_card_no")
  31986. // insutype := c.GetString("insutype")
  31987. // med_type := c.GetString("med_type")
  31988. // admin_user_id, _ := c.GetInt64("admin_user_id")
  31989. //
  31990. // adminUser := c.GetAdminUserInfo()
  31991. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  31992. //
  31993. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31994. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31995. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31996. //
  31997. // if miConfig.MdtrtareaAdmvs == "421300" {
  31998. // var res ResultTwo
  31999. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  32000. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32001. // "&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)
  32002. // resp, requestErr := http.Get(api)
  32003. // if requestErr != nil {
  32004. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32005. // return
  32006. // }
  32007. //
  32008. // body, ioErr := ioutil.ReadAll(resp.Body)
  32009. // if ioErr != nil {
  32010. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32011. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32012. // return
  32013. // }
  32014. // var respJSON map[string]interface{}
  32015. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32016. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32017. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32018. // return
  32019. // }
  32020. //
  32021. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32022. // result, _ := json.Marshal(respJSON)
  32023. //
  32024. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  32025. // utils.ErrorLog("解析失败:%v", err)
  32026. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32027. // return
  32028. // }
  32029. //
  32030. // if res.Infcode == 0 {
  32031. //
  32032. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  32033. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32034. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  32035. // resp, requestErr := http.Get(api)
  32036. // if requestErr != nil {
  32037. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32038. // return
  32039. // }
  32040. //
  32041. // body, ioErr := ioutil.ReadAll(resp.Body)
  32042. // if ioErr != nil {
  32043. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32044. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32045. // return
  32046. // }
  32047. // var respJSON map[string]interface{}
  32048. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32049. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32050. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32051. // return
  32052. // }
  32053. // var res Result2001
  32054. //
  32055. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32056. // result2, _ := json.Marshal(respJSON)
  32057. //
  32058. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  32059. // utils.ErrorLog("解析失败:%v", err)
  32060. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32061. // return
  32062. // }
  32063. //
  32064. // if res.Infcode == 0 {
  32065. // c.ServeSuccessJSON(map[string]interface{}{
  32066. // "msg": res.Output.Trtinfo,
  32067. // })
  32068. // }
  32069. //
  32070. // } else {
  32071. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  32072. // return
  32073. // }
  32074. //
  32075. // } else {
  32076. //
  32077. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  32078. // var dat map[string]interface{}
  32079. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32080. // fmt.Println(dat)
  32081. // } else {
  32082. // fmt.Println(err)
  32083. // }
  32084. // userJSONBytes, _ := json.Marshal(dat)
  32085. // var res ResultTwo
  32086. // var res10265 ResultTwo10265
  32087. // if miConfig.Code == "H15049901371" {
  32088. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  32089. // utils.ErrorLog("解析失败:%v", err)
  32090. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32091. // return
  32092. // }
  32093. // res.ErrMsg = res10265.ErrMsg
  32094. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  32095. // res.Infcode = infocode
  32096. // res.Output = res10265.Output
  32097. // res.InfRefmsgid = res10265.InfRefmsgid
  32098. // } else {
  32099. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32100. // utils.ErrorLog("解析失败:%v", err)
  32101. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32102. // return
  32103. // }
  32104. // }
  32105. //
  32106. // var user_name string
  32107. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  32108. // if role.ID == 0 {
  32109. // user_name = "xxx"
  32110. // } else {
  32111. // user_name = role.UserName
  32112. // }
  32113. //
  32114. // baseParams := models.BaseParams{
  32115. // SecretKey: miConfig.SecretKey,
  32116. // FixmedinsCode: miConfig.Code,
  32117. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  32118. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  32119. // OrgName: miConfig.OrgName,
  32120. // Doctor: user_name,
  32121. // }
  32122. //
  32123. // if config.IsOpen == 1 {
  32124. // if miConfig.Code == "H15049901371" {
  32125. // if med_type == "14" {
  32126. // if insutype == "390" {
  32127. // med_type = "9933"
  32128. // } else if insutype == "310" {
  32129. // med_type = "990502"
  32130. // }
  32131. // } else if med_type == "11" {
  32132. // med_type = "11"
  32133. // }
  32134. // }
  32135. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  32136. // var dat map[string]interface{}
  32137. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32138. // fmt.Println(dat)
  32139. // } else {
  32140. // fmt.Println(err)
  32141. // }
  32142. // var res Result2001
  32143. // var res10265 Result2001Org10265
  32144. // if miConfig.Code == "H15049901371" {
  32145. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  32146. // utils.ErrorLog("解析失败:%v", err)
  32147. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32148. // return
  32149. // }
  32150. // res.ErrMsg = res10265.ErrMsg
  32151. // res.Output = res10265.Output
  32152. // res.InfRefmsgid = res10265.InfRefmsgid
  32153. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  32154. // res.Infcode = infocode
  32155. // } else {
  32156. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  32157. // utils.ErrorLog("解析失败:%v", err)
  32158. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32159. // return
  32160. // }
  32161. // }
  32162. // if res.Infcode == 0 {
  32163. // c.ServeSuccessJSON(map[string]interface{}{
  32164. // "msg": res.Output.Trtinfo,
  32165. // })
  32166. // }
  32167. // }
  32168. // }
  32169. //}
  32170. //func (c *HisApiController) PutRecord() {
  32171. // id, _ := c.GetInt64("id")
  32172. // record_time := c.GetString("record_time")
  32173. // timeLayout := "2006-01-02"
  32174. // loc, _ := time.LoadLocation("Local")
  32175. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32176. // if err != nil {
  32177. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32178. // return
  32179. // }
  32180. // recordDateTime := theTime.Unix()
  32181. //
  32182. // adminInfo := c.GetAdminUserInfo()
  32183. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  32184. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  32185. //
  32186. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  32187. //
  32188. // fmt.Println(miConfig.SecretKey)
  32189. //
  32190. // if patient == nil {
  32191. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  32192. // return
  32193. // }
  32194. // if len(patient.IdCardNo) == 0 {
  32195. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  32196. // return
  32197. // }
  32198. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  32199. // if config.IsOpen == 1 {
  32200. // 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
  32201. // resp, requestErr := http.Get(api)
  32202. // if requestErr != nil {
  32203. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32204. // return
  32205. // }
  32206. // defer resp.Body.Close()
  32207. // body, ioErr := ioutil.ReadAll(resp.Body)
  32208. // if ioErr != nil {
  32209. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32210. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32211. // return
  32212. // }
  32213. // var respJSON map[string]interface{}
  32214. //
  32215. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32216. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32217. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32218. // return
  32219. // }
  32220. //
  32221. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32222. // userJSONBytes, _ := json.Marshal(userJSON)
  32223. // var res ResultTwo
  32224. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32225. // utils.ErrorLog("解析失败:%v", err)
  32226. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32227. // return
  32228. // }
  32229. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  32230. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  32231. // infoStr := string(Iinfos)
  32232. // idetinfoStr := string(Idetinfos)
  32233. //
  32234. // if res.Infcode == 0 {
  32235. // his := models.VMHisPatient{
  32236. // Status: 1,
  32237. // Ctime: time.Now().Unix(),
  32238. // Mtime: time.Now().Unix(),
  32239. // PsnNo: res.Output.Baseinfo.PsnNo,
  32240. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  32241. // Certno: res.Output.Baseinfo.Certno,
  32242. // PsnName: res.Output.Baseinfo.PsnName,
  32243. // Gend: res.Output.Baseinfo.Gend,
  32244. // Naty: res.Output.Baseinfo.Naty,
  32245. // Brdy: res.Output.Baseinfo.Brdy,
  32246. // Age: res.Output.Baseinfo.Age,
  32247. // Iinfo: infoStr,
  32248. // Idetinfo: idetinfoStr,
  32249. // PatientId: patient.ID,
  32250. // RecordDate: theTime.Unix(),
  32251. // UserOrgId: adminInfo.CurrentOrgId,
  32252. // AdminUserId: adminInfo.AdminUser.Id,
  32253. // IsReturn: 1,
  32254. // }
  32255. //
  32256. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  32257. // //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")
  32258. // //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")
  32259. //
  32260. // //var dat map[string]interface{}
  32261. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32262. // // fmt.Println(dat)
  32263. // //} else {
  32264. // // fmt.Println(err)
  32265. // //}
  32266. //
  32267. // var dat2 map[string]interface{}
  32268. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  32269. // fmt.Println(dat2)
  32270. // } else {
  32271. // fmt.Println(err)
  32272. // }
  32273. //
  32274. // } else {
  32275. // adminUser := c.GetAdminUserInfo()
  32276. // errlog := &models.HisOrderError{
  32277. // UserOrgId: adminUser.CurrentOrgId,
  32278. // Ctime: time.Now().Unix(),
  32279. // Mtime: time.Now().Unix(),
  32280. // ErrMsg: res.ErrMsg,
  32281. // Status: 1,
  32282. // PatientId: id,
  32283. // RecordTime: recordDateTime,
  32284. // Stage: 1,
  32285. // }
  32286. // service.CreateErrMsgLog(errlog)
  32287. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  32288. // return
  32289. // }
  32290. // }
  32291. //
  32292. //}
  32293. //func (c *HisApiController) GetUploadDiag() {
  32294. // id, _ := c.GetInt64("id")
  32295. // record_time := c.GetString("record_time")
  32296. //
  32297. // diagnosis_id, _ := c.GetInt64("diagnosis")
  32298. // sick_type, _ := c.GetInt64("sick_type")
  32299. // reg_type, _ := c.GetInt64("reg_type")
  32300. //
  32301. // timeLayout := "2006-01-02"
  32302. // loc, _ := time.LoadLocation("Local")
  32303. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32304. // if err != nil {
  32305. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32306. // return
  32307. // }
  32308. //
  32309. // var patientPrescription models.HisPrescriptionInfo
  32310. // recordDateTime := theTime.Unix()
  32311. // adminInfo := c.GetAdminUserInfo()
  32312. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  32313. //
  32314. // if patientPrescription.ID == 0 {
  32315. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  32316. // }
  32317. //
  32318. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  32319. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  32320. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  32321. // sickConfig, _ := service.FindSickById(sick_type)
  32322. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  32323. //
  32324. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  32325. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  32326. // "&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 +
  32327. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  32328. // resp2, requestErr2 := http.Get(api2)
  32329. // if requestErr2 != nil {
  32330. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32331. // return
  32332. // }
  32333. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  32334. // if ioErr2 != nil {
  32335. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  32336. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32337. // return
  32338. // }
  32339. // var respJSON2 map[string]interface{}
  32340. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  32341. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32342. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32343. // return
  32344. // }
  32345. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32346. // userJSONBytes2, _ := json.Marshal(respJSON2)
  32347. //
  32348. // var res2 ResultSix
  32349. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  32350. // utils.ErrorLog("解析失败:%v", err)
  32351. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32352. // return
  32353. // }
  32354. // if res2.Infcode != 0 {
  32355. // adminUser := c.GetAdminUserInfo()
  32356. // errlog := &models.HisOrderError{
  32357. // UserOrgId: adminUser.CurrentOrgId,
  32358. // Ctime: time.Now().Unix(),
  32359. // Mtime: time.Now().Unix(),
  32360. // ErrMsg: res2.ErrMsg,
  32361. // Status: 1,
  32362. // PatientId: id,
  32363. // RecordTime: recordDateTime,
  32364. // Stage: 3,
  32365. // }
  32366. // service.CreateErrMsgLog(errlog)
  32367. //
  32368. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  32369. // return
  32370. // }
  32371. //
  32372. // c.ServeSuccessJSON(map[string]interface{}{
  32373. // "msg": "上传成功",
  32374. // })
  32375. //
  32376. //}
  32377. type QueryResult struct {
  32378. ID int64
  32379. Name string
  32380. Code string
  32381. List_type_code string
  32382. }
  32383. func (c *HisApiController) GetCheckCode() {
  32384. ids_str := c.GetString("ids")
  32385. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  32386. ids_arr := strings.Split(ids_str, ",")
  32387. var queryResult []QueryResult
  32388. ids := make([]int64, 0)
  32389. for _, item := range ids_arr {
  32390. id, _ := strconv.ParseInt(item, 10, 64)
  32391. ids = append(ids, id)
  32392. }
  32393. if record_type == 1 {
  32394. drugs, _ := service.GetBatchDrugList(ids)
  32395. for _, item := range drugs {
  32396. result := QueryResult{
  32397. ID: item.ID,
  32398. Name: item.DrugName,
  32399. Code: item.MedicalInsuranceNumber,
  32400. List_type_code: "101",
  32401. }
  32402. queryResult = append(queryResult, result)
  32403. }
  32404. } else if record_type == 2 {
  32405. goods, _ := service.GetBatchGoodInformationList(ids)
  32406. fmt.Println(goods)
  32407. for _, item := range goods {
  32408. result := QueryResult{
  32409. ID: item.ID,
  32410. Name: item.GoodName,
  32411. Code: item.SocialSecurityDirectoryCode,
  32412. List_type_code: "301",
  32413. }
  32414. queryResult = append(queryResult, result)
  32415. }
  32416. } else if record_type == 3 {
  32417. projects, _ := service.GetBathchMyPorjecgList(ids)
  32418. for _, item := range projects {
  32419. result := QueryResult{
  32420. ID: item.ID,
  32421. Name: item.ProjectName,
  32422. Code: item.MedicalCode,
  32423. List_type_code: "201",
  32424. }
  32425. queryResult = append(queryResult, result)
  32426. }
  32427. }
  32428. admin_user_id, _ := c.GetInt64("admin_user_id")
  32429. adminUser := c.GetAdminUserInfo()
  32430. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32431. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32432. var user_name string
  32433. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32434. if role.ID == 0 {
  32435. user_name = "管理员"
  32436. } else {
  32437. user_name = role.UserName
  32438. }
  32439. baseParams := models.BaseParams{
  32440. SecretKey: miConfig.SecretKey,
  32441. FixmedinsCode: miConfig.Code,
  32442. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  32443. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  32444. OrgName: miConfig.OrgName,
  32445. Doctor: user_name,
  32446. }
  32447. var result string
  32448. if miConfig.MdtrtareaAdmvs == "430800" {
  32449. for _, item := range queryResult {
  32450. if record_type == 1 {
  32451. 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)
  32452. } else if record_type == 2 {
  32453. fmt.Println(item.Code)
  32454. 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)
  32455. } else if record_type == 3 {
  32456. 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)
  32457. }
  32458. var dat map[string]interface{}
  32459. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32460. fmt.Println(dat)
  32461. } else {
  32462. fmt.Println(err)
  32463. }
  32464. userJSONBytes, _ := json.Marshal(dat)
  32465. var res ResultSix
  32466. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32467. utils.ErrorLog("解析失败:%v", err)
  32468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32469. return
  32470. }
  32471. if res.Infcode == 0 {
  32472. if record_type == 1 {
  32473. service.UpdateBaseDrugById(item.ID)
  32474. } else if record_type == 2 {
  32475. service.UpdateGoodInformaitonByDetail(item.ID)
  32476. } else if record_type == 3 {
  32477. service.UpdateProjectById(item.ID)
  32478. }
  32479. c.ServeSuccessJSON(map[string]interface{}{
  32480. "failed_code": 0,
  32481. "msg": "目录对照成功",
  32482. })
  32483. } else {
  32484. c.ServeSuccessJSON(map[string]interface{}{
  32485. "failed_code": -10,
  32486. "msg": res.ErrMsg,
  32487. })
  32488. }
  32489. }
  32490. } else {
  32491. for _, item := range queryResult {
  32492. var result string
  32493. if record_type == 1 {
  32494. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  32495. } else if record_type == 2 {
  32496. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  32497. } else if record_type == 3 {
  32498. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  32499. }
  32500. var dat map[string]interface{}
  32501. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32502. fmt.Println(dat)
  32503. } else {
  32504. fmt.Println(err)
  32505. }
  32506. userJSONBytes, _ := json.Marshal(dat)
  32507. var res ResultSix
  32508. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32509. utils.ErrorLog("解析失败:%v", err)
  32510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32511. return
  32512. }
  32513. if res.Infcode == 0 {
  32514. if record_type == 1 {
  32515. service.UpdateBaseDrugById(item.ID)
  32516. } else if record_type == 2 {
  32517. service.UpdateGoodInformaitonByDetail(item.ID)
  32518. } else if record_type == 3 {
  32519. service.UpdateProjectById(item.ID)
  32520. }
  32521. c.ServeSuccessJSON(map[string]interface{}{
  32522. "failed_code": 0,
  32523. "msg": "目录对照成功",
  32524. })
  32525. } else {
  32526. c.ServeSuccessJSON(map[string]interface{}{
  32527. "failed_code": -10,
  32528. "msg": res.ErrMsg,
  32529. })
  32530. }
  32531. }
  32532. }
  32533. }
  32534. func (c *HisApiController) UnCheckCode() {
  32535. ids_str := c.GetString("ids")
  32536. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  32537. admin_user_id, _ := c.GetInt64("admin_user_id")
  32538. ids_arr := strings.Split(ids_str, ",")
  32539. var queryResult []QueryResult
  32540. ids := make([]int64, 0)
  32541. for _, item := range ids_arr {
  32542. id, _ := strconv.ParseInt(item, 10, 64)
  32543. ids = append(ids, id)
  32544. }
  32545. if record_type == 1 {
  32546. drugs, _ := service.GetBatchDrugList(ids)
  32547. for _, item := range drugs {
  32548. result := QueryResult{
  32549. ID: item.ID,
  32550. Name: item.DrugName,
  32551. Code: item.MedicalInsuranceNumber,
  32552. List_type_code: "101",
  32553. }
  32554. queryResult = append(queryResult, result)
  32555. }
  32556. } else if record_type == 2 {
  32557. goods, _ := service.GetBatchGoodInformationList(ids)
  32558. for _, item := range goods {
  32559. result := QueryResult{
  32560. ID: item.ID,
  32561. Name: item.GoodName,
  32562. Code: item.SocialSecurityDirectoryCode,
  32563. List_type_code: "301",
  32564. }
  32565. queryResult = append(queryResult, result)
  32566. }
  32567. } else if record_type == 3 {
  32568. projects, _ := service.GetBathchMyPorjecgList(ids)
  32569. for _, item := range projects {
  32570. result := QueryResult{
  32571. ID: item.ID,
  32572. Name: item.ProjectName,
  32573. Code: item.MedicalCode,
  32574. List_type_code: "201",
  32575. }
  32576. queryResult = append(queryResult, result)
  32577. }
  32578. }
  32579. adminUser := c.GetAdminUserInfo()
  32580. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32581. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32582. var user_name string
  32583. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32584. if role.ID == 0 {
  32585. user_name = "xxx"
  32586. } else {
  32587. user_name = role.UserName
  32588. }
  32589. baseParams := &models.BaseParams{
  32590. SecretKey: miConfig.SecretKey,
  32591. FixmedinsCode: miConfig.Code,
  32592. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  32593. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  32594. OrgName: miConfig.OrgName,
  32595. Doctor: user_name,
  32596. }
  32597. if config.IsOpen == 1 {
  32598. if miConfig.MdtrtareaAdmvs == "430800" {
  32599. for _, item := range queryResult {
  32600. var result string
  32601. if record_type == 1 {
  32602. 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)
  32603. } else if record_type == 2 {
  32604. fmt.Println(item.Code)
  32605. 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)
  32606. } else if record_type == 3 {
  32607. 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)
  32608. }
  32609. var dat map[string]interface{}
  32610. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32611. fmt.Println(dat)
  32612. } else {
  32613. fmt.Println(err)
  32614. }
  32615. userJSONBytes, _ := json.Marshal(dat)
  32616. var res ResultSix
  32617. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32618. utils.ErrorLog("解析失败:%v", err)
  32619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32620. return
  32621. }
  32622. if res.Infcode == 0 {
  32623. if record_type == 1 {
  32624. service.UpdateBaseDrugById(item.ID)
  32625. } else if record_type == 2 {
  32626. service.UpdateGoodInformaitonByDetail(item.ID)
  32627. } else if record_type == 3 {
  32628. service.UpdateProjectById(item.ID)
  32629. }
  32630. c.ServeSuccessJSON(map[string]interface{}{
  32631. "failed_code": 0,
  32632. "msg": "目录对照成功",
  32633. })
  32634. } else {
  32635. c.ServeSuccessJSON(map[string]interface{}{
  32636. "failed_code": -10,
  32637. "msg": res.ErrMsg,
  32638. })
  32639. }
  32640. }
  32641. } else {
  32642. for _, item := range queryResult {
  32643. var result string
  32644. if record_type == 1 {
  32645. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  32646. } else if record_type == 2 {
  32647. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  32648. } else if record_type == 3 {
  32649. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  32650. }
  32651. var dat2 map[string]interface{}
  32652. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  32653. fmt.Println(dat2)
  32654. } else {
  32655. fmt.Println(err)
  32656. }
  32657. userJSONBytes, _ := json.Marshal(dat2)
  32658. var res ResultSix
  32659. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32660. utils.ErrorLog("解析失败:%v", err)
  32661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32662. return
  32663. }
  32664. if res.Infcode == 0 {
  32665. if record_type == 1 {
  32666. service.UpdateDrugByIdDetail(item.ID)
  32667. } else if record_type == 2 {
  32668. service.UpdateGoodInfoById(item.ID)
  32669. } else if record_type == 3 {
  32670. service.UpdateMyProjectById(item.ID)
  32671. }
  32672. c.ServeSuccessJSON(map[string]interface{}{
  32673. "failed_code": 0,
  32674. "msg": "撤销目录对照成功",
  32675. })
  32676. } else {
  32677. c.ServeSuccessJSON(map[string]interface{}{
  32678. "failed_code": -10,
  32679. "msg": res.ErrMsg,
  32680. })
  32681. }
  32682. }
  32683. }
  32684. }
  32685. }
  32686. func (c *HisApiController) GetPatientInfo() {
  32687. id_card_no := c.GetString("id_card_no")
  32688. admin_user_id, _ := c.GetInt64("admin_user_id")
  32689. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  32690. if patient.ID == 0 {
  32691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  32692. return
  32693. }
  32694. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  32695. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  32696. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  32697. var res ResultTwo
  32698. var res10265 ResultTwo10265
  32699. if config.IsOpen == 1 {
  32700. if miConfig.MdtrtareaAdmvs == "150499" {
  32701. //请求内网数据
  32702. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  32703. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  32704. "&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
  32705. resp, requestErr := http.Get(api)
  32706. if requestErr != nil {
  32707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32708. return
  32709. }
  32710. body, ioErr := ioutil.ReadAll(resp.Body)
  32711. if ioErr != nil {
  32712. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32714. return
  32715. }
  32716. var respJSON map[string]interface{}
  32717. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32718. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32720. return
  32721. }
  32722. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32723. result_byte, _ := json.Marshal(respJSON)
  32724. result := string(result_byte)
  32725. var dat map[string]interface{}
  32726. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32727. fmt.Println(dat)
  32728. } else {
  32729. fmt.Println(err)
  32730. }
  32731. userJSONBytes, _ := json.Marshal(dat)
  32732. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  32733. utils.ErrorLog("解析失败:%v", err)
  32734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32735. return
  32736. }
  32737. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  32738. res.Infcode = Infcode
  32739. res.ErrMsg = res10265.ErrMsg
  32740. res.Output = res10265.Output
  32741. res.InfRefmsgid = res10265.InfRefmsgid
  32742. res.RespondTime = res10265.RespondTime
  32743. res.WarnInfo = res10265.WarnInfo
  32744. } else {
  32745. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  32746. var dat map[string]interface{}
  32747. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32748. fmt.Println(dat)
  32749. } else {
  32750. fmt.Println(err)
  32751. }
  32752. userJSONBytes, _ := json.Marshal(dat)
  32753. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32754. utils.ErrorLog("解析失败:%v", err)
  32755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32756. return
  32757. }
  32758. }
  32759. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32760. // utils.ErrorLog("解析失败:%v", err)
  32761. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32762. // return
  32763. //}
  32764. for index, item := range res.Output.Iinfo {
  32765. if item.PsnInsuStas == "2" {
  32766. fmt.Println("--------")
  32767. res.Output.Iinfo[index].Insutype = "300"
  32768. res.Output.Iinfo[index].PsnInsuStas = "1"
  32769. }
  32770. }
  32771. fmt.Println(res.Output.Iinfo)
  32772. if res.Infcode != 0 {
  32773. c.ServeSuccessJSON(map[string]interface{}{
  32774. "failed_code": -10,
  32775. "msg": res.ErrMsg,
  32776. })
  32777. } else {
  32778. c.ServeSuccessJSON(map[string]interface{}{
  32779. "failed_code": 0,
  32780. "info": res,
  32781. })
  32782. }
  32783. }
  32784. }
  32785. func (c *HisApiController) PsnPutOnRecord() {
  32786. record_type, _ := c.GetInt64("type")
  32787. patient_id, _ := c.GetInt64("patient_id")
  32788. admin_user_id, _ := c.GetInt64("admin_user_id")
  32789. start_time := c.GetString("start_time")
  32790. end_time := c.GetString("end_time")
  32791. adminUser := c.GetAdminUserInfo()
  32792. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32793. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32794. var patients []*models.Patients
  32795. if record_type == 1 { //全部备案
  32796. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  32797. patients = append(patients, patient...)
  32798. } else { //单个备案
  32799. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  32800. patients = append(patients, patient)
  32801. }
  32802. var user_name string
  32803. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32804. if role.ID == 0 {
  32805. user_name = "xxx"
  32806. } else {
  32807. user_name = role.UserName
  32808. }
  32809. if config.IsOpen == 1 {
  32810. for _, item := range patients {
  32811. 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
  32812. resp, requestErr := http.Get(api)
  32813. if requestErr != nil {
  32814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32815. return
  32816. }
  32817. defer resp.Body.Close()
  32818. body, ioErr := ioutil.ReadAll(resp.Body)
  32819. if ioErr != nil {
  32820. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32822. return
  32823. }
  32824. var respJSON map[string]interface{}
  32825. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32826. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32828. return
  32829. }
  32830. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32831. userJSONBytes, _ := json.Marshal(userJSON)
  32832. var res ResultTwo
  32833. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32834. utils.ErrorLog("解析失败:%v", err)
  32835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32836. return
  32837. }
  32838. if res.Infcode == 0 {
  32839. 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)
  32840. var dat map[string]interface{}
  32841. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32842. fmt.Println(dat)
  32843. } else {
  32844. fmt.Println(err)
  32845. }
  32846. userJSONBytes, _ := json.Marshal(dat)
  32847. var res2 ResultThirteen
  32848. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32849. utils.ErrorLog("解析失败:%v", err)
  32850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32851. return
  32852. }
  32853. if res2.Infcode == 0 {
  32854. psnResult := &models.GdybPsnRecord{
  32855. UserOrgId: adminUser.CurrentOrgId,
  32856. PatientId: item.ID,
  32857. PsnNo: res.Output.Baseinfo.PsnNo,
  32858. Ctime: time.Now().Unix(),
  32859. Mtime: time.Now().Unix(),
  32860. Status: 1,
  32861. IsCancel: 1,
  32862. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  32863. }
  32864. service.CreatePsnRecord(psnResult)
  32865. } else {
  32866. c.ServeSuccessJSON(map[string]interface{}{
  32867. "failed_code": -10,
  32868. "msg": res2.ErrMsg,
  32869. })
  32870. return
  32871. }
  32872. }
  32873. }
  32874. }
  32875. }
  32876. func (c *HisApiController) PsnUnPutOnRecord() {
  32877. id, _ := c.GetInt64("id")
  32878. //record_type, _ := c.GetInt64("type")
  32879. admin_user_id, _ := c.GetInt64("admin_user_id")
  32880. adminUser := c.GetAdminUserInfo()
  32881. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32882. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32883. var user_name string
  32884. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32885. if role.ID == 0 {
  32886. user_name = "xxx"
  32887. } else {
  32888. user_name = role.UserName
  32889. }
  32890. psn_record, _ := service.GetPsnRecordById(id)
  32891. if psn_record.ID == 0 {
  32892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  32893. return
  32894. }
  32895. if config.IsOpen == 1 {
  32896. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  32897. var dat map[string]interface{}
  32898. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32899. fmt.Println(dat)
  32900. } else {
  32901. fmt.Println(err)
  32902. }
  32903. userJSONBytes, _ := json.Marshal(dat)
  32904. var res ResultFourteen
  32905. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32906. utils.ErrorLog("解析失败:%v", err)
  32907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32908. return
  32909. }
  32910. if res.Infcode == 0 {
  32911. psn_record.IsCancel = 2
  32912. service.CreatePsnRecord(&psn_record)
  32913. } else {
  32914. c.ServeSuccessJSON(map[string]interface{}{
  32915. "failed_code": -10,
  32916. "msg": res.ErrMsg,
  32917. })
  32918. return
  32919. }
  32920. }
  32921. }
  32922. func (c *HisApiController) PsnPutNCDSOnRecord() {
  32923. patient_id, _ := c.GetInt64("patient_id")
  32924. insutype_two := c.GetString("insutype")
  32925. psn_no := c.GetString("psn_no")
  32926. doctor_id, _ := c.GetInt64("doctor_id")
  32927. sick_id, _ := c.GetInt64("sick_id")
  32928. department_id, _ := c.GetInt64("department_id")
  32929. start_time := c.GetString("start_time")
  32930. end_time := c.GetString("end_time")
  32931. check_time := c.GetString("check_time")
  32932. hospital_code := c.GetString("hospital_code")
  32933. hospital_name := c.GetString("hospital_name")
  32934. adminUser := c.GetAdminUserInfo()
  32935. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  32936. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32937. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32938. sick, _ := service.FindSickById(sick_id)
  32939. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  32940. if len(hospital_code) == 0 {
  32941. hospital_code = miConfig.Code
  32942. }
  32943. if len(hospital_name) == 0 {
  32944. hospital_name = miConfig.OrgName
  32945. }
  32946. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  32947. var res ResultTwo
  32948. var res10265 ResultTwo10265
  32949. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32950. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  32951. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  32952. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  32953. "&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
  32954. resp, requestErr := http.Get(api)
  32955. if requestErr != nil {
  32956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32957. return
  32958. }
  32959. body, ioErr := ioutil.ReadAll(resp.Body)
  32960. if ioErr != nil {
  32961. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32963. return
  32964. }
  32965. var respJSON map[string]interface{}
  32966. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32967. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32969. return
  32970. }
  32971. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32972. result, _ := json.Marshal(respJSON)
  32973. fmt.Println("log")
  32974. fmt.Println(string(result))
  32975. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  32976. utils.ErrorLog("解析失败:%v", err)
  32977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32978. return
  32979. }
  32980. res.ErrMsg = res10265.ErrMsg
  32981. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  32982. res.Infcode = infocode
  32983. res.Output = res10265.Output
  32984. res.InfRefmsgid = res10265.InfRefmsgid
  32985. } else {
  32986. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  32987. if miConfig.Code == "H15049901371" {
  32988. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  32989. utils.ErrorLog("解析失败:%v", err)
  32990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32991. return
  32992. }
  32993. res.ErrMsg = res10265.ErrMsg
  32994. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  32995. res.Infcode = infocode
  32996. res.Output = res10265.Output
  32997. res.InfRefmsgid = res10265.InfRefmsgid
  32998. } else {
  32999. if err := json.Unmarshal([]byte(result), &res); err != nil {
  33000. utils.ErrorLog("解析失败:%v", err)
  33001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33002. return
  33003. }
  33004. }
  33005. }
  33006. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  33007. infoStr := string(Iinfos)
  33008. var rf []*ResultFive
  33009. json.Unmarshal([]byte(infoStr), &rf)
  33010. var insuplc_admdvs string
  33011. var insutype string
  33012. var is390 int = 0
  33013. var is310 int = 0
  33014. var insutypes []*ResultFive
  33015. for _, item := range rf {
  33016. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  33017. insutypes = append(insutypes, item)
  33018. }
  33019. }
  33020. if len(insutypes) == 1 {
  33021. insutype = insutypes[0].Insutype
  33022. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  33023. } else {
  33024. for _, i := range insutypes {
  33025. if i.Insutype == "390" {
  33026. is390 = 1
  33027. }
  33028. if i.Insutype == "310" {
  33029. is310 = 1
  33030. }
  33031. }
  33032. }
  33033. if is390 == 1 {
  33034. insutype = "390"
  33035. }
  33036. if is310 == 1 {
  33037. insutype = "310"
  33038. }
  33039. if len(insutypes) == 2 {
  33040. insutype = insutype_two
  33041. }
  33042. if len(insutypes) == 0 {
  33043. insutype = "310"
  33044. }
  33045. insutype = insutype_two
  33046. fmt.Println(insutype)
  33047. for _, item := range rf {
  33048. fmt.Println(item.Insutype)
  33049. fmt.Println(insutype)
  33050. if item.Insutype == insutype {
  33051. fmt.Println(item.Insutype)
  33052. fmt.Println(insutype)
  33053. insuplc_admdvs = item.InsuplcAdmdvs
  33054. }
  33055. }
  33056. fmt.Println(insuplc_admdvs)
  33057. var res2 ResultThirteen
  33058. var res10265_2 ResultThirteen10265
  33059. if config.IsOpen == 1 {
  33060. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33061. } else {
  33062. if miConfig.MdtrtareaAdmvs == "150499" {
  33063. //
  33064. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  33065. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  33066. // "&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
  33067. //resp, requestErr := http.Get(api)
  33068. //if requestErr != nil {
  33069. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33070. // return
  33071. //}
  33072. //
  33073. //body, ioErr := ioutil.ReadAll(resp.Body)
  33074. //if ioErr != nil {
  33075. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33076. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33077. // return
  33078. //}
  33079. //var respJSON map[string]interface{}
  33080. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33081. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33082. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33083. // return
  33084. //}
  33085. //
  33086. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33087. //result, _ := json.Marshal(respJSON)
  33088. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  33089. // utils.ErrorLog("解析失败:%v", err)
  33090. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33091. // return
  33092. //}
  33093. //infocode = resThree.Infcode
  33094. //result, _ := json.Marshal(respJSON)
  33095. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  33096. // utils.ErrorLog("解析失败:%v", err)
  33097. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33098. // return
  33099. //}
  33100. //
  33101. //resThree.ErrMsg = resThree10265.ErrMsg
  33102. //
  33103. //resThree.Output = resThree10265.Output
  33104. //
  33105. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  33106. //
  33107. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  33108. //
  33109. } else {
  33110. 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)
  33111. var dat map[string]interface{}
  33112. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33113. fmt.Println(dat)
  33114. } else {
  33115. fmt.Println(err)
  33116. }
  33117. userJSONBytes, _ := json.Marshal(dat)
  33118. if miConfig.Code == "H15049901371" {
  33119. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  33120. utils.ErrorLog("解析失败:%v", err)
  33121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33122. return
  33123. }
  33124. res2.ErrMsg = res10265_2.ErrMsg
  33125. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  33126. res2.Infcode = infocode
  33127. res2.Output = res10265_2.Output
  33128. res2.InfRefmsgid = res10265_2.InfRefmsgid
  33129. } else {
  33130. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33131. utils.ErrorLog("解析失败:%v", err)
  33132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33133. return
  33134. }
  33135. }
  33136. }
  33137. }
  33138. if res2.Infcode == 0 {
  33139. psnResult := &models.GdybPsnNcdsRecord{
  33140. UserOrgId: adminUser.CurrentOrgId,
  33141. PatientId: patient.ID,
  33142. PsnNo: psn_no,
  33143. DoctorId: doctor.AdminUserId,
  33144. DepartmentId: department_id,
  33145. SickType: sick_id,
  33146. Insutype: insutype,
  33147. Ctime: time.Now().Unix(),
  33148. Mtime: time.Now().Unix(),
  33149. Status: 1,
  33150. IsCancel: 1,
  33151. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  33152. }
  33153. service.CreatePsnNCDSRecord(psnResult)
  33154. c.ServeSuccessJSON(map[string]interface{}{
  33155. "failed_code": 0,
  33156. "msg": "备案成功",
  33157. "result": psnResult,
  33158. })
  33159. } else {
  33160. c.ServeSuccessJSON(map[string]interface{}{
  33161. "failed_code": -10,
  33162. "msg": res2.ErrMsg,
  33163. })
  33164. return
  33165. }
  33166. }
  33167. }
  33168. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  33169. id, _ := c.GetInt64("id")
  33170. admin_user_id, _ := c.GetInt64("admin_user_id")
  33171. adminUser := c.GetAdminUserInfo()
  33172. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33173. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33174. //config, _ := service.Ge(adminUser.CurrentOrgId)
  33175. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  33176. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33177. //var user_name string
  33178. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33179. //if role.ID == 0 {
  33180. // user_name = "xxx"
  33181. //} else {
  33182. // user_name = role.UserName
  33183. //}
  33184. psn_record, _ := service.GetPsnNCDSRecordById(id)
  33185. if psn_record.ID == 0 {
  33186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  33187. return
  33188. }
  33189. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  33190. var res ResultTwo
  33191. var res10265 ResultTwo10265
  33192. if miConfig.Code == "H15049901371" {
  33193. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  33194. utils.ErrorLog("解析失败:%v", err)
  33195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33196. return
  33197. }
  33198. res.ErrMsg = res10265.ErrMsg
  33199. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  33200. res.Infcode = infocode
  33201. res.Output = res10265.Output
  33202. res.InfRefmsgid = res10265.InfRefmsgid
  33203. } else {
  33204. if err := json.Unmarshal([]byte(result), &res); err != nil {
  33205. utils.ErrorLog("解析失败:%v", err)
  33206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33207. return
  33208. }
  33209. }
  33210. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  33211. infoStr := string(Iinfos)
  33212. var rf []*ResultFive
  33213. json.Unmarshal([]byte(infoStr), &rf)
  33214. var insuplc_admdvs string
  33215. var insutype string
  33216. var is390 int = 0
  33217. var is310 int = 0
  33218. var insutypes []*ResultFive
  33219. for _, item := range rf {
  33220. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  33221. insutypes = append(insutypes, item)
  33222. }
  33223. }
  33224. if len(insutypes) == 1 {
  33225. insutype = insutypes[0].Insutype
  33226. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  33227. } else {
  33228. for _, i := range insutypes {
  33229. if i.Insutype == "390" {
  33230. is390 = 1
  33231. }
  33232. if i.Insutype == "310" {
  33233. is310 = 1
  33234. }
  33235. }
  33236. }
  33237. if is390 == 1 {
  33238. insutype = "390"
  33239. }
  33240. if is310 == 1 {
  33241. insutype = "310"
  33242. }
  33243. if len(insutypes) == 0 {
  33244. insutype = "310"
  33245. }
  33246. insutype = psn_record.Insutype
  33247. for _, item := range rf {
  33248. if item.Insutype == insutype {
  33249. insuplc_admdvs = item.InsuplcAdmdvs
  33250. }
  33251. }
  33252. if config.IsOpen == 1 {
  33253. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  33254. var dat map[string]interface{}
  33255. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33256. fmt.Println(dat)
  33257. } else {
  33258. fmt.Println(err)
  33259. }
  33260. userJSONBytes, _ := json.Marshal(dat)
  33261. var res ResultFourteen
  33262. var res10265 ResultFourteen10265
  33263. if miConfig.Code == "H15049901371" {
  33264. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  33265. utils.ErrorLog("解析失败:%v", err)
  33266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33267. return
  33268. }
  33269. res.ErrMsg = res10265.ErrMsg
  33270. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  33271. res.Infcode = infocode
  33272. res.Output = res10265.Output
  33273. res.InfRefmsgid = res10265.InfRefmsgid
  33274. } else {
  33275. if err := json.Unmarshal([]byte(result), &res); err != nil {
  33276. utils.ErrorLog("解析失败:%v", err)
  33277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33278. return
  33279. }
  33280. }
  33281. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33282. // utils.ErrorLog("解析失败:%v", err)
  33283. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33284. // return
  33285. //}
  33286. if res.Infcode == 0 {
  33287. psn_record.IsCancel = 2
  33288. service.CreatePsnNCDSRecord(&psn_record)
  33289. c.ServeSuccessJSON(map[string]interface{}{
  33290. "failed_code": 0,
  33291. "msg": "撤销备案成功",
  33292. })
  33293. } else {
  33294. c.ServeSuccessJSON(map[string]interface{}{
  33295. "failed_code": -10,
  33296. "msg": res.ErrMsg,
  33297. })
  33298. return
  33299. }
  33300. }
  33301. }
  33302. func (c *HisApiController) TestTest() {
  33303. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  33304. fmt.Println(patient.Iinfo)
  33305. }
  33306. type CustomData struct {
  33307. MsgId string
  33308. PsnNo string
  33309. Info string
  33310. }
  33311. func (c *HisApiController) ReversalData() {
  33312. var customData []*CustomData
  33313. custom := &CustomData{
  33314. MsgId: "H44022900158202103301714472004",
  33315. PsnNo: "44020000001101329945",
  33316. Info: "2207",
  33317. }
  33318. customData = append(customData, custom)
  33319. custom1 := &CustomData{
  33320. MsgId: "H4402290015820210330172057803",
  33321. PsnNo: "44020000001101161813",
  33322. Info: "2207",
  33323. }
  33324. customData = append(customData, custom1)
  33325. custom2 := &CustomData{
  33326. MsgId: "H44022900158202103301705198813",
  33327. PsnNo: "44190000133097375417",
  33328. Info: "2207",
  33329. }
  33330. customData = append(customData, custom2)
  33331. custom3 := &CustomData{
  33332. MsgId: "H44022900158202103301715524756",
  33333. PsnNo: "44020000001100187221",
  33334. Info: "2207",
  33335. }
  33336. customData = append(customData, custom3)
  33337. custom4 := &CustomData{
  33338. MsgId: "H44022900158202103301730376224",
  33339. PsnNo: "44020000001101959155",
  33340. Info: "2207",
  33341. }
  33342. customData = append(customData, custom4)
  33343. custom5 := &CustomData{
  33344. MsgId: "H44022900158202103301748008725",
  33345. PsnNo: "44020000001104246641",
  33346. Info: "2207",
  33347. }
  33348. customData = append(customData, custom5)
  33349. custom6 := &CustomData{
  33350. MsgId: "H44022900158202103301718096755",
  33351. PsnNo: "44020000001102211860",
  33352. Info: "2207",
  33353. }
  33354. customData = append(customData, custom6)
  33355. custom7 := &CustomData{
  33356. MsgId: "H44022900158202103301736551640",
  33357. PsnNo: "44020000001102687718",
  33358. Info: "2207",
  33359. }
  33360. customData = append(customData, custom7)
  33361. custom8 := &CustomData{
  33362. MsgId: "H44022900158202103301743097676",
  33363. PsnNo: "44020000001102127785",
  33364. Info: "2207",
  33365. }
  33366. customData = append(customData, custom8)
  33367. custom9 := &CustomData{
  33368. MsgId: "H44022900158202103301712304203",
  33369. PsnNo: "44020000001101518097",
  33370. Info: "2207",
  33371. }
  33372. customData = append(customData, custom9)
  33373. custom10 := &CustomData{
  33374. MsgId: "H44022900158202103301738448785",
  33375. PsnNo: "44020000001100500813",
  33376. Info: "2207",
  33377. }
  33378. customData = append(customData, custom10)
  33379. custom11 := &CustomData{
  33380. MsgId: "H44022900158202103301732455843",
  33381. PsnNo: "44020000001102690557",
  33382. Info: "2207",
  33383. }
  33384. customData = append(customData, custom11)
  33385. custom12 := &CustomData{
  33386. MsgId: "H44022900158202103301745421708",
  33387. PsnNo: "44020000001102211928",
  33388. Info: "2207",
  33389. }
  33390. customData = append(customData, custom12)
  33391. custom1212 := &CustomData{
  33392. MsgId: "H440229001582021033017351627",
  33393. PsnNo: "44020000001102481733",
  33394. Info: "2207",
  33395. }
  33396. customData = append(customData, custom1212)
  33397. custom13 := &CustomData{
  33398. MsgId: "H44022900158202103301740327951",
  33399. PsnNo: "44020000001103174866",
  33400. Info: "2207",
  33401. }
  33402. customData = append(customData, custom13)
  33403. custom14 := &CustomData{
  33404. MsgId: "H4402290015820210330174922668",
  33405. PsnNo: "44020000001102927272",
  33406. Info: "2207",
  33407. }
  33408. customData = append(customData, custom14)
  33409. custom15 := &CustomData{
  33410. MsgId: "H44022900158202103301752362273",
  33411. PsnNo: "44020000001102942890",
  33412. Info: "2207",
  33413. }
  33414. customData = append(customData, custom15)
  33415. custom16 := &CustomData{
  33416. MsgId: "H44022900158202103301751082917",
  33417. PsnNo: "44020000001101662162",
  33418. Info: "2207",
  33419. }
  33420. customData = append(customData, custom16)
  33421. custom17 := &CustomData{
  33422. MsgId: "H44022900158202103301754147728",
  33423. PsnNo: "44020000000229014511",
  33424. Info: "2207",
  33425. }
  33426. customData = append(customData, custom17)
  33427. adminUser := c.GetAdminUserInfo()
  33428. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33429. for _, item := range customData {
  33430. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  33431. fmt.Println(result)
  33432. }
  33433. }
  33434. func (c *HisApiController) GetAllopatry() {
  33435. year := c.GetString("year")
  33436. month := c.GetString("month")
  33437. admin_user_id, _ := c.GetInt64("admin_user_id")
  33438. adminUser := c.GetAdminUserInfo()
  33439. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33440. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33441. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  33442. var dat map[string]interface{}
  33443. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33444. fmt.Println(dat)
  33445. } else {
  33446. fmt.Println(err)
  33447. }
  33448. userJSONBytes, _ := json.Marshal(dat)
  33449. var res models.Result9001
  33450. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33451. utils.ErrorLog("解析失败:%v", err)
  33452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33453. return
  33454. }
  33455. fmt.Println(res.Output.Signinoutb)
  33456. fmt.Println(res.Output.Signinoutb.SignNo)
  33457. fmt.Println(string(userJSONBytes))
  33458. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  33459. var dat3 map[string]interface{}
  33460. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  33461. fmt.Println(dat3)
  33462. } else {
  33463. fmt.Println(err)
  33464. }
  33465. userJSONBytes3, _ := json.Marshal(dat3)
  33466. var res3 models.Result3260
  33467. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  33468. utils.ErrorLog("解析失败:%v", err)
  33469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33470. return
  33471. }
  33472. var curpage int
  33473. var pagesize int = 100
  33474. var start int = 1
  33475. //var stop int
  33476. //pagecount := 10
  33477. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  33478. var res22 []models.Result3260
  33479. for curpage = 1; curpage <= pagecount; curpage++ {
  33480. if curpage == 1 {
  33481. start = 0
  33482. } else {
  33483. start = (curpage-1)*pagesize + 1
  33484. }
  33485. fmt.Println(start)
  33486. //stop = curpage * pagesize
  33487. //if stop > int(res3.Output.Totalrow) {
  33488. // stop =int(res3.Output.Totalrow)
  33489. //}
  33490. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  33491. var dat2 map[string]interface{}
  33492. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  33493. fmt.Println(dat)
  33494. } else {
  33495. fmt.Println(err)
  33496. }
  33497. userJSONBytes2, _ := json.Marshal(dat2)
  33498. var res2 models.Result3260
  33499. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  33500. utils.ErrorLog("解析失败:%v", err)
  33501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33502. return
  33503. }
  33504. if res2.Infcode == 0 {
  33505. res22 = append(res22, res2)
  33506. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  33507. //var dat2 map[string]interface{}
  33508. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  33509. // fmt.Println(dat)
  33510. //} else {
  33511. // fmt.Println(err)
  33512. //}
  33513. //c.ServeSuccessJSON(map[string]interface{}{
  33514. // "list": res2.Output.Data,
  33515. //})
  33516. //continue
  33517. }
  33518. }
  33519. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  33520. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  33521. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  33522. //var dat2 map[string]interface{}
  33523. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  33524. // fmt.Println(dat)
  33525. //} else {
  33526. // fmt.Println(err)
  33527. //}
  33528. //userJSONBytes2, _ := json.Marshal(dat2)
  33529. //var res2 models.Result3260
  33530. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  33531. // utils.ErrorLog("解析失败:%v", err)
  33532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33533. // return
  33534. //}
  33535. //if res2.Infcode == 0 {
  33536. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  33537. // var dat2 map[string]interface{}
  33538. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  33539. // fmt.Println(dat)
  33540. // } else {
  33541. // fmt.Println(err)
  33542. // }
  33543. // c.ServeSuccessJSON(map[string]interface{}{
  33544. // "list": res2.Output.Data,
  33545. // })
  33546. //}
  33547. }
  33548. func (c *HisApiController) ComfirmAllopatry() {
  33549. year := c.GetString("year")
  33550. month := c.GetString("month")
  33551. admin_user_id, _ := c.GetInt64("admin_user_id")
  33552. adminUser := c.GetAdminUserInfo()
  33553. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33554. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33555. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  33556. var dat map[string]interface{}
  33557. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33558. fmt.Println(dat)
  33559. } else {
  33560. fmt.Println(err)
  33561. }
  33562. userJSONBytes, _ := json.Marshal(dat)
  33563. var res models.Result9001
  33564. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33565. utils.ErrorLog("解析失败:%v", err)
  33566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33567. return
  33568. }
  33569. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  33570. var dat2 map[string]interface{}
  33571. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  33572. fmt.Println(dat)
  33573. } else {
  33574. fmt.Println(err)
  33575. }
  33576. userJSONBytes2, _ := json.Marshal(dat2)
  33577. var res2 models.Result3260
  33578. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  33579. utils.ErrorLog("解析失败:%v", err)
  33580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33581. return
  33582. }
  33583. //if res2.Infcode == 0 {
  33584. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  33585. // var dat map[string]interface{}
  33586. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33587. // fmt.Println(dat)
  33588. // } else {
  33589. // fmt.Println(err)
  33590. // }
  33591. // userJSONBytes, _ := json.Marshal(dat)
  33592. // var res3 models.Result3261
  33593. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  33594. // utils.ErrorLog("解析失败:%v", err)
  33595. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33596. // return
  33597. // }
  33598. //
  33599. // if res3.Infcode == 0 {
  33600. // record := &models.HisYidiClearRecord{
  33601. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  33602. // Ctime: time.Now().Unix(),
  33603. // Mtime: time.Now().Unix(),
  33604. // Status: 1,
  33605. // MsgId: msgId,
  33606. // }
  33607. // service.SaveClearRecord(record)
  33608. // c.ServeSuccessJSON(map[string]interface{}{
  33609. // "msg": "提取成功",
  33610. // })
  33611. // }
  33612. //}
  33613. }
  33614. func (c *HisApiController) RefundAllopatry() {
  33615. year := c.GetString("year")
  33616. month := c.GetString("month")
  33617. //id, _ := c.GetInt64("id")
  33618. admin_user_id, _ := c.GetInt64("admin_user_id")
  33619. adminUser := c.GetAdminUserInfo()
  33620. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33621. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33622. //record, _ := service.GetClearRecordById(id)
  33623. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  33624. var dat map[string]interface{}
  33625. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33626. fmt.Println(dat)
  33627. } else {
  33628. fmt.Println(err)
  33629. }
  33630. userJSONBytes, _ := json.Marshal(dat)
  33631. var res models.Result9001
  33632. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33633. utils.ErrorLog("解析失败:%v", err)
  33634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33635. return
  33636. }
  33637. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  33638. var dat2 map[string]interface{}
  33639. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  33640. fmt.Println(dat)
  33641. } else {
  33642. fmt.Println(err)
  33643. }
  33644. userJSONBytes2, _ := json.Marshal(dat2)
  33645. var empty ResultFourteen
  33646. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  33647. utils.ErrorLog("解析失败:%v", err)
  33648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33649. return
  33650. }
  33651. if empty.Infcode == 0 {
  33652. c.ServeSuccessJSON(map[string]interface{}{
  33653. "msg": "撤销成功",
  33654. })
  33655. return
  33656. }
  33657. }
  33658. func (c *HisApiController) ReversalOtherData() {
  33659. var customData []*CustomData
  33660. custom := &CustomData{
  33661. MsgId: "H44022900158202103301714472004",
  33662. PsnNo: "44020000001101329945",
  33663. Info: "2208",
  33664. }
  33665. customData = append(customData, custom)
  33666. custom1 := &CustomData{
  33667. MsgId: "H4402290015820210330172057803",
  33668. PsnNo: "44020000001101161813",
  33669. Info: "2208",
  33670. }
  33671. customData = append(customData, custom1)
  33672. custom2 := &CustomData{
  33673. MsgId: "H44022900158202103301705198813",
  33674. PsnNo: "44190000133097375417",
  33675. Info: "2208",
  33676. }
  33677. customData = append(customData, custom2)
  33678. custom3 := &CustomData{
  33679. MsgId: "H44022900158202103301715524756",
  33680. PsnNo: "44020000001100187221",
  33681. Info: "2208",
  33682. }
  33683. customData = append(customData, custom3)
  33684. custom4 := &CustomData{
  33685. MsgId: "H44022900158202103301730376224",
  33686. PsnNo: "44020000001101959155",
  33687. Info: "2208",
  33688. }
  33689. customData = append(customData, custom4)
  33690. custom5 := &CustomData{
  33691. MsgId: "H44022900158202103301748008725",
  33692. PsnNo: "44020000001104246641",
  33693. Info: "2208",
  33694. }
  33695. customData = append(customData, custom5)
  33696. custom6 := &CustomData{
  33697. MsgId: "H44022900158202103301718096755",
  33698. PsnNo: "44020000001102211860",
  33699. Info: "2208",
  33700. }
  33701. customData = append(customData, custom6)
  33702. custom7 := &CustomData{
  33703. MsgId: "H44022900158202103301736551640",
  33704. PsnNo: "44020000001102687718",
  33705. Info: "2208",
  33706. }
  33707. customData = append(customData, custom7)
  33708. custom8 := &CustomData{
  33709. MsgId: "H44022900158202103301743097676",
  33710. PsnNo: "44020000001102127785",
  33711. Info: "2208",
  33712. }
  33713. customData = append(customData, custom8)
  33714. custom9 := &CustomData{
  33715. MsgId: "H44022900158202103301712304203",
  33716. PsnNo: "44020000001101518097",
  33717. Info: "2208",
  33718. }
  33719. customData = append(customData, custom9)
  33720. custom10 := &CustomData{
  33721. MsgId: "H44022900158202103301738448785",
  33722. PsnNo: "44020000001100500813",
  33723. Info: "2208",
  33724. }
  33725. customData = append(customData, custom10)
  33726. custom11 := &CustomData{
  33727. MsgId: "H44022900158202103301732455843",
  33728. PsnNo: "44020000001102690557",
  33729. Info: "2208",
  33730. }
  33731. customData = append(customData, custom11)
  33732. custom12 := &CustomData{
  33733. MsgId: "H44022900158202103301745421708",
  33734. PsnNo: "44020000001102211928",
  33735. Info: "2208",
  33736. }
  33737. customData = append(customData, custom12)
  33738. custom1212 := &CustomData{
  33739. MsgId: "H440229001582021033017351627",
  33740. PsnNo: "44020000001102481733",
  33741. Info: "2208",
  33742. }
  33743. customData = append(customData, custom1212)
  33744. custom13 := &CustomData{
  33745. MsgId: "H44022900158202103301740327951",
  33746. PsnNo: "44020000001103174866",
  33747. Info: "2208",
  33748. }
  33749. customData = append(customData, custom13)
  33750. custom14 := &CustomData{
  33751. MsgId: "H4402290015820210330174922668",
  33752. PsnNo: "44020000001102927272",
  33753. Info: "2208",
  33754. }
  33755. customData = append(customData, custom14)
  33756. custom15 := &CustomData{
  33757. MsgId: "H44022900158202103301752362273",
  33758. PsnNo: "44020000001102942890",
  33759. Info: "2208",
  33760. }
  33761. customData = append(customData, custom15)
  33762. custom16 := &CustomData{
  33763. MsgId: "H44022900158202103301751082917",
  33764. PsnNo: "44020000001101662162",
  33765. Info: "2208",
  33766. }
  33767. customData = append(customData, custom16)
  33768. custom17 := &CustomData{
  33769. MsgId: "H44022900158202103301754147728",
  33770. PsnNo: "44020000000229014511",
  33771. Info: "2208",
  33772. }
  33773. customData = append(customData, custom17)
  33774. adminUser := c.GetAdminUserInfo()
  33775. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33776. for _, item := range customData {
  33777. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  33778. fmt.Println(result)
  33779. }
  33780. }
  33781. func PathExists(path string) (bool, error) {
  33782. _, err := os.Stat(path)
  33783. if err == nil {
  33784. return true, nil
  33785. }
  33786. if os.IsNotExist(err) {
  33787. return false, nil
  33788. }
  33789. return false, err
  33790. }
  33791. // 创建文件夹
  33792. func Mkdir(dir string) {
  33793. // 创建文件夹
  33794. exist, err := PathExists(dir)
  33795. if err != nil {
  33796. fmt.Println(err.Error())
  33797. } else {
  33798. if exist {
  33799. fmt.Println(dir + "文件夹已存在!")
  33800. } else {
  33801. // 文件夹名称,权限
  33802. err := os.Mkdir(dir, os.ModePerm)
  33803. if err != nil {
  33804. fmt.Println(dir+"文件夹创建失败:", err.Error())
  33805. } else {
  33806. fmt.Println(dir + "文件夹创建成功!")
  33807. }
  33808. }
  33809. }
  33810. }
  33811. // 压缩文件
  33812. func Zip(srcFile string, destZip string) error {
  33813. zipfile, err := os.Create(destZip)
  33814. if err != nil {
  33815. return err
  33816. }
  33817. defer zipfile.Close()
  33818. archive := zip.NewWriter(zipfile)
  33819. defer archive.Close()
  33820. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  33821. if err != nil {
  33822. return err
  33823. }
  33824. header, err := zip.FileInfoHeader(info)
  33825. if err != nil {
  33826. return err
  33827. }
  33828. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  33829. // header.Name = path
  33830. if info.IsDir() {
  33831. header.Name += "/"
  33832. } else {
  33833. header.Method = zip.Deflate
  33834. }
  33835. writer, err := archive.CreateHeader(header)
  33836. if err != nil {
  33837. return err
  33838. }
  33839. if !info.IsDir() {
  33840. file, err := os.Open(path)
  33841. if err != nil {
  33842. return err
  33843. }
  33844. defer file.Close()
  33845. _, err = io.Copy(writer, file)
  33846. }
  33847. return err
  33848. })
  33849. return err
  33850. }
  33851. func ReadFile(filePath string) []byte {
  33852. f, err := os.Open(filePath)
  33853. if err != nil {
  33854. fmt.Println("read file fail", err)
  33855. return nil
  33856. }
  33857. defer f.Close()
  33858. fd, err := ioutil.ReadAll(f)
  33859. if err != nil {
  33860. fmt.Println("read to fd fail", err)
  33861. return nil
  33862. }
  33863. return fd
  33864. }
  33865. func saveLogq(result string, request string, infno string, desc string) {
  33866. dir := "日志"
  33867. utils.Mkdir(dir)
  33868. month := time.Unix(1557042972, 0).Format("1")
  33869. year := time.Now().Format("2006")
  33870. month = time.Now().Format("01")
  33871. day := time.Now().Format("02")
  33872. hour := time.Now().Format("15")
  33873. min := time.Now().Format("04")
  33874. sec := time.Now().Format("05")
  33875. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  33876. file := year + month + day + "_log"
  33877. file_name := file + ".txt"
  33878. file_path := "日志" + "/" + file_name
  33879. exist, _ := utils.PathExists(file_path)
  33880. if exist { //存在
  33881. fmt.Println("存在")
  33882. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  33883. if err != nil {
  33884. fmt.Println("read fail")
  33885. }
  33886. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  33887. n, _ := f.Seek(0, 2)
  33888. _, err = f.WriteAt([]byte(content), n)
  33889. } else { //不存在
  33890. fmt.Println("文件不存在,创建文件")
  33891. f, err := os.Create("日志" + "/" + file_name)
  33892. defer f.Close()
  33893. if err != nil {
  33894. } else {
  33895. _, err = f.Write([]byte("记录日志"))
  33896. }
  33897. }
  33898. }
  33899. func saveLog(result string, request string, infno string, desc string) {
  33900. org_id, _ := beego.AppConfig.Int64("org_id")
  33901. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  33902. dir := miConfig.OrgName + "日志"
  33903. utils.Mkdir(dir)
  33904. month := time.Unix(1557042972, 0).Format("1")
  33905. year := time.Now().Format("2006")
  33906. month = time.Now().Format("01")
  33907. day := time.Now().Format("02")
  33908. hour := time.Now().Format("15")
  33909. min := time.Now().Format("04")
  33910. sec := time.Now().Format("05")
  33911. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  33912. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  33913. file_name := file + ".txt"
  33914. file_path := miConfig.OrgName + "日志" + "/" + file_name
  33915. exist, _ := utils.PathExists(file_path)
  33916. if exist { //存在
  33917. fmt.Println("存在")
  33918. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  33919. if err != nil {
  33920. fmt.Println("read fail")
  33921. }
  33922. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  33923. n, _ := f.Seek(0, 2)
  33924. _, err = f.WriteAt([]byte(content), n)
  33925. } else { //不存在
  33926. fmt.Println("文件不存在,创建文件")
  33927. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  33928. defer f.Close()
  33929. if err != nil {
  33930. } else {
  33931. _, err = f.Write([]byte("记录日志"))
  33932. }
  33933. }
  33934. }
  33935. type Charset string
  33936. const (
  33937. UTF8 = Charset("UTF-8")
  33938. GB18030 = Charset("GB18030")
  33939. )
  33940. func ConvertToString(src string, srcCode string, tagCode string) string {
  33941. srcCoder := mahonia.NewDecoder(srcCode)
  33942. srcResult := srcCoder.ConvertString(src)
  33943. tagCoder := mahonia.NewDecoder(tagCode)
  33944. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  33945. result := string(cdata)
  33946. return result
  33947. }
  33948. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  33949. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  33950. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  33951. var token string
  33952. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33953. var api string
  33954. if miConfig.MdtrtareaAdmvs == "320921" {
  33955. 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 +
  33956. "&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
  33957. fmt.Println(api)
  33958. } else {
  33959. 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 +
  33960. "&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
  33961. }
  33962. resp, requestErr := http.Get(api)
  33963. if requestErr != nil {
  33964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33965. return ""
  33966. }
  33967. body, ioErr := ioutil.ReadAll(resp.Body)
  33968. if ioErr != nil {
  33969. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33971. return ""
  33972. }
  33973. var respJSON map[string]interface{}
  33974. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33975. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33977. return ""
  33978. }
  33979. var status string
  33980. status = respJSON["data"].(map[string]interface{})["status"].(string)
  33981. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  33982. var res ResultTwo //1101结果
  33983. var res10265 ResultTwo10265 //1101结果
  33984. if status == "0" { //读卡成功
  33985. var card_info string //卡信息
  33986. var busi_card_info string
  33987. token = respJSON["data"].(map[string]interface{})["token"].(string)
  33988. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  33989. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  33990. fmt.Println(card_info)
  33991. fmt.Println(busi_card_info)
  33992. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  33993. result, _ := json.Marshal(respJSON)
  33994. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  33995. utils.ErrorLog("解析失败:%v", err)
  33996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33997. return ""
  33998. }
  33999. res.ErrMsg = res10265.ErrMsg
  34000. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  34001. res.Infcode = infocode
  34002. res.Output = res10265.Output
  34003. res.InfRefmsgid = res10265.InfRefmsgid
  34004. if res.Infcode == 0 {
  34005. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  34006. if err == gorm.ErrRecordNotFound {
  34007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  34008. return ""
  34009. } else if err != nil {
  34010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  34011. return ""
  34012. } else {
  34013. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  34014. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  34015. infoStr := string(Iinfos)
  34016. idetinfoStr := string(Idetinfos)
  34017. psn := &models.HisPsn{
  34018. PsnNo: res.Output.Baseinfo.PsnNo,
  34019. PatientId: patient.ID,
  34020. Certno: res.Output.Baseinfo.Certno,
  34021. Gend: res.Output.Baseinfo.Gend,
  34022. Naty: res.Output.Baseinfo.Naty,
  34023. PsnCertType: res.Output.Baseinfo.PsnCertType,
  34024. PsnName: res.Output.Baseinfo.PsnName,
  34025. Idetinfo: idetinfoStr,
  34026. Insuinfo: infoStr,
  34027. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  34028. CardInfo: card_info,
  34029. VerifyNumber: token,
  34030. }
  34031. service.CreateHisPsn(psn)
  34032. return token
  34033. }
  34034. }
  34035. } else {
  34036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  34037. return ""
  34038. }
  34039. } else { //读卡失败
  34040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  34041. return ""
  34042. }
  34043. return token
  34044. }
  34045. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  34046. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  34047. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  34048. var token string
  34049. var api string
  34050. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  34051. "&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
  34052. fmt.Println(api)
  34053. resp, requestErr := http.Get(api)
  34054. if requestErr != nil {
  34055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34056. return ""
  34057. }
  34058. body, ioErr := ioutil.ReadAll(resp.Body)
  34059. if ioErr != nil {
  34060. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34062. return ""
  34063. }
  34064. var respJSON map[string]interface{}
  34065. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34066. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34068. return ""
  34069. }
  34070. var status string
  34071. status = respJSON["data"].(map[string]interface{})["status"].(string)
  34072. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  34073. var res ResultTwo //1101结果
  34074. if status == "1" { //读卡成功
  34075. var card_info string //卡信息
  34076. var busi_card_info string
  34077. token = respJSON["data"].(map[string]interface{})["token"].(string)
  34078. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  34079. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  34080. fmt.Println(card_info)
  34081. fmt.Println(busi_card_info)
  34082. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  34083. result, _ := json.Marshal(respJSON)
  34084. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34085. utils.ErrorLog("解析失败:%v", err)
  34086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34087. return ""
  34088. }
  34089. if res.Infcode == 0 {
  34090. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  34091. if err == gorm.ErrRecordNotFound {
  34092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  34093. return ""
  34094. } else if err != nil {
  34095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  34096. return ""
  34097. } else {
  34098. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  34099. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  34100. infoStr := string(Iinfos)
  34101. idetinfoStr := string(Idetinfos)
  34102. psn := &models.HisPsn{
  34103. PsnNo: res.Output.Baseinfo.PsnNo,
  34104. PatientId: patient.ID,
  34105. Certno: res.Output.Baseinfo.Certno,
  34106. Gend: res.Output.Baseinfo.Gend,
  34107. Naty: res.Output.Baseinfo.Naty,
  34108. PsnCertType: res.Output.Baseinfo.PsnCertType,
  34109. PsnName: res.Output.Baseinfo.PsnName,
  34110. Idetinfo: idetinfoStr,
  34111. Insuinfo: infoStr,
  34112. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  34113. CardInfo: card_info,
  34114. VerifyNumber: token,
  34115. }
  34116. service.CreateHisPsn(psn)
  34117. return token
  34118. }
  34119. }
  34120. } else {
  34121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  34122. return ""
  34123. }
  34124. return token
  34125. }
  34126. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  34127. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  34128. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  34129. var token string
  34130. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34131. var api string
  34132. if miConfig.MdtrtareaAdmvs == "320921" {
  34133. 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 +
  34134. "&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
  34135. fmt.Println(api)
  34136. } else {
  34137. 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 +
  34138. "&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
  34139. }
  34140. resp, requestErr := http.Get(api)
  34141. if requestErr != nil {
  34142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34143. return ""
  34144. }
  34145. body, ioErr := ioutil.ReadAll(resp.Body)
  34146. if ioErr != nil {
  34147. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34149. return ""
  34150. }
  34151. var respJSON map[string]interface{}
  34152. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34153. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34155. return ""
  34156. }
  34157. var status string
  34158. status = respJSON["data"].(map[string]interface{})["status"].(string)
  34159. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  34160. var res ResultTwo //1101结果
  34161. var res10265 ResultTwo10265 //1101结果
  34162. if status == "0" { //读卡成功
  34163. var card_info string //卡信息
  34164. var busi_card_info string
  34165. token = respJSON["data"].(map[string]interface{})["token"].(string)
  34166. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  34167. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  34168. fmt.Println(card_info)
  34169. fmt.Println(busi_card_info)
  34170. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  34171. result, _ := json.Marshal(respJSON)
  34172. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  34173. utils.ErrorLog("解析失败:%v", err)
  34174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34175. return ""
  34176. }
  34177. res.ErrMsg = res10265.ErrMsg
  34178. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  34179. res.Infcode = infocode
  34180. res.Output = res10265.Output
  34181. res.InfRefmsgid = res10265.InfRefmsgid
  34182. if res.Infcode == 0 {
  34183. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  34184. if err == gorm.ErrRecordNotFound {
  34185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  34186. return ""
  34187. } else if err != nil {
  34188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  34189. return ""
  34190. } else {
  34191. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  34192. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  34193. infoStr := string(Iinfos)
  34194. idetinfoStr := string(Idetinfos)
  34195. psn := &models.HisPsn{
  34196. PsnNo: res.Output.Baseinfo.PsnNo,
  34197. PatientId: patient.ID,
  34198. Certno: res.Output.Baseinfo.Certno,
  34199. Gend: res.Output.Baseinfo.Gend,
  34200. Naty: res.Output.Baseinfo.Naty,
  34201. PsnCertType: res.Output.Baseinfo.PsnCertType,
  34202. PsnName: res.Output.Baseinfo.PsnName,
  34203. Idetinfo: idetinfoStr,
  34204. Insuinfo: infoStr,
  34205. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  34206. CardInfo: card_info,
  34207. VerifyNumber: token,
  34208. }
  34209. service.CreateHisPsn(psn)
  34210. return token
  34211. }
  34212. }
  34213. } else {
  34214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  34215. return ""
  34216. }
  34217. } else { //读卡失败
  34218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  34219. return ""
  34220. }
  34221. return token
  34222. }
  34223. func DeleteExtraSpaceTwo(s string) string {
  34224. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  34225. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  34226. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  34227. reg, _ := regexp.Compile(regstr) //编译正则表达式
  34228. s2 := make([]byte, len(s1)) //定义字符数组切片
  34229. copy(s2, s1) //将字符串复制到切片
  34230. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  34231. for len(spc_index) > 0 { //找到适配项
  34232. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  34233. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  34234. }
  34235. return string(s2)
  34236. }
  34237. func Remove0000(s string) string {
  34238. str := make([]rune, 0, len(s))
  34239. for _, v := range []rune(s) {
  34240. if v == 0 {
  34241. continue
  34242. }
  34243. str = append(str, v)
  34244. }
  34245. return string(str)
  34246. }
  34247. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  34248. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  34249. readCard := DllDef.MustFindProc("EcQuery")
  34250. pCardInfo := make([]byte, 8192)
  34251. pBusiCardInfo := make([]byte, 8192)
  34252. data := make(map[string]interface{})
  34253. //pData := make(map[string]interface{})
  34254. inputData := make(map[string]interface{})
  34255. inputData["orgId"] = code
  34256. inputData["businessType"] = "01101"
  34257. inputData["operatorId"] = operator_id
  34258. inputData["operatorName"] = operator_name
  34259. inputData["officeId"] = "001"
  34260. inputData["officeName"] = "血透室"
  34261. //
  34262. data["data"] = inputData
  34263. data["transType"] = "ec.query"
  34264. data["orgId"] = code
  34265. bytesData, _ := json.Marshal(data)
  34266. pCardInfo = bytesData
  34267. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  34268. fmt.Println(ret2)
  34269. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  34270. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  34271. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  34272. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  34273. if ret2 != 0 {
  34274. return "", ""
  34275. }
  34276. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  34277. }
  34278. func DeleteExtraSpace(s string) string {
  34279. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  34280. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  34281. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  34282. reg, _ := regexp.Compile(regstr) //编译正则表达式
  34283. s2 := make([]byte, len(s1)) //定义字符数组切片
  34284. copy(s2, s1) //将字符串复制到切片
  34285. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  34286. for len(spc_index) > 0 { //找到适配项
  34287. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  34288. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  34289. }
  34290. return string(s2)
  34291. }
  34292. // 对账
  34293. func (c *HisApiController) Post3202() {
  34294. start_time := c.GetString("start_time")
  34295. end_time := c.GetString("end_time")
  34296. //insutype := c.GetString("insutype")
  34297. clr_type := c.GetString("clr_type")
  34298. clr_org := c.GetString("clr_optins")
  34299. admin_user_id, _ := c.GetInt64("admin_user_id")
  34300. adminUser := c.GetAdminUserInfo()
  34301. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34302. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34303. if len(clr_org) == 0 {
  34304. clr_org = miConfig.MdtrtareaAdmvs
  34305. }
  34306. timeLayout := "2006-01-02"
  34307. loc, _ := time.LoadLocation("Local")
  34308. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34309. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34310. var orders []*models.HisOrder
  34311. if clr_org == "421300" {
  34312. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34313. } else if clr_org == "420902" {
  34314. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34315. } else {
  34316. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34317. }
  34318. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  34319. //fixmedins_setl_cnt := int64(len(orders))
  34320. var medfee_sumamt float64
  34321. var acct_pay float64
  34322. var fund_pay_sumamt float64
  34323. for _, item := range orders {
  34324. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34325. acct_pay = acct_pay + item.AcctPay
  34326. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34327. }
  34328. //var medfee_sumamt_two float64
  34329. //var acct_pay_two float64
  34330. //var fund_pay_sumamt_two float64
  34331. //for _, item := range orders_two {
  34332. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  34333. // acct_pay_two = acct_pay_two + item.AcctPay
  34334. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  34335. //}
  34336. //var user_name string
  34337. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34338. //if role.ID == 0 {
  34339. // user_name = "xxx"
  34340. //} else {
  34341. // user_name = role.UserName
  34342. //}
  34343. var res ResultSix
  34344. if config.IsOpen == 1 {
  34345. var bps []*models.BusinessParamsTwo
  34346. var bp models.BusinessParamsTwo
  34347. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  34348. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  34349. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  34350. bp.MedfeeSumamt = medfee_sumamt_str
  34351. bp.AcctPay = acct_pay_str
  34352. bp.FundPaySumamt = fund_pay_sumamt_str
  34353. bp.Insutype = ""
  34354. bp.StmtBegndate = start_time
  34355. bp.ClrType = clr_type
  34356. bp.SetlOptins = clr_org
  34357. bp.StmtEnddate = end_time
  34358. bps = append(bps, &bp)
  34359. data := make(map[string]interface{})
  34360. data["bps"] = bps
  34361. data["org_name"] = miConfig.OrgName
  34362. data["doctor"] = role.UserName
  34363. data["fixmedins_code"] = miConfig.Code
  34364. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34365. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34366. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  34367. if miConfig.MdtrtareaAdmvs == "421300" {
  34368. client := &http.Client{}
  34369. bytesData, _ := json.Marshal(data)
  34370. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  34371. resp, _ := client.Do(req)
  34372. defer resp.Body.Close()
  34373. body, ioErr := ioutil.ReadAll(resp.Body)
  34374. if ioErr != nil {
  34375. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34377. return
  34378. }
  34379. var respJSON map[string]interface{}
  34380. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34381. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34383. return
  34384. }
  34385. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34386. userJSONBytes, _ := json.Marshal(respJSON)
  34387. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34388. utils.ErrorLog("解析失败:%v", err)
  34389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34390. return
  34391. }
  34392. }
  34393. if miConfig.MdtrtareaAdmvs == "420200" {
  34394. client := &http.Client{}
  34395. bytesData, _ := json.Marshal(data)
  34396. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  34397. resp, _ := client.Do(req)
  34398. defer resp.Body.Close()
  34399. body, ioErr := ioutil.ReadAll(resp.Body)
  34400. if ioErr != nil {
  34401. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34403. return
  34404. }
  34405. var respJSON map[string]interface{}
  34406. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34409. return
  34410. }
  34411. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34412. userJSONBytes, _ := json.Marshal(respJSON)
  34413. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34414. utils.ErrorLog("解析失败:%v", err)
  34415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34416. return
  34417. }
  34418. }
  34419. if miConfig.MdtrtareaAdmvs == "421182" {
  34420. client := &http.Client{}
  34421. bytesData, _ := json.Marshal(data)
  34422. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  34423. resp, _ := client.Do(req)
  34424. defer resp.Body.Close()
  34425. body, ioErr := ioutil.ReadAll(resp.Body)
  34426. if ioErr != nil {
  34427. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34429. return
  34430. }
  34431. var respJSON map[string]interface{}
  34432. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34433. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34435. return
  34436. }
  34437. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34438. userJSONBytes, _ := json.Marshal(respJSON)
  34439. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34440. utils.ErrorLog("解析失败:%v", err)
  34441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34442. return
  34443. }
  34444. }
  34445. if miConfig.MdtrtareaAdmvs == "420902" {
  34446. client := &http.Client{}
  34447. bytesData, _ := json.Marshal(data)
  34448. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  34449. resp, _ := client.Do(req)
  34450. defer resp.Body.Close()
  34451. body, ioErr := ioutil.ReadAll(resp.Body)
  34452. if ioErr != nil {
  34453. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34455. return
  34456. }
  34457. var respJSON map[string]interface{}
  34458. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34459. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34461. return
  34462. }
  34463. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34464. userJSONBytes, _ := json.Marshal(respJSON)
  34465. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34466. utils.ErrorLog("解析失败:%v", err)
  34467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34468. return
  34469. }
  34470. }
  34471. if res.Infcode == 0 {
  34472. c.ServeSuccessJSON(map[string]interface{}{
  34473. "msg": "发起成功",
  34474. })
  34475. } else {
  34476. c.ServeSuccessJSON(map[string]interface{}{
  34477. "failed_code": -10,
  34478. "msg": res.ErrMsg,
  34479. })
  34480. }
  34481. }
  34482. }
  34483. func (c *HisApiController) Post3204a() {
  34484. start_time := c.GetString("start_time")
  34485. end_time := c.GetString("end_time")
  34486. //insutype := c.GetString("insutype")
  34487. clr_type := c.GetString("clr_type")
  34488. clr_org := c.GetString("clr_optins")
  34489. admin_user_id, _ := c.GetInt64("admin_user_id")
  34490. adminUser := c.GetAdminUserInfo()
  34491. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34492. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34493. if len(clr_org) == 0 {
  34494. clr_org = miConfig.MdtrtareaAdmvs
  34495. }
  34496. timeLayout := "2006-01-02"
  34497. loc, _ := time.LoadLocation("Local")
  34498. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34499. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34500. var orders []*models.HisOrder
  34501. if clr_org == "421300" {
  34502. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34503. } else if clr_org == "420902" {
  34504. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34505. } else {
  34506. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34507. }
  34508. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  34509. //fixmedins_setl_cnt := int64(len(orders))
  34510. var medfee_sumamt float64
  34511. var acct_pay float64
  34512. var fund_pay_sumamt float64
  34513. for _, item := range orders {
  34514. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34515. acct_pay = acct_pay + item.AcctPay
  34516. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34517. }
  34518. //var medfee_sumamt_two float64
  34519. //var acct_pay_two float64
  34520. //var fund_pay_sumamt_two float64
  34521. //for _, item := range orders_two {
  34522. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  34523. // acct_pay_two = acct_pay_two + item.AcctPay
  34524. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  34525. //}
  34526. //var user_name string
  34527. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34528. //if role.ID == 0 {
  34529. // user_name = "xxx"
  34530. //} else {
  34531. // user_name = role.UserName
  34532. //}
  34533. var res ResultSix
  34534. if config.IsOpen == 1 {
  34535. var bps []*models.BusinessParamsTwo
  34536. var bp models.BusinessParamsTwo
  34537. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  34538. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  34539. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  34540. bp.MedfeeSumamt = medfee_sumamt_str
  34541. bp.AcctPay = acct_pay_str
  34542. bp.FundPaySumamt = fund_pay_sumamt_str
  34543. bp.Insutype = ""
  34544. bp.StmtBegndate = start_time
  34545. bp.ClrType = clr_type
  34546. bp.SetlOptins = clr_org
  34547. bp.StmtEnddate = end_time
  34548. bps = append(bps, &bp)
  34549. data := make(map[string]interface{})
  34550. data["bps"] = bps
  34551. data["org_name"] = miConfig.OrgName
  34552. data["doctor"] = role.UserName
  34553. data["fixmedins_code"] = miConfig.Code
  34554. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34555. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34556. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  34557. if miConfig.MdtrtareaAdmvs == "421300" {
  34558. client := &http.Client{}
  34559. bytesData, _ := json.Marshal(data)
  34560. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  34561. resp, _ := client.Do(req)
  34562. defer resp.Body.Close()
  34563. body, ioErr := ioutil.ReadAll(resp.Body)
  34564. if ioErr != nil {
  34565. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34567. return
  34568. }
  34569. var respJSON map[string]interface{}
  34570. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34573. return
  34574. }
  34575. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34576. userJSONBytes, _ := json.Marshal(respJSON)
  34577. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34578. utils.ErrorLog("解析失败:%v", err)
  34579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34580. return
  34581. }
  34582. }
  34583. if miConfig.MdtrtareaAdmvs == "420200" {
  34584. client := &http.Client{}
  34585. bytesData, _ := json.Marshal(data)
  34586. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  34587. resp, _ := client.Do(req)
  34588. defer resp.Body.Close()
  34589. body, ioErr := ioutil.ReadAll(resp.Body)
  34590. if ioErr != nil {
  34591. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34593. return
  34594. }
  34595. var respJSON map[string]interface{}
  34596. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34597. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34599. return
  34600. }
  34601. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34602. userJSONBytes, _ := json.Marshal(respJSON)
  34603. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34604. utils.ErrorLog("解析失败:%v", err)
  34605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34606. return
  34607. }
  34608. }
  34609. if miConfig.MdtrtareaAdmvs == "421182" {
  34610. client := &http.Client{}
  34611. bytesData, _ := json.Marshal(data)
  34612. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  34613. resp, _ := client.Do(req)
  34614. defer resp.Body.Close()
  34615. body, ioErr := ioutil.ReadAll(resp.Body)
  34616. if ioErr != nil {
  34617. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34619. return
  34620. }
  34621. var respJSON map[string]interface{}
  34622. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34623. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34625. return
  34626. }
  34627. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34628. userJSONBytes, _ := json.Marshal(respJSON)
  34629. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34630. utils.ErrorLog("解析失败:%v", err)
  34631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34632. return
  34633. }
  34634. }
  34635. if miConfig.MdtrtareaAdmvs == "420902" {
  34636. client := &http.Client{}
  34637. bytesData, _ := json.Marshal(data)
  34638. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  34639. resp, _ := client.Do(req)
  34640. defer resp.Body.Close()
  34641. body, ioErr := ioutil.ReadAll(resp.Body)
  34642. if ioErr != nil {
  34643. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34645. return
  34646. }
  34647. var respJSON map[string]interface{}
  34648. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34649. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34651. return
  34652. }
  34653. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34654. userJSONBytes, _ := json.Marshal(respJSON)
  34655. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34656. utils.ErrorLog("解析失败:%v", err)
  34657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34658. return
  34659. }
  34660. }
  34661. if res.Infcode == 0 {
  34662. c.ServeSuccessJSON(map[string]interface{}{
  34663. "msg": "撤销成功",
  34664. })
  34665. } else {
  34666. c.ServeSuccessJSON(map[string]interface{}{
  34667. "failed_code": -10,
  34668. "msg": res.ErrMsg,
  34669. })
  34670. }
  34671. }
  34672. }
  34673. func (c *HisApiController) Post3204() {
  34674. admin_user_id, _ := c.GetInt64("admin_user_id")
  34675. id := c.GetString("id")
  34676. adminUser := c.GetAdminUserInfo()
  34677. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34678. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34679. //clr_org := miConfig.MdtrtareaAdmvs
  34680. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34681. var res ResultSix
  34682. if config.IsOpen == 1 {
  34683. data := make(map[string]interface{})
  34684. data["id"] = id
  34685. data["org_name"] = miConfig.OrgName
  34686. data["doctor"] = role.UserName
  34687. data["fixmedins_code"] = miConfig.Code
  34688. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34689. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  34690. client := &http.Client{}
  34691. bytesData, _ := json.Marshal(data)
  34692. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  34693. resp, _ := client.Do(req)
  34694. defer resp.Body.Close()
  34695. body, ioErr := ioutil.ReadAll(resp.Body)
  34696. if ioErr != nil {
  34697. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34699. return
  34700. }
  34701. var respJSON map[string]interface{}
  34702. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34705. return
  34706. }
  34707. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34708. userJSONBytes, _ := json.Marshal(respJSON)
  34709. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34710. utils.ErrorLog("解析失败:%v", err)
  34711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34712. return
  34713. }
  34714. if res.Infcode == 0 {
  34715. c.ServeSuccessJSON(map[string]interface{}{
  34716. "msg": "发起成功",
  34717. })
  34718. } else {
  34719. c.ServeSuccessJSON(map[string]interface{}{
  34720. "failed_code": -10,
  34721. "msg": res.ErrMsg,
  34722. })
  34723. }
  34724. }
  34725. }
  34726. func (c *HisApiController) Post8404() {
  34727. admin_user_id, _ := c.GetInt64("admin_user_id")
  34728. month := c.GetString("month")
  34729. adminUser := c.GetAdminUserInfo()
  34730. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34731. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34732. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34733. var res ResultSix
  34734. if config.IsOpen == 1 {
  34735. data := make(map[string]interface{})
  34736. data["month"] = month
  34737. data["org_name"] = miConfig.OrgName
  34738. data["doctor"] = role.UserName
  34739. data["fixmedins_code"] = miConfig.Code
  34740. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34741. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  34742. client := &http.Client{}
  34743. bytesData, _ := json.Marshal(data)
  34744. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  34745. resp, _ := client.Do(req)
  34746. defer resp.Body.Close()
  34747. body, ioErr := ioutil.ReadAll(resp.Body)
  34748. if ioErr != nil {
  34749. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34751. return
  34752. }
  34753. var respJSON map[string]interface{}
  34754. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34755. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34757. return
  34758. }
  34759. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34760. userJSONBytes, _ := json.Marshal(respJSON)
  34761. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34762. utils.ErrorLog("解析失败:%v", err)
  34763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34764. return
  34765. }
  34766. if res.Infcode == 0 {
  34767. c.ServeSuccessJSON(map[string]interface{}{
  34768. "msg": "查询成功",
  34769. })
  34770. } else {
  34771. c.ServeSuccessJSON(map[string]interface{}{
  34772. "failed_code": -10,
  34773. "msg": res.ErrMsg,
  34774. })
  34775. }
  34776. }
  34777. }
  34778. func (c *HisApiController) Post3202b() {
  34779. start_time := c.GetString("start_time")
  34780. end_time := c.GetString("end_time")
  34781. //insutype := c.GetString("insutype")
  34782. clr_type := c.GetString("clr_type")
  34783. clr_org := c.GetString("clr_optins")
  34784. admin_user_id, _ := c.GetInt64("admin_user_id")
  34785. adminUser := c.GetAdminUserInfo()
  34786. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34787. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34788. if len(clr_org) == 0 {
  34789. clr_org = miConfig.MdtrtareaAdmvs
  34790. }
  34791. timeLayout := "2006-01-02"
  34792. loc, _ := time.LoadLocation("Local")
  34793. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34794. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34795. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34796. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  34797. //fixmedins_setl_cnt := int64(len(orders))
  34798. var medfee_sumamt float64
  34799. var acct_pay float64
  34800. var fund_pay_sumamt float64
  34801. for _, item := range orders {
  34802. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34803. acct_pay = acct_pay + item.AcctPay
  34804. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34805. }
  34806. //var medfee_sumamt_two float64
  34807. //var acct_pay_two float64
  34808. //var fund_pay_sumamt_two float64
  34809. //for _, item := range orders_two {
  34810. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  34811. // acct_pay_two = acct_pay_two + item.AcctPay
  34812. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  34813. //}
  34814. //var user_name string
  34815. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34816. //if role.ID == 0 {
  34817. // user_name = "xxx"
  34818. //} else {
  34819. // user_name = role.UserName
  34820. //}
  34821. var res ResultSix
  34822. if config.IsOpen == 1 {
  34823. var bps []*models.BusinessParamsTwo
  34824. var bp models.BusinessParamsTwo
  34825. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  34826. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  34827. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  34828. bp.MedfeeSumamt = medfee_sumamt_str
  34829. bp.AcctPay = acct_pay_str
  34830. bp.FundPaySumamt = fund_pay_sumamt_str
  34831. bp.Insutype = "390"
  34832. bp.StmtBegndate = start_time
  34833. bp.ClrType = clr_type
  34834. bp.SetlOptins = clr_org
  34835. bp.StmtEnddate = end_time
  34836. bps = append(bps, &bp)
  34837. data := make(map[string]interface{})
  34838. data["bps"] = bps
  34839. data["org_name"] = miConfig.OrgName
  34840. data["doctor"] = role.UserName
  34841. data["fixmedins_code"] = miConfig.Code
  34842. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34843. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  34844. if miConfig.MdtrtareaAdmvs == "421300" {
  34845. client := &http.Client{}
  34846. bytesData, _ := json.Marshal(data)
  34847. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  34848. resp, _ := client.Do(req)
  34849. defer resp.Body.Close()
  34850. body, ioErr := ioutil.ReadAll(resp.Body)
  34851. if ioErr != nil {
  34852. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34854. return
  34855. }
  34856. var respJSON map[string]interface{}
  34857. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34858. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34860. return
  34861. }
  34862. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34863. userJSONBytes, _ := json.Marshal(respJSON)
  34864. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34865. utils.ErrorLog("解析失败:%v", err)
  34866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34867. return
  34868. }
  34869. }
  34870. if miConfig.MdtrtareaAdmvs == "420200" {
  34871. client := &http.Client{}
  34872. bytesData, _ := json.Marshal(data)
  34873. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  34874. resp, _ := client.Do(req)
  34875. defer resp.Body.Close()
  34876. body, ioErr := ioutil.ReadAll(resp.Body)
  34877. if ioErr != nil {
  34878. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34880. return
  34881. }
  34882. var respJSON map[string]interface{}
  34883. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34884. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34886. return
  34887. }
  34888. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34889. userJSONBytes, _ := json.Marshal(respJSON)
  34890. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34891. utils.ErrorLog("解析失败:%v", err)
  34892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34893. return
  34894. }
  34895. }
  34896. if miConfig.MdtrtareaAdmvs == "421182" {
  34897. client := &http.Client{}
  34898. bytesData, _ := json.Marshal(data)
  34899. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  34900. resp, _ := client.Do(req)
  34901. defer resp.Body.Close()
  34902. body, ioErr := ioutil.ReadAll(resp.Body)
  34903. if ioErr != nil {
  34904. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34906. return
  34907. }
  34908. var respJSON map[string]interface{}
  34909. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34910. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34912. return
  34913. }
  34914. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34915. userJSONBytes, _ := json.Marshal(respJSON)
  34916. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34917. utils.ErrorLog("解析失败:%v", err)
  34918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34919. return
  34920. }
  34921. }
  34922. if res.Infcode == 0 {
  34923. c.ServeSuccessJSON(map[string]interface{}{
  34924. "msg": "发起成功",
  34925. })
  34926. } else {
  34927. c.ServeSuccessJSON(map[string]interface{}{
  34928. "failed_code": -10,
  34929. "msg": res.ErrMsg,
  34930. })
  34931. }
  34932. }
  34933. }
  34934. func (c *HisApiController) Post1608() {
  34935. start_time := c.GetString("start_time")
  34936. end_time := c.GetString("end_time")
  34937. admin_user_id, _ := c.GetInt64("admin_user_id")
  34938. adminUser := c.GetAdminUserInfo()
  34939. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34940. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34941. timeLayout := "2006-01-02"
  34942. loc, _ := time.LoadLocation("Local")
  34943. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34944. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34945. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34946. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  34947. fixmedins_setl_cnt := int64(len(orders))
  34948. var medfee_sumamt float64
  34949. var func_smamt float64
  34950. for _, item := range orders {
  34951. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34952. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  34953. }
  34954. times := strings.Split(start_time, "-")
  34955. time_tows := strings.Split(end_time, "-")
  34956. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34957. var res ResultSix
  34958. if config.IsOpen == 1 {
  34959. //var bps []*models.BusinessParamsTwo
  34960. //var bp models.BusinessParamsTwo
  34961. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  34962. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  34963. data := make(map[string]interface{})
  34964. data["org_name"] = miConfig.OrgName
  34965. data["doctor"] = role.UserName
  34966. data["func_smamt"] = func_smamt_str
  34967. data["fixmedins_code"] = miConfig.Code
  34968. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34969. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  34970. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  34971. data["medfee_sumamt"] = medfee_sumamt_str
  34972. data["start_time"] = times[0] + times[1] + times[2]
  34973. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  34974. if miConfig.MdtrtareaAdmvs == "421300" {
  34975. client := &http.Client{}
  34976. bytesData, _ := json.Marshal(data)
  34977. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  34978. resp, _ := client.Do(req)
  34979. defer resp.Body.Close()
  34980. body, ioErr := ioutil.ReadAll(resp.Body)
  34981. if ioErr != nil {
  34982. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34984. return
  34985. }
  34986. var respJSON map[string]interface{}
  34987. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34990. return
  34991. }
  34992. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34993. userJSONBytes, _ := json.Marshal(respJSON)
  34994. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34995. utils.ErrorLog("解析失败:%v", err)
  34996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34997. return
  34998. }
  34999. }
  35000. if miConfig.MdtrtareaAdmvs == "420200" {
  35001. client := &http.Client{}
  35002. bytesData, _ := json.Marshal(data)
  35003. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  35004. resp, _ := client.Do(req)
  35005. defer resp.Body.Close()
  35006. body, ioErr := ioutil.ReadAll(resp.Body)
  35007. if ioErr != nil {
  35008. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35010. return
  35011. }
  35012. var respJSON map[string]interface{}
  35013. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35014. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35016. return
  35017. }
  35018. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35019. userJSONBytes, _ := json.Marshal(respJSON)
  35020. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35021. utils.ErrorLog("解析失败:%v", err)
  35022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35023. return
  35024. }
  35025. }
  35026. if miConfig.MdtrtareaAdmvs == "421182" {
  35027. client := &http.Client{}
  35028. bytesData, _ := json.Marshal(data)
  35029. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  35030. resp, _ := client.Do(req)
  35031. defer resp.Body.Close()
  35032. body, ioErr := ioutil.ReadAll(resp.Body)
  35033. if ioErr != nil {
  35034. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35036. return
  35037. }
  35038. var respJSON map[string]interface{}
  35039. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35040. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35042. return
  35043. }
  35044. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35045. userJSONBytes, _ := json.Marshal(respJSON)
  35046. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35047. utils.ErrorLog("解析失败:%v", err)
  35048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35049. return
  35050. }
  35051. }
  35052. if res.Infcode == 0 {
  35053. c.ServeSuccessJSON(map[string]interface{}{
  35054. "msg": "发起成功",
  35055. })
  35056. } else {
  35057. c.ServeSuccessJSON(map[string]interface{}{
  35058. "failed_code": -10,
  35059. "msg": res.ErrMsg,
  35060. })
  35061. }
  35062. }
  35063. }
  35064. // 5.11.1.1【5262】结算信息按时间段查询
  35065. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  35066. admin_user_id, _ := c.GetInt64("admin_user_id")
  35067. adminUser := c.GetAdminUserInfo()
  35068. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35069. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35070. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35071. var res Result5262
  35072. if config.IsOpen == 1 {
  35073. if miConfig.MdtrtareaAdmvs == "421300" {
  35074. data := make(map[string]interface{})
  35075. data["bps"] = bp
  35076. data["org_name"] = miConfig.OrgName
  35077. data["doctor"] = role.UserName
  35078. data["fixmedins_code"] = miConfig.Code
  35079. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35080. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35081. data["page"] = strconv.FormatInt(page, 10)
  35082. data["limit"] = strconv.FormatInt(limit, 10)
  35083. fmt.Println(data)
  35084. client := &http.Client{}
  35085. bytesData, _ := json.Marshal(data)
  35086. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  35087. resp, _ := client.Do(req)
  35088. defer resp.Body.Close()
  35089. body, ioErr := ioutil.ReadAll(resp.Body)
  35090. if ioErr != nil {
  35091. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35093. return
  35094. }
  35095. var respJSON map[string]interface{}
  35096. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35097. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35099. return
  35100. }
  35101. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35102. userJSONBytes, _ := json.Marshal(respJSON)
  35103. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35104. utils.ErrorLog("解析失败:%v", err)
  35105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35106. return
  35107. }
  35108. }
  35109. if miConfig.MdtrtareaAdmvs == "420200" {
  35110. data := make(map[string]interface{})
  35111. data["bps"] = bp
  35112. data["org_name"] = miConfig.OrgName
  35113. data["doctor"] = role.UserName
  35114. data["fixmedins_code"] = miConfig.Code
  35115. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35116. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35117. data["page"] = strconv.FormatInt(page, 10)
  35118. data["limit"] = strconv.FormatInt(limit, 10)
  35119. fmt.Println(data)
  35120. client := &http.Client{}
  35121. bytesData, _ := json.Marshal(data)
  35122. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  35123. resp, _ := client.Do(req)
  35124. defer resp.Body.Close()
  35125. body, ioErr := ioutil.ReadAll(resp.Body)
  35126. if ioErr != nil {
  35127. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35129. return
  35130. }
  35131. var respJSON map[string]interface{}
  35132. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35133. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35135. return
  35136. }
  35137. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35138. userJSONBytes, _ := json.Marshal(respJSON)
  35139. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35140. utils.ErrorLog("解析失败:%v", err)
  35141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35142. return
  35143. }
  35144. }
  35145. if miConfig.MdtrtareaAdmvs == "421182" {
  35146. data := make(map[string]interface{})
  35147. data["bps"] = bp
  35148. data["org_name"] = miConfig.OrgName
  35149. data["doctor"] = role.UserName
  35150. data["fixmedins_code"] = miConfig.Code
  35151. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35152. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35153. data["page"] = strconv.FormatInt(page, 10)
  35154. data["limit"] = strconv.FormatInt(limit, 10)
  35155. fmt.Println(data)
  35156. client := &http.Client{}
  35157. bytesData, _ := json.Marshal(data)
  35158. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  35159. resp, _ := client.Do(req)
  35160. defer resp.Body.Close()
  35161. body, ioErr := ioutil.ReadAll(resp.Body)
  35162. if ioErr != nil {
  35163. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35165. return
  35166. }
  35167. var respJSON map[string]interface{}
  35168. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35169. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35171. return
  35172. }
  35173. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35174. userJSONBytes, _ := json.Marshal(respJSON)
  35175. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35176. utils.ErrorLog("解析失败:%v", err)
  35177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35178. return
  35179. }
  35180. }
  35181. if miConfig.MdtrtareaAdmvs == "420902" {
  35182. data := make(map[string]interface{})
  35183. data["bps"] = bp
  35184. data["org_name"] = miConfig.OrgName
  35185. data["doctor"] = role.UserName
  35186. data["fixmedins_code"] = miConfig.Code
  35187. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35188. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35189. data["page"] = strconv.FormatInt(page, 10)
  35190. data["limit"] = strconv.FormatInt(limit, 10)
  35191. fmt.Println(data)
  35192. client := &http.Client{}
  35193. bytesData, _ := json.Marshal(data)
  35194. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  35195. resp, _ := client.Do(req)
  35196. defer resp.Body.Close()
  35197. body, ioErr := ioutil.ReadAll(resp.Body)
  35198. if ioErr != nil {
  35199. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35201. return
  35202. }
  35203. var respJSON map[string]interface{}
  35204. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35205. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35207. return
  35208. }
  35209. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35210. userJSONBytes, _ := json.Marshal(respJSON)
  35211. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35212. utils.ErrorLog("解析失败:%v", err)
  35213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35214. return
  35215. }
  35216. }
  35217. if res.Infcode == 0 {
  35218. c.ServeSuccessJSON(map[string]interface{}{
  35219. "order": res.Output.Result,
  35220. "total": res.Output.PageInfo.RecordCounts,
  35221. })
  35222. } else {
  35223. c.ServeSuccessJSON(map[string]interface{}{
  35224. "failed_code": -10,
  35225. "msg": res.ErrMsg,
  35226. })
  35227. }
  35228. }
  35229. }
  35230. // 5.11.1.2【5267】异地结算信息时间段查询
  35231. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  35232. admin_user_id, _ := c.GetInt64("admin_user_id")
  35233. adminUser := c.GetAdminUserInfo()
  35234. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35235. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35236. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35237. var res Result5267
  35238. if config.IsOpen == 1 {
  35239. if miConfig.MdtrtareaAdmvs == "421300" {
  35240. data := make(map[string]interface{})
  35241. data["bps"] = bp
  35242. data["org_name"] = miConfig.OrgName
  35243. data["doctor"] = role.UserName
  35244. data["fixmedins_code"] = miConfig.Code
  35245. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35246. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35247. data["page"] = page
  35248. data["limit"] = limit
  35249. fmt.Println(data)
  35250. client := &http.Client{}
  35251. bytesData, _ := json.Marshal(data)
  35252. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  35253. resp, _ := client.Do(req)
  35254. defer resp.Body.Close()
  35255. body, ioErr := ioutil.ReadAll(resp.Body)
  35256. if ioErr != nil {
  35257. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35259. return
  35260. }
  35261. var respJSON map[string]interface{}
  35262. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35263. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35265. return
  35266. }
  35267. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35268. userJSONBytes, _ := json.Marshal(respJSON)
  35269. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35270. utils.ErrorLog("解析失败:%v", err)
  35271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35272. return
  35273. }
  35274. }
  35275. if miConfig.MdtrtareaAdmvs == "420200" {
  35276. data := make(map[string]interface{})
  35277. data["bps"] = bp
  35278. data["org_name"] = miConfig.OrgName
  35279. data["doctor"] = role.UserName
  35280. data["fixmedins_code"] = miConfig.Code
  35281. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35282. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35283. data["page"] = page
  35284. data["limit"] = limit
  35285. fmt.Println(data)
  35286. client := &http.Client{}
  35287. bytesData, _ := json.Marshal(data)
  35288. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  35289. resp, _ := client.Do(req)
  35290. defer resp.Body.Close()
  35291. body, ioErr := ioutil.ReadAll(resp.Body)
  35292. if ioErr != nil {
  35293. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35295. return
  35296. }
  35297. var respJSON map[string]interface{}
  35298. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35301. return
  35302. }
  35303. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35304. userJSONBytes, _ := json.Marshal(respJSON)
  35305. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35306. utils.ErrorLog("解析失败:%v", err)
  35307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35308. return
  35309. }
  35310. }
  35311. if miConfig.MdtrtareaAdmvs == "421182" {
  35312. data := make(map[string]interface{})
  35313. data["bps"] = bp
  35314. data["org_name"] = miConfig.OrgName
  35315. data["doctor"] = role.UserName
  35316. data["fixmedins_code"] = miConfig.Code
  35317. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35318. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35319. data["page"] = page
  35320. data["limit"] = limit
  35321. fmt.Println(data)
  35322. client := &http.Client{}
  35323. bytesData, _ := json.Marshal(data)
  35324. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  35325. resp, _ := client.Do(req)
  35326. defer resp.Body.Close()
  35327. body, ioErr := ioutil.ReadAll(resp.Body)
  35328. if ioErr != nil {
  35329. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35331. return
  35332. }
  35333. var respJSON map[string]interface{}
  35334. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35337. return
  35338. }
  35339. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35340. userJSONBytes, _ := json.Marshal(respJSON)
  35341. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35342. utils.ErrorLog("解析失败:%v", err)
  35343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35344. return
  35345. }
  35346. }
  35347. if res.Infcode == 0 {
  35348. c.ServeSuccessJSON(map[string]interface{}{
  35349. "order": res.Output.Result,
  35350. "total": res.Output.PageInfo.RecordCounts,
  35351. })
  35352. } else {
  35353. c.ServeSuccessJSON(map[string]interface{}{
  35354. "failed_code": -10,
  35355. "msg": res.ErrMsg,
  35356. })
  35357. }
  35358. }
  35359. }
  35360. func (c *HisApiController) Post3501() {
  35361. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35362. data := make(map[string]interface{})
  35363. var struct3501s []models.Struct3501
  35364. var struct3501 models.Struct3501
  35365. struct3501.OrgName = miConfig.OrgName
  35366. struct3501.AccessKey = miConfig.AccessKey
  35367. struct3501.RequestUrl = miConfig.Url
  35368. struct3501.SecretKey = miConfig.SecretKey
  35369. struct3501.ManuDate = "2022-08-17"
  35370. struct3501.FixmedinsBchno = ""
  35371. struct3501.ManuLotnum = ""
  35372. struct3501.RxFlag = "0"
  35373. struct3501.ExpyEnd = "2022-08-17"
  35374. struct3501.Invdate = "2022-08-17"
  35375. struct3501.InvCnt = "20.25"
  35376. struct3501.Memo = ""
  35377. struct3501.MedListCodg = "XB01ABD056B002020200517"
  35378. struct3501.FixmedinsHilistId = miConfig.Code
  35379. struct3501.FixmedinsHilistName = miConfig.OrgName
  35380. struct3501s = append(struct3501s, struct3501)
  35381. data["struct_3501s"] = struct3501s
  35382. client := &http.Client{}
  35383. bytesData, _ := json.Marshal(data)
  35384. var req *http.Request
  35385. if miConfig.MdtrtareaAdmvs == "320921" {
  35386. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35387. } else {
  35388. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35389. }
  35390. resp, _ := client.Do(req)
  35391. defer resp.Body.Close()
  35392. body, ioErr := ioutil.ReadAll(resp.Body)
  35393. if ioErr != nil {
  35394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35396. return
  35397. }
  35398. var respJSON map[string]interface{}
  35399. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35402. return
  35403. }
  35404. var res ResultSix
  35405. var resSix10265 ResultSix10265 //1101结果
  35406. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  35407. result, _ := json.Marshal(respJSON)
  35408. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  35409. utils.ErrorLog("解析失败:%v", err)
  35410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35411. return
  35412. }
  35413. res.InfRefmsgid = resSix10265.InfRefmsgid
  35414. res.Output = resSix10265.Output
  35415. res.ErrMsg = resSix10265.ErrMsg
  35416. res.Cainfo = resSix10265.Cainfo
  35417. res.WarnMsg = resSix10265.WarnMsg
  35418. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35419. res.Infcode = infocode
  35420. if infocode == 0 {
  35421. c.ServeSuccessJSON(map[string]interface{}{
  35422. "msg": "上传成功",
  35423. })
  35424. return
  35425. } else {
  35426. c.ServeSuccessJSON(map[string]interface{}{
  35427. "failed_code": -10,
  35428. "msg": res.ErrMsg,
  35429. })
  35430. return
  35431. }
  35432. }
  35433. func (c *HisApiController) Post3502() {
  35434. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35435. data := make(map[string]interface{})
  35436. var struct3502s []models.Struct3502
  35437. var struct3502 models.Struct3502
  35438. struct3502.OrgName = miConfig.OrgName
  35439. struct3502.AccessKey = miConfig.AccessKey
  35440. struct3502.RequestUrl = miConfig.Url
  35441. struct3502.SecretKey = miConfig.SecretKey
  35442. struct3502.ManuDate = "2022-08-15"
  35443. struct3502.FixmedinsBchno = ""
  35444. struct3502.ManuLotnum = ""
  35445. struct3502.RxFlag = "0"
  35446. struct3502.ExpyEnd = "2022-08-15"
  35447. struct3502.Invdate = "2022-08-15"
  35448. struct3502.InvCnt = "20.25"
  35449. struct3502.Memo = ""
  35450. struct3502.MedListCodg = "XB01ABD056B002020200517"
  35451. struct3502.FixmedinsHilistId = miConfig.Code
  35452. struct3502.FixmedinsHilistName = miConfig.OrgName
  35453. struct3502s = append(struct3502s, struct3502)
  35454. data["struct_3502s"] = struct3502s
  35455. client := &http.Client{}
  35456. bytesData, _ := json.Marshal(data)
  35457. var req *http.Request
  35458. if miConfig.MdtrtareaAdmvs == "320921" {
  35459. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35460. } else {
  35461. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35462. }
  35463. resp, _ := client.Do(req)
  35464. defer resp.Body.Close()
  35465. body, ioErr := ioutil.ReadAll(resp.Body)
  35466. if ioErr != nil {
  35467. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35469. return
  35470. }
  35471. var respJSON map[string]interface{}
  35472. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35475. return
  35476. }
  35477. var res ResultSix
  35478. var resSix10265 ResultSix10265 //1101结果
  35479. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  35480. result, _ := json.Marshal(respJSON)
  35481. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  35482. utils.ErrorLog("解析失败:%v", err)
  35483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35484. return
  35485. }
  35486. res.InfRefmsgid = resSix10265.InfRefmsgid
  35487. res.Output = resSix10265.Output
  35488. res.ErrMsg = resSix10265.ErrMsg
  35489. res.Cainfo = resSix10265.Cainfo
  35490. res.WarnMsg = resSix10265.WarnMsg
  35491. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35492. res.Infcode = infocode
  35493. if infocode == 0 {
  35494. c.ServeSuccessJSON(map[string]interface{}{
  35495. "msg": "上传成功",
  35496. })
  35497. return
  35498. } else {
  35499. c.ServeSuccessJSON(map[string]interface{}{
  35500. "failed_code": -10,
  35501. "msg": res.ErrMsg,
  35502. })
  35503. return
  35504. }
  35505. }
  35506. func (c *HisApiController) Post3503() {
  35507. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35508. data := make(map[string]interface{})
  35509. var struct3501s []models.Struct3501
  35510. var struct3501 models.Struct3501
  35511. struct3501.OrgName = miConfig.OrgName
  35512. struct3501.AccessKey = miConfig.AccessKey
  35513. struct3501.RequestUrl = miConfig.Url
  35514. struct3501.SecretKey = miConfig.SecretKey
  35515. struct3501.ManuDate = "2022-08-15"
  35516. struct3501.FixmedinsBchno = ""
  35517. struct3501.ManuLotnum = ""
  35518. struct3501.RxFlag = "0"
  35519. struct3501.ExpyEnd = "2022-08-15"
  35520. struct3501.Invdate = "2022-08-15"
  35521. struct3501.InvCnt = "20.25"
  35522. struct3501.Memo = ""
  35523. struct3501.MedListCodg = "XB01ABD056B002020200517"
  35524. struct3501.FixmedinsHilistId = miConfig.Code
  35525. struct3501.FixmedinsHilistName = miConfig.OrgName
  35526. struct3501s = append(struct3501s, struct3501)
  35527. data["struct_3501s"] = struct3501s
  35528. client := &http.Client{}
  35529. bytesData, _ := json.Marshal(data)
  35530. var req *http.Request
  35531. if miConfig.MdtrtareaAdmvs == "320921" {
  35532. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35533. } else {
  35534. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35535. }
  35536. resp, _ := client.Do(req)
  35537. defer resp.Body.Close()
  35538. body, ioErr := ioutil.ReadAll(resp.Body)
  35539. if ioErr != nil {
  35540. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35542. return
  35543. }
  35544. var respJSON map[string]interface{}
  35545. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35548. return
  35549. }
  35550. var res ResultSix
  35551. var resSix10265 ResultSix10265 //1101结果
  35552. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  35553. result, _ := json.Marshal(respJSON)
  35554. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  35555. utils.ErrorLog("解析失败:%v", err)
  35556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35557. return
  35558. }
  35559. res.InfRefmsgid = resSix10265.InfRefmsgid
  35560. res.Output = resSix10265.Output
  35561. res.ErrMsg = resSix10265.ErrMsg
  35562. res.Cainfo = resSix10265.Cainfo
  35563. res.WarnMsg = resSix10265.WarnMsg
  35564. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35565. res.Infcode = infocode
  35566. if infocode == 0 {
  35567. c.ServeSuccessJSON(map[string]interface{}{
  35568. "msg": "上传成功",
  35569. })
  35570. return
  35571. } else {
  35572. c.ServeSuccessJSON(map[string]interface{}{
  35573. "failed_code": -10,
  35574. "msg": res.ErrMsg,
  35575. })
  35576. return
  35577. }
  35578. }
  35579. func (c *HisApiController) Post3504() {
  35580. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35581. data := make(map[string]interface{})
  35582. var struct3501s []models.Struct3501
  35583. var struct3501 models.Struct3501
  35584. struct3501.OrgName = miConfig.OrgName
  35585. struct3501.AccessKey = miConfig.AccessKey
  35586. struct3501.RequestUrl = miConfig.Url
  35587. struct3501.SecretKey = miConfig.SecretKey
  35588. struct3501.ManuDate = "2022-08-15"
  35589. struct3501.FixmedinsBchno = ""
  35590. struct3501.ManuLotnum = ""
  35591. struct3501.RxFlag = "0"
  35592. struct3501.ExpyEnd = "2022-08-15"
  35593. struct3501.Invdate = "2022-08-15"
  35594. struct3501.InvCnt = "20.25"
  35595. struct3501.Memo = ""
  35596. struct3501.MedListCodg = "XB01ABD056B002020200517"
  35597. struct3501.FixmedinsHilistId = miConfig.Code
  35598. struct3501.FixmedinsHilistName = miConfig.OrgName
  35599. struct3501s = append(struct3501s, struct3501)
  35600. data["struct_3501s"] = struct3501s
  35601. client := &http.Client{}
  35602. bytesData, _ := json.Marshal(data)
  35603. var req *http.Request
  35604. if miConfig.MdtrtareaAdmvs == "320921" {
  35605. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35606. } else {
  35607. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35608. }
  35609. resp, _ := client.Do(req)
  35610. defer resp.Body.Close()
  35611. body, ioErr := ioutil.ReadAll(resp.Body)
  35612. if ioErr != nil {
  35613. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35615. return
  35616. }
  35617. var respJSON map[string]interface{}
  35618. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35619. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35621. return
  35622. }
  35623. var res ResultSix
  35624. var resSix10265 ResultSix10265 //1101结果
  35625. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  35626. result, _ := json.Marshal(respJSON)
  35627. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  35628. utils.ErrorLog("解析失败:%v", err)
  35629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35630. return
  35631. }
  35632. res.InfRefmsgid = resSix10265.InfRefmsgid
  35633. res.Output = resSix10265.Output
  35634. res.ErrMsg = resSix10265.ErrMsg
  35635. res.Cainfo = resSix10265.Cainfo
  35636. res.WarnMsg = resSix10265.WarnMsg
  35637. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35638. res.Infcode = infocode
  35639. if infocode == 0 {
  35640. c.ServeSuccessJSON(map[string]interface{}{
  35641. "msg": "上传成功",
  35642. })
  35643. return
  35644. } else {
  35645. c.ServeSuccessJSON(map[string]interface{}{
  35646. "failed_code": -10,
  35647. "msg": res.ErrMsg,
  35648. })
  35649. return
  35650. }
  35651. }
  35652. func (c *HisApiController) Post3505() {
  35653. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35654. data := make(map[string]interface{})
  35655. var struct3501s []models.Struct3501
  35656. var struct3501 models.Struct3501
  35657. struct3501.OrgName = miConfig.OrgName
  35658. struct3501.AccessKey = miConfig.AccessKey
  35659. struct3501.RequestUrl = miConfig.Url
  35660. struct3501.SecretKey = miConfig.SecretKey
  35661. struct3501.ManuDate = "2022-08-15"
  35662. struct3501.FixmedinsBchno = ""
  35663. struct3501.ManuLotnum = ""
  35664. struct3501.RxFlag = "0"
  35665. struct3501.ExpyEnd = "2022-08-15"
  35666. struct3501.Invdate = "2022-08-15"
  35667. struct3501.InvCnt = "20.25"
  35668. struct3501.Memo = ""
  35669. struct3501.MedListCodg = "XB01ABD056B002020200517"
  35670. struct3501.FixmedinsHilistId = miConfig.Code
  35671. struct3501.FixmedinsHilistName = miConfig.OrgName
  35672. struct3501s = append(struct3501s, struct3501)
  35673. data["struct_3501s"] = struct3501s
  35674. client := &http.Client{}
  35675. bytesData, _ := json.Marshal(data)
  35676. var req *http.Request
  35677. if miConfig.MdtrtareaAdmvs == "320921" {
  35678. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35679. } else {
  35680. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35681. }
  35682. resp, _ := client.Do(req)
  35683. defer resp.Body.Close()
  35684. body, ioErr := ioutil.ReadAll(resp.Body)
  35685. if ioErr != nil {
  35686. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35688. return
  35689. }
  35690. var respJSON map[string]interface{}
  35691. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35692. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35694. return
  35695. }
  35696. var res ResultSix
  35697. var resSix10265 ResultSix10265 //1101结果
  35698. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  35699. result, _ := json.Marshal(respJSON)
  35700. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  35701. utils.ErrorLog("解析失败:%v", err)
  35702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35703. return
  35704. }
  35705. res.InfRefmsgid = resSix10265.InfRefmsgid
  35706. res.Output = resSix10265.Output
  35707. res.ErrMsg = resSix10265.ErrMsg
  35708. res.Cainfo = resSix10265.Cainfo
  35709. res.WarnMsg = resSix10265.WarnMsg
  35710. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35711. res.Infcode = infocode
  35712. if infocode == 0 {
  35713. c.ServeSuccessJSON(map[string]interface{}{
  35714. "msg": "上传成功",
  35715. })
  35716. return
  35717. } else {
  35718. c.ServeSuccessJSON(map[string]interface{}{
  35719. "failed_code": -10,
  35720. "msg": res.ErrMsg,
  35721. })
  35722. return
  35723. }
  35724. }
  35725. func (c *HisApiController) Post3506() {
  35726. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35727. data := make(map[string]interface{})
  35728. var struct3501s []models.Struct3501
  35729. var struct3501 models.Struct3501
  35730. struct3501.OrgName = miConfig.OrgName
  35731. struct3501.AccessKey = miConfig.AccessKey
  35732. struct3501.RequestUrl = miConfig.Url
  35733. struct3501.SecretKey = miConfig.SecretKey
  35734. struct3501.ManuDate = "2022-08-15"
  35735. struct3501.FixmedinsBchno = ""
  35736. struct3501.ManuLotnum = ""
  35737. struct3501.RxFlag = "0"
  35738. struct3501.ExpyEnd = "2022-08-15"
  35739. struct3501.Invdate = "2022-08-15"
  35740. struct3501.InvCnt = "20.25"
  35741. struct3501.Memo = ""
  35742. struct3501.MedListCodg = "XB01ABD056B002020200517"
  35743. struct3501.FixmedinsHilistId = miConfig.Code
  35744. struct3501.FixmedinsHilistName = miConfig.OrgName
  35745. struct3501s = append(struct3501s, struct3501)
  35746. data["struct_3501s"] = struct3501s
  35747. client := &http.Client{}
  35748. bytesData, _ := json.Marshal(data)
  35749. var req *http.Request
  35750. if miConfig.MdtrtareaAdmvs == "320921" {
  35751. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35752. } else {
  35753. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35754. }
  35755. resp, _ := client.Do(req)
  35756. defer resp.Body.Close()
  35757. body, ioErr := ioutil.ReadAll(resp.Body)
  35758. if ioErr != nil {
  35759. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35761. return
  35762. }
  35763. var respJSON map[string]interface{}
  35764. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35765. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35767. return
  35768. }
  35769. var res ResultSix
  35770. var resSix10265 ResultSix10265 //1101结果
  35771. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  35772. result, _ := json.Marshal(respJSON)
  35773. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  35774. utils.ErrorLog("解析失败:%v", err)
  35775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35776. return
  35777. }
  35778. res.InfRefmsgid = resSix10265.InfRefmsgid
  35779. res.Output = resSix10265.Output
  35780. res.ErrMsg = resSix10265.ErrMsg
  35781. res.Cainfo = resSix10265.Cainfo
  35782. res.WarnMsg = resSix10265.WarnMsg
  35783. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35784. res.Infcode = infocode
  35785. if infocode == 0 {
  35786. c.ServeSuccessJSON(map[string]interface{}{
  35787. "msg": "上传成功",
  35788. })
  35789. return
  35790. } else {
  35791. c.ServeSuccessJSON(map[string]interface{}{
  35792. "failed_code": -10,
  35793. "msg": res.ErrMsg,
  35794. })
  35795. return
  35796. }
  35797. }
  35798. func (c *HisApiController) Post3507() {
  35799. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35800. data := make(map[string]interface{})
  35801. var struct3501s []models.Struct3501
  35802. var struct3501 models.Struct3501
  35803. struct3501.OrgName = miConfig.OrgName
  35804. struct3501.AccessKey = miConfig.AccessKey
  35805. struct3501.RequestUrl = miConfig.Url
  35806. struct3501.SecretKey = miConfig.SecretKey
  35807. struct3501.ManuDate = "2022-08-15"
  35808. struct3501.FixmedinsBchno = ""
  35809. struct3501.ManuLotnum = ""
  35810. struct3501.RxFlag = "0"
  35811. struct3501.ExpyEnd = "2022-08-15"
  35812. struct3501.Invdate = "2022-08-15"
  35813. struct3501.InvCnt = "20.25"
  35814. struct3501.Memo = ""
  35815. struct3501.MedListCodg = "XB01ABD056B002020200517"
  35816. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  35817. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  35818. struct3501s = append(struct3501s, struct3501)
  35819. data["struct_3501s"] = struct3501s
  35820. client := &http.Client{}
  35821. bytesData, _ := json.Marshal(data)
  35822. var req *http.Request
  35823. if miConfig.MdtrtareaAdmvs == "320921" {
  35824. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35825. } else {
  35826. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35827. }
  35828. resp, _ := client.Do(req)
  35829. defer resp.Body.Close()
  35830. body, ioErr := ioutil.ReadAll(resp.Body)
  35831. if ioErr != nil {
  35832. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35834. return
  35835. }
  35836. var respJSON map[string]interface{}
  35837. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35838. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35840. return
  35841. }
  35842. var res ResultSix
  35843. var resSix10265 ResultSix10265 //1101结果
  35844. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  35845. result, _ := json.Marshal(respJSON)
  35846. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  35847. utils.ErrorLog("解析失败:%v", err)
  35848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35849. return
  35850. }
  35851. res.InfRefmsgid = resSix10265.InfRefmsgid
  35852. res.Output = resSix10265.Output
  35853. res.ErrMsg = resSix10265.ErrMsg
  35854. res.Cainfo = resSix10265.Cainfo
  35855. res.WarnMsg = resSix10265.WarnMsg
  35856. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35857. res.Infcode = infocode
  35858. if infocode == 0 {
  35859. c.ServeSuccessJSON(map[string]interface{}{
  35860. "msg": "上传成功",
  35861. })
  35862. return
  35863. } else {
  35864. c.ServeSuccessJSON(map[string]interface{}{
  35865. "failed_code": -10,
  35866. "msg": res.ErrMsg,
  35867. })
  35868. return
  35869. }
  35870. }
  35871. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  35872. // WebSocket服务器地址
  35873. serverURL := "ws://127.0.0.1:8899"
  35874. // 解析WebSocket服务器地址
  35875. u, err := url.Parse(serverURL)
  35876. if err != nil {
  35877. }
  35878. // 建立WebSocket连接
  35879. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  35880. if err != nil {
  35881. }
  35882. defer conn.Close()
  35883. input2 := make(map[string]interface{})
  35884. input := make(map[string]interface{})
  35885. inputData := make(map[string]interface{})
  35886. inputData["orgId"] = code
  35887. inputData["businessType"] = "01101"
  35888. inputData["operatorId"] = operator_id
  35889. inputData["operatorName"] = operator_name
  35890. inputData["officeId"] = "001"
  35891. inputData["officeName"] = "血透室"
  35892. inputData["deviceType"] = ""
  35893. input["data"] = inputData
  35894. input["orgId"] = code
  35895. input["transType"] = "ec.query"
  35896. //if md == ""
  35897. if md[:4] == "4403" {
  35898. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  35899. } else if md[:4] == "4401" {
  35900. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  35901. } else {
  35902. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  35903. }
  35904. input2["indata"] = input
  35905. fmt.Println(input2)
  35906. bytesData, _ := json.Marshal(input2)
  35907. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  35908. if err != nil {
  35909. fmt.Println(err)
  35910. }
  35911. // 接收消息
  35912. _, receivedMessage, err := conn.ReadMessage()
  35913. if err != nil {
  35914. fmt.Println(err)
  35915. }
  35916. return "", string(receivedMessage)
  35917. }
  35918. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  35919. // WebSocket服务器地址
  35920. serverURL := "ws://127.0.0.1:8899"
  35921. // 解析WebSocket服务器地址
  35922. u, err := url.Parse(serverURL)
  35923. if err != nil {
  35924. }
  35925. // 建立WebSocket连接
  35926. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  35927. if err != nil {
  35928. }
  35929. defer conn.Close()
  35930. input2 := make(map[string]interface{})
  35931. input := make(map[string]interface{})
  35932. inputData := make(map[string]interface{})
  35933. inputData["orgId"] = code
  35934. inputData["businessType"] = "01101"
  35935. inputData["operatorId"] = operator_id
  35936. inputData["operatorName"] = operator_name
  35937. inputData["officeId"] = "001"
  35938. inputData["officeName"] = "血透室"
  35939. inputData["deviceType"] = ""
  35940. input["data"] = inputData
  35941. input["orgId"] = code
  35942. input["transType"] = "ec.query"
  35943. //if md == ""
  35944. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  35945. input2["indata"] = input
  35946. fmt.Println(input2)
  35947. bytesData, _ := json.Marshal(input2)
  35948. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  35949. if err != nil {
  35950. fmt.Println(err)
  35951. }
  35952. // 接收消息
  35953. _, receivedMessage, err := conn.ReadMessage()
  35954. if err != nil {
  35955. fmt.Println(err)
  35956. }
  35957. return "", string(receivedMessage)
  35958. }
  35959. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  35960. // WebSocket服务器地址
  35961. serverURL := "ws://127.0.0.1:8899"
  35962. // 解析WebSocket服务器地址
  35963. u, err := url.Parse(serverURL)
  35964. if err != nil {
  35965. }
  35966. // 建立WebSocket连接
  35967. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  35968. if err != nil {
  35969. }
  35970. defer conn.Close()
  35971. input2 := make(map[string]interface{})
  35972. input := make(map[string]interface{})
  35973. inputData := make(map[string]interface{})
  35974. inputData["orgId"] = code
  35975. inputData["businessType"] = "01301"
  35976. inputData["operatorId"] = operator_id
  35977. inputData["operatorName"] = operator_name
  35978. inputData["officeId"] = "001"
  35979. inputData["officeName"] = "血透室"
  35980. inputData["deviceType"] = ""
  35981. input["data"] = inputData
  35982. input["orgId"] = code
  35983. input["transType"] = "ec.query"
  35984. //if md == ""
  35985. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  35986. input2["indata"] = input
  35987. fmt.Println(input2)
  35988. bytesData, _ := json.Marshal(input2)
  35989. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  35990. if err != nil {
  35991. fmt.Println(err)
  35992. }
  35993. // 接收消息
  35994. _, receivedMessage, err := conn.ReadMessage()
  35995. if err != nil {
  35996. fmt.Println(err)
  35997. }
  35998. return "", string(receivedMessage)
  35999. }
  36000. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  36001. // WebSocket服务器地址
  36002. serverURL := "ws://127.0.0.1:8899"
  36003. // 解析WebSocket服务器地址
  36004. u, err := url.Parse(serverURL)
  36005. if err != nil {
  36006. }
  36007. // 建立WebSocket连接
  36008. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  36009. if err != nil {
  36010. }
  36011. defer conn.Close()
  36012. input2 := make(map[string]interface{})
  36013. input := make(map[string]interface{})
  36014. inputData := make(map[string]interface{})
  36015. inputData["orgId"] = code
  36016. inputData["businessType"] = "01103"
  36017. inputData["operatorId"] = operator_id
  36018. inputData["operatorName"] = operator_name
  36019. inputData["officeId"] = "001"
  36020. inputData["officeName"] = "血透室"
  36021. inputData["deviceType"] = ""
  36022. input["data"] = inputData
  36023. input["orgId"] = code
  36024. input["transType"] = "ec.query"
  36025. //if md ==
  36026. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  36027. input2["indata"] = input
  36028. fmt.Println(input2)
  36029. bytesData, _ := json.Marshal(input2)
  36030. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  36031. if err != nil {
  36032. fmt.Println(err)
  36033. }
  36034. // 接收消息
  36035. _, receivedMessage, err := conn.ReadMessage()
  36036. if err != nil {
  36037. fmt.Println(err)
  36038. }
  36039. return "", string(receivedMessage)
  36040. }
  36041. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  36042. // WebSocket服务器地址
  36043. serverURL := "ws://127.0.0.1:8899"
  36044. // 解析WebSocket服务器地址
  36045. u, err := url.Parse(serverURL)
  36046. if err != nil {
  36047. }
  36048. // 建立WebSocket连接
  36049. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  36050. if err != nil {
  36051. }
  36052. defer conn.Close()
  36053. input2 := make(map[string]interface{})
  36054. input := make(map[string]interface{})
  36055. inputData := make(map[string]interface{})
  36056. inputData["orgId"] = code
  36057. inputData["businessType"] = "01101"
  36058. inputData["operatorId"] = operator_id
  36059. inputData["operatorName"] = operator_name
  36060. inputData["officeId"] = "001"
  36061. inputData["officeName"] = "血透室"
  36062. inputData["deviceType"] = ""
  36063. input["data"] = inputData
  36064. input["orgId"] = code
  36065. input["transType"] = "ec.query"
  36066. //if md == ""
  36067. if md[:4] == "4403" {
  36068. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  36069. } else if md[:4] == "4401" {
  36070. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  36071. } else {
  36072. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  36073. }
  36074. input2["indata"] = input
  36075. fmt.Println(input2)
  36076. bytesData, _ := json.Marshal(input2)
  36077. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  36078. if err != nil {
  36079. fmt.Println(err)
  36080. }
  36081. // 接收消息
  36082. _, receivedMessage, err := conn.ReadMessage()
  36083. if err != nil {
  36084. fmt.Println(err)
  36085. }
  36086. return "", string(receivedMessage)
  36087. }
  36088. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  36089. // WebSocket服务器地址
  36090. serverURL := "ws://127.0.0.1:8899"
  36091. // 解析WebSocket服务器地址
  36092. u, err := url.Parse(serverURL)
  36093. if err != nil {
  36094. }
  36095. // 建立WebSocket连接
  36096. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  36097. if err != nil {
  36098. }
  36099. defer conn.Close()
  36100. input2 := make(map[string]interface{})
  36101. input := make(map[string]interface{})
  36102. inputData := make(map[string]interface{})
  36103. inputData["orgId"] = code
  36104. inputData["businessType"] = "01301"
  36105. inputData["operatorId"] = operator_id
  36106. inputData["operatorName"] = operator_name
  36107. inputData["officeId"] = "001"
  36108. inputData["officeName"] = "血透室"
  36109. inputData["deviceType"] = ""
  36110. input["data"] = inputData
  36111. input["orgId"] = code
  36112. input["transType"] = "ec.query"
  36113. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  36114. input2["indata"] = input
  36115. bytesData, _ := json.Marshal(input2)
  36116. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  36117. if err != nil {
  36118. fmt.Println(err)
  36119. }
  36120. // 接收消息
  36121. _, receivedMessage, err := conn.ReadMessage()
  36122. if err != nil {
  36123. fmt.Println(err)
  36124. }
  36125. return "", string(receivedMessage)
  36126. }
  36127. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  36128. newArr = make([]string, 0)
  36129. for i := 0; i < len(arr); i++ {
  36130. repeat := false
  36131. for j := i + 1; j < len(arr); j++ {
  36132. if arr[i] == arr[j] {
  36133. repeat = true
  36134. break
  36135. }
  36136. }
  36137. if !repeat {
  36138. newArr = append(newArr, arr[i])
  36139. }
  36140. }
  36141. return
  36142. }
  36143. func getBirthdateAndAge(idNumber string) (string, int, error) {
  36144. if len(idNumber) != 18 {
  36145. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  36146. }
  36147. // 提取出生日期
  36148. year, err := strconv.Atoi(idNumber[6:10])
  36149. if err != nil {
  36150. return "", 0, err
  36151. }
  36152. month, err := strconv.Atoi(idNumber[10:12])
  36153. if err != nil {
  36154. return "", 0, err
  36155. }
  36156. day, err := strconv.Atoi(idNumber[12:14])
  36157. if err != nil {
  36158. return "", 0, err
  36159. }
  36160. // 格式化生日字符串
  36161. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  36162. birthdateFormatted := birthdate.Format("2006-01-02")
  36163. // 计算年龄
  36164. today := time.Now()
  36165. age := today.Year() - birthdate.Year()
  36166. if today.YearDay() < birthdate.YearDay() {
  36167. age--
  36168. }
  36169. return birthdateFormatted, age, nil
  36170. }
  36171. // 从身份证号码中提取出生年月日
  36172. func getBirthDateFromIDCard(idCard string) (string, error) {
  36173. // 身份证号码长度应为18位
  36174. if len(idCard) != 18 {
  36175. return "", fmt.Errorf("身份证号码长度应为18位")
  36176. }
  36177. // 提取出生日期部分 (YYYYMMDD)
  36178. birthDateStr := idCard[6:14]
  36179. // 解析出生日期
  36180. birthDate, err := time.Parse("20060102", birthDateStr)
  36181. if err != nil {
  36182. return "", fmt.Errorf("解析出生日期失败: %v", err)
  36183. }
  36184. // 格式化出生日期为 YYYY-MM-DD
  36185. formattedDate := birthDate.Format("2006-01-02")
  36186. return formattedDate, nil
  36187. }