his_api_controller.go 1.6MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. //"encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. "encoding/json"
  8. "fmt"
  9. "gdyb/controllers"
  10. "gdyb/enums"
  11. "gdyb/models"
  12. "gdyb/service"
  13. "gdyb/utils"
  14. "github.com/astaxie/beego"
  15. "github.com/axgle/mahonia"
  16. "github.com/go-ole/go-ole/oleutil"
  17. "github.com/gorilla/websocket"
  18. "github.com/jinzhu/gorm"
  19. "github.com/shopspring/decimal"
  20. "io"
  21. "io/ioutil"
  22. "math"
  23. "math/rand"
  24. "net/http"
  25. "net/url"
  26. "os"
  27. "path/filepath"
  28. "regexp"
  29. "strconv"
  30. "strings"
  31. "syscall"
  32. "time"
  33. "unsafe"
  34. "github.com/go-ole/go-ole"
  35. )
  36. type HisApiController struct {
  37. controllers.BaseAuthAPIController
  38. }
  39. func HisManagerApiRegistRouters() {
  40. //挂号
  41. beego.Router("/test/net", &HisApiController{}, "get:TestNet")
  42. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  43. //上传就诊信息-上传明细-结算
  44. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  45. //查询
  46. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  47. //对总账
  48. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  49. //对明细
  50. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  51. //退费,退明细
  52. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  53. //退号
  54. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  55. //退明细
  56. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  57. //上传就诊信息-上传明细-预结算
  58. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  59. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  60. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  61. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  62. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  63. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  64. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  65. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  66. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  67. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  68. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  69. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  70. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  71. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  72. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  73. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  74. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  75. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  76. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  77. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  78. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  79. beego.Router("/api/check", &HisApiController{}, "get:Check")
  80. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  81. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  82. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  83. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  84. beego.Router("/api/3204a", &HisApiController{}, "get:Post3204a")
  85. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  86. beego.Router("/api/8404", &HisApiController{}, "get:Post8404")
  87. beego.Router("/api/3204", &HisApiController{}, "get:Post3204")
  88. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  89. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  90. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  91. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  92. //beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  93. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  94. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  95. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  96. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  97. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  98. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  99. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  100. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  101. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  102. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  103. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  104. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  105. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  106. //beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  107. //beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  108. //beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  109. //beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  110. //beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  111. //beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  112. //beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  113. //beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  114. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  115. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  116. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  117. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  118. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  119. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  120. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  121. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  122. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  123. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  124. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  125. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  126. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  127. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  128. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  129. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  130. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  131. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  132. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  133. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  134. beego.Router("/api/3103", &HisApiController{}, "get:Get3103")
  135. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  136. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  137. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  138. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  139. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  140. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  141. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  142. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  143. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  144. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  145. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  146. //beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  147. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  148. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  149. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  150. //库盘和变更
  151. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  152. //删除库盘和变更
  153. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  154. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  155. //药品变更
  156. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  157. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  158. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  159. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  160. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  161. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  162. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  163. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  164. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  165. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  166. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  167. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  168. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  169. beego.Router("/api/changedrug/five", &HisApiController{}, "get:ChangeDrugFive")
  170. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  171. beego.Router("/api/delete_xs_bg_three", &HisApiController{}, "get:DeleteXSandBGThree")
  172. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  173. }
  174. func (c *HisApiController) Get3201() {
  175. adminUser := c.GetAdminUserInfo()
  176. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  177. result, _ := service.AHyb3201(932, 0, 571536.19, 543283.9, "2024-10-01", "2024-10-31", "340699", "11", "390", miConfig.OrgName, "王幸子", miConfig.Code, "340399", "340399", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey, miConfig.Cainfo)
  178. var response Response
  179. if err := json.Unmarshal([]byte(result), &response); err != nil {
  180. fmt.Println("Error decoding JSON:", err)
  181. return
  182. }
  183. }
  184. func (c *HisApiController) TestNet() {
  185. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  186. //return
  187. c.ServeSuccessJSON(map[string]interface{}{
  188. "msg": "成功",
  189. })
  190. }
  191. func (c *HisApiController) Get3508() {
  192. admin_user_id, _ := c.GetInt64("admin_user_id")
  193. drug_id, _ := c.GetInt64("id")
  194. start_time := c.GetString("start_time")
  195. end_time := c.GetString("end_time")
  196. adminUser := c.GetAdminUserInfo()
  197. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  198. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  199. drug, _ := service.GetDrugByID(drug_id)
  200. var struct3508 models.Struct3508
  201. struct3508.OrgName = miConfig.OrgName
  202. struct3508.FixmedinsCode = miConfig.Code
  203. struct3508.AccessKey = miConfig.AccessKey
  204. struct3508.Opter = curRoles.UserName
  205. struct3508.RequestUrl = miConfig.Url
  206. struct3508.Url = miConfig.Url
  207. struct3508.AppId = miConfig.Cainfo
  208. struct3508.AppSecret = miConfig.AppSecret
  209. struct3508.Enckey = miConfig.EncKey
  210. struct3508.SignKey = miConfig.SignKey
  211. struct3508.SecretKey = miConfig.SecretKey
  212. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  213. struct3508.Begndate = start_time
  214. struct3508.Enddate = end_time
  215. result1, result2, _ := service.FJyb3508(struct3508)
  216. saveLog(result1, result2, "3508", "3508")
  217. var res models.Result3508
  218. var respJSON2 map[string]interface{}
  219. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  222. return
  223. }
  224. userJSONBytes2, _ := json.Marshal(respJSON2)
  225. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  226. utils.ErrorLog("解析失败:%v", err)
  227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  228. return
  229. }
  230. if res.Infcode == -1 {
  231. c.ServeSuccessJSON(map[string]interface{}{
  232. "failed_code": -10,
  233. "msg": res.ErrMsg,
  234. })
  235. } else {
  236. c.ServeSuccessJSON(map[string]interface{}{
  237. "info": res.Output,
  238. })
  239. }
  240. }
  241. func (c *HisApiController) Get3509() {
  242. admin_user_id, _ := c.GetInt64("admin_user_id")
  243. drug_id, _ := c.GetInt64("id")
  244. start_time := c.GetString("start_time")
  245. end_time := c.GetString("end_time")
  246. adminUser := c.GetAdminUserInfo()
  247. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  248. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  249. drug, _ := service.GetDrugByID(drug_id)
  250. var struct3508 models.Struct3509
  251. struct3508.OrgName = miConfig.OrgName
  252. struct3508.FixmedinsCode = miConfig.Code
  253. struct3508.AccessKey = miConfig.AccessKey
  254. struct3508.Opter = curRoles.UserName
  255. struct3508.RequestUrl = miConfig.Url
  256. struct3508.Url = miConfig.Url
  257. struct3508.AppId = miConfig.Cainfo
  258. struct3508.AppSecret = miConfig.AppSecret
  259. struct3508.Enckey = miConfig.EncKey
  260. struct3508.SignKey = miConfig.SignKey
  261. struct3508.SecretKey = miConfig.SecretKey
  262. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  263. struct3508.Begndate = start_time
  264. struct3508.Enddate = end_time
  265. result1, result2, _ := service.FJyb3509(struct3508)
  266. saveLog(result1, result2, "3509", "3509")
  267. var res models.Result3509
  268. var respJSON2 map[string]interface{}
  269. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  270. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  272. return
  273. }
  274. userJSONBytes2, _ := json.Marshal(respJSON2)
  275. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  276. utils.ErrorLog("解析失败:%v", err)
  277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  278. return
  279. }
  280. if res.Infcode == -1 {
  281. c.ServeSuccessJSON(map[string]interface{}{
  282. "failed_code": -10,
  283. "msg": res.ErrMsg,
  284. })
  285. } else {
  286. c.ServeSuccessJSON(map[string]interface{}{
  287. "info": res.Output,
  288. })
  289. }
  290. }
  291. func (c *HisApiController) Get3510() {
  292. admin_user_id, _ := c.GetInt64("admin_user_id")
  293. drug_id, _ := c.GetInt64("id")
  294. start_time := c.GetString("start_time")
  295. end_time := c.GetString("end_time")
  296. adminUser := c.GetAdminUserInfo()
  297. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  298. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  299. drug, _ := service.GetDrugByID(drug_id)
  300. var struct3508 models.Struct3510
  301. struct3508.FixmedinsCode = miConfig.Code
  302. struct3508.OrgName = miConfig.OrgName
  303. struct3508.AccessKey = miConfig.AccessKey
  304. struct3508.Opter = curRoles.UserName
  305. struct3508.RequestUrl = miConfig.Url
  306. struct3508.Url = miConfig.Url
  307. struct3508.AppId = miConfig.Cainfo
  308. struct3508.AppSecret = miConfig.AppSecret
  309. struct3508.Enckey = miConfig.EncKey
  310. struct3508.SignKey = miConfig.SignKey
  311. struct3508.SecretKey = miConfig.SecretKey
  312. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  313. struct3508.Begndate = start_time
  314. struct3508.Enddate = end_time
  315. result1, result2, _ := service.FJyb3510(struct3508)
  316. saveLog(result1, result2, "3510", "3510")
  317. var res models.Result3510
  318. var respJSON2 map[string]interface{}
  319. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  322. return
  323. }
  324. userJSONBytes2, _ := json.Marshal(respJSON2)
  325. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  326. utils.ErrorLog("解析失败:%v", err)
  327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  328. return
  329. }
  330. if res.Infcode == -1 {
  331. c.ServeSuccessJSON(map[string]interface{}{
  332. "failed_code": -10,
  333. "msg": res.ErrMsg,
  334. })
  335. } else {
  336. c.ServeSuccessJSON(map[string]interface{}{
  337. "info": res.Output,
  338. })
  339. }
  340. }
  341. func (c *HisApiController) Get3511() {
  342. admin_user_id, _ := c.GetInt64("admin_user_id")
  343. drug_id, _ := c.GetInt64("id")
  344. start_time := c.GetString("start_time")
  345. end_time := c.GetString("end_time")
  346. adminUser := c.GetAdminUserInfo()
  347. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  348. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  349. drug, _ := service.GetDrugByID(drug_id)
  350. var struct3508 models.Struct3511
  351. struct3508.FixmedinsCode = miConfig.Code
  352. struct3508.OrgName = miConfig.OrgName
  353. struct3508.AccessKey = miConfig.AccessKey
  354. struct3508.Opter = curRoles.UserName
  355. struct3508.RequestUrl = miConfig.Url
  356. struct3508.Url = miConfig.Url
  357. struct3508.AppId = miConfig.Cainfo
  358. struct3508.AppSecret = miConfig.AppSecret
  359. struct3508.Enckey = miConfig.EncKey
  360. struct3508.SignKey = miConfig.SignKey
  361. struct3508.SecretKey = miConfig.SecretKey
  362. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  363. struct3508.Begndate = start_time
  364. struct3508.Enddate = end_time
  365. result1, result2, _ := service.FJyb3511(struct3508)
  366. saveLog(result1, result2, "3511", "3511")
  367. var res models.Result3511
  368. var respJSON2 map[string]interface{}
  369. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  370. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  372. return
  373. }
  374. userJSONBytes2, _ := json.Marshal(respJSON2)
  375. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  376. utils.ErrorLog("解析失败:%v", err)
  377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  378. return
  379. }
  380. if res.Infcode == -1 {
  381. c.ServeSuccessJSON(map[string]interface{}{
  382. "failed_code": -10,
  383. "msg": res.ErrMsg,
  384. })
  385. } else {
  386. c.ServeSuccessJSON(map[string]interface{}{
  387. "info": res.Output,
  388. })
  389. }
  390. }
  391. func (c *HisApiController) Get3512() {
  392. admin_user_id, _ := c.GetInt64("admin_user_id")
  393. drug_id, _ := c.GetInt64("id")
  394. start_time := c.GetString("start_time")
  395. end_time := c.GetString("end_time")
  396. adminUser := c.GetAdminUserInfo()
  397. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  398. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  399. drug, _ := service.GetDrugByID(drug_id)
  400. var struct3508 models.Struct3512
  401. struct3508.FixmedinsCode = miConfig.Code
  402. struct3508.OrgName = miConfig.OrgName
  403. struct3508.AccessKey = miConfig.AccessKey
  404. struct3508.Opter = curRoles.UserName
  405. struct3508.RequestUrl = miConfig.Url
  406. struct3508.Url = miConfig.Url
  407. struct3508.AppId = miConfig.Cainfo
  408. struct3508.AppSecret = miConfig.AppSecret
  409. struct3508.Enckey = miConfig.EncKey
  410. struct3508.SignKey = miConfig.SignKey
  411. struct3508.SecretKey = miConfig.SecretKey
  412. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  413. struct3508.Begndate = start_time
  414. struct3508.Enddate = end_time
  415. result1, result2, _ := service.FJyb3512(struct3508)
  416. saveLog(result1, result2, "3512", "3512")
  417. var res models.Result3512
  418. var respJSON2 map[string]interface{}
  419. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  420. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  422. return
  423. }
  424. userJSONBytes2, _ := json.Marshal(respJSON2)
  425. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  426. utils.ErrorLog("解析失败:%v", err)
  427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  428. return
  429. }
  430. if res.Infcode == -1 {
  431. c.ServeSuccessJSON(map[string]interface{}{
  432. "failed_code": -10,
  433. "msg": res.ErrMsg,
  434. })
  435. } else {
  436. c.ServeSuccessJSON(map[string]interface{}{
  437. "info": res.Output,
  438. })
  439. }
  440. }
  441. func (c *HisApiController) Get3513() {
  442. admin_user_id, _ := c.GetInt64("admin_user_id")
  443. drug_id, _ := c.GetInt64("id")
  444. start_time := c.GetString("start_time")
  445. end_time := c.GetString("end_time")
  446. adminUser := c.GetAdminUserInfo()
  447. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  448. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  449. drug, _ := service.GetDrugByID(drug_id)
  450. var struct3508 models.Struct3513
  451. struct3508.FixmedinsCode = miConfig.Code
  452. struct3508.OrgName = miConfig.OrgName
  453. struct3508.AccessKey = miConfig.AccessKey
  454. struct3508.Opter = curRoles.UserName
  455. struct3508.RequestUrl = miConfig.Url
  456. struct3508.Url = miConfig.Url
  457. struct3508.AppId = miConfig.Cainfo
  458. struct3508.AppSecret = miConfig.AppSecret
  459. struct3508.Enckey = miConfig.EncKey
  460. struct3508.SignKey = miConfig.SignKey
  461. struct3508.SecretKey = miConfig.SecretKey
  462. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  463. struct3508.Begndate = start_time
  464. struct3508.Enddate = end_time
  465. result1, result2, _ := service.FJyb3513(struct3508)
  466. saveLog(result1, result2, "3513", "3513")
  467. var res models.Result3513
  468. var respJSON2 map[string]interface{}
  469. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  470. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  472. return
  473. }
  474. userJSONBytes2, _ := json.Marshal(respJSON2)
  475. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  476. utils.ErrorLog("解析失败:%v", err)
  477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  478. return
  479. }
  480. if res.Infcode == -1 {
  481. c.ServeSuccessJSON(map[string]interface{}{
  482. "failed_code": -10,
  483. "msg": res.ErrMsg,
  484. })
  485. } else {
  486. c.ServeSuccessJSON(map[string]interface{}{
  487. "info": res.Output,
  488. })
  489. }
  490. }
  491. func (c *HisApiController) Get35081() {
  492. admin_user_id, _ := c.GetInt64("admin_user_id")
  493. drug_id, _ := c.GetInt64("id")
  494. //start_time := c.GetString("start_time")
  495. //end_time := c.GetString("end_time")
  496. page, _ := c.GetInt("page")
  497. adminUser := c.GetAdminUserInfo()
  498. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  499. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  500. drug, _ := service.GetDrugByID(drug_id)
  501. var struct3508 models.Struct35081
  502. struct3508.FixmedinsCode = miConfig.Code
  503. struct3508.OrgName = miConfig.OrgName
  504. struct3508.AccessKey = miConfig.AccessKey
  505. struct3508.Opter = curRoles.UserName
  506. struct3508.RequestUrl = miConfig.Url
  507. struct3508.Url = miConfig.Url
  508. struct3508.AppId = miConfig.Cainfo
  509. struct3508.AppSecret = miConfig.AppSecret
  510. struct3508.Enckey = miConfig.EncKey
  511. struct3508.SignKey = miConfig.SignKey
  512. struct3508.SecretKey = miConfig.SecretKey
  513. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  514. struct3508.PageNum = page
  515. struct3508.PageSize = 10
  516. result1, result2, _ := service.FJyb35081(struct3508)
  517. saveLog(result1, result2, "35081", "35081")
  518. var res models.Result35081
  519. var respJSON2 map[string]interface{}
  520. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  521. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  523. return
  524. }
  525. userJSONBytes2, _ := json.Marshal(respJSON2)
  526. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  527. utils.ErrorLog("解析失败:%v", err)
  528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  529. return
  530. }
  531. if res.Infcode == -1 {
  532. c.ServeSuccessJSON(map[string]interface{}{
  533. "failed_code": -10,
  534. "msg": res.ErrMsg,
  535. })
  536. } else {
  537. c.ServeSuccessJSON(map[string]interface{}{
  538. "info": res.Output,
  539. })
  540. }
  541. }
  542. func (c *HisApiController) Get35082() {
  543. admin_user_id, _ := c.GetInt64("admin_user_id")
  544. drug_id, _ := c.GetInt64("id")
  545. //start_time := c.GetString("start_time")
  546. //end_time := c.GetString("end_time")
  547. page, _ := c.GetInt("page")
  548. adminUser := c.GetAdminUserInfo()
  549. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  550. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  551. drug, _ := service.GetDrugByID(drug_id)
  552. var struct3508 models.Struct35082
  553. struct3508.FixmedinsCode = miConfig.Code
  554. struct3508.OrgName = miConfig.OrgName
  555. struct3508.AccessKey = miConfig.AccessKey
  556. struct3508.Opter = curRoles.UserName
  557. struct3508.RequestUrl = miConfig.Url
  558. struct3508.Url = miConfig.Url
  559. struct3508.AppId = miConfig.Cainfo
  560. struct3508.AppSecret = miConfig.AppSecret
  561. struct3508.Enckey = miConfig.EncKey
  562. struct3508.SignKey = miConfig.SignKey
  563. struct3508.SecretKey = miConfig.SecretKey
  564. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  565. struct3508.PageNum = page
  566. struct3508.PageSize = 10
  567. result1, result2, _ := service.FJyb35082(struct3508)
  568. saveLog(result1, result2, "35082", "35082")
  569. var res models.Result35082
  570. var respJSON2 map[string]interface{}
  571. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  572. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  574. return
  575. }
  576. userJSONBytes2, _ := json.Marshal(respJSON2)
  577. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  578. utils.ErrorLog("解析失败:%v", err)
  579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  580. return
  581. }
  582. if res.Infcode == -1 {
  583. c.ServeSuccessJSON(map[string]interface{}{
  584. "failed_code": -10,
  585. "msg": res.ErrMsg,
  586. })
  587. } else {
  588. c.ServeSuccessJSON(map[string]interface{}{
  589. "info": res.Output,
  590. })
  591. }
  592. }
  593. func (c *HisApiController) FJ3501AND3502() {
  594. ids := c.GetString("ids")
  595. admin_user_id, _ := c.GetInt64("admin_user_id")
  596. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  597. id_arr := strings.Split(ids, ",")
  598. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  599. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  600. //库盘
  601. var errs []string
  602. for _, drug := range drugs {
  603. if drug.IsPc == 0 {
  604. var res2 ResultSix
  605. var res3 ResultSix
  606. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  607. var struct3501 models.Struct3501
  608. struct3501.Code = miConfig.Code
  609. struct3501.OrgName = miConfig.OrgName
  610. struct3501.AccessKey = miConfig.AccessKey
  611. struct3501.Opter = roles.UserName
  612. struct3501.RequestUrl = miConfig.Url
  613. struct3501.Url = miConfig.Url
  614. struct3501.AppId = miConfig.Cainfo
  615. struct3501.AppSecret = miConfig.AppSecret
  616. struct3501.Enckey = miConfig.EncKey
  617. struct3501.SignKey = miConfig.SignKey
  618. struct3501.SecretKey = miConfig.SecretKey
  619. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  620. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  621. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  622. struct3501.RxFlag = "1"
  623. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  624. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  625. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  626. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  627. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  628. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  629. struct3501.FixmedinsBchno = number
  630. struct3501.DrugTracCodg = drug.DrugCode
  631. memo := make(map[string]interface{})
  632. memo["pric"] = drug.Price
  633. bytesData, _ := json.Marshal(memo)
  634. struct3501.Memo = string(bytesData)
  635. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  636. result1, result2, _ := service.FJyb3501(struct3501)
  637. saveLog(result1, result2, "3501", "3501")
  638. //saveLog(result, requestLog, "2201", "挂号")
  639. var respJSON2 map[string]interface{}
  640. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  641. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  643. return
  644. }
  645. userJSONBytes2, _ := json.Marshal(respJSON2)
  646. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  647. utils.ErrorLog("解析失败:%v", err)
  648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  649. return
  650. }
  651. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  652. data := make(map[string]interface{})
  653. data["struct_3501s"] = struct3501
  654. client := &http.Client{}
  655. bytesData, _ := json.Marshal(data)
  656. var req *http.Request
  657. if miConfig.MdtrtareaAdmvs == "320921" {
  658. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  659. } else {
  660. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  661. }
  662. resp, _ := client.Do(req)
  663. defer resp.Body.Close()
  664. body, ioErr := ioutil.ReadAll(resp.Body)
  665. if ioErr != nil {
  666. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  667. }
  668. var respJSON map[string]interface{}
  669. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  670. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  672. return
  673. }
  674. var resSix10265 ResultSix10265 //1101结果
  675. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  676. result, _ := json.Marshal(respJSON)
  677. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  678. utils.ErrorLog("解析失败:%v", err)
  679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  680. return
  681. }
  682. res2.InfRefmsgid = resSix10265.InfRefmsgid
  683. res2.Output = resSix10265.Output
  684. res2.ErrMsg = resSix10265.ErrMsg
  685. res2.Cainfo = resSix10265.Cainfo
  686. res2.WarnMsg = resSix10265.WarnMsg
  687. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  688. res2.Infcode = infocode
  689. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  690. data := make(map[string]interface{})
  691. data["struct_3501s"] = struct3501
  692. client := &http.Client{}
  693. bytesData, _ := json.Marshal(data)
  694. var req *http.Request
  695. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  696. resp, _ := client.Do(req)
  697. defer resp.Body.Close()
  698. body, ioErr := ioutil.ReadAll(resp.Body)
  699. if ioErr != nil {
  700. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  701. }
  702. var respJSON map[string]interface{}
  703. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  706. return
  707. }
  708. var resSix10265 ResultSix10265 //1101结果
  709. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  710. result, _ := json.Marshal(respJSON)
  711. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  712. utils.ErrorLog("解析失败:%v", err)
  713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  714. return
  715. }
  716. res2.InfRefmsgid = resSix10265.InfRefmsgid
  717. res2.Output = resSix10265.Output
  718. res2.ErrMsg = resSix10265.ErrMsg
  719. res2.Cainfo = resSix10265.Cainfo
  720. res2.WarnMsg = resSix10265.WarnMsg
  721. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  722. res2.Infcode = infocode
  723. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  724. data := make(map[string]interface{})
  725. data["struct_3501s"] = struct3501
  726. client := &http.Client{}
  727. bytesData, _ := json.Marshal(data)
  728. var req *http.Request
  729. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  730. resp, _ := client.Do(req)
  731. defer resp.Body.Close()
  732. body, ioErr := ioutil.ReadAll(resp.Body)
  733. if ioErr != nil {
  734. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  735. }
  736. var respJSON map[string]interface{}
  737. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  740. return
  741. }
  742. var resSix10265 ResultSix10265 //1101结果
  743. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  744. result, _ := json.Marshal(respJSON)
  745. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  746. utils.ErrorLog("解析失败:%v", err)
  747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  748. return
  749. }
  750. res2.InfRefmsgid = resSix10265.InfRefmsgid
  751. res2.Output = resSix10265.Output
  752. res2.ErrMsg = resSix10265.ErrMsg
  753. res2.Cainfo = resSix10265.Cainfo
  754. res2.WarnMsg = resSix10265.WarnMsg
  755. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  756. res2.Infcode = infocode
  757. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  758. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  759. saveLog(result1, result2, "3501", "3501")
  760. //saveLog(result, requestLog, "2201", "挂号")
  761. var respJSON2 map[string]interface{}
  762. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  765. return
  766. }
  767. userJSONBytes2, _ := json.Marshal(respJSON2)
  768. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  769. utils.ErrorLog("解析失败:%v", err)
  770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  771. return
  772. }
  773. }
  774. if res2.Infcode != -1 {
  775. drug.IsPc = 1
  776. drug.Bchno = number
  777. drug.PcDate = time.Now().Unix()
  778. err := service.SaveW(drug)
  779. if err == nil {
  780. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  781. var struct3502 models.Struct3502
  782. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  783. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  784. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  785. struct3502.FixmedinsCode = miConfig.Code
  786. struct3502.Code = miConfig.Code
  787. struct3502.RxFlag = "0"
  788. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  789. struct3502.OrgName = miConfig.OrgName
  790. struct3502.Opter = roles.UserName
  791. struct3502.AccessKey = miConfig.AccessKey
  792. struct3502.RequestUrl = miConfig.Url
  793. struct3502.SecretKey = miConfig.SecretKey
  794. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  795. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  796. struct3502.Url = miConfig.Url
  797. struct3502.AppId = miConfig.Cainfo
  798. struct3502.AppSecret = miConfig.AppSecret
  799. struct3502.Enckey = miConfig.EncKey
  800. struct3502.SignKey = miConfig.SignKey
  801. struct3502.SecretKey = miConfig.SecretKey
  802. struct3502.DrugTracCodg = drug.DrugCode
  803. struct3502.Memo = ""
  804. struct3502.InvChgType = "108"
  805. struct3502.FixmedinsBchno = bg_number
  806. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  807. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  808. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  809. result11, result22, _ := service.FJyb3502(struct3502)
  810. saveLog(result11, result22, "3502", "3502")
  811. var respJSON3 map[string]interface{}
  812. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  815. return
  816. }
  817. userJSONBytes3, _ := json.Marshal(respJSON3)
  818. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  819. utils.ErrorLog("解析失败:%v", err)
  820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  821. return
  822. }
  823. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  824. data := make(map[string]interface{})
  825. data["struct_3502s"] = struct3502
  826. client := &http.Client{}
  827. bytesData, _ := json.Marshal(data)
  828. var req *http.Request
  829. if miConfig.MdtrtareaAdmvs == "320921" {
  830. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  831. } else {
  832. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  833. }
  834. resp, _ := client.Do(req)
  835. defer resp.Body.Close()
  836. body, ioErr := ioutil.ReadAll(resp.Body)
  837. if ioErr != nil {
  838. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  839. }
  840. var respJSON map[string]interface{}
  841. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  842. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  844. return
  845. }
  846. var resSix10265 ResultSix10265 //1101结果
  847. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  848. result, _ := json.Marshal(respJSON)
  849. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  850. utils.ErrorLog("解析失败:%v", err)
  851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  852. return
  853. }
  854. res3.InfRefmsgid = resSix10265.InfRefmsgid
  855. res3.Output = resSix10265.Output
  856. res3.ErrMsg = resSix10265.ErrMsg
  857. res3.Cainfo = resSix10265.Cainfo
  858. res3.WarnMsg = resSix10265.WarnMsg
  859. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  860. res3.Infcode = infocode
  861. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  862. data := make(map[string]interface{})
  863. data["struct_3502s"] = struct3502
  864. client := &http.Client{}
  865. bytesData, _ := json.Marshal(data)
  866. var req *http.Request
  867. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  868. resp, _ := client.Do(req)
  869. defer resp.Body.Close()
  870. body, ioErr := ioutil.ReadAll(resp.Body)
  871. if ioErr != nil {
  872. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  873. }
  874. var respJSON map[string]interface{}
  875. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  876. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  878. return
  879. }
  880. var resSix10265 ResultSix10265 //1101结果
  881. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  882. result, _ := json.Marshal(respJSON)
  883. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  884. utils.ErrorLog("解析失败:%v", err)
  885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  886. return
  887. }
  888. res3.InfRefmsgid = resSix10265.InfRefmsgid
  889. res3.Output = resSix10265.Output
  890. res3.ErrMsg = resSix10265.ErrMsg
  891. res3.Cainfo = resSix10265.Cainfo
  892. res3.WarnMsg = resSix10265.WarnMsg
  893. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  894. res3.Infcode = infocode
  895. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  896. data := make(map[string]interface{})
  897. data["struct_3501s"] = struct3501
  898. client := &http.Client{}
  899. bytesData, _ := json.Marshal(data)
  900. var req *http.Request
  901. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  902. resp, _ := client.Do(req)
  903. defer resp.Body.Close()
  904. body, ioErr := ioutil.ReadAll(resp.Body)
  905. if ioErr != nil {
  906. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  907. }
  908. var respJSON map[string]interface{}
  909. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  910. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  912. return
  913. }
  914. var resSix10265 ResultSix10265 //1101结果
  915. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  916. result, _ := json.Marshal(respJSON)
  917. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  918. utils.ErrorLog("解析失败:%v", err)
  919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  920. return
  921. }
  922. res2.InfRefmsgid = resSix10265.InfRefmsgid
  923. res2.Output = resSix10265.Output
  924. res2.ErrMsg = resSix10265.ErrMsg
  925. res2.Cainfo = resSix10265.Cainfo
  926. res2.WarnMsg = resSix10265.WarnMsg
  927. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  928. res2.Infcode = infocode
  929. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  930. result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  931. saveLog(result11, result22, "3502", "3502")
  932. var respJSON3 map[string]interface{}
  933. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  934. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  936. return
  937. }
  938. userJSONBytes3, _ := json.Marshal(respJSON3)
  939. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  940. utils.ErrorLog("解析失败:%v", err)
  941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  942. return
  943. }
  944. }
  945. if res3.Infcode == -1 {
  946. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  947. c.ServeSuccessJSON(map[string]interface{}{
  948. "failed_code": -10,
  949. "msg": res3.ErrMsg,
  950. })
  951. } else {
  952. drug.IsBg = 1
  953. drug.BgBchno = bg_number
  954. service.SaveW(drug)
  955. }
  956. }
  957. } else {
  958. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  959. }
  960. }
  961. //变更
  962. }
  963. if len(errs) == 0 {
  964. c.ServeSuccessJSON(map[string]interface{}{
  965. "msg": "盘存变更成功",
  966. })
  967. } else {
  968. c.ServeSuccessJSON(map[string]interface{}{
  969. "failed_code": -10,
  970. "msg": errs,
  971. })
  972. }
  973. }
  974. func (c *HisApiController) DeletePCandBG() {
  975. ids := c.GetString("ids")
  976. id_arr := strings.Split(ids, ",")
  977. admin_user_id, _ := c.GetInt64("admin_user_id")
  978. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  979. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  980. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  981. var err []string
  982. for _, item := range drugs {
  983. if item.IsPc == 1 && item.IsBg == 1 {
  984. var res FJ3507Result
  985. var res2 FJ3507Result
  986. var struct3507 models.Struct3507
  987. struct3507.FixmedinsBchno = item.Bchno
  988. struct3507.InvDataType = "1"
  989. struct3507.Opter = roles.UserName
  990. struct3507.OrgName = miConfig.OrgName
  991. struct3507.AccessKey = miConfig.AccessKey
  992. struct3507.RequestUrl = miConfig.Url
  993. struct3507.FixmedinsCode = miConfig.Code
  994. struct3507.Code = miConfig.Code
  995. struct3507.SecretKey = miConfig.SecretKey
  996. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  997. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  998. struct3507.Url = miConfig.Url
  999. struct3507.AppId = miConfig.Cainfo
  1000. struct3507.AppSecret = miConfig.AppSecret
  1001. struct3507.Enckey = miConfig.EncKey
  1002. struct3507.SignKey = miConfig.SignKey
  1003. struct3507.SecretKey = miConfig.SecretKey
  1004. if miConfig.MdtrtareaAdmvs == "350500" {
  1005. result, result1, _ := service.FJyb3507(struct3507)
  1006. saveLog(result, result1, "3507", "3507")
  1007. var respJSON2 map[string]interface{}
  1008. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1009. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1011. return
  1012. }
  1013. userJSONBytes2, _ := json.Marshal(respJSON2)
  1014. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1015. utils.ErrorLog("解析失败:%v", err)
  1016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1017. return
  1018. }
  1019. } else {
  1020. data := make(map[string]interface{})
  1021. data["struct_3507s"] = struct3507
  1022. client := &http.Client{}
  1023. bytesData, _ := json.Marshal(data)
  1024. var req *http.Request
  1025. if miConfig.MdtrtareaAdmvs == "320921" {
  1026. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1027. } else {
  1028. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1029. }
  1030. resp, _ := client.Do(req)
  1031. defer resp.Body.Close()
  1032. body, ioErr := ioutil.ReadAll(resp.Body)
  1033. if ioErr != nil {
  1034. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1035. }
  1036. var respJSON map[string]interface{}
  1037. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1038. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1040. return
  1041. }
  1042. var resSix10265 ResultSix10265 //1101结果
  1043. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1044. result, _ := json.Marshal(respJSON)
  1045. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1046. utils.ErrorLog("解析失败:%v", err)
  1047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1048. return
  1049. }
  1050. res.InfRefmsgid = resSix10265.InfRefmsgid
  1051. //res.Output = resSix10265.Output
  1052. res.ErrMsg = resSix10265.ErrMsg
  1053. res.Cainfo = resSix10265.Cainfo
  1054. res.WarnMsg = resSix10265.WarnMsg
  1055. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1056. res.Infcode = infocode
  1057. }
  1058. if res.Infcode == 0 {
  1059. item.IsPc = 0
  1060. err2 := service.SaveW(item)
  1061. if err2 == nil {
  1062. var struct3507_2 models.Struct3507
  1063. struct3507_2.OrgName = miConfig.OrgName
  1064. struct3507_2.AccessKey = miConfig.AccessKey
  1065. struct3507_2.RequestUrl = miConfig.Url
  1066. struct3507_2.Opter = roles.UserName
  1067. struct3507_2.FixmedinsCode = miConfig.Code
  1068. struct3507_2.Code = miConfig.Code
  1069. struct3507_2.SecretKey = miConfig.SecretKey
  1070. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1071. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1072. struct3507_2.Url = miConfig.Url
  1073. struct3507_2.AppId = miConfig.Cainfo
  1074. struct3507_2.AppSecret = miConfig.AppSecret
  1075. struct3507_2.Enckey = miConfig.EncKey
  1076. struct3507_2.SignKey = miConfig.SignKey
  1077. struct3507_2.SecretKey = miConfig.SecretKey
  1078. struct3507_2.FixmedinsBchno = item.BgBchno
  1079. struct3507_2.InvDataType = "2"
  1080. if miConfig.MdtrtareaAdmvs == "350500" {
  1081. result11, result22, _ := service.FJyb3507(struct3507_2)
  1082. saveLog(result11, result22, "3507", "3507")
  1083. var respJSON3 map[string]interface{}
  1084. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1085. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1087. return
  1088. }
  1089. userJSONBytes3, _ := json.Marshal(respJSON3)
  1090. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1091. utils.ErrorLog("解析失败:%v", err)
  1092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1093. return
  1094. }
  1095. } else {
  1096. data := make(map[string]interface{})
  1097. data["struct_3507s"] = struct3507_2
  1098. client := &http.Client{}
  1099. bytesData, _ := json.Marshal(data)
  1100. var req *http.Request
  1101. if miConfig.MdtrtareaAdmvs == "320921" {
  1102. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1103. } else {
  1104. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1105. }
  1106. resp, _ := client.Do(req)
  1107. defer resp.Body.Close()
  1108. body, ioErr := ioutil.ReadAll(resp.Body)
  1109. if ioErr != nil {
  1110. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1111. }
  1112. var respJSON map[string]interface{}
  1113. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1114. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1116. return
  1117. }
  1118. var resSix10265 ResultSix10265 //1101结果
  1119. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1120. result, _ := json.Marshal(respJSON)
  1121. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1122. utils.ErrorLog("解析失败:%v", err)
  1123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1124. return
  1125. }
  1126. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1127. //res2.Output = resSix10265.Output
  1128. res2.ErrMsg = resSix10265.ErrMsg
  1129. res2.Cainfo = resSix10265.Cainfo
  1130. res2.WarnMsg = resSix10265.WarnMsg
  1131. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1132. res2.Infcode = infocode
  1133. }
  1134. if res2.Infcode != -1 {
  1135. item.IsBg = 0
  1136. item.Bchno = ""
  1137. item.BgBchno = ""
  1138. item.PcDate = 0
  1139. service.SaveW(item)
  1140. } else {
  1141. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1142. }
  1143. }
  1144. } else {
  1145. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1146. }
  1147. }
  1148. if item.IsPc == 1 && item.IsBg == 0 {
  1149. var res FJ3507Result
  1150. var struct3507 models.Struct3507
  1151. struct3507.FixmedinsBchno = item.Bchno
  1152. struct3507.InvDataType = "1"
  1153. struct3507.Opter = roles.UserName
  1154. struct3507.FixmedinsCode = miConfig.Code
  1155. struct3507.Code = miConfig.Code
  1156. struct3507.OrgName = miConfig.OrgName
  1157. struct3507.AccessKey = miConfig.AccessKey
  1158. struct3507.RequestUrl = miConfig.Url
  1159. struct3507.SecretKey = miConfig.SecretKey
  1160. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1161. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1162. struct3507.Url = miConfig.Url
  1163. struct3507.AppId = miConfig.Cainfo
  1164. struct3507.AppSecret = miConfig.AppSecret
  1165. struct3507.Enckey = miConfig.EncKey
  1166. struct3507.SignKey = miConfig.SignKey
  1167. struct3507.SecretKey = miConfig.SecretKey
  1168. //result, result1, _ := service.FJyb3507(struct3507)
  1169. //saveLog(result, result1, "3507", "3507")
  1170. if miConfig.MdtrtareaAdmvs == "350500" {
  1171. result, result1, _ := service.FJyb3507(struct3507)
  1172. saveLog(result, result1, "3507", "3507")
  1173. var respJSON2 map[string]interface{}
  1174. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1177. return
  1178. }
  1179. userJSONBytes2, _ := json.Marshal(respJSON2)
  1180. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1181. utils.ErrorLog("解析失败:%v", err)
  1182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1183. return
  1184. }
  1185. } else {
  1186. data := make(map[string]interface{})
  1187. data["struct_3507s"] = struct3507
  1188. client := &http.Client{}
  1189. bytesData, _ := json.Marshal(data)
  1190. var req *http.Request
  1191. if miConfig.MdtrtareaAdmvs == "320921" {
  1192. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1193. } else {
  1194. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1195. }
  1196. resp, _ := client.Do(req)
  1197. defer resp.Body.Close()
  1198. body, ioErr := ioutil.ReadAll(resp.Body)
  1199. if ioErr != nil {
  1200. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1201. }
  1202. var respJSON map[string]interface{}
  1203. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1204. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1206. return
  1207. }
  1208. var resSix10265 ResultSix10265 //1101结果
  1209. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1210. result, _ := json.Marshal(respJSON)
  1211. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1212. utils.ErrorLog("解析失败:%v", err)
  1213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1214. return
  1215. }
  1216. res.InfRefmsgid = resSix10265.InfRefmsgid
  1217. //res.Output = resSix10265.Output
  1218. res.ErrMsg = resSix10265.ErrMsg
  1219. res.Cainfo = resSix10265.Cainfo
  1220. res.WarnMsg = resSix10265.WarnMsg
  1221. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1222. res.Infcode = infocode
  1223. }
  1224. if res.Infcode == 0 {
  1225. item.IsPc = 0
  1226. item.Bchno = ""
  1227. item.BgBchno = ""
  1228. item.PcDate = 0
  1229. service.SaveW(item)
  1230. } else {
  1231. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1232. }
  1233. }
  1234. if item.IsPc == 0 && item.IsBg == 1 {
  1235. var res FJ3507Result
  1236. var struct3507 models.Struct3507
  1237. struct3507.FixmedinsBchno = item.BgBchno
  1238. struct3507.InvDataType = "2"
  1239. struct3507.Opter = roles.UserName
  1240. struct3507.FixmedinsCode = miConfig.Code
  1241. struct3507.OrgName = miConfig.OrgName
  1242. struct3507.AccessKey = miConfig.AccessKey
  1243. struct3507.RequestUrl = miConfig.Url
  1244. struct3507.SecretKey = miConfig.SecretKey
  1245. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1246. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1247. struct3507.Url = miConfig.Url
  1248. struct3507.AppId = miConfig.Cainfo
  1249. struct3507.AppSecret = miConfig.AppSecret
  1250. struct3507.Enckey = miConfig.EncKey
  1251. struct3507.SignKey = miConfig.SignKey
  1252. struct3507.SecretKey = miConfig.SecretKey
  1253. //result, result1, _ := service.FJyb3507(struct3507)
  1254. //saveLog(result, result1, "3507", "3507")
  1255. if miConfig.MdtrtareaAdmvs == "350500" {
  1256. result, result1, _ := service.FJyb3507(struct3507)
  1257. saveLog(result, result1, "3507", "3507")
  1258. var respJSON2 map[string]interface{}
  1259. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1260. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1262. return
  1263. }
  1264. userJSONBytes2, _ := json.Marshal(respJSON2)
  1265. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1266. utils.ErrorLog("解析失败:%v", err)
  1267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1268. return
  1269. }
  1270. } else {
  1271. data := make(map[string]interface{})
  1272. data["struct_3507s"] = struct3507
  1273. client := &http.Client{}
  1274. bytesData, _ := json.Marshal(data)
  1275. var req *http.Request
  1276. if miConfig.MdtrtareaAdmvs == "320921" {
  1277. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1278. } else {
  1279. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1280. }
  1281. resp, _ := client.Do(req)
  1282. defer resp.Body.Close()
  1283. body, ioErr := ioutil.ReadAll(resp.Body)
  1284. if ioErr != nil {
  1285. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1286. }
  1287. var respJSON map[string]interface{}
  1288. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1289. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1291. return
  1292. }
  1293. var resSix10265 ResultSix10265 //1101结果
  1294. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1295. result, _ := json.Marshal(respJSON)
  1296. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1297. utils.ErrorLog("解析失败:%v", err)
  1298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1299. return
  1300. }
  1301. res.InfRefmsgid = resSix10265.InfRefmsgid
  1302. //res.Output = resSix10265.Output
  1303. res.ErrMsg = resSix10265.ErrMsg
  1304. res.Cainfo = resSix10265.Cainfo
  1305. res.WarnMsg = resSix10265.WarnMsg
  1306. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1307. res.Infcode = infocode
  1308. }
  1309. if res.Infcode == 0 {
  1310. item.IsBg = 0
  1311. item.Bchno = ""
  1312. item.BgBchno = ""
  1313. item.PcDate = 0
  1314. service.SaveW(item)
  1315. } else {
  1316. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1317. }
  1318. }
  1319. }
  1320. if len(err) == 0 {
  1321. c.ServeSuccessJSON(map[string]interface{}{
  1322. "msg": "删除盘存变更成功",
  1323. })
  1324. } else {
  1325. c.ServeSuccessJSON(map[string]interface{}{
  1326. "failed_code": -10,
  1327. "msg": err,
  1328. })
  1329. }
  1330. }
  1331. func (c *HisApiController) DeleteXSandBG() {
  1332. ids := c.GetString("ids")
  1333. id_arr := strings.Split(ids, ",")
  1334. admin_user_id, _ := c.GetInt64("admin_user_id")
  1335. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1336. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1337. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1338. var err []string
  1339. for _, item := range flows {
  1340. if item.IsSale == 1 && item.IsChange == 1 {
  1341. var res FJ3507Result
  1342. var res2 FJ3507Result
  1343. var struct3507 models.Struct3507
  1344. struct3507.FixmedinsBchno = item.Bchno
  1345. struct3507.InvDataType = "4"
  1346. struct3507.Opter = roles.UserName
  1347. struct3507.OrgName = miConfig.OrgName
  1348. struct3507.AccessKey = miConfig.AccessKey
  1349. struct3507.RequestUrl = miConfig.Url
  1350. struct3507.FixmedinsCode = miConfig.Code
  1351. struct3507.SecretKey = miConfig.SecretKey
  1352. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1353. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1354. struct3507.Url = miConfig.Url
  1355. struct3507.AppId = miConfig.Cainfo
  1356. struct3507.AppSecret = miConfig.AppSecret
  1357. struct3507.Enckey = miConfig.EncKey
  1358. struct3507.SignKey = miConfig.SignKey
  1359. struct3507.SecretKey = miConfig.SecretKey
  1360. //result, result1, _ := service.FJyb3507(struct3507)
  1361. //saveLog(result, result1, "3507", "3507")
  1362. if miConfig.MdtrtareaAdmvs == "350500" {
  1363. result, result1, _ := service.FJyb3507(struct3507)
  1364. saveLog(result, result1, "3507", "3507")
  1365. var respJSON2 map[string]interface{}
  1366. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1369. return
  1370. }
  1371. userJSONBytes2, _ := json.Marshal(respJSON2)
  1372. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1373. utils.ErrorLog("解析失败:%v", err)
  1374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1375. return
  1376. }
  1377. } else {
  1378. data := make(map[string]interface{})
  1379. data["struct_3507s"] = struct3507
  1380. client := &http.Client{}
  1381. bytesData, _ := json.Marshal(data)
  1382. var req *http.Request
  1383. if miConfig.MdtrtareaAdmvs == "320921" {
  1384. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1385. } else {
  1386. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1387. }
  1388. resp, _ := client.Do(req)
  1389. defer resp.Body.Close()
  1390. body, ioErr := ioutil.ReadAll(resp.Body)
  1391. if ioErr != nil {
  1392. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1393. }
  1394. var respJSON map[string]interface{}
  1395. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1398. return
  1399. }
  1400. var resSix10265 ResultSix10265 //1101结果
  1401. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1402. result, _ := json.Marshal(respJSON)
  1403. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1404. utils.ErrorLog("解析失败:%v", err)
  1405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1406. return
  1407. }
  1408. res.InfRefmsgid = resSix10265.InfRefmsgid
  1409. //res.Output = resSix10265.Output
  1410. res.ErrMsg = resSix10265.ErrMsg
  1411. res.Cainfo = resSix10265.Cainfo
  1412. res.WarnMsg = resSix10265.WarnMsg
  1413. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1414. res.Infcode = infocode
  1415. }
  1416. if res.Infcode == 0 {
  1417. item.IsSale = 0
  1418. item.SaleDate = ""
  1419. item.Bchno = ""
  1420. err2 := service.SaveDF(item)
  1421. if err2 == nil {
  1422. var struct3507_2 models.Struct3507
  1423. struct3507_2.OrgName = miConfig.OrgName
  1424. struct3507_2.AccessKey = miConfig.AccessKey
  1425. struct3507_2.RequestUrl = miConfig.Url
  1426. struct3507_2.Opter = roles.UserName
  1427. struct3507_2.FixmedinsCode = miConfig.Code
  1428. struct3507_2.Code = miConfig.Code
  1429. struct3507_2.SecretKey = miConfig.SecretKey
  1430. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1431. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1432. struct3507_2.Url = miConfig.Url
  1433. struct3507_2.AppId = miConfig.Cainfo
  1434. struct3507_2.AppSecret = miConfig.AppSecret
  1435. struct3507_2.Enckey = miConfig.EncKey
  1436. struct3507_2.SignKey = miConfig.SignKey
  1437. struct3507_2.SecretKey = miConfig.SecretKey
  1438. struct3507_2.FixmedinsBchno = item.BgBchno
  1439. struct3507_2.InvDataType = "2"
  1440. if miConfig.MdtrtareaAdmvs == "350500" {
  1441. result11, result22, _ := service.FJyb3507(struct3507_2)
  1442. saveLog(result11, result22, "3507", "3507")
  1443. var respJSON3 map[string]interface{}
  1444. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1445. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1447. return
  1448. }
  1449. userJSONBytes3, _ := json.Marshal(respJSON3)
  1450. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1451. utils.ErrorLog("解析失败:%v", err)
  1452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1453. return
  1454. }
  1455. } else {
  1456. data := make(map[string]interface{})
  1457. data["struct_3507s"] = struct3507_2
  1458. client := &http.Client{}
  1459. bytesData, _ := json.Marshal(data)
  1460. var req *http.Request
  1461. if miConfig.MdtrtareaAdmvs == "320921" {
  1462. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1463. } else {
  1464. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1465. }
  1466. resp, _ := client.Do(req)
  1467. defer resp.Body.Close()
  1468. body, ioErr := ioutil.ReadAll(resp.Body)
  1469. if ioErr != nil {
  1470. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1471. }
  1472. var respJSON map[string]interface{}
  1473. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1474. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1476. return
  1477. }
  1478. var resSix10265 ResultSix10265 //1101结果
  1479. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1480. result, _ := json.Marshal(respJSON)
  1481. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1482. utils.ErrorLog("解析失败:%v", err)
  1483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1484. return
  1485. }
  1486. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1487. //res.Output = resSix10265.Output
  1488. res2.ErrMsg = resSix10265.ErrMsg
  1489. res2.Cainfo = resSix10265.Cainfo
  1490. res2.WarnMsg = resSix10265.WarnMsg
  1491. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1492. res2.Infcode = infocode
  1493. }
  1494. if res2.Infcode == 0 {
  1495. item.IsChange = 0
  1496. item.BgBchno = ""
  1497. service.SaveDF2(item)
  1498. } else {
  1499. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1500. }
  1501. }
  1502. } else {
  1503. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1504. }
  1505. }
  1506. if item.IsSale == 2 && item.IsChange == 1 {
  1507. var res FJ3507Result
  1508. var res2 FJ3507Result
  1509. var struct3507 models.Struct3507
  1510. struct3507.FixmedinsBchno = item.Bchno
  1511. struct3507.InvDataType = "4"
  1512. struct3507.Opter = roles.UserName
  1513. struct3507.OrgName = miConfig.OrgName
  1514. struct3507.AccessKey = miConfig.AccessKey
  1515. struct3507.RequestUrl = miConfig.Url
  1516. struct3507.FixmedinsCode = miConfig.Code
  1517. struct3507.Code = miConfig.Code
  1518. struct3507.SecretKey = miConfig.SecretKey
  1519. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1520. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1521. struct3507.Url = miConfig.Url
  1522. struct3507.AppId = miConfig.Cainfo
  1523. struct3507.AppSecret = miConfig.AppSecret
  1524. struct3507.Enckey = miConfig.EncKey
  1525. struct3507.SignKey = miConfig.SignKey
  1526. struct3507.SecretKey = miConfig.SecretKey
  1527. //result, result1, _ := service.FJyb3507(struct3507)
  1528. //saveLog(result, result1, "3507", "3507")
  1529. //
  1530. //var respJSON2 map[string]interface{}
  1531. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1532. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1533. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1534. // return
  1535. //}
  1536. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1537. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1538. // utils.ErrorLog("解析失败:%v", err)
  1539. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1540. // return
  1541. //}
  1542. if miConfig.MdtrtareaAdmvs == "350500" {
  1543. result, result1, _ := service.FJyb3507(struct3507)
  1544. saveLog(result, result1, "3507", "3507")
  1545. var respJSON2 map[string]interface{}
  1546. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1547. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1549. return
  1550. }
  1551. userJSONBytes2, _ := json.Marshal(respJSON2)
  1552. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1553. utils.ErrorLog("解析失败:%v", err)
  1554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1555. return
  1556. }
  1557. } else {
  1558. data := make(map[string]interface{})
  1559. data["struct_3507s"] = struct3507
  1560. client := &http.Client{}
  1561. bytesData, _ := json.Marshal(data)
  1562. var req *http.Request
  1563. if miConfig.MdtrtareaAdmvs == "320921" {
  1564. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1565. } else {
  1566. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1567. }
  1568. resp, _ := client.Do(req)
  1569. defer resp.Body.Close()
  1570. body, ioErr := ioutil.ReadAll(resp.Body)
  1571. if ioErr != nil {
  1572. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1573. }
  1574. var respJSON map[string]interface{}
  1575. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1576. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1578. return
  1579. }
  1580. var resSix10265 ResultSix10265 //1101结果
  1581. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1582. result, _ := json.Marshal(respJSON)
  1583. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1584. utils.ErrorLog("解析失败:%v", err)
  1585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1586. return
  1587. }
  1588. res.InfRefmsgid = resSix10265.InfRefmsgid
  1589. //res.Output = resSix10265.Output
  1590. res.ErrMsg = resSix10265.ErrMsg
  1591. res.Cainfo = resSix10265.Cainfo
  1592. res.WarnMsg = resSix10265.WarnMsg
  1593. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1594. res.Infcode = infocode
  1595. }
  1596. if res.Infcode == 0 {
  1597. item.IsSale = 0
  1598. item.SaleDate = ""
  1599. item.Bchno = ""
  1600. err2 := service.SaveDF(item)
  1601. if err2 == nil {
  1602. var struct3507_2 models.Struct3507
  1603. struct3507_2.OrgName = miConfig.OrgName
  1604. struct3507_2.AccessKey = miConfig.AccessKey
  1605. struct3507_2.RequestUrl = miConfig.Url
  1606. struct3507_2.Opter = roles.UserName
  1607. struct3507_2.FixmedinsCode = miConfig.Code
  1608. struct3507_2.Code = miConfig.Code
  1609. struct3507_2.SecretKey = miConfig.SecretKey
  1610. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1611. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1612. struct3507_2.Url = miConfig.Url
  1613. struct3507_2.AppId = miConfig.Cainfo
  1614. struct3507_2.AppSecret = miConfig.AppSecret
  1615. struct3507_2.Enckey = miConfig.EncKey
  1616. struct3507_2.SignKey = miConfig.SignKey
  1617. struct3507_2.SecretKey = miConfig.SecretKey
  1618. struct3507_2.FixmedinsBchno = item.BgBchno
  1619. struct3507_2.InvDataType = "2"
  1620. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1621. //saveLog(result11, result22, "3507", "3507")
  1622. //var respJSON3 map[string]interface{}
  1623. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1624. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1625. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1626. // return
  1627. //}
  1628. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1629. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1630. // utils.ErrorLog("解析失败:%v", err)
  1631. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1632. // return
  1633. //}
  1634. if miConfig.MdtrtareaAdmvs == "350500" {
  1635. result11, result22, _ := service.FJyb3507(struct3507_2)
  1636. saveLog(result11, result22, "3507", "3507")
  1637. var respJSON3 map[string]interface{}
  1638. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1639. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1641. return
  1642. }
  1643. userJSONBytes3, _ := json.Marshal(respJSON3)
  1644. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1645. utils.ErrorLog("解析失败:%v", err)
  1646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1647. return
  1648. }
  1649. } else {
  1650. data := make(map[string]interface{})
  1651. data["struct_3507s"] = struct3507_2
  1652. client := &http.Client{}
  1653. bytesData, _ := json.Marshal(data)
  1654. var req *http.Request
  1655. if miConfig.MdtrtareaAdmvs == "320921" {
  1656. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1657. } else {
  1658. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1659. }
  1660. resp, _ := client.Do(req)
  1661. defer resp.Body.Close()
  1662. body, ioErr := ioutil.ReadAll(resp.Body)
  1663. if ioErr != nil {
  1664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1665. }
  1666. var respJSON map[string]interface{}
  1667. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1670. return
  1671. }
  1672. var resSix10265 ResultSix10265 //1101结果
  1673. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1674. result, _ := json.Marshal(respJSON)
  1675. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1676. utils.ErrorLog("解析失败:%v", err)
  1677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1678. return
  1679. }
  1680. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1681. //res.Output = resSix10265.Output
  1682. res2.ErrMsg = resSix10265.ErrMsg
  1683. res2.Cainfo = resSix10265.Cainfo
  1684. res2.WarnMsg = resSix10265.WarnMsg
  1685. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1686. res2.Infcode = infocode
  1687. }
  1688. if res2.Infcode == 0 {
  1689. item.IsChange = 0
  1690. item.BgBchno = ""
  1691. service.SaveDF2(item)
  1692. } else {
  1693. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1694. }
  1695. }
  1696. } else {
  1697. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1698. }
  1699. }
  1700. if item.IsSale == 1 && item.IsChange == 0 {
  1701. var res FJ3507Result
  1702. var struct3507 models.Struct3507
  1703. struct3507.FixmedinsBchno = item.Bchno
  1704. struct3507.InvDataType = "4"
  1705. struct3507.Opter = roles.UserName
  1706. struct3507.FixmedinsCode = miConfig.Code
  1707. struct3507.Code = miConfig.Code
  1708. struct3507.OrgName = miConfig.OrgName
  1709. struct3507.AccessKey = miConfig.AccessKey
  1710. struct3507.RequestUrl = miConfig.Url
  1711. struct3507.SecretKey = miConfig.SecretKey
  1712. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1713. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1714. struct3507.Url = miConfig.Url
  1715. struct3507.AppId = miConfig.Cainfo
  1716. struct3507.AppSecret = miConfig.AppSecret
  1717. struct3507.Enckey = miConfig.EncKey
  1718. struct3507.SignKey = miConfig.SignKey
  1719. struct3507.SecretKey = miConfig.SecretKey
  1720. //result, result1, _ := service.FJyb3507(struct3507)
  1721. //saveLog(result, result1, "3507", "3507")
  1722. //
  1723. //var respJSON3 map[string]interface{}
  1724. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1725. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1726. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1727. // return
  1728. //}
  1729. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1730. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1731. // utils.ErrorLog("解析失败:%v", err)
  1732. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1733. // return
  1734. //}
  1735. if miConfig.MdtrtareaAdmvs == "350500" {
  1736. result, result1, _ := service.FJyb3507(struct3507)
  1737. saveLog(result, result1, "3507", "3507")
  1738. var respJSON2 map[string]interface{}
  1739. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1740. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1742. return
  1743. }
  1744. userJSONBytes2, _ := json.Marshal(respJSON2)
  1745. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1746. utils.ErrorLog("解析失败:%v", err)
  1747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1748. return
  1749. }
  1750. } else {
  1751. data := make(map[string]interface{})
  1752. data["struct_3507s"] = struct3507
  1753. client := &http.Client{}
  1754. bytesData, _ := json.Marshal(data)
  1755. var req *http.Request
  1756. if miConfig.MdtrtareaAdmvs == "320921" {
  1757. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1758. } else {
  1759. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1760. }
  1761. resp, _ := client.Do(req)
  1762. defer resp.Body.Close()
  1763. body, ioErr := ioutil.ReadAll(resp.Body)
  1764. if ioErr != nil {
  1765. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1766. }
  1767. var respJSON map[string]interface{}
  1768. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1769. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1771. return
  1772. }
  1773. var resSix10265 ResultSix10265 //1101结果
  1774. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1775. result, _ := json.Marshal(respJSON)
  1776. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1777. utils.ErrorLog("解析失败:%v", err)
  1778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1779. return
  1780. }
  1781. res.InfRefmsgid = resSix10265.InfRefmsgid
  1782. //res.Output = resSix10265.Output
  1783. res.ErrMsg = resSix10265.ErrMsg
  1784. res.Cainfo = resSix10265.Cainfo
  1785. res.WarnMsg = resSix10265.WarnMsg
  1786. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1787. res.Infcode = infocode
  1788. }
  1789. if res.Infcode == 0 {
  1790. item.IsSale = 0
  1791. item.SaleDate = ""
  1792. service.SaveDF(item)
  1793. } else {
  1794. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1795. }
  1796. }
  1797. if item.IsSale == 2 && item.IsChange == 0 {
  1798. var res FJ3507Result
  1799. var struct3507 models.Struct3507
  1800. struct3507.FixmedinsBchno = item.Bchno
  1801. struct3507.InvDataType = "4"
  1802. struct3507.Opter = roles.UserName
  1803. struct3507.FixmedinsCode = miConfig.Code
  1804. struct3507.Code = miConfig.Code
  1805. struct3507.OrgName = miConfig.OrgName
  1806. struct3507.AccessKey = miConfig.AccessKey
  1807. struct3507.RequestUrl = miConfig.Url
  1808. struct3507.SecretKey = miConfig.SecretKey
  1809. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1810. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1811. struct3507.Url = miConfig.Url
  1812. struct3507.AppId = miConfig.Cainfo
  1813. struct3507.AppSecret = miConfig.AppSecret
  1814. struct3507.Enckey = miConfig.EncKey
  1815. struct3507.SignKey = miConfig.SignKey
  1816. struct3507.SecretKey = miConfig.SecretKey
  1817. //result, result1, _ := service.FJyb3507(struct3507)
  1818. //saveLog(result, result1, "3507", "3507")
  1819. //
  1820. //var respJSON3 map[string]interface{}
  1821. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1822. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1823. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1824. // return
  1825. //}
  1826. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1827. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1828. // utils.ErrorLog("解析失败:%v", err)
  1829. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1830. // return
  1831. //}
  1832. if miConfig.MdtrtareaAdmvs == "350500" {
  1833. result, result1, _ := service.FJyb3507(struct3507)
  1834. saveLog(result, result1, "3507", "3507")
  1835. var respJSON2 map[string]interface{}
  1836. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1837. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1839. return
  1840. }
  1841. userJSONBytes2, _ := json.Marshal(respJSON2)
  1842. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1843. utils.ErrorLog("解析失败:%v", err)
  1844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1845. return
  1846. }
  1847. } else {
  1848. data := make(map[string]interface{})
  1849. data["struct_3507s"] = struct3507
  1850. client := &http.Client{}
  1851. bytesData, _ := json.Marshal(data)
  1852. var req *http.Request
  1853. if miConfig.MdtrtareaAdmvs == "320921" {
  1854. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1855. } else {
  1856. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1857. }
  1858. resp, _ := client.Do(req)
  1859. defer resp.Body.Close()
  1860. body, ioErr := ioutil.ReadAll(resp.Body)
  1861. if ioErr != nil {
  1862. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1863. }
  1864. var respJSON map[string]interface{}
  1865. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1868. return
  1869. }
  1870. var resSix10265 ResultSix10265 //1101结果
  1871. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1872. result, _ := json.Marshal(respJSON)
  1873. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1874. utils.ErrorLog("解析失败:%v", err)
  1875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1876. return
  1877. }
  1878. res.InfRefmsgid = resSix10265.InfRefmsgid
  1879. //res.Output = resSix10265.Output
  1880. res.ErrMsg = resSix10265.ErrMsg
  1881. res.Cainfo = resSix10265.Cainfo
  1882. res.WarnMsg = resSix10265.WarnMsg
  1883. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1884. res.Infcode = infocode
  1885. }
  1886. if res.Infcode == 0 {
  1887. item.IsSale = 0
  1888. item.SaleDate = ""
  1889. item.Bchno = ""
  1890. service.SaveDF(item)
  1891. } else {
  1892. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1893. }
  1894. }
  1895. if item.IsSale == 0 && item.IsChange == 1 {
  1896. var res FJ3507Result
  1897. var struct3507 models.Struct3507
  1898. struct3507.FixmedinsBchno = item.BgBchno
  1899. struct3507.InvDataType = "2"
  1900. struct3507.Opter = roles.UserName
  1901. struct3507.FixmedinsCode = miConfig.Code
  1902. struct3507.Code = miConfig.Code
  1903. struct3507.OrgName = miConfig.OrgName
  1904. struct3507.AccessKey = miConfig.AccessKey
  1905. struct3507.RequestUrl = miConfig.Url
  1906. struct3507.SecretKey = miConfig.SecretKey
  1907. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1908. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1909. struct3507.Url = miConfig.Url
  1910. struct3507.AppId = miConfig.Cainfo
  1911. struct3507.AppSecret = miConfig.AppSecret
  1912. struct3507.Enckey = miConfig.EncKey
  1913. struct3507.SignKey = miConfig.SignKey
  1914. struct3507.SecretKey = miConfig.SecretKey
  1915. //result, result1, _ := service.FJyb3507(struct3507)
  1916. //saveLog(result, result1, "3507", "3507")
  1917. //
  1918. //var respJSON3 map[string]interface{}
  1919. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1920. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1921. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1922. // return
  1923. //}
  1924. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1925. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1926. // utils.ErrorLog("解析失败:%v", err)
  1927. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1928. // return
  1929. //}
  1930. if miConfig.MdtrtareaAdmvs == "350500" {
  1931. result, result1, _ := service.FJyb3507(struct3507)
  1932. saveLog(result, result1, "3507", "3507")
  1933. var respJSON2 map[string]interface{}
  1934. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1935. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1937. return
  1938. }
  1939. userJSONBytes2, _ := json.Marshal(respJSON2)
  1940. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1941. utils.ErrorLog("解析失败:%v", err)
  1942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1943. return
  1944. }
  1945. } else {
  1946. data := make(map[string]interface{})
  1947. data["struct_3507s"] = struct3507
  1948. client := &http.Client{}
  1949. bytesData, _ := json.Marshal(data)
  1950. var req *http.Request
  1951. if miConfig.MdtrtareaAdmvs == "320921" {
  1952. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1953. } else {
  1954. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1955. }
  1956. resp, _ := client.Do(req)
  1957. defer resp.Body.Close()
  1958. body, ioErr := ioutil.ReadAll(resp.Body)
  1959. if ioErr != nil {
  1960. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1961. }
  1962. var respJSON map[string]interface{}
  1963. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1964. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1966. return
  1967. }
  1968. var resSix10265 ResultSix10265 //1101结果
  1969. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1970. result, _ := json.Marshal(respJSON)
  1971. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1972. utils.ErrorLog("解析失败:%v", err)
  1973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1974. return
  1975. }
  1976. res.InfRefmsgid = resSix10265.InfRefmsgid
  1977. //res.Output = resSix10265.Output
  1978. res.ErrMsg = resSix10265.ErrMsg
  1979. res.Cainfo = resSix10265.Cainfo
  1980. res.WarnMsg = resSix10265.WarnMsg
  1981. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1982. res.Infcode = infocode
  1983. }
  1984. if res.Infcode == 0 {
  1985. item.IsChange = 0
  1986. item.BgBchno = ""
  1987. service.SaveDF2(item)
  1988. } else {
  1989. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1990. }
  1991. }
  1992. }
  1993. if len(err) == 0 {
  1994. c.ServeSuccessJSON(map[string]interface{}{
  1995. "msg": "删除销售变更成功",
  1996. })
  1997. } else {
  1998. c.ServeSuccessJSON(map[string]interface{}{
  1999. "failed_code": -10,
  2000. "msg": err,
  2001. })
  2002. }
  2003. }
  2004. //func (c *HisApiController) BatchFJ3501AND3502() {
  2005. // //ids := c.GetString("ids")
  2006. // start_time := c.GetString("start_time")
  2007. // end_time := c.GetString("end_time")
  2008. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2009. //
  2010. //
  2011. // timeLayout := "2006-01-02"
  2012. // loc, _ := time.LoadLocation("Local")
  2013. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2014. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2015. //
  2016. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2017. // //id_arr := strings.Split(ids, ",")
  2018. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2019. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2020. // //库盘
  2021. // var errs []string
  2022. // for _, drug := range drugs {
  2023. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2024. // var res2 ResultSix
  2025. // var res3 ResultSix
  2026. //
  2027. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2028. // var struct3501 models.Struct3501
  2029. // struct3501.Code = miConfig.Code
  2030. // struct3501.OrgName = miConfig.OrgName
  2031. // struct3501.AccessKey = miConfig.AccessKey
  2032. // struct3501.Opter = roles.UserName
  2033. // struct3501.RequestUrl = miConfig.Url
  2034. // struct3501.Url = miConfig.Url
  2035. // struct3501.AppId = miConfig.Cainfo
  2036. // struct3501.AppSecret = miConfig.AppSecret
  2037. // struct3501.Enckey = miConfig.EncKey
  2038. // struct3501.SignKey = miConfig.SignKey
  2039. // struct3501.SecretKey = miConfig.SecretKey
  2040. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2041. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2042. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2043. // struct3501.RxFlag = "1"
  2044. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2045. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2046. //
  2047. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2048. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2049. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2050. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2051. // struct3501.FixmedinsBchno = number
  2052. // struct3501.DrugTracCodg = drug.DrugCode
  2053. // memo := make(map[string]interface{})
  2054. // memo["pric"] = drug.Price
  2055. // bytesData, _ := json.Marshal(memo)
  2056. // struct3501.Memo = string(bytesData)
  2057. //
  2058. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2059. //
  2060. // result1, result2, _ := service.FJyb3501(struct3501)
  2061. // saveLog(result1, result2, "3501", "3501")
  2062. // //saveLog(result, requestLog, "2201", "挂号")
  2063. //
  2064. // var respJSON2 map[string]interface{}
  2065. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2066. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2067. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2068. // return
  2069. // }
  2070. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2071. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2072. // utils.ErrorLog("解析失败:%v", err)
  2073. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2074. // return
  2075. // }
  2076. //
  2077. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2078. // data := make(map[string]interface{})
  2079. // data["struct_3501s"] = struct3501
  2080. // client := &http.Client{}
  2081. // bytesData, _ := json.Marshal(data)
  2082. // var req *http.Request
  2083. // if miConfig.MdtrtareaAdmvs == "320921" {
  2084. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2085. // } else {
  2086. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2087. // }
  2088. //
  2089. // resp, _ := client.Do(req)
  2090. // defer resp.Body.Close()
  2091. // body, ioErr := ioutil.ReadAll(resp.Body)
  2092. // if ioErr != nil {
  2093. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2094. // }
  2095. // var respJSON map[string]interface{}
  2096. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2097. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2098. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2099. // return
  2100. // }
  2101. // var resSix10265 ResultSix10265 //1101结果
  2102. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2103. // result, _ := json.Marshal(respJSON)
  2104. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2105. // utils.ErrorLog("解析失败:%v", err)
  2106. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2107. // return
  2108. // }
  2109. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2110. // res2.Output = resSix10265.Output
  2111. // res2.ErrMsg = resSix10265.ErrMsg
  2112. // res2.Cainfo = resSix10265.Cainfo
  2113. // res2.WarnMsg = resSix10265.WarnMsg
  2114. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2115. // res2.Infcode = infocode
  2116. //
  2117. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2118. // data := make(map[string]interface{})
  2119. // data["struct_3501s"] = struct3501
  2120. // client := &http.Client{}
  2121. // bytesData, _ := json.Marshal(data)
  2122. // var req *http.Request
  2123. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2124. // resp, _ := client.Do(req)
  2125. // defer resp.Body.Close()
  2126. // body, ioErr := ioutil.ReadAll(resp.Body)
  2127. // if ioErr != nil {
  2128. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2129. // }
  2130. // var respJSON map[string]interface{}
  2131. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2132. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2133. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2134. // return
  2135. // }
  2136. // var resSix10265 ResultSix10265 //1101结果
  2137. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2138. // result, _ := json.Marshal(respJSON)
  2139. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2140. // utils.ErrorLog("解析失败:%v", err)
  2141. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2142. // return
  2143. // }
  2144. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2145. // res2.Output = resSix10265.Output
  2146. // res2.ErrMsg = resSix10265.ErrMsg
  2147. // res2.Cainfo = resSix10265.Cainfo
  2148. // res2.WarnMsg = resSix10265.WarnMsg
  2149. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2150. // res2.Infcode = infocode
  2151. //
  2152. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2153. // data := make(map[string]interface{})
  2154. // data["struct_3501s"] = struct3501
  2155. // client := &http.Client{}
  2156. // bytesData, _ := json.Marshal(data)
  2157. // var req *http.Request
  2158. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2159. // resp, _ := client.Do(req)
  2160. // defer resp.Body.Close()
  2161. // body, ioErr := ioutil.ReadAll(resp.Body)
  2162. // if ioErr != nil {
  2163. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2164. // }
  2165. // var respJSON map[string]interface{}
  2166. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2167. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2168. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2169. // return
  2170. // }
  2171. // var resSix10265 ResultSix10265 //1101结果
  2172. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2173. // result, _ := json.Marshal(respJSON)
  2174. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2175. // utils.ErrorLog("解析失败:%v", err)
  2176. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2177. // return
  2178. // }
  2179. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2180. // res2.Output = resSix10265.Output
  2181. // res2.ErrMsg = resSix10265.ErrMsg
  2182. // res2.Cainfo = resSix10265.Cainfo
  2183. // res2.WarnMsg = resSix10265.WarnMsg
  2184. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2185. // res2.Infcode = infocode
  2186. //
  2187. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2188. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2189. // saveLog(result1, result2, "3501", "3501")
  2190. // //saveLog(result, requestLog, "2201", "挂号")
  2191. //
  2192. // var respJSON2 map[string]interface{}
  2193. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2194. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2195. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2196. // return
  2197. // }
  2198. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2199. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2200. // utils.ErrorLog("解析失败:%v", err)
  2201. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2202. // return
  2203. // }
  2204. //
  2205. // }
  2206. //
  2207. // if res2.Infcode != -1 {
  2208. // drug.IsPc = 1
  2209. // drug.Bchno = number
  2210. // drug.PcDate = time.Now().Unix()
  2211. // err := service.SaveW(drug)
  2212. // if err == nil {
  2213. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2214. // var struct3502 models.Struct3502
  2215. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2216. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2217. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2218. // struct3502.FixmedinsCode = miConfig.Code
  2219. // struct3502.Code = miConfig.Code
  2220. //
  2221. // struct3502.RxFlag = "0"
  2222. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2223. // struct3502.OrgName = miConfig.OrgName
  2224. // struct3502.Opter = roles.UserName
  2225. // struct3502.AccessKey = miConfig.AccessKey
  2226. // struct3502.RequestUrl = miConfig.Url
  2227. // struct3502.SecretKey = miConfig.SecretKey
  2228. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2229. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2230. // struct3502.Url = miConfig.Url
  2231. // struct3502.AppId = miConfig.Cainfo
  2232. // struct3502.AppSecret = miConfig.AppSecret
  2233. // struct3502.Enckey = miConfig.EncKey
  2234. // struct3502.SignKey = miConfig.SignKey
  2235. // struct3502.SecretKey = miConfig.SecretKey
  2236. // struct3502.DrugTracCodg = drug.DrugCode
  2237. //
  2238. // struct3502.Memo = ""
  2239. // struct3502.InvChgType = "108"
  2240. // struct3502.FixmedinsBchno = bg_number
  2241. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2242. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2243. //
  2244. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2245. // result11, result22, _ := service.FJyb3502(struct3502)
  2246. // saveLog(result11, result22, "3502", "3502")
  2247. //
  2248. // var respJSON3 map[string]interface{}
  2249. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2250. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2251. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2252. // return
  2253. // }
  2254. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2255. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2256. // utils.ErrorLog("解析失败:%v", err)
  2257. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2258. // return
  2259. // }
  2260. //
  2261. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2262. // data := make(map[string]interface{})
  2263. // data["struct_3502s"] = struct3502
  2264. // client := &http.Client{}
  2265. // bytesData, _ := json.Marshal(data)
  2266. // var req *http.Request
  2267. // if miConfig.MdtrtareaAdmvs == "320921" {
  2268. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2269. // } else {
  2270. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2271. // }
  2272. //
  2273. // resp, _ := client.Do(req)
  2274. // defer resp.Body.Close()
  2275. // body, ioErr := ioutil.ReadAll(resp.Body)
  2276. // if ioErr != nil {
  2277. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2278. // }
  2279. // var respJSON map[string]interface{}
  2280. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2281. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2282. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2283. // return
  2284. // }
  2285. // var resSix10265 ResultSix10265 //1101结果
  2286. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2287. // result, _ := json.Marshal(respJSON)
  2288. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2289. // utils.ErrorLog("解析失败:%v", err)
  2290. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2291. // return
  2292. // }
  2293. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2294. // res3.Output = resSix10265.Output
  2295. // res3.ErrMsg = resSix10265.ErrMsg
  2296. // res3.Cainfo = resSix10265.Cainfo
  2297. // res3.WarnMsg = resSix10265.WarnMsg
  2298. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2299. // res3.Infcode = infocode
  2300. //
  2301. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2302. //
  2303. // data := make(map[string]interface{})
  2304. // data["struct_3502s"] = struct3502
  2305. // client := &http.Client{}
  2306. // bytesData, _ := json.Marshal(data)
  2307. // var req *http.Request
  2308. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2309. // resp, _ := client.Do(req)
  2310. // defer resp.Body.Close()
  2311. // body, ioErr := ioutil.ReadAll(resp.Body)
  2312. // if ioErr != nil {
  2313. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2314. // }
  2315. // var respJSON map[string]interface{}
  2316. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2317. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2318. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2319. // return
  2320. // }
  2321. // var resSix10265 ResultSix10265 //1101结果
  2322. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2323. // result, _ := json.Marshal(respJSON)
  2324. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2325. // utils.ErrorLog("解析失败:%v", err)
  2326. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2327. // return
  2328. // }
  2329. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2330. // res3.Output = resSix10265.Output
  2331. // res3.ErrMsg = resSix10265.ErrMsg
  2332. // res3.Cainfo = resSix10265.Cainfo
  2333. // res3.WarnMsg = resSix10265.WarnMsg
  2334. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2335. // res3.Infcode = infocode
  2336. //
  2337. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2338. //
  2339. // data := make(map[string]interface{})
  2340. // data["struct_3501s"] = struct3501
  2341. // client := &http.Client{}
  2342. // bytesData, _ := json.Marshal(data)
  2343. // var req *http.Request
  2344. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2345. // resp, _ := client.Do(req)
  2346. // defer resp.Body.Close()
  2347. // body, ioErr := ioutil.ReadAll(resp.Body)
  2348. // if ioErr != nil {
  2349. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2350. // }
  2351. // var respJSON map[string]interface{}
  2352. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2353. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2354. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2355. // return
  2356. // }
  2357. // var resSix10265 ResultSix10265 //1101结果
  2358. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2359. // result, _ := json.Marshal(respJSON)
  2360. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2361. // utils.ErrorLog("解析失败:%v", err)
  2362. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2363. // return
  2364. // }
  2365. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2366. // res2.Output = resSix10265.Output
  2367. // res2.ErrMsg = resSix10265.ErrMsg
  2368. // res2.Cainfo = resSix10265.Cainfo
  2369. // res2.WarnMsg = resSix10265.WarnMsg
  2370. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2371. // res2.Infcode = infocode
  2372. //
  2373. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2374. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2375. // saveLog(result11, result22, "3502", "3502")
  2376. //
  2377. // var respJSON3 map[string]interface{}
  2378. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2379. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2380. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2381. // return
  2382. // }
  2383. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2384. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2385. // utils.ErrorLog("解析失败:%v", err)
  2386. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2387. // return
  2388. // }
  2389. // }
  2390. // if res3.Infcode == -1 {
  2391. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2392. // c.ServeSuccessJSON(map[string]interface{}{
  2393. // "failed_code": -10,
  2394. // "msg": res3.ErrMsg,
  2395. // })
  2396. // } else {
  2397. // drug.IsBg = 1
  2398. // drug.BgBchno = bg_number
  2399. // service.SaveW(drug)
  2400. // }
  2401. // }
  2402. // } else {
  2403. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2404. // }
  2405. // }
  2406. // //变更
  2407. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2408. // var res3 ResultSix
  2409. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2410. //
  2411. // var struct3502 models.Struct3502
  2412. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2413. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2414. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2415. // struct3502.FixmedinsCode = miConfig.Code
  2416. // struct3502.Code = miConfig.Code
  2417. //
  2418. // struct3502.Opter = roles.UserName
  2419. // struct3502.RxFlag = "0"
  2420. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2421. // struct3502.OrgName = miConfig.OrgName
  2422. // struct3502.AccessKey = miConfig.AccessKey
  2423. // struct3502.RequestUrl = miConfig.Url
  2424. // struct3502.SecretKey = miConfig.SecretKey
  2425. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2426. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2427. // struct3502.InvChgType = "108"
  2428. // struct3502.DrugTracCodg = drug.DrugCode
  2429. //
  2430. // struct3502.Url = miConfig.Url
  2431. // struct3502.AppId = miConfig.Cainfo
  2432. // struct3502.AppSecret = miConfig.AppSecret
  2433. // struct3502.Enckey = miConfig.EncKey
  2434. // struct3502.SignKey = miConfig.SignKey
  2435. // struct3502.SecretKey = miConfig.SecretKey
  2436. //
  2437. // struct3502.FixmedinsBchno = bg_number
  2438. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2439. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2440. //
  2441. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2442. // result1, result2, _ := service.FJyb3502(struct3502)
  2443. // saveLog(result1, result2, "3502", "3502")
  2444. // var respJSON3 map[string]interface{}
  2445. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2446. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2447. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2448. // return
  2449. // }
  2450. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2451. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2452. // utils.ErrorLog("解析失败:%v", err)
  2453. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2454. // return
  2455. // }
  2456. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2457. // data := make(map[string]interface{})
  2458. // data["struct_3502s"] = struct3502
  2459. // client := &http.Client{}
  2460. // bytesData, _ := json.Marshal(data)
  2461. // var req *http.Request
  2462. // if miConfig.MdtrtareaAdmvs == "320921" {
  2463. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2464. // } else {
  2465. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2466. // }
  2467. // resp, _ := client.Do(req)
  2468. // defer resp.Body.Close()
  2469. // body, ioErr := ioutil.ReadAll(resp.Body)
  2470. // if ioErr != nil {
  2471. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2472. // }
  2473. // var respJSON map[string]interface{}
  2474. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2475. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2476. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2477. // return
  2478. // }
  2479. // var resSix10265 ResultSix10265 //1101结果
  2480. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2481. // result, _ := json.Marshal(respJSON)
  2482. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2483. // utils.ErrorLog("解析失败:%v", err)
  2484. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2485. // return
  2486. // }
  2487. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2488. // res3.Output = resSix10265.Output
  2489. // res3.ErrMsg = resSix10265.ErrMsg
  2490. // res3.Cainfo = resSix10265.Cainfo
  2491. // res3.WarnMsg = resSix10265.WarnMsg
  2492. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2493. // res3.Infcode = infocode
  2494. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2495. //
  2496. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2497. //
  2498. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2499. //
  2500. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2501. //
  2502. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2503. // saveLog(result1, result2, "3501", "3501")
  2504. // //saveLog(result, requestLog, "2201", "挂号")
  2505. //
  2506. // var respJSON2 map[string]interface{}
  2507. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2508. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2509. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2510. // return
  2511. // }
  2512. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2513. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2514. // utils.ErrorLog("解析失败:%v", err)
  2515. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2516. // return
  2517. // }
  2518. //
  2519. // }
  2520. // if res3.Infcode == -1 {
  2521. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2522. // } else {
  2523. // drug.IsBg = 1
  2524. // drug.BgBchno = bg_number
  2525. // service.SaveW(drug)
  2526. // }
  2527. // }
  2528. // }
  2529. //
  2530. // if len(errs) == 0 {
  2531. // c.ServeSuccessJSON(map[string]interface{}{
  2532. // "msg": "盘存变更成功",
  2533. // })
  2534. // } else {
  2535. // c.ServeSuccessJSON(map[string]interface{}{
  2536. // "failed_code": -10,
  2537. // "msg": errs,
  2538. // })
  2539. // }
  2540. //}
  2541. func (c *HisApiController) DeleteXSandBGTwo() {
  2542. patient_id, _ := c.GetInt64("patient_id")
  2543. admin_user_id, _ := c.GetInt64("admin_user_id")
  2544. times := c.GetString("time", "")
  2545. timeLayout := "2006-01-02"
  2546. loc, _ := time.LoadLocation("Local")
  2547. var stime, etime int64
  2548. if times == "" {
  2549. stime, etime = GetNowTime()
  2550. } else {
  2551. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2552. stime = stmp.Unix()
  2553. etime = stime + 86399
  2554. }
  2555. advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2556. var flows []*models.DrugFlow
  2557. for _, item := range advicelist {
  2558. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2559. flows = append(flows, flow...)
  2560. }
  2561. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2562. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2563. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2564. var err []string
  2565. for _, item := range flows {
  2566. if item.IsSale == 1 {
  2567. var res FJ3507Result
  2568. var struct3507 models.Struct3507
  2569. struct3507.FixmedinsBchno = item.Bchno
  2570. struct3507.InvDataType = "4"
  2571. struct3507.Opter = roles.UserName
  2572. struct3507.OrgName = miConfig.OrgName
  2573. struct3507.AccessKey = miConfig.AccessKey
  2574. struct3507.RequestUrl = miConfig.Url
  2575. struct3507.FixmedinsCode = miConfig.Code
  2576. struct3507.SecretKey = miConfig.SecretKey
  2577. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2578. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2579. struct3507.Url = miConfig.Url
  2580. struct3507.AppId = miConfig.Cainfo
  2581. struct3507.AppSecret = miConfig.AppSecret
  2582. struct3507.Enckey = miConfig.EncKey
  2583. struct3507.SignKey = miConfig.SignKey
  2584. struct3507.SecretKey = miConfig.SecretKey
  2585. if miConfig.MdtrtareaAdmvs == "350500" {
  2586. result, result1, _ := service.FJyb3507(struct3507)
  2587. saveLog(result, result1, "3507", "3507")
  2588. var respJSON2 map[string]interface{}
  2589. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2590. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2592. return
  2593. }
  2594. userJSONBytes2, _ := json.Marshal(respJSON2)
  2595. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2596. utils.ErrorLog("解析失败:%v", err)
  2597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2598. return
  2599. }
  2600. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2601. data := make(map[string]interface{})
  2602. data["struct_3507s"] = struct3507
  2603. client := &http.Client{}
  2604. bytesData, _ := json.Marshal(data)
  2605. var req *http.Request
  2606. if miConfig.MdtrtareaAdmvs == "320921" {
  2607. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2608. } else {
  2609. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2610. }
  2611. resp, _ := client.Do(req)
  2612. defer resp.Body.Close()
  2613. body, ioErr := ioutil.ReadAll(resp.Body)
  2614. if ioErr != nil {
  2615. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2616. }
  2617. var respJSON map[string]interface{}
  2618. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2619. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2621. return
  2622. }
  2623. var resSix10265 ResultSix10265 //1101结果
  2624. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2625. result, _ := json.Marshal(respJSON)
  2626. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2627. utils.ErrorLog("解析失败:%v", err)
  2628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2629. return
  2630. }
  2631. res.InfRefmsgid = resSix10265.InfRefmsgid
  2632. //res.Output = resSix10265.Output
  2633. res.ErrMsg = resSix10265.ErrMsg
  2634. res.Cainfo = resSix10265.Cainfo
  2635. res.WarnMsg = resSix10265.WarnMsg
  2636. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2637. res.Infcode = infocode
  2638. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2639. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2640. saveLog(result2, result1, "3507", "3507")
  2641. var respJSON2 map[string]interface{}
  2642. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2643. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2645. return
  2646. }
  2647. userJSONBytes2, _ := json.Marshal(respJSON2)
  2648. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2649. utils.ErrorLog("解析失败:%v", err)
  2650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2651. return
  2652. }
  2653. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2654. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2655. saveLog(result2, result1, "3507", "3507")
  2656. var respJSON2 map[string]interface{}
  2657. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2658. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2660. return
  2661. }
  2662. userJSONBytes2, _ := json.Marshal(respJSON2)
  2663. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2664. utils.ErrorLog("解析失败:%v", err)
  2665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2666. return
  2667. }
  2668. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2669. result1, result2 := service.Jxyb3507(struct3507)
  2670. saveLog(result2, result1, "3507", "3507")
  2671. var respJSON2 map[string]interface{}
  2672. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2675. return
  2676. }
  2677. userJSONBytes2, _ := json.Marshal(respJSON2)
  2678. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2679. utils.ErrorLog("解析失败:%v", err)
  2680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2681. return
  2682. }
  2683. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2684. result1, result2 := service.AHyb3507(struct3507)
  2685. saveLog(result2, result1, "3507", "3507")
  2686. var respJSON2 map[string]interface{}
  2687. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2688. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2690. return
  2691. }
  2692. userJSONBytes2, _ := json.Marshal(respJSON2)
  2693. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2694. utils.ErrorLog("解析失败:%v", err)
  2695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2696. return
  2697. }
  2698. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2699. data := make(map[string]interface{})
  2700. data["struct_3507s"] = struct3507
  2701. client := &http.Client{}
  2702. bytesData, _ := json.Marshal(data)
  2703. var req *http.Request
  2704. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2705. resp, _ := client.Do(req)
  2706. defer resp.Body.Close()
  2707. body, ioErr := ioutil.ReadAll(resp.Body)
  2708. if ioErr != nil {
  2709. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2710. }
  2711. var respJSON map[string]interface{}
  2712. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2713. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2714. }
  2715. var resSix10265 ResultSix10265 //1101结果
  2716. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2717. result, _ := json.Marshal(respJSON)
  2718. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2719. utils.ErrorLog("解析失败:%v", err)
  2720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2721. return
  2722. }
  2723. res.InfRefmsgid = resSix10265.InfRefmsgid
  2724. res.ErrMsg = resSix10265.ErrMsg
  2725. res.Cainfo = resSix10265.Cainfo
  2726. res.WarnMsg = resSix10265.WarnMsg
  2727. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2728. res.Infcode = infocode
  2729. }
  2730. if res.Infcode == 0 {
  2731. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2732. item.IsSale = 0
  2733. item.SaleDate = ""
  2734. item.Bchno = ""
  2735. service.SaveDF(item)
  2736. } else {
  2737. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2738. }
  2739. }
  2740. }
  2741. c.ServeSuccessJSON(map[string]interface{}{
  2742. "msg": "删除销售数据成功",
  2743. })
  2744. }
  2745. // 删除
  2746. func (c *HisApiController) DeleteXSandBGThree() {
  2747. id, _ := c.GetInt64("id")
  2748. admin_user_id, _ := c.GetInt64("admin_user_id")
  2749. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  2750. var flows []*models.DrugFlow
  2751. for _, item := range advicelist {
  2752. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  2753. flows = append(flows, flow...)
  2754. }
  2755. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2756. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2757. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2758. var err []string
  2759. for _, item := range flows {
  2760. if item.IsSale == 1 {
  2761. var res FJ3507Result
  2762. var struct3507 models.Struct3507
  2763. struct3507.FixmedinsBchno = item.Bchno
  2764. struct3507.InvDataType = "4"
  2765. struct3507.Opter = roles.UserName
  2766. struct3507.OrgName = miConfig.OrgName
  2767. struct3507.AccessKey = miConfig.AccessKey
  2768. struct3507.RequestUrl = miConfig.Url
  2769. struct3507.FixmedinsCode = miConfig.Code
  2770. struct3507.SecretKey = miConfig.SecretKey
  2771. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2772. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2773. struct3507.Url = miConfig.Url
  2774. struct3507.AppId = miConfig.Cainfo
  2775. struct3507.AppSecret = miConfig.AppSecret
  2776. struct3507.Enckey = miConfig.EncKey
  2777. struct3507.SignKey = miConfig.SignKey
  2778. struct3507.SecretKey = miConfig.SecretKey
  2779. if miConfig.MdtrtareaAdmvs == "350500" {
  2780. result, result1, _ := service.FJyb3507(struct3507)
  2781. saveLog(result, result1, "3507", "3507")
  2782. var respJSON2 map[string]interface{}
  2783. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2784. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2786. return
  2787. }
  2788. userJSONBytes2, _ := json.Marshal(respJSON2)
  2789. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2790. utils.ErrorLog("解析失败:%v", err)
  2791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2792. return
  2793. }
  2794. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2795. data := make(map[string]interface{})
  2796. data["struct_3507s"] = struct3507
  2797. client := &http.Client{}
  2798. bytesData, _ := json.Marshal(data)
  2799. var req *http.Request
  2800. if miConfig.MdtrtareaAdmvs == "320921" {
  2801. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2802. } else {
  2803. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2804. }
  2805. resp, _ := client.Do(req)
  2806. defer resp.Body.Close()
  2807. body, ioErr := ioutil.ReadAll(resp.Body)
  2808. if ioErr != nil {
  2809. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2810. }
  2811. var respJSON map[string]interface{}
  2812. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2815. return
  2816. }
  2817. var resSix10265 ResultSix10265 //1101结果
  2818. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2819. result, _ := json.Marshal(respJSON)
  2820. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2821. utils.ErrorLog("解析失败:%v", err)
  2822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2823. return
  2824. }
  2825. res.InfRefmsgid = resSix10265.InfRefmsgid
  2826. //res.Output = resSix10265.Output
  2827. res.ErrMsg = resSix10265.ErrMsg
  2828. res.Cainfo = resSix10265.Cainfo
  2829. res.WarnMsg = resSix10265.WarnMsg
  2830. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2831. res.Infcode = infocode
  2832. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2833. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2834. saveLog(result2, result1, "3507", "3507")
  2835. var respJSON2 map[string]interface{}
  2836. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2837. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2839. return
  2840. }
  2841. userJSONBytes2, _ := json.Marshal(respJSON2)
  2842. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2843. utils.ErrorLog("解析失败:%v", err)
  2844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2845. return
  2846. }
  2847. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2848. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2849. saveLog(result2, result1, "3507", "3507")
  2850. var respJSON2 map[string]interface{}
  2851. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2852. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2854. return
  2855. }
  2856. userJSONBytes2, _ := json.Marshal(respJSON2)
  2857. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2858. utils.ErrorLog("解析失败:%v", err)
  2859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2860. return
  2861. }
  2862. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2863. result1, result2 := service.Jxyb3507(struct3507)
  2864. saveLog(result2, result1, "3507", "3507")
  2865. var respJSON2 map[string]interface{}
  2866. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2867. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2869. return
  2870. }
  2871. userJSONBytes2, _ := json.Marshal(respJSON2)
  2872. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2873. utils.ErrorLog("解析失败:%v", err)
  2874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2875. return
  2876. }
  2877. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2878. result1, result2 := service.AHyb3507(struct3507)
  2879. saveLog(result2, result1, "3507", "3507")
  2880. var respJSON2 map[string]interface{}
  2881. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2882. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2884. return
  2885. }
  2886. userJSONBytes2, _ := json.Marshal(respJSON2)
  2887. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2888. utils.ErrorLog("解析失败:%v", err)
  2889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2890. return
  2891. }
  2892. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2893. data := make(map[string]interface{})
  2894. data["struct_3507s"] = struct3507
  2895. client := &http.Client{}
  2896. bytesData, _ := json.Marshal(data)
  2897. var req *http.Request
  2898. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2899. resp, _ := client.Do(req)
  2900. defer resp.Body.Close()
  2901. body, ioErr := ioutil.ReadAll(resp.Body)
  2902. if ioErr != nil {
  2903. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2904. }
  2905. var respJSON map[string]interface{}
  2906. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2907. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2908. }
  2909. var resSix10265 ResultSix10265 //1101结果
  2910. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2911. result, _ := json.Marshal(respJSON)
  2912. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2913. utils.ErrorLog("解析失败:%v", err)
  2914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2915. return
  2916. }
  2917. res.InfRefmsgid = resSix10265.InfRefmsgid
  2918. res.ErrMsg = resSix10265.ErrMsg
  2919. res.Cainfo = resSix10265.Cainfo
  2920. res.WarnMsg = resSix10265.WarnMsg
  2921. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2922. res.Infcode = infocode
  2923. }
  2924. if res.Infcode == 0 {
  2925. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2926. item.IsSale = 0
  2927. item.SaleDate = ""
  2928. item.Bchno = ""
  2929. service.SaveDF(item)
  2930. } else {
  2931. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2932. }
  2933. }
  2934. }
  2935. c.ServeSuccessJSON(map[string]interface{}{
  2936. "msg": "删除销售数据成功",
  2937. })
  2938. }
  2939. // 获取当天起止时间戳
  2940. func GetNowTime() (int64, int64) {
  2941. t := time.Now()
  2942. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  2943. timesamp := addTime.Unix()
  2944. return timesamp, timesamp + 86399
  2945. }
  2946. func (c *HisApiController) ChangeDrugfour() {
  2947. patient_id, _ := c.GetInt64("patient_id")
  2948. admin_user_id, _ := c.GetInt64("admin_user_id")
  2949. times := c.GetString("time", "")
  2950. timeLayout := "2006-01-02"
  2951. loc, _ := time.LoadLocation("Local")
  2952. var stime, etime int64
  2953. if times == "" {
  2954. stime, etime = GetNowTime()
  2955. } else {
  2956. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2957. stime = stmp.Unix()
  2958. etime = stime + 86399
  2959. }
  2960. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2961. var flows []*models.DrugFlow
  2962. for _, item := range advicelist {
  2963. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2964. flows = append(flows, flow...)
  2965. }
  2966. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2967. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2968. var err []string
  2969. for _, item := range flows {
  2970. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  2971. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2972. if prescription.OrderStatus == 2 {
  2973. if item.IsSale == 0 {
  2974. var res FJ3507Result
  2975. var res3507for10188 FJ3507ResultFor10188
  2976. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  2977. //进行商品销售接口
  2978. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2979. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  2980. var respJSON3 map[string]interface{}
  2981. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  2982. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2984. return
  2985. }
  2986. userJSONBytes3, _ := json.Marshal(respJSON3)
  2987. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2988. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2989. utils.ErrorLog("解析失败:%v", err)
  2990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2991. return
  2992. }
  2993. //if res3507for10188.Infcode
  2994. res.InfRefmsgid = res3507for10188.InfRefmsgid
  2995. //res.Output = resSix10265.Output
  2996. res.ErrMsg = res3507for10188.ErrMsg
  2997. res.Cainfo = res3507for10188.Cainfo
  2998. res.WarnMsg = res3507for10188.WarnMsg
  2999. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3000. res.Infcode = infocode
  3001. } else {
  3002. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3003. utils.ErrorLog("解析失败:%v", err)
  3004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3005. return
  3006. }
  3007. }
  3008. if res.Infcode == 0 {
  3009. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3010. item.IsSale = 1
  3011. item.Bchno = number
  3012. item.SaleDate = time.Now().Format("2006-01-02")
  3013. service.SaveDF(item)
  3014. } else {
  3015. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3016. }
  3017. }
  3018. } else { //还没结,提示用户去结算,并药品追溯上传
  3019. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3020. }
  3021. }
  3022. }
  3023. str := strings.Join(err, " ")
  3024. saveLog(str, str, "3505", "3505自动上传日志")
  3025. c.ServeSuccessJSON(map[string]interface{}{
  3026. "status": "1",
  3027. "msg": err,
  3028. })
  3029. }
  3030. func (c *HisApiController) ChangeDrugFive() {
  3031. id, _ := c.GetInt64("id")
  3032. admin_user_id, _ := c.GetInt64("admin_user_id")
  3033. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  3034. var flows []*models.DrugFlow
  3035. for _, item := range advicelist {
  3036. flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3037. flows = append(flows, flow...)
  3038. }
  3039. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3040. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3041. var err []string
  3042. for _, item := range flows {
  3043. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3044. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3045. if prescription.OrderStatus == 2 {
  3046. if item.IsSale == 0 {
  3047. var res FJ3507Result
  3048. var res3507for10188 FJ3507ResultFor10188
  3049. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3050. //进行商品销售接口
  3051. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3052. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3053. var respJSON3 map[string]interface{}
  3054. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3055. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3057. return
  3058. }
  3059. userJSONBytes3, _ := json.Marshal(respJSON3)
  3060. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3061. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3062. utils.ErrorLog("解析失败:%v", err)
  3063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3064. return
  3065. }
  3066. //if res3507for10188.Infcode
  3067. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3068. //res.Output = resSix10265.Output
  3069. res.ErrMsg = res3507for10188.ErrMsg
  3070. res.Cainfo = res3507for10188.Cainfo
  3071. res.WarnMsg = res3507for10188.WarnMsg
  3072. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3073. res.Infcode = infocode
  3074. } else {
  3075. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3076. utils.ErrorLog("解析失败:%v", err)
  3077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3078. return
  3079. }
  3080. }
  3081. if res.Infcode == 0 {
  3082. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3083. item.IsSale = 1
  3084. item.Bchno = number
  3085. item.SaleDate = time.Now().Format("2006-01-02")
  3086. service.SaveDF(item)
  3087. } else {
  3088. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3089. }
  3090. }
  3091. } else { //还没结,提示用户去结算,并药品追溯上传
  3092. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3093. }
  3094. }
  3095. }
  3096. str := strings.Join(err, " ")
  3097. saveLog(str, str, "3505", "3505自动上传日志")
  3098. c.ServeSuccessJSON(map[string]interface{}{
  3099. "status": "1",
  3100. "msg": err,
  3101. })
  3102. }
  3103. //func (c *HisApiController) ChangeDrugfour() {
  3104. // patient_id, _ := c.GetInt64("patient_id")
  3105. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3106. // //id_arr := strings.Split(ids, ",")
  3107. // times := c.GetString("time", "")
  3108. // timeLayout := "2006-01-02"
  3109. // loc, _ := time.LoadLocation("Local")
  3110. // var stime, etime int64
  3111. // if times == "" {
  3112. // stime, etime = GetNowTime()
  3113. // } else {
  3114. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3115. // stime = stmp.Unix()
  3116. // etime = stime + 86399
  3117. // }
  3118. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3119. // var flows []*models.DrugFlow
  3120. // for _, item := range advicelist {
  3121. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3122. // flows = append(flows, flow...)
  3123. // }
  3124. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3125. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3126. // var err []string
  3127. //
  3128. // for _, item := range flows {
  3129. // var res3 ResultSix
  3130. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3131. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3132. // if prescription.OrderStatus == 2 {
  3133. // //已经结算
  3134. // //判断是否已经销售
  3135. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3136. // //是否已经变更 1是 0否
  3137. // if item.IsChange == 0 { //没变更,进行变更操作
  3138. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3139. //
  3140. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3141. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3142. // var respJSON3 map[string]interface{}
  3143. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3144. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3145. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3146. // return
  3147. // }
  3148. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3149. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3150. // utils.ErrorLog("解析失败:%v", err)
  3151. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3152. // return
  3153. // }
  3154. // if res3.Infcode == 0 {
  3155. // item.IsChange = 1
  3156. // item.BgBchno = bg_number
  3157. // service.SaveDF2(item)
  3158. // } else {
  3159. //
  3160. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3161. // }
  3162. // }
  3163. // } else { //没销售,
  3164. // var res FJ3507Result
  3165. // var res3507for10188 FJ3507ResultFor10188
  3166. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3167. //
  3168. // //进行商品销售接口
  3169. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3170. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3171. // var respJSON3 map[string]interface{}
  3172. // if err := json.Unmarshal([]byte(string(result3)), &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. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3186. // //res.Output = resSix10265.Output
  3187. // res.ErrMsg = res3507for10188.ErrMsg
  3188. // res.Cainfo = res3507for10188.Cainfo
  3189. // res.WarnMsg = res3507for10188.WarnMsg
  3190. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3191. // res.Infcode = infocode
  3192. // } else {
  3193. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3194. // utils.ErrorLog("解析失败:%v", err)
  3195. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3196. // return
  3197. // }
  3198. //
  3199. // }
  3200. // if res.Infcode == 0 {
  3201. // item.IsSale = 1
  3202. // item.Bchno = number
  3203. // item.SaleDate = time.Now().Format("2006-01-02")
  3204. //
  3205. // err5 := service.SaveDF(item)
  3206. // if err5 == nil {
  3207. // if item.IsChange == 0 { //没变更,进行变更操作
  3208. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3209. //
  3210. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3211. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3212. //
  3213. // var respJSON3 map[string]interface{}
  3214. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3215. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3216. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3217. // return
  3218. // }
  3219. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3220. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3221. // utils.ErrorLog("解析失败:%v", err)
  3222. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3223. // return
  3224. // }
  3225. // //if res3507for10188.Infcode
  3226. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3227. // //res.Output = resSix10265.Output
  3228. // res3.ErrMsg = res3507for10188.ErrMsg
  3229. // res3.Cainfo = res3507for10188.Cainfo
  3230. // res3.WarnMsg = res3507for10188.WarnMsg
  3231. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3232. // res3.Infcode = infocode
  3233. // } else {
  3234. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3235. // utils.ErrorLog("解析失败:%v", err)
  3236. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3237. // return
  3238. // }
  3239. // }
  3240. // if res3.Infcode == 0 {
  3241. // item.IsChange = 1
  3242. // item.BgBchno = bg_number
  3243. // service.SaveDF2(item)
  3244. // } else {
  3245. //
  3246. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3247. // }
  3248. // }
  3249. // }
  3250. // } else {
  3251. //
  3252. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3253. // }
  3254. // }
  3255. //
  3256. // } else { //还没结,提示用户去结算,并药品追溯上传
  3257. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3258. // }
  3259. // }
  3260. // }
  3261. // if len(err) == 0 {
  3262. // c.ServeSuccessJSON(map[string]interface{}{
  3263. // "msg": "销售变更成功",
  3264. // })
  3265. // } else {
  3266. // c.ServeSuccessJSON(map[string]interface{}{
  3267. // "failed_code": -10,
  3268. // "msg": err,
  3269. // })
  3270. // }
  3271. //}
  3272. func (c *HisApiController) ChangeDrug() {
  3273. ids := c.GetString("ids")
  3274. id_arr := strings.Split(ids, ",")
  3275. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3276. admin_user_id, _ := c.GetInt64("admin_user_id")
  3277. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3278. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3279. var err []string
  3280. for _, item := range flows {
  3281. var res3 ResultSix
  3282. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3283. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3284. if prescription.OrderStatus == 2 {
  3285. //已经结算
  3286. //判断是否已经销售
  3287. if item.IsSale == 1 { //是否已经销售,1是 0否
  3288. //是否已经变更 1是 0否
  3289. if item.IsChange == 0 { //没变更,进行变更操作
  3290. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3291. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3292. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3293. var respJSON3 map[string]interface{}
  3294. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3297. return
  3298. }
  3299. userJSONBytes3, _ := json.Marshal(respJSON3)
  3300. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3301. utils.ErrorLog("解析失败:%v", err)
  3302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3303. return
  3304. }
  3305. if res3.Infcode == 0 {
  3306. item.IsChange = 1
  3307. item.BgBchno = bg_number
  3308. service.SaveDF2(item)
  3309. } else {
  3310. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3311. }
  3312. }
  3313. } else { //没销售,
  3314. var res FJ3507Result
  3315. var res3507for10188 FJ3507ResultFor10188
  3316. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3317. //进行商品销售接口
  3318. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3319. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3320. var respJSON3 map[string]interface{}
  3321. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3324. return
  3325. }
  3326. userJSONBytes3, _ := json.Marshal(respJSON3)
  3327. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3328. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3329. utils.ErrorLog("解析失败:%v", err)
  3330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3331. return
  3332. }
  3333. //if res3507for10188.Infcode
  3334. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3335. //res.Output = resSix10265.Output
  3336. res.ErrMsg = res3507for10188.ErrMsg
  3337. res.Cainfo = res3507for10188.Cainfo
  3338. res.WarnMsg = res3507for10188.WarnMsg
  3339. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3340. res.Infcode = infocode
  3341. } else {
  3342. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3343. utils.ErrorLog("解析失败:%v", err)
  3344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3345. return
  3346. }
  3347. }
  3348. if res.Infcode == 0 {
  3349. item.IsSale = 1
  3350. item.Bchno = number
  3351. item.SaleDate = time.Now().Format("2006-01-02")
  3352. err5 := service.SaveDF(item)
  3353. if err5 == nil {
  3354. if item.IsChange == 0 { //没变更,进行变更操作
  3355. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3356. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3357. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3358. var respJSON3 map[string]interface{}
  3359. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3362. return
  3363. }
  3364. userJSONBytes3, _ := json.Marshal(respJSON3)
  3365. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3366. utils.ErrorLog("解析失败:%v", err)
  3367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3368. return
  3369. }
  3370. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3371. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3372. utils.ErrorLog("解析失败:%v", err)
  3373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3374. return
  3375. }
  3376. //if res3507for10188.Infcode
  3377. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3378. //res.Output = resSix10265.Output
  3379. res3.ErrMsg = res3507for10188.ErrMsg
  3380. res3.Cainfo = res3507for10188.Cainfo
  3381. res3.WarnMsg = res3507for10188.WarnMsg
  3382. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3383. res3.Infcode = infocode
  3384. } else {
  3385. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3386. utils.ErrorLog("解析失败:%v", err)
  3387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3388. return
  3389. }
  3390. }
  3391. if res3.Infcode == 0 {
  3392. item.IsChange = 1
  3393. item.BgBchno = bg_number
  3394. service.SaveDF2(item)
  3395. } else {
  3396. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3397. }
  3398. }
  3399. }
  3400. } else {
  3401. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3402. }
  3403. }
  3404. } else { //还没结算
  3405. var res3507for10188 FJ3507ResultFor10188
  3406. if item.IsChange == 0 { //没变更,进行变更操作
  3407. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3408. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3409. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3410. var respJSON3 map[string]interface{}
  3411. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3414. return
  3415. }
  3416. userJSONBytes3, _ := json.Marshal(respJSON3)
  3417. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3418. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3419. utils.ErrorLog("解析失败:%v", err)
  3420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3421. return
  3422. }
  3423. //if res3507for10188.Infcode
  3424. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3425. //res.Output = resSix10265.Output
  3426. res3.ErrMsg = res3507for10188.ErrMsg
  3427. res3.Cainfo = res3507for10188.Cainfo
  3428. res3.WarnMsg = res3507for10188.WarnMsg
  3429. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3430. res3.Infcode = infocode
  3431. } else {
  3432. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3433. utils.ErrorLog("解析失败:%v", err)
  3434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3435. return
  3436. }
  3437. }
  3438. if res3.Infcode == 0 {
  3439. item.IsChange = 1
  3440. item.BgBchno = bg_number
  3441. service.SaveDF2(item)
  3442. } else {
  3443. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3444. }
  3445. }
  3446. }
  3447. } else if item.ConsumableType == 7 {
  3448. var res3507for10188 FJ3507ResultFor10188
  3449. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3450. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3451. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3452. //判断是否已经销售
  3453. if item.IsSale == 2 { //是否已经销售,1是 0否
  3454. //是否已经变更 1是 0否
  3455. if item.IsChange == 0 { //没变更,进行变更操作
  3456. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3457. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3458. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3459. var respJSON3 map[string]interface{}
  3460. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3461. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3463. return
  3464. }
  3465. userJSONBytes3, _ := json.Marshal(respJSON3)
  3466. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3467. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3468. utils.ErrorLog("解析失败:%v", err)
  3469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3470. return
  3471. }
  3472. //if res3507for10188.Infcode
  3473. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3474. //res.Output = resSix10265.Output
  3475. res3.ErrMsg = res3507for10188.ErrMsg
  3476. res3.Cainfo = res3507for10188.Cainfo
  3477. res3.WarnMsg = res3507for10188.WarnMsg
  3478. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3479. res3.Infcode = infocode
  3480. } else {
  3481. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3482. utils.ErrorLog("解析失败:%v", err)
  3483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3484. return
  3485. }
  3486. }
  3487. if res3.Infcode == 0 {
  3488. item.IsChange = 1
  3489. item.BgBchno = bg_number
  3490. service.SaveDF2(item)
  3491. } else {
  3492. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3493. }
  3494. }
  3495. } else { //没销售,
  3496. //进行商品销售退货接口
  3497. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3498. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3499. saveLog(result111, result222, "3506", "销售退货")
  3500. var res7 FJ3507Result
  3501. //进行商品销售接口
  3502. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3503. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3504. var respJSON3 map[string]interface{}
  3505. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3508. return
  3509. }
  3510. userJSONBytes3, _ := json.Marshal(respJSON3)
  3511. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3512. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3513. utils.ErrorLog("解析失败:%v", err)
  3514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3515. return
  3516. }
  3517. //if res3507for10188.Infcode
  3518. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3519. //res.Output = resSix10265.Output
  3520. res7.ErrMsg = res3507for10188.ErrMsg
  3521. res7.Cainfo = res3507for10188.Cainfo
  3522. res7.WarnMsg = res3507for10188.WarnMsg
  3523. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3524. res7.Infcode = infocode
  3525. } else {
  3526. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3527. utils.ErrorLog("解析失败:%v", err)
  3528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3529. return
  3530. }
  3531. }
  3532. if res7.Infcode == 0 {
  3533. item.IsSale = 2
  3534. item.SaleDate = item.SaleDate
  3535. item.Bchno = number
  3536. service.SaveDF(item)
  3537. if item.IsChange == 0 { //没变更,进行变更操作
  3538. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3539. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3540. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3541. var respJSON3 map[string]interface{}
  3542. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3543. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3545. return
  3546. }
  3547. userJSONBytes3, _ := json.Marshal(respJSON3)
  3548. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3549. // utils.ErrorLog("解析失败:%v", err)
  3550. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3551. // return
  3552. //}
  3553. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3554. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3555. utils.ErrorLog("解析失败:%v", err)
  3556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3557. return
  3558. }
  3559. //if res3507for10188.Infcode
  3560. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3561. //res.Output = resSix10265.Output
  3562. res3.ErrMsg = res3507for10188.ErrMsg
  3563. res3.Cainfo = res3507for10188.Cainfo
  3564. res3.WarnMsg = res3507for10188.WarnMsg
  3565. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3566. res3.Infcode = infocode
  3567. } else {
  3568. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3569. utils.ErrorLog("解析失败:%v", err)
  3570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3571. return
  3572. }
  3573. }
  3574. if res3.Infcode == 0 {
  3575. item.IsChange = 1
  3576. item.BgBchno = bg_number
  3577. service.SaveDF2(item)
  3578. } else {
  3579. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3580. }
  3581. }
  3582. } else {
  3583. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3584. }
  3585. }
  3586. } else { //还没结算
  3587. if item.IsChange == 0 { //没变更,进行变更操作
  3588. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3589. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3590. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3591. var respJSON3 map[string]interface{}
  3592. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3593. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3595. return
  3596. }
  3597. userJSONBytes3, _ := json.Marshal(respJSON3)
  3598. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3599. // utils.ErrorLog("解析失败:%v", err)
  3600. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3601. // return
  3602. //}
  3603. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3604. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3605. utils.ErrorLog("解析失败:%v", err)
  3606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3607. return
  3608. }
  3609. //if res3507for10188.Infcode
  3610. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3611. //res.Output = resSix10265.Output
  3612. res3.ErrMsg = res3507for10188.ErrMsg
  3613. res3.Cainfo = res3507for10188.Cainfo
  3614. res3.WarnMsg = res3507for10188.WarnMsg
  3615. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3616. res3.Infcode = infocode
  3617. } else {
  3618. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3619. utils.ErrorLog("解析失败:%v", err)
  3620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3621. return
  3622. }
  3623. }
  3624. if res3.Infcode == 0 {
  3625. item.IsChange = 1
  3626. item.BgBchno = bg_number
  3627. service.SaveDF2(item)
  3628. } else {
  3629. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3630. }
  3631. }
  3632. }
  3633. }
  3634. }
  3635. if len(err) == 0 {
  3636. c.ServeSuccessJSON(map[string]interface{}{
  3637. "msg": "销售变更成功",
  3638. })
  3639. } else {
  3640. c.ServeSuccessJSON(map[string]interface{}{
  3641. "failed_code": -10,
  3642. "msg": err,
  3643. })
  3644. }
  3645. }
  3646. func (c *HisApiController) ChangeDrugtwo() {
  3647. //ids := c.GetString("ids")
  3648. //id_arr := strings.Split(ids, ",")
  3649. flows, _ := service.GetNewDrugFlowInfothree123()
  3650. admin_user_id, _ := c.GetInt64("admin_user_id")
  3651. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3652. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3653. var err []string
  3654. for _, item := range flows {
  3655. var res3 ResultSix
  3656. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3657. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3658. if prescription.OrderStatus == 2 {
  3659. //已经结算
  3660. //判断是否已经销售
  3661. //if item.IsSale == 1 { //是否已经销售,1是 0否
  3662. // //是否已经变更 1是 0否
  3663. // if item.IsChange == 0 { //没变更,进行变更操作
  3664. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3665. //
  3666. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3667. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3668. // var respJSON3 map[string]interface{}
  3669. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3670. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3671. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3672. // return
  3673. // }
  3674. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3675. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3676. // utils.ErrorLog("解析失败:%v", err)
  3677. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3678. // return
  3679. // }
  3680. // if res3.Infcode == 0 {
  3681. // item.IsChange = 1
  3682. // item.BgBchno = bg_number
  3683. // service.SaveDF2(item)
  3684. // } else {
  3685. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3686. // }
  3687. // }
  3688. //}
  3689. //else
  3690. { //没销售,
  3691. var res FJ3507Result
  3692. var res3507for10188 FJ3507ResultFor10188
  3693. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3694. //进行商品销售接口
  3695. result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3696. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3697. var respJSON3 map[string]interface{}
  3698. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3699. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3701. return
  3702. }
  3703. userJSONBytes3, _ := json.Marshal(respJSON3)
  3704. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3705. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3706. utils.ErrorLog("解析失败:%v", err)
  3707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3708. return
  3709. }
  3710. //if res3507for10188.Infcode
  3711. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3712. //res.Output = resSix10265.Output
  3713. res.ErrMsg = res3507for10188.ErrMsg
  3714. res.Cainfo = res3507for10188.Cainfo
  3715. res.WarnMsg = res3507for10188.WarnMsg
  3716. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3717. res.Infcode = infocode
  3718. } else {
  3719. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3720. utils.ErrorLog("解析失败:%v", err)
  3721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3722. return
  3723. }
  3724. }
  3725. if res.Infcode == 0 {
  3726. item.IsSale = 1
  3727. item.Bchno = number
  3728. item.SaleDate = time.Now().Format("2006-01-02")
  3729. service.SaveDF(item)
  3730. //if err5 == nil {
  3731. // if item.IsChange == 0 { //没变更,进行变更操作
  3732. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3733. //
  3734. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3735. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3736. //
  3737. // var respJSON3 map[string]interface{}
  3738. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3739. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3740. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3741. // return
  3742. // }
  3743. //
  3744. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3745. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3746. // utils.ErrorLog("解析失败:%v", err)
  3747. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3748. // return
  3749. // }
  3750. // //if res3507for10188.Infcode
  3751. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3752. // //res.Output = resSix10265.Output
  3753. // res3.ErrMsg = res3507for10188.ErrMsg
  3754. // res3.Cainfo = res3507for10188.Cainfo
  3755. // res3.WarnMsg = res3507for10188.WarnMsg
  3756. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3757. // res3.Infcode = infocode
  3758. // } else {
  3759. //
  3760. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3761. // utils.ErrorLog("解析失败:%v", err)
  3762. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3763. // return
  3764. // }
  3765. //
  3766. // }
  3767. //
  3768. // if res3.Infcode == 0 {
  3769. // item.IsChange = 1
  3770. // item.BgBchno = bg_number
  3771. // service.SaveDF2(item)
  3772. // } else {
  3773. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3774. // }
  3775. // }
  3776. //}
  3777. } else {
  3778. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3779. }
  3780. }
  3781. } else { //还没结算
  3782. var res3507for10188 FJ3507ResultFor10188
  3783. if item.IsChange == 0 { //没变更,进行变更操作
  3784. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3785. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3786. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3787. var respJSON3 map[string]interface{}
  3788. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3789. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3791. return
  3792. }
  3793. userJSONBytes3, _ := json.Marshal(respJSON3)
  3794. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3795. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3796. utils.ErrorLog("解析失败:%v", err)
  3797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3798. return
  3799. }
  3800. //if res3507for10188.Infcode
  3801. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3802. //res.Output = resSix10265.Output
  3803. res3.ErrMsg = res3507for10188.ErrMsg
  3804. res3.Cainfo = res3507for10188.Cainfo
  3805. res3.WarnMsg = res3507for10188.WarnMsg
  3806. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3807. res3.Infcode = infocode
  3808. } else {
  3809. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3810. utils.ErrorLog("解析失败:%v", err)
  3811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3812. return
  3813. }
  3814. }
  3815. if res3.Infcode == 0 {
  3816. item.IsChange = 1
  3817. item.BgBchno = bg_number
  3818. service.SaveDF2(item)
  3819. } else {
  3820. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3821. }
  3822. }
  3823. }
  3824. }
  3825. //if item.ConsumableType == 7 {
  3826. // var res3507for10188 FJ3507ResultFor10188
  3827. //
  3828. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3829. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3830. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3831. // //判断是否已经销售
  3832. // if item.IsSale == 2 { //是否已经销售,1是 0否
  3833. // //是否已经变更 1是 0否
  3834. // if item.IsChange == 0 { //没变更,进行变更操作
  3835. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3836. //
  3837. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3838. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3839. //
  3840. // var respJSON3 map[string]interface{}
  3841. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3842. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3843. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3844. // return
  3845. // }
  3846. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3847. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3848. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3849. // utils.ErrorLog("解析失败:%v", err)
  3850. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3851. // return
  3852. // }
  3853. // //if res3507for10188.Infcode
  3854. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3855. // //res.Output = resSix10265.Output
  3856. // res3.ErrMsg = res3507for10188.ErrMsg
  3857. // res3.Cainfo = res3507for10188.Cainfo
  3858. // res3.WarnMsg = res3507for10188.WarnMsg
  3859. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3860. // res3.Infcode = infocode
  3861. // } else {
  3862. //
  3863. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3864. // utils.ErrorLog("解析失败:%v", err)
  3865. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3866. // return
  3867. // }
  3868. //
  3869. // }
  3870. // if res3.Infcode == 0 {
  3871. // item.IsChange = 1
  3872. // item.BgBchno = bg_number
  3873. // service.SaveDF2(item)
  3874. // } else {
  3875. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3876. // }
  3877. // }
  3878. // } else { //没销售,
  3879. // //进行商品销售退货接口
  3880. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3881. //
  3882. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3883. // saveLog(result111, result222, "3506", "销售退货")
  3884. // var res7 FJ3507Result
  3885. //
  3886. // //进行商品销售接口
  3887. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3888. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3889. // var respJSON3 map[string]interface{}
  3890. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3891. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3892. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3893. // return
  3894. // }
  3895. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3896. //
  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. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3905. // //res.Output = resSix10265.Output
  3906. // res7.ErrMsg = res3507for10188.ErrMsg
  3907. // res7.Cainfo = res3507for10188.Cainfo
  3908. // res7.WarnMsg = res3507for10188.WarnMsg
  3909. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3910. // res7.Infcode = infocode
  3911. // } else {
  3912. //
  3913. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3914. // utils.ErrorLog("解析失败:%v", err)
  3915. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3916. // return
  3917. // }
  3918. //
  3919. // }
  3920. // if res7.Infcode == 0 {
  3921. // item.IsSale = 2
  3922. // item.SaleDate = item.SaleDate
  3923. // item.Bchno = number
  3924. // service.SaveDF(item)
  3925. // if item.IsChange == 0 { //没变更,进行变更操作
  3926. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3927. //
  3928. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3929. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3930. //
  3931. // var respJSON3 map[string]interface{}
  3932. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3933. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3934. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3935. // return
  3936. // }
  3937. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3938. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3939. // // utils.ErrorLog("解析失败:%v", err)
  3940. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3941. // // return
  3942. // //}
  3943. //
  3944. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3945. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3946. // utils.ErrorLog("解析失败:%v", err)
  3947. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3948. // return
  3949. // }
  3950. // //if res3507for10188.Infcode
  3951. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3952. // //res.Output = resSix10265.Output
  3953. // res3.ErrMsg = res3507for10188.ErrMsg
  3954. // res3.Cainfo = res3507for10188.Cainfo
  3955. // res3.WarnMsg = res3507for10188.WarnMsg
  3956. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3957. // res3.Infcode = infocode
  3958. // } else {
  3959. //
  3960. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3961. // utils.ErrorLog("解析失败:%v", err)
  3962. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3963. // return
  3964. // }
  3965. //
  3966. // }
  3967. // if res3.Infcode == 0 {
  3968. // item.IsChange = 1
  3969. // item.BgBchno = bg_number
  3970. // service.SaveDF2(item)
  3971. // } else {
  3972. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3973. // }
  3974. // }
  3975. // } else {
  3976. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3977. // }
  3978. // }
  3979. // } else { //还没结算
  3980. // if item.IsChange == 0 { //没变更,进行变更操作
  3981. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3982. //
  3983. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3984. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3985. //
  3986. // var respJSON3 map[string]interface{}
  3987. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3988. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3989. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3990. // return
  3991. // }
  3992. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3993. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3994. // // utils.ErrorLog("解析失败:%v", err)
  3995. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3996. // // return
  3997. // //}
  3998. //
  3999. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4000. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4001. // utils.ErrorLog("解析失败:%v", err)
  4002. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4003. // return
  4004. // }
  4005. // //if res3507for10188.Infcode
  4006. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4007. // //res.Output = resSix10265.Output
  4008. // res3.ErrMsg = res3507for10188.ErrMsg
  4009. // res3.Cainfo = res3507for10188.Cainfo
  4010. // res3.WarnMsg = res3507for10188.WarnMsg
  4011. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4012. // res3.Infcode = infocode
  4013. // } else {
  4014. //
  4015. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4016. // utils.ErrorLog("解析失败:%v", err)
  4017. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4018. // return
  4019. // }
  4020. //
  4021. // }
  4022. // if res3.Infcode == 0 {
  4023. // item.IsChange = 1
  4024. // item.BgBchno = bg_number
  4025. // service.SaveDF2(item)
  4026. // } else {
  4027. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4028. // }
  4029. // }
  4030. // }
  4031. //}
  4032. }
  4033. if len(err) == 0 {
  4034. c.ServeSuccessJSON(map[string]interface{}{
  4035. "msg": "销售变更成功",
  4036. })
  4037. } else {
  4038. c.ServeSuccessJSON(map[string]interface{}{
  4039. "failed_code": -10,
  4040. "msg": err,
  4041. })
  4042. }
  4043. }
  4044. func (c *HisApiController) ChangeDrugthree() {
  4045. //ids := c.GetString("ids")
  4046. //id_arr := strings.Split(ids, ",")
  4047. flows, _ := service.GetNewDrugFlowInfothree()
  4048. admin_user_id, _ := c.GetInt64("admin_user_id")
  4049. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4050. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4051. var err []string
  4052. for _, item := range flows {
  4053. var res3 ResultSix
  4054. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4055. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4056. if prescription.OrderStatus == 2 {
  4057. //已经结算
  4058. //判断是否已经销售
  4059. if item.IsSale == 1 { //是否已经销售,1是 0否
  4060. //是否已经变更 1是 0否
  4061. if item.IsChange == 0 { //没变更,进行变更操作
  4062. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4063. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4064. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4065. var respJSON3 map[string]interface{}
  4066. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4067. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4069. return
  4070. }
  4071. userJSONBytes3, _ := json.Marshal(respJSON3)
  4072. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4073. utils.ErrorLog("解析失败:%v", err)
  4074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4075. return
  4076. }
  4077. if res3.Infcode == 0 {
  4078. item.IsChange = 1
  4079. item.BgBchno = bg_number
  4080. service.SaveDF2(item)
  4081. } else {
  4082. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4083. }
  4084. }
  4085. } else { //没销售,
  4086. var res FJ3507Result
  4087. var res3507for10188 FJ3507ResultFor10188
  4088. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4089. //进行商品销售接口
  4090. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4091. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4092. var respJSON3 map[string]interface{}
  4093. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4094. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4096. return
  4097. }
  4098. userJSONBytes3, _ := json.Marshal(respJSON3)
  4099. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4100. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4101. utils.ErrorLog("解析失败:%v", err)
  4102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4103. return
  4104. }
  4105. //if res3507for10188.Infcode
  4106. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4107. //res.Output = resSix10265.Output
  4108. res.ErrMsg = res3507for10188.ErrMsg
  4109. res.Cainfo = res3507for10188.Cainfo
  4110. res.WarnMsg = res3507for10188.WarnMsg
  4111. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4112. res.Infcode = infocode
  4113. } else {
  4114. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4115. utils.ErrorLog("解析失败:%v", err)
  4116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4117. return
  4118. }
  4119. }
  4120. if res.Infcode == 0 {
  4121. item.IsSale = 1
  4122. item.Bchno = number
  4123. item.SaleDate = time.Now().Format("2006-01-02")
  4124. err5 := service.SaveDF(item)
  4125. if err5 == nil {
  4126. if item.IsChange == 0 { //没变更,进行变更操作
  4127. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4128. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4129. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4130. var respJSON3 map[string]interface{}
  4131. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4134. return
  4135. }
  4136. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4137. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4138. utils.ErrorLog("解析失败:%v", err)
  4139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4140. return
  4141. }
  4142. //if res3507for10188.Infcode
  4143. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4144. //res.Output = resSix10265.Output
  4145. res3.ErrMsg = res3507for10188.ErrMsg
  4146. res3.Cainfo = res3507for10188.Cainfo
  4147. res3.WarnMsg = res3507for10188.WarnMsg
  4148. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4149. res3.Infcode = infocode
  4150. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4151. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4152. utils.ErrorLog("解析失败:%v", err)
  4153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4154. return
  4155. }
  4156. //if res3507for10188.Infcode
  4157. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4158. //res.Output = resSix10265.Output
  4159. res3.ErrMsg = res3507for10188.ErrMsg
  4160. res3.Cainfo = res3507for10188.Cainfo
  4161. res3.WarnMsg = res3507for10188.WarnMsg
  4162. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4163. res3.Infcode = infocode
  4164. } else {
  4165. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4166. utils.ErrorLog("解析失败:%v", err)
  4167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4168. return
  4169. }
  4170. }
  4171. if res3.Infcode == 0 {
  4172. item.IsChange = 1
  4173. item.BgBchno = bg_number
  4174. service.SaveDF2(item)
  4175. } else {
  4176. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4177. }
  4178. }
  4179. }
  4180. } else {
  4181. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4182. }
  4183. }
  4184. } else { //还没结算
  4185. var res3507for10188 FJ3507ResultFor10188
  4186. if item.IsChange == 0 { //没变更,进行变更操作
  4187. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4188. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4189. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4190. var respJSON3 map[string]interface{}
  4191. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4194. return
  4195. }
  4196. userJSONBytes3, _ := json.Marshal(respJSON3)
  4197. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4198. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4199. utils.ErrorLog("解析失败:%v", err)
  4200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4201. return
  4202. }
  4203. //if res3507for10188.Infcode
  4204. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4205. //res.Output = resSix10265.Output
  4206. res3.ErrMsg = res3507for10188.ErrMsg
  4207. res3.Cainfo = res3507for10188.Cainfo
  4208. res3.WarnMsg = res3507for10188.WarnMsg
  4209. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4210. res3.Infcode = infocode
  4211. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4212. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4213. utils.ErrorLog("解析失败:%v", err)
  4214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4215. return
  4216. }
  4217. //if res3507for10188.Infcode
  4218. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4219. //res.Output = resSix10265.Output
  4220. res3.ErrMsg = res3507for10188.ErrMsg
  4221. res3.Cainfo = res3507for10188.Cainfo
  4222. res3.WarnMsg = res3507for10188.WarnMsg
  4223. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4224. res3.Infcode = infocode
  4225. } else {
  4226. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4227. utils.ErrorLog("解析失败:%v", err)
  4228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4229. return
  4230. }
  4231. }
  4232. if res3.Infcode == 0 {
  4233. item.IsChange = 1
  4234. item.BgBchno = bg_number
  4235. service.SaveDF2(item)
  4236. } else {
  4237. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4238. }
  4239. }
  4240. }
  4241. } else if item.ConsumableType == 7 {
  4242. var res3507for10188 FJ3507ResultFor10188
  4243. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4244. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4245. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4246. //判断是否已经销售
  4247. if item.IsSale == 2 { //是否已经销售,1是 0否
  4248. //是否已经变更 1是 0否
  4249. if item.IsChange == 0 { //没变更,进行变更操作
  4250. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4251. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4252. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4253. var respJSON3 map[string]interface{}
  4254. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4255. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4257. return
  4258. }
  4259. userJSONBytes3, _ := json.Marshal(respJSON3)
  4260. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4261. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4262. utils.ErrorLog("解析失败:%v", err)
  4263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4264. return
  4265. }
  4266. //if res3507for10188.Infcode
  4267. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4268. //res.Output = resSix10265.Output
  4269. res3.ErrMsg = res3507for10188.ErrMsg
  4270. res3.Cainfo = res3507for10188.Cainfo
  4271. res3.WarnMsg = res3507for10188.WarnMsg
  4272. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4273. res3.Infcode = infocode
  4274. } else {
  4275. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4276. utils.ErrorLog("解析失败:%v", err)
  4277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4278. return
  4279. }
  4280. }
  4281. if res3.Infcode == 0 {
  4282. item.IsChange = 1
  4283. item.BgBchno = bg_number
  4284. service.SaveDF2(item)
  4285. } else {
  4286. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4287. }
  4288. }
  4289. } else { //没销售,
  4290. //进行商品销售退货接口
  4291. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4292. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4293. saveLog(result111, result222, "3506", "销售退货")
  4294. var res7 FJ3507Result
  4295. //进行商品销售接口
  4296. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4297. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4298. var respJSON3 map[string]interface{}
  4299. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4300. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4302. return
  4303. }
  4304. userJSONBytes3, _ := json.Marshal(respJSON3)
  4305. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4306. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4307. utils.ErrorLog("解析失败:%v", err)
  4308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4309. return
  4310. }
  4311. //if res3507for10188.Infcode
  4312. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4313. //res.Output = resSix10265.Output
  4314. res7.ErrMsg = res3507for10188.ErrMsg
  4315. res7.Cainfo = res3507for10188.Cainfo
  4316. res7.WarnMsg = res3507for10188.WarnMsg
  4317. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4318. res7.Infcode = infocode
  4319. } else {
  4320. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4321. utils.ErrorLog("解析失败:%v", err)
  4322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4323. return
  4324. }
  4325. }
  4326. if res7.Infcode == 0 {
  4327. item.IsSale = 2
  4328. item.SaleDate = item.SaleDate
  4329. item.Bchno = number
  4330. service.SaveDF(item)
  4331. if item.IsChange == 0 { //没变更,进行变更操作
  4332. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4333. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4334. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4335. var respJSON3 map[string]interface{}
  4336. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4337. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4339. return
  4340. }
  4341. userJSONBytes3, _ := json.Marshal(respJSON3)
  4342. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4343. // utils.ErrorLog("解析失败:%v", err)
  4344. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4345. // return
  4346. //}
  4347. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4348. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4349. utils.ErrorLog("解析失败:%v", err)
  4350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4351. return
  4352. }
  4353. //if res3507for10188.Infcode
  4354. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4355. //res.Output = resSix10265.Output
  4356. res3.ErrMsg = res3507for10188.ErrMsg
  4357. res3.Cainfo = res3507for10188.Cainfo
  4358. res3.WarnMsg = res3507for10188.WarnMsg
  4359. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4360. res3.Infcode = infocode
  4361. } else {
  4362. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4363. utils.ErrorLog("解析失败:%v", err)
  4364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4365. return
  4366. }
  4367. }
  4368. if res3.Infcode == 0 {
  4369. item.IsChange = 1
  4370. item.BgBchno = bg_number
  4371. service.SaveDF2(item)
  4372. } else {
  4373. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4374. }
  4375. }
  4376. } else {
  4377. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4378. }
  4379. }
  4380. } else { //还没结算
  4381. if item.IsChange == 0 { //没变更,进行变更操作
  4382. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4383. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4384. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4385. var respJSON3 map[string]interface{}
  4386. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4387. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4389. return
  4390. }
  4391. userJSONBytes3, _ := json.Marshal(respJSON3)
  4392. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4393. // utils.ErrorLog("解析失败:%v", err)
  4394. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4395. // return
  4396. //}
  4397. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4398. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4399. utils.ErrorLog("解析失败:%v", err)
  4400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4401. return
  4402. }
  4403. //if res3507for10188.Infcode
  4404. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4405. //res.Output = resSix10265.Output
  4406. res3.ErrMsg = res3507for10188.ErrMsg
  4407. res3.Cainfo = res3507for10188.Cainfo
  4408. res3.WarnMsg = res3507for10188.WarnMsg
  4409. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4410. res3.Infcode = infocode
  4411. } else {
  4412. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4413. utils.ErrorLog("解析失败:%v", err)
  4414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4415. return
  4416. }
  4417. }
  4418. if res3.Infcode == 0 {
  4419. item.IsChange = 1
  4420. item.BgBchno = bg_number
  4421. service.SaveDF2(item)
  4422. } else {
  4423. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4424. }
  4425. }
  4426. }
  4427. }
  4428. }
  4429. if len(err) == 0 {
  4430. c.ServeSuccessJSON(map[string]interface{}{
  4431. "msg": "销售变更成功",
  4432. })
  4433. } else {
  4434. c.ServeSuccessJSON(map[string]interface{}{
  4435. "failed_code": -10,
  4436. "msg": err,
  4437. })
  4438. }
  4439. }
  4440. func (c *HisApiController) ChangeDrugTen() {
  4441. start_time_str := c.GetString("start_time")
  4442. end_time_str := c.GetString("end_time")
  4443. //ids := c.GetString("ids")
  4444. //id_arr := strings.Split(ids, ",")
  4445. timeLayout := "2006-01-02"
  4446. loc, _ := time.LoadLocation("Local")
  4447. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4448. recordStartTime := theStartTime.Unix()
  4449. theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4450. recordEndTime := theEndTime.Unix()
  4451. //timestamp := int64(1729612800)
  4452. flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4453. admin_user_id, _ := c.GetInt64("admin_user_id")
  4454. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4455. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4456. var err []string
  4457. for _, item := range flows {
  4458. var res3 ResultSix
  4459. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4460. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4461. continue
  4462. }
  4463. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4464. continue
  4465. }
  4466. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4467. if prescription.OrderStatus == 2 {
  4468. //已经结算
  4469. //判断 是否已经销售
  4470. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4471. ////是否已经变更 1是 0否
  4472. //if item.IsChange == 0 { //没变更,进行变更操作
  4473. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4474. //
  4475. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4476. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4477. // var respJSON3 map[string]interface{}
  4478. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4479. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4480. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4481. // return
  4482. // }
  4483. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4484. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4485. // utils.ErrorLog("解析失败:%v", err)
  4486. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4487. // return
  4488. // }
  4489. // if res3.Infcode == 0 {
  4490. // item.IsChange = 1
  4491. // item.BgBchno = bg_number
  4492. // service.SaveDF2(item)
  4493. // } else {
  4494. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4495. // }
  4496. //}
  4497. //} else
  4498. if item.IsSale == 0 { //没销售,
  4499. var res FJ3507Result
  4500. var res3507for10188 FJ3507ResultFor10188
  4501. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4502. //进行商品销售接口
  4503. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4504. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4505. var respJSON3 map[string]interface{}
  4506. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4509. return
  4510. }
  4511. userJSONBytes3, _ := json.Marshal(respJSON3)
  4512. if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4513. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4514. utils.ErrorLog("解析失败:%v", err)
  4515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4516. return
  4517. }
  4518. //if res3507for10188.Infcode
  4519. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4520. //res.Output = resSix10265.Output
  4521. res.ErrMsg = res3507for10188.ErrMsg
  4522. res.Cainfo = res3507for10188.Cainfo
  4523. res.WarnMsg = res3507for10188.WarnMsg
  4524. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4525. res.Infcode = infocode
  4526. } else if c.GetAdminUserInfo().CurrentOrgId == 10480 {
  4527. } else {
  4528. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4529. utils.ErrorLog("解析失败:%v", err)
  4530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4531. return
  4532. }
  4533. }
  4534. if res.Infcode == 0 {
  4535. item.IsSale = 1
  4536. item.Bchno = number
  4537. item.SaleDate = time.Now().Format("2006-01-02")
  4538. err5 := service.SaveDF(item)
  4539. utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  4540. //if err5 == nil {
  4541. //
  4542. // if item.IsChange == 1 { //没变更,进行变更操作
  4543. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4544. //
  4545. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4546. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4547. //
  4548. // var respJSON3 map[string]interface{}
  4549. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4550. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4551. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4552. // return
  4553. // }
  4554. //
  4555. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4556. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4557. // utils.ErrorLog("解析失败:%v", err)
  4558. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4559. // return
  4560. // }
  4561. // //if res3507for10188.Infcode
  4562. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4563. // //res.Output = resSix10265.Output
  4564. // res3.ErrMsg = res3507for10188.ErrMsg
  4565. // res3.Cainfo = res3507for10188.Cainfo
  4566. // res3.WarnMsg = res3507for10188.WarnMsg
  4567. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4568. // res3.Infcode = infocode
  4569. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4570. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4571. // utils.ErrorLog("解析失败:%v", err)
  4572. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4573. // return
  4574. // }
  4575. // //if res3507for10188.Infcode
  4576. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4577. // //res.Output = resSix10265.Output
  4578. // res3.ErrMsg = res3507for10188.ErrMsg
  4579. // res3.Cainfo = res3507for10188.Cainfo
  4580. // res3.WarnMsg = res3507for10188.WarnMsg
  4581. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4582. // res3.Infcode = infocode
  4583. //
  4584. // } else {
  4585. //
  4586. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4587. // utils.ErrorLog("解析失败:%v", err)
  4588. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4589. // return
  4590. // }
  4591. //
  4592. // }
  4593. //
  4594. // if res3.Infcode == 0 {
  4595. // item.IsChange = 1
  4596. // item.BgBchno = bg_number
  4597. // service.SaveDF2(item)
  4598. // return
  4599. // } else {
  4600. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4601. // }
  4602. // }
  4603. //}
  4604. } else {
  4605. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4606. }
  4607. }
  4608. }
  4609. } else if item.ConsumableType == 7 {
  4610. var res3507for10188 FJ3507ResultFor10188
  4611. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4612. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4613. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4614. //判断是否已经销售
  4615. if item.IsSale == 2 { //是否已经销售,1是 0否
  4616. //是否已经变更 1是 0否
  4617. if item.IsChange == 0 { //没变更,进行变更操作
  4618. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4619. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4620. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4621. var respJSON3 map[string]interface{}
  4622. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4623. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4625. return
  4626. }
  4627. userJSONBytes3, _ := json.Marshal(respJSON3)
  4628. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4629. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4630. utils.ErrorLog("解析失败:%v", err)
  4631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4632. return
  4633. }
  4634. //if res3507for10188.Infcode
  4635. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4636. //res.Output = resSix10265.Output
  4637. res3.ErrMsg = res3507for10188.ErrMsg
  4638. res3.Cainfo = res3507for10188.Cainfo
  4639. res3.WarnMsg = res3507for10188.WarnMsg
  4640. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4641. res3.Infcode = infocode
  4642. } else {
  4643. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4644. utils.ErrorLog("解析失败:%v", err)
  4645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4646. return
  4647. }
  4648. }
  4649. if res3.Infcode == 0 {
  4650. item.IsChange = 1
  4651. item.BgBchno = bg_number
  4652. service.SaveDF2(item)
  4653. } else {
  4654. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4655. }
  4656. }
  4657. } else { //没销售,
  4658. //进行商品销售退货接口
  4659. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4660. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4661. saveLog(result111, result222, "3506", "销售退货")
  4662. var res7 FJ3507Result
  4663. //进行商品销售接口
  4664. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4665. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4666. var respJSON3 map[string]interface{}
  4667. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4670. return
  4671. }
  4672. userJSONBytes3, _ := json.Marshal(respJSON3)
  4673. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4674. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4675. utils.ErrorLog("解析失败:%v", err)
  4676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4677. return
  4678. }
  4679. //if res3507for10188.Infcode
  4680. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4681. //res.Output = resSix10265.Output
  4682. res7.ErrMsg = res3507for10188.ErrMsg
  4683. res7.Cainfo = res3507for10188.Cainfo
  4684. res7.WarnMsg = res3507for10188.WarnMsg
  4685. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4686. res7.Infcode = infocode
  4687. } else {
  4688. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4689. utils.ErrorLog("解析失败:%v", err)
  4690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4691. return
  4692. }
  4693. }
  4694. if res7.Infcode == 0 {
  4695. item.IsSale = 2
  4696. item.SaleDate = item.SaleDate
  4697. item.Bchno = number
  4698. service.SaveDF(item)
  4699. if item.IsChange == 0 { //没变更,进行变更操作
  4700. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4701. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4702. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4703. var respJSON3 map[string]interface{}
  4704. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4705. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4707. return
  4708. }
  4709. userJSONBytes3, _ := json.Marshal(respJSON3)
  4710. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4711. // utils.ErrorLog("解析失败:%v", err)
  4712. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4713. // return
  4714. //}
  4715. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4716. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4717. utils.ErrorLog("解析失败:%v", err)
  4718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4719. return
  4720. }
  4721. //if res3507for10188.Infcode
  4722. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4723. //res.Output = resSix10265.Output
  4724. res3.ErrMsg = res3507for10188.ErrMsg
  4725. res3.Cainfo = res3507for10188.Cainfo
  4726. res3.WarnMsg = res3507for10188.WarnMsg
  4727. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4728. res3.Infcode = infocode
  4729. } else {
  4730. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4731. utils.ErrorLog("解析失败:%v", err)
  4732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4733. return
  4734. }
  4735. }
  4736. if res3.Infcode == 0 {
  4737. item.IsChange = 1
  4738. item.BgBchno = bg_number
  4739. service.SaveDF2(item)
  4740. } else {
  4741. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4742. }
  4743. }
  4744. } else {
  4745. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4746. }
  4747. }
  4748. } else { //还没结算
  4749. if item.IsChange == 0 { //没变更,进行变更操作
  4750. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4751. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4752. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4753. var respJSON3 map[string]interface{}
  4754. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4755. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4757. return
  4758. }
  4759. userJSONBytes3, _ := json.Marshal(respJSON3)
  4760. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4761. // utils.ErrorLog("解析失败:%v", err)
  4762. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4763. // return
  4764. //}
  4765. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4766. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4767. utils.ErrorLog("解析失败:%v", err)
  4768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4769. return
  4770. }
  4771. //if res3507for10188.Infcode
  4772. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4773. //res.Output = resSix10265.Output
  4774. res3.ErrMsg = res3507for10188.ErrMsg
  4775. res3.Cainfo = res3507for10188.Cainfo
  4776. res3.WarnMsg = res3507for10188.WarnMsg
  4777. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4778. res3.Infcode = infocode
  4779. } else {
  4780. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4781. utils.ErrorLog("解析失败:%v", err)
  4782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4783. return
  4784. }
  4785. }
  4786. if res3.Infcode == 0 {
  4787. item.IsChange = 1
  4788. item.BgBchno = bg_number
  4789. service.SaveDF2(item)
  4790. } else {
  4791. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4792. }
  4793. }
  4794. }
  4795. }
  4796. }
  4797. if len(err) == 0 {
  4798. c.ServeSuccessJSON(map[string]interface{}{
  4799. "msg": "销售变更成功",
  4800. })
  4801. } else {
  4802. c.ServeSuccessJSON(map[string]interface{}{
  4803. "failed_code": -10,
  4804. "msg": err,
  4805. })
  4806. }
  4807. }
  4808. func ChangeDrugTenone() {
  4809. //ids := c.GetString("ids")
  4810. //id_arr := strings.Split(ids, ",")
  4811. now := time.Now()
  4812. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  4813. //timestamp := int64(1729612800)
  4814. flows, _ := service.GetNewDrugFlowInforTen(timestamp, 10188)
  4815. admin_user_id := int64(2463)
  4816. roles, _ := service.GetAdminUserInfoByID(10188, admin_user_id)
  4817. miConfig, _ := service.FindMedicalInsuranceInfo(10188)
  4818. var err []string
  4819. for _, item := range flows {
  4820. var res3 ResultSix
  4821. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4822. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4823. continue
  4824. }
  4825. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4826. continue
  4827. }
  4828. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4829. if prescription.OrderStatus == 2 {
  4830. //已经结算
  4831. //判断是否已经销售
  4832. if item.IsSale == 1 { //是否已经销售,1是 0否
  4833. //是否已经变更 1是 0否
  4834. if item.IsChange == 0 { //没变更,进行变更操作
  4835. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4836. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4837. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4838. var respJSON3 map[string]interface{}
  4839. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4840. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4841. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4842. return
  4843. }
  4844. userJSONBytes3, _ := json.Marshal(respJSON3)
  4845. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4846. utils.ErrorLog("解析失败:%v", err)
  4847. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4848. return
  4849. }
  4850. if res3.Infcode == 0 {
  4851. item.IsChange = 1
  4852. item.BgBchno = bg_number
  4853. service.SaveDF2(item)
  4854. } else {
  4855. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4856. }
  4857. }
  4858. } else { //没销售,
  4859. var res FJ3507Result
  4860. var res3507for10188 FJ3507ResultFor10188
  4861. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4862. //进行商品销售接口
  4863. result3, result4 := SaleStock(10188, prescription, item, miConfig, "", roles, number)
  4864. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4865. var respJSON3 map[string]interface{}
  4866. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4867. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4868. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4869. return
  4870. }
  4871. userJSONBytes3, _ := json.Marshal(respJSON3)
  4872. {
  4873. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4874. utils.ErrorLog("解析失败:%v", err)
  4875. return
  4876. }
  4877. //if res3507for10188.Infcode
  4878. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4879. //res.Output = resSix10265.Output
  4880. res.ErrMsg = res3507for10188.ErrMsg
  4881. res.Cainfo = res3507for10188.Cainfo
  4882. res.WarnMsg = res3507for10188.WarnMsg
  4883. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4884. res.Infcode = infocode
  4885. }
  4886. if res.Infcode == 0 {
  4887. item.IsSale = 1
  4888. item.Bchno = number
  4889. item.SaleDate = time.Now().Format("2006-01-02")
  4890. err5 := service.SaveDF(item)
  4891. if err5 == nil {
  4892. if item.IsChange == 1 { //没变更,进行变更操作
  4893. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4894. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4895. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4896. var respJSON3 map[string]interface{}
  4897. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4898. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4899. return
  4900. }
  4901. {
  4902. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4903. utils.ErrorLog("解析失败:%v", err)
  4904. return
  4905. }
  4906. //if res3507for10188.Infcode
  4907. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4908. //res.Output = resSix10265.Output
  4909. res3.ErrMsg = res3507for10188.ErrMsg
  4910. res3.Cainfo = res3507for10188.Cainfo
  4911. res3.WarnMsg = res3507for10188.WarnMsg
  4912. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4913. res3.Infcode = infocode
  4914. }
  4915. if res3.Infcode == 0 {
  4916. item.IsChange = 1
  4917. item.BgBchno = bg_number
  4918. service.SaveDF2(item)
  4919. } else {
  4920. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4921. }
  4922. }
  4923. }
  4924. } else {
  4925. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4926. }
  4927. }
  4928. }
  4929. }
  4930. }
  4931. }
  4932. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4933. var struct3502 models.Struct3502
  4934. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4935. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4936. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4937. struct3502.FixmedinsCode = miConfig.Code
  4938. struct3502.Code = miConfig.Code
  4939. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  4940. struct3502.Opter = role.UserName
  4941. struct3502.RxFlag = "1"
  4942. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  4943. struct3502.OrgName = miConfig.OrgName
  4944. struct3502.AccessKey = miConfig.AccessKey
  4945. struct3502.RequestUrl = miConfig.Url
  4946. struct3502.SecretKey = miConfig.SecretKey
  4947. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4948. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4949. struct3502.Url = miConfig.Url
  4950. struct3502.AppId = miConfig.Cainfo
  4951. struct3502.AppSecret = miConfig.AppSecret
  4952. struct3502.Enckey = miConfig.EncKey
  4953. struct3502.SignKey = miConfig.SignKey
  4954. struct3502.SecretKey = miConfig.SecretKey
  4955. struct3502.InvChgType = chgType
  4956. struct3502.FixmedinsBchno = number
  4957. struct3502.Cnt = strconv.FormatInt(count, 10)
  4958. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  4959. //result1, result2, _ := service.FJyb3502(struct3502)
  4960. if miConfig.MdtrtareaAdmvs == "350500" {
  4961. result1, result2, _ := service.FJyb3502(struct3502)
  4962. //saveLog(result1, result2, "3502", "3502")
  4963. return result1, result2
  4964. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4965. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  4966. return result1, result2
  4967. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  4968. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  4969. return result1, result2
  4970. } else {
  4971. data := make(map[string]interface{})
  4972. data["struct_3502s"] = struct3502
  4973. client := &http.Client{}
  4974. bytesData, _ := json.Marshal(data)
  4975. var req *http.Request
  4976. if miConfig.MdtrtareaAdmvs == "320921" {
  4977. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4978. } else {
  4979. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4980. }
  4981. resp, _ := client.Do(req)
  4982. defer resp.Body.Close()
  4983. body, ioErr := ioutil.ReadAll(resp.Body)
  4984. if ioErr != nil {
  4985. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4986. }
  4987. var respJSON map[string]interface{}
  4988. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4990. }
  4991. //var resSix10265 ResultSix10265 //1101结果
  4992. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4993. result, _ := json.Marshal(respJSON)
  4994. return string(result), ""
  4995. }
  4996. }
  4997. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4998. var struct3505 models.Struct3505
  4999. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5000. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5001. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5002. struct3505.FixmedinsBchno = number
  5003. struct3505.Opter = role.UserName
  5004. struct3505.Bchno = "---"
  5005. struct3505.FixmedinsCode = miConfig.Code
  5006. struct3505.Code = miConfig.Code
  5007. struct3505.FinlTrnsPric = drug.HisDoctorAdviceInfo.Price
  5008. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5009. struct3505.PrscDrName = roles.UserName
  5010. if org_id == 10191 {
  5011. struct3505.PharName = "刘水山"
  5012. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5013. }
  5014. if org_id == 10188 {
  5015. struct3505.PharName = "李汉清"
  5016. struct3505.PharPracCertNo = "30220200932022010034"
  5017. }
  5018. if org_id == 10217 {
  5019. struct3505.PharName = "张敏"
  5020. struct3505.PharPracCertNo = "30220230432090100108"
  5021. }
  5022. if org_id == 10318 {
  5023. struct3505.PharName = "邹刘阳"
  5024. struct3505.PharPracCertNo = "210441200001378"
  5025. }
  5026. if org_id == 10402 {
  5027. struct3505.PharName = "刘韶健"
  5028. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5029. }
  5030. if org_id == 9919 {
  5031. struct3505.PharName = "周君权"
  5032. struct3505.PharPracCertNo = "089644396094401375"
  5033. }
  5034. if org_id == 10644 {
  5035. struct3505.PharName = "陈金娣"
  5036. struct3505.PharPracCertNo = "20181441500320100066"
  5037. }
  5038. if org_id == 10567 {
  5039. struct3505.PharName = "范小兰"
  5040. struct3505.PharPracCertNo = "0200102079485"
  5041. }
  5042. if org_id == 10721 {
  5043. struct3505.PharName = "孙莉侠"
  5044. struct3505.PharPracCertNo = "060399"
  5045. }
  5046. if org_id == 10726 {
  5047. struct3505.PharName = "彭建福"
  5048. struct3505.PharPracCertNo = "D445281006261"
  5049. }
  5050. if org_id == 10265 {
  5051. struct3505.PharName = "李彩星"
  5052. struct3505.PharPracCertNo = "20171110600110100019"
  5053. }
  5054. if org_id == 10028 {
  5055. struct3505.PharName = "曾细平"
  5056. struct3505.PharPracCertNo = "D440307022134"
  5057. }
  5058. if org_id == 10138 {
  5059. struct3505.PharName = "彭斯遥"
  5060. struct3505.PharPracCertNo = "30220200943042010052"
  5061. }
  5062. if org_id == 10278 {
  5063. struct3505.PharName = "彭斯遥"
  5064. struct3505.PharPracCertNo = "30220200943042010052"
  5065. }
  5066. if org_id == 10610 {
  5067. struct3505.PharName = "彭斯遥"
  5068. struct3505.PharPracCertNo = "30220200943042010052"
  5069. }
  5070. if org_id == 10537 {
  5071. struct3505.PharName = "彭斯遥"
  5072. struct3505.PharPracCertNo = "30220200943042010052"
  5073. }
  5074. if org_id == 9504 {
  5075. struct3505.PharName = "资美红"
  5076. struct3505.PharPracCertNo = "D440904006635"
  5077. }
  5078. if org_id == 10480 {
  5079. struct3505.PharName = "陈思"
  5080. struct3505.PharPracCertNo = "30220240434110010470"
  5081. }
  5082. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5083. struct3505.SetlId = order.SetlId
  5084. struct3505.MdtrtSn = order.MdtrtId
  5085. struct3505.ManuLotnum = drug.BatchNumber
  5086. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5087. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5088. struct3505.RxFlag = "1"
  5089. if drug.HisDoctorAdviceInfo.PrescribingNumberUnit != drug.HisDoctorAdviceInfo.BaseDrugLib.MinUnit {
  5090. struct3505.TrdnFlag = "0"
  5091. } else {
  5092. struct3505.TrdnFlag = "1"
  5093. }
  5094. if drug.HisDoctorAdviceInfo.ZeroFlag == 1 {
  5095. struct3505.TrdnFlag = "1"
  5096. }
  5097. if drug.HisDoctorAdviceInfo.ZeroFlag == 2 {
  5098. struct3505.TrdnFlag = "0"
  5099. }
  5100. struct3505.RtalDocno = order.Number
  5101. struct3505.PsnCertType = "01"
  5102. struct3505.CertNo = order.Certno
  5103. struct3505.PsnNo = order.PsnNo
  5104. struct3505.PsnName = order.PsnName
  5105. struct3505.Url = miConfig.Url
  5106. struct3505.AppId = miConfig.Cainfo
  5107. struct3505.AppSecret = miConfig.AppSecret
  5108. struct3505.Enckey = miConfig.EncKey
  5109. struct3505.SignKey = miConfig.SignKey
  5110. struct3505.SecretKey = miConfig.SecretKey
  5111. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5112. struct3505.SelRetnCnt = strValue
  5113. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5114. struct3505.SelRetnOpterName = role.UserName
  5115. if order.IsMedicineInsurance == 1 {
  5116. struct3505.MdtrtSetlType = "1"
  5117. } else {
  5118. struct3505.MdtrtSetlType = "2"
  5119. }
  5120. struct3505.OrgName = miConfig.OrgName
  5121. struct3505.AccessKey = miConfig.AccessKey
  5122. struct3505.RequestUrl = miConfig.Url
  5123. struct3505.SecretKey = miConfig.SecretKey
  5124. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5125. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5126. struct3505.Cainfo = miConfig.Cainfo
  5127. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5128. if miConfig.MdtrtareaAdmvs == "350500" {
  5129. result1, result2, _ := service.FJyb3505(struct3505)
  5130. return result1, result2
  5131. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5132. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5133. return result1, result2
  5134. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5135. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5136. return result1, result2
  5137. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5138. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5139. return result1, result2
  5140. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5141. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5142. return result1, result2
  5143. } else if miConfig.MdtrtareaAdmvs == "150499" {
  5144. data := make(map[string]interface{})
  5145. data["struct_3505s"] = struct3505
  5146. client := &http.Client{}
  5147. bytesData, _ := json.Marshal(data)
  5148. var req *http.Request
  5149. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  5150. resp, _ := client.Do(req)
  5151. defer resp.Body.Close()
  5152. body, ioErr := ioutil.ReadAll(resp.Body)
  5153. if ioErr != nil {
  5154. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5155. }
  5156. var respJSON map[string]interface{}
  5157. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5159. }
  5160. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5161. result, _ := json.Marshal(respJSON)
  5162. return string(result), ""
  5163. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5164. data := make(map[string]interface{})
  5165. data["struct_3505s"] = struct3505
  5166. client := &http.Client{}
  5167. bytesData, _ := json.Marshal(data)
  5168. var req *http.Request
  5169. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3505", bytes.NewReader(bytesData))
  5170. resp, _ := client.Do(req)
  5171. defer resp.Body.Close()
  5172. body, ioErr := ioutil.ReadAll(resp.Body)
  5173. if ioErr != nil {
  5174. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5175. }
  5176. var respJSON map[string]interface{}
  5177. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5178. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5179. }
  5180. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5181. if status == "0" {
  5182. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5183. utils.ErrorLog("接口返回数据读取失败: %v", err_msg)
  5184. }
  5185. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5186. result, _ := json.Marshal(respJSON)
  5187. return string(result), ""
  5188. } else {
  5189. data := make(map[string]interface{})
  5190. data["struct_3505s"] = struct3505
  5191. client := &http.Client{}
  5192. bytesData, _ := json.Marshal(data)
  5193. var req *http.Request
  5194. if miConfig.MdtrtareaAdmvs == "320921" {
  5195. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5196. } else {
  5197. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5198. }
  5199. resp, _ := client.Do(req)
  5200. defer resp.Body.Close()
  5201. body, ioErr := ioutil.ReadAll(resp.Body)
  5202. if ioErr != nil {
  5203. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5204. }
  5205. var respJSON map[string]interface{}
  5206. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5207. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5208. }
  5209. //var resSix10265 ResultSix10265 //1101结果
  5210. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5211. result, _ := json.Marshal(respJSON)
  5212. return string(result), ""
  5213. }
  5214. }
  5215. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5216. var struct3505 models.Struct3505
  5217. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5218. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5219. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5220. struct3505.FixmedinsBchno = number
  5221. struct3505.Opter = role.UserName
  5222. struct3505.FixmedinsCode = miConfig.Code
  5223. struct3505.Code = miConfig.Code
  5224. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5225. struct3505.PrscDrName = roles.UserName
  5226. if org_id == 10191 {
  5227. struct3505.PharName = "刘水山"
  5228. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5229. }
  5230. if org_id == 10188 {
  5231. struct3505.PharName = "李汉清"
  5232. struct3505.PharPracCertNo = "30220200932022010034"
  5233. }
  5234. if org_id == 10217 {
  5235. struct3505.PharName = "张敏"
  5236. struct3505.PharPracCertNo = "30220230432090100108"
  5237. }
  5238. if org_id == 10318 {
  5239. struct3505.PharName = "邹刘阳"
  5240. struct3505.PharPracCertNo = "210441200001378"
  5241. }
  5242. if org_id == 10402 {
  5243. struct3505.PharName = "刘韶健"
  5244. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5245. }
  5246. if org_id == 9919 {
  5247. struct3505.PharName = "周君权"
  5248. struct3505.PharPracCertNo = "089644396094401375"
  5249. }
  5250. if org_id == 10644 {
  5251. struct3505.PharName = "陈金娣"
  5252. struct3505.PharPracCertNo = "20181441500320100066"
  5253. }
  5254. if org_id == 10567 {
  5255. struct3505.PharName = "范小兰"
  5256. struct3505.PharPracCertNo = "0200102079485"
  5257. }
  5258. if org_id == 10721 {
  5259. struct3505.PharName = "孙莉侠"
  5260. struct3505.PharPracCertNo = "060399"
  5261. }
  5262. if org_id == 10726 {
  5263. struct3505.PharName = "彭建福"
  5264. struct3505.PharPracCertNo = "D445281006261"
  5265. }
  5266. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5267. struct3505.SetlId = order.SetlId
  5268. struct3505.MdtrtSn = order.MdtrtId
  5269. struct3505.ManuLotnum = drug.Number
  5270. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5271. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5272. struct3505.RxFlag = "1"
  5273. struct3505.TrdnFlag = "0"
  5274. struct3505.RtalDocno = order.Number
  5275. struct3505.PsnCertType = "01"
  5276. struct3505.CertNo = order.Certno
  5277. struct3505.PsnNo = order.PsnNo
  5278. struct3505.PsnName = order.PsnName
  5279. struct3505.Url = miConfig.Url
  5280. struct3505.AppId = miConfig.Cainfo
  5281. struct3505.AppSecret = miConfig.AppSecret
  5282. struct3505.Enckey = miConfig.EncKey
  5283. struct3505.SignKey = miConfig.SignKey
  5284. struct3505.SecretKey = miConfig.SecretKey
  5285. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5286. struct3505.SelRetnCnt = strValue
  5287. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5288. struct3505.SelRetnOpterName = role.UserName
  5289. if order.IsMedicineInsurance == 1 {
  5290. struct3505.MdtrtSetlType = "1"
  5291. } else {
  5292. struct3505.MdtrtSetlType = "2"
  5293. }
  5294. struct3505.OrgName = miConfig.OrgName
  5295. struct3505.AccessKey = miConfig.AccessKey
  5296. struct3505.RequestUrl = miConfig.Url
  5297. struct3505.SecretKey = miConfig.SecretKey
  5298. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5299. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5300. struct3505.Cainfo = miConfig.Cainfo
  5301. struct3505.DrugTracCodg = drug.DrugCode
  5302. if miConfig.MdtrtareaAdmvs == "350500" {
  5303. result1, result2, _ := service.FJyb3505(struct3505)
  5304. return result1, result2
  5305. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5306. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5307. return result1, result2
  5308. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5309. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5310. return result1, result2
  5311. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5312. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5313. return result1, result2
  5314. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5315. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5316. return result1, result2
  5317. } else {
  5318. data := make(map[string]interface{})
  5319. data["struct_3505s"] = struct3505
  5320. client := &http.Client{}
  5321. bytesData, _ := json.Marshal(data)
  5322. var req *http.Request
  5323. if miConfig.MdtrtareaAdmvs == "320921" {
  5324. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5325. } else {
  5326. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5327. }
  5328. resp, _ := client.Do(req)
  5329. defer resp.Body.Close()
  5330. body, ioErr := ioutil.ReadAll(resp.Body)
  5331. if ioErr != nil {
  5332. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5333. }
  5334. var respJSON map[string]interface{}
  5335. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5336. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5337. }
  5338. //var resSix10265 ResultSix10265 //1101结果
  5339. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5340. result, _ := json.Marshal(respJSON)
  5341. return string(result), ""
  5342. }
  5343. }
  5344. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5345. var struct3506 models.Struct3506
  5346. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5347. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5348. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5349. struct3506.FixmedinsCode = miConfig.Code
  5350. struct3506.Code = miConfig.Code
  5351. struct3506.FixmedinsBchno = number
  5352. struct3506.Opter = role.UserName
  5353. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5354. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5355. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5356. struct3506.MdtrtSn = order.MdtrtId
  5357. struct3506.ExpyEnd = ""
  5358. struct3506.RxFlag = "0"
  5359. struct3506.TrdnFlag = "1"
  5360. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5361. struct3506.SelRetnCnt = strValue
  5362. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5363. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5364. struct3506.SelRetnOpterName = role.UserName
  5365. struct3506.OrgName = miConfig.OrgName
  5366. struct3506.AccessKey = miConfig.AccessKey
  5367. struct3506.RequestUrl = miConfig.Url
  5368. struct3506.SecretKey = miConfig.SecretKey
  5369. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5370. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5371. struct3506.Url = miConfig.Url
  5372. struct3506.AppId = miConfig.Cainfo
  5373. struct3506.AppSecret = miConfig.AppSecret
  5374. struct3506.Enckey = miConfig.EncKey
  5375. struct3506.SignKey = miConfig.SignKey
  5376. struct3506.SecretKey = miConfig.SecretKey
  5377. struct3506.DrugTracCodg = drug.DrugCode
  5378. if miConfig.MdtrtareaAdmvs == "350500" {
  5379. result1, result2, _ := service.FJyb3506(struct3506)
  5380. return result1, result2
  5381. } else {
  5382. data := make(map[string]interface{})
  5383. data["struct_3506s"] = struct3506
  5384. client := &http.Client{}
  5385. bytesData, _ := json.Marshal(data)
  5386. var req *http.Request
  5387. if miConfig.MdtrtareaAdmvs == "320921" {
  5388. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5389. } else {
  5390. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5391. }
  5392. resp, _ := client.Do(req)
  5393. defer resp.Body.Close()
  5394. body, ioErr := ioutil.ReadAll(resp.Body)
  5395. if ioErr != nil {
  5396. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5397. }
  5398. var respJSON map[string]interface{}
  5399. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5401. }
  5402. //var resSix10265 ResultSix10265 //1101结果
  5403. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5404. result, _ := json.Marshal(respJSON)
  5405. return string(result), ""
  5406. }
  5407. }
  5408. func (c *HisApiController) Get1318() {
  5409. adminUser := c.GetAdminUserInfo()
  5410. admin_user_id, _ := c.GetInt64("admin_user_id")
  5411. code := c.GetString("code")
  5412. code = ""
  5413. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5414. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5415. api := ""
  5416. if miConfig.MdtrtareaAdmvs == "320921" {
  5417. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5418. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5419. } else {
  5420. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5421. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5422. }
  5423. resp, requestErr := http.Get(api)
  5424. if requestErr != nil {
  5425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5426. return
  5427. }
  5428. body, ioErr := ioutil.ReadAll(resp.Body)
  5429. if ioErr != nil {
  5430. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5432. return
  5433. }
  5434. var respJSON map[string]interface{}
  5435. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5436. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5438. return
  5439. }
  5440. //var res Result2406
  5441. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5442. result, _ := json.Marshal(respJSON)
  5443. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5444. utils.ErrorLog("解析失败:%v", err)
  5445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5446. return
  5447. }
  5448. if res.Infcode == "0" {
  5449. c.ServeSuccessJSON(map[string]interface{}{
  5450. "result": "",
  5451. })
  5452. } else {
  5453. c.ServeSuccessJSON(map[string]interface{}{
  5454. "failed_code": -10,
  5455. "msg": res.ErrMsg,
  5456. })
  5457. */return
  5458. //}
  5459. }
  5460. func (c *HisApiController) Get2503() {
  5461. adminUser := c.GetAdminUserInfo()
  5462. admin_user_id, _ := c.GetInt64("admin_user_id")
  5463. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5464. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5465. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5466. }
  5467. func (c *HisApiController) Get2406() {
  5468. id, _ := c.GetInt64("id")
  5469. record_time := c.GetString("record_time")
  5470. his_patient_id, _ := c.GetInt64("his_patient_id")
  5471. admin_user_id, _ := c.GetInt64("admin_user_id")
  5472. diagnosis_id := c.GetString("diagnosis")
  5473. timeLayout := "2006-01-02"
  5474. loc, _ := time.LoadLocation("Local")
  5475. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5476. if err != nil {
  5477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5478. return
  5479. }
  5480. recordDateTime := theTime.Unix()
  5481. adminUser := c.GetAdminUserInfo()
  5482. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5483. var config []*models.HisXtDiagnoseConfig
  5484. for _, item := range diagnosis_ids {
  5485. id, _ := strconv.ParseInt(item, 10, 64)
  5486. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5487. config = append(config, &diagnosisConfig)
  5488. }
  5489. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5490. fmt.Println(his_patient_id)
  5491. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5492. //timestamp := time.Now().Unix()
  5493. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5494. var patientPrescription models.HisPrescriptionInfo
  5495. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5496. if patientPrescription.ID == 0 {
  5497. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5498. }
  5499. var res2 Result2406
  5500. if miConfig.MdtrtareaAdmvs == "341203" {
  5501. data := make(map[string]interface{})
  5502. client := &http.Client{}
  5503. data["psn_no"] = his.PsnNo
  5504. data["mdtrt_id"] = his.Number
  5505. data["operator"] = roles.UserName
  5506. data["cert_no"] = his.IdCardNo
  5507. data["org_name"] = miConfig.OrgName
  5508. data["psn_name"] = his.Name
  5509. data["ipt_otp_no"] = his.IptOtpNo
  5510. data["ipt_psn_sp_flag_type"] = "0901"
  5511. data["ipt_psn_sp_flag"] = "1"
  5512. data["fixmedins_code"] = miConfig.Code
  5513. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5514. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5515. data["url"] = miConfig.Url
  5516. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5517. bytesData, _ := json.Marshal(data)
  5518. var req *http.Request
  5519. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5520. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5521. resp, _ := client.Do(req)
  5522. defer resp.Body.Close()
  5523. body, ioErr := ioutil.ReadAll(resp.Body)
  5524. if ioErr != nil {
  5525. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5527. return
  5528. }
  5529. var respJSON map[string]interface{}
  5530. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5531. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5533. return
  5534. }
  5535. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5536. if status == "0" {
  5537. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5538. c.ServeSuccessJSON(map[string]interface{}{
  5539. "failed_code": -10,
  5540. "msg": err_msg,
  5541. })
  5542. return
  5543. }
  5544. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5545. userJSONBytes, _ := json.Marshal(respJSON)
  5546. fmt.Println("log")
  5547. fmt.Println(string(userJSONBytes))
  5548. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5549. utils.ErrorLog("解析失败:%v", err)
  5550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5551. return
  5552. }
  5553. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5554. data := make(map[string]interface{})
  5555. client := &http.Client{}
  5556. data["psn_no"] = his.PsnNo
  5557. data["mdtrt_id"] = his.Number
  5558. data["operator"] = roles.UserName
  5559. data["cert_no"] = his.IdCardNo
  5560. data["org_name"] = miConfig.OrgName
  5561. data["psn_name"] = his.Name
  5562. data["ipt_otp_no"] = his.IptOtpNo
  5563. data["ipt_psn_sp_flag_type"] = "0901"
  5564. data["ipt_psn_sp_flag"] = "1"
  5565. data["fixmedins_code"] = miConfig.Code
  5566. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5567. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5568. data["url"] = miConfig.Url
  5569. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5570. bytesData, _ := json.Marshal(data)
  5571. var req *http.Request
  5572. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5573. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5574. resp, _ := client.Do(req)
  5575. defer resp.Body.Close()
  5576. body, ioErr := ioutil.ReadAll(resp.Body)
  5577. if ioErr != nil {
  5578. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5580. return
  5581. }
  5582. var respJSON map[string]interface{}
  5583. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5586. return
  5587. }
  5588. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5589. if status == "0" {
  5590. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5591. c.ServeSuccessJSON(map[string]interface{}{
  5592. "failed_code": -10,
  5593. "msg": err_msg,
  5594. })
  5595. return
  5596. }
  5597. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5598. userJSONBytes, _ := json.Marshal(respJSON)
  5599. fmt.Println("log")
  5600. fmt.Println(string(userJSONBytes))
  5601. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5602. utils.ErrorLog("解析失败:%v", err)
  5603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5604. return
  5605. }
  5606. }
  5607. if res2.Infcode != 0 {
  5608. adminUser := c.GetAdminUserInfo()
  5609. errlog := &models.HisOrderError{
  5610. UserOrgId: adminUser.CurrentOrgId,
  5611. Ctime: time.Now().Unix(),
  5612. Mtime: time.Now().Unix(),
  5613. ErrMsg: res2.ErrMsg,
  5614. Status: 1,
  5615. PatientId: id,
  5616. RecordTime: recordDateTime,
  5617. Stage: 3,
  5618. }
  5619. service.CreateErrMsgLog(errlog)
  5620. c.ServeSuccessJSON(map[string]interface{}{
  5621. "failed_code": -10,
  5622. "msg": res2.ErrMsg,
  5623. })
  5624. return
  5625. } else {
  5626. c.ServeSuccessJSON(map[string]interface{}{
  5627. "msg": "上传成功",
  5628. })
  5629. return
  5630. }
  5631. }
  5632. func (c *HisApiController) Get4105() {
  5633. }
  5634. func (c *HisApiController) Post5302() {
  5635. patient_id, _ := c.GetInt64("id")
  5636. admin_user_id, _ := c.GetInt64("admin_user_id")
  5637. p, _ := service.GetHisPatientById(patient_id)
  5638. adminUser := c.GetAdminUserInfo()
  5639. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5640. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5641. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5642. }
  5643. func (c *HisApiController) Get4104() {
  5644. }
  5645. type Output struct {
  5646. CertNo string `json:"certno"`
  5647. PsnName string `json:"psn_name"`
  5648. CardNo string `json:"card_no"`
  5649. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5650. CardSN string `json:"card_sn"`
  5651. PsnCertType string `json:"psn_cert_type"`
  5652. MdtrtCertNo string `json:"mdtrt_cert_no"`
  5653. MdtrtCertType string `json:"mdtrt_cert_type"`
  5654. QRCode string `json:"qrCode"`
  5655. EcToken string `json:"ecToken"`
  5656. }
  5657. type AHResponse struct {
  5658. Body AHBody `json:"body"`
  5659. Code int `json:"code"`
  5660. CSBCode int `json:"csbCode"`
  5661. Message string `json:"message"`
  5662. RequestID string `json:"requestId"`
  5663. State struct{} `json:"state"`
  5664. }
  5665. type AHBody struct {
  5666. ErrMsg string `json:"err_msg"`
  5667. InfRefMsgID string `json:"inf_refmsgid"`
  5668. InfCode int `json:"infcode"`
  5669. Output struct {
  5670. Result []struct {
  5671. BasMednFlag string `json:"bas_medn_flag"`
  5672. ChldMedcFlag string `json:"chld_medc_flag"`
  5673. ChrgitmLv string `json:"chrgitm_lv"`
  5674. Cnt float64 `json:"cnt"`
  5675. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5676. DrtReimFlag string `json:"drt_reim_flag"`
  5677. FeedetlSn string `json:"feedetl_sn"`
  5678. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5679. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5680. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5681. ListSpItemFlag string `json:"list_sp_item_flag"`
  5682. LmtUsedFlag string `json:"lmt_used_flag"`
  5683. MedChrgitmType string `json:"med_chrgitm_type"`
  5684. Memo string `json:"memo"`
  5685. OverlmtAmt float64 `json:"overlmt_amt"`
  5686. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5687. Pric float64 `json:"pric"`
  5688. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5689. SelfpayProp float64 `json:"selfpay_prop"`
  5690. } `json:"result"`
  5691. } `json:"output"`
  5692. }
  5693. type Response struct {
  5694. Output Output `json:"output"`
  5695. Infcode int `json:"infcode"`
  5696. InfRefMsgID string `json:"inf_refmsgid"`
  5697. RefMsgTime string `json:"refmsg_time"`
  5698. RespondTime string `json:"respond_time"`
  5699. ErrMsg string `json:"err_msg"`
  5700. WarnMsg string `json:"warn_msg"`
  5701. SignType string `json:"signtype"`
  5702. CAInfo string `json:"cainfo"`
  5703. }
  5704. func (c *HisApiController) Getquerydata() {
  5705. query_type, _ := c.GetInt64("type")
  5706. refd_setl_flag := c.GetString("refd_setl_flag")
  5707. med_type := c.GetString("med_type")
  5708. //admin_user_id,_ := c.GetInt64("admin_user_id")
  5709. cert_no := c.GetString("cert_no")
  5710. psn_no := c.GetString("psn_no")
  5711. start_time := c.GetString("start_time")
  5712. end_time := c.GetString("end_time")
  5713. page, _ := c.GetInt64("page")
  5714. limit, _ := c.GetInt64("limit")
  5715. var bp models.BusinessParams5262
  5716. bp.RefdSetlFlag = refd_setl_flag
  5717. bp.MedType = med_type
  5718. bp.Certno = cert_no
  5719. bp.Psnno = psn_no
  5720. bp.QBegntime = start_time
  5721. bp.QEndtime = end_time
  5722. if query_type == 1 { //本地
  5723. Post5262(c, bp, page, limit)
  5724. } else { //异地
  5725. Post5267(c, bp, page, limit)
  5726. }
  5727. }
  5728. func (c *HisApiController) Drugscheck() {
  5729. admin_user_id, _ := c.GetInt64("admin_user_id")
  5730. adminUser := c.GetAdminUserInfo()
  5731. var queryResult []QueryResult
  5732. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  5733. for _, item := range drugs {
  5734. result := QueryResult{
  5735. ID: item.ID,
  5736. Name: item.DrugName,
  5737. Code: item.MedicalInsuranceNumber,
  5738. List_type_code: "101",
  5739. }
  5740. queryResult = append(queryResult, result)
  5741. }
  5742. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5743. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5744. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5745. for _, item := range queryResult {
  5746. 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)
  5747. }
  5748. }
  5749. func (c *HisApiController) Goodcheck() {
  5750. admin_user_id, _ := c.GetInt64("admin_user_id")
  5751. adminUser := c.GetAdminUserInfo()
  5752. var queryResult []QueryResult
  5753. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  5754. for _, item := range goods {
  5755. result := QueryResult{
  5756. ID: item.ID,
  5757. Name: item.GoodName,
  5758. Code: item.SocialSecurityDirectoryCode,
  5759. List_type_code: "301",
  5760. }
  5761. queryResult = append(queryResult, result)
  5762. }
  5763. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5764. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5765. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5766. for _, item := range queryResult {
  5767. 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)
  5768. //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)
  5769. }
  5770. }
  5771. func (c *HisApiController) Projectcheck() {
  5772. admin_user_id, _ := c.GetInt64("admin_user_id")
  5773. adminUser := c.GetAdminUserInfo()
  5774. var queryResult []QueryResult
  5775. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  5776. for _, item := range projects {
  5777. result := QueryResult{
  5778. ID: item.ID,
  5779. Name: item.ProjectName,
  5780. Code: item.MedicalCode,
  5781. List_type_code: "201",
  5782. }
  5783. queryResult = append(queryResult, result)
  5784. }
  5785. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5786. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5787. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5788. for _, item := range queryResult {
  5789. 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)
  5790. }
  5791. }
  5792. //func (c *HisApiController)CancleDia(){
  5793. //
  5794. // id, _ := c.GetInt64("id")
  5795. // record_time := c.GetString("record_time")
  5796. // his_patient_id, _ := c.GetInt64("his_patient_id")
  5797. //
  5798. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5799. //
  5800. // diagnosis_id := c.GetString("diagnosis")
  5801. // sick_type, _ := c.GetInt64("sick_type")
  5802. // reg_type, _ := c.GetInt64("p_type")
  5803. // begin_time := c.GetString("begin_time")
  5804. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  5805. //
  5806. //
  5807. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  5808. //
  5809. // fmt.Println(acct_used_flag)
  5810. //
  5811. //
  5812. // timeLayout := "2006-01-02"
  5813. // loc, _ := time.LoadLocation("Local")
  5814. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5815. // if err != nil {
  5816. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5817. // return
  5818. // }
  5819. // recordDateTime := theTime.Unix()
  5820. // adminUser := c.GetAdminUserInfo()
  5821. //
  5822. //
  5823. //
  5824. //
  5825. //
  5826. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5827. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5828. // var patientPrescription models.HisPrescriptionInfo
  5829. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5830. // if patientPrescription.ID == 0 {
  5831. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5832. // }
  5833. // //if patientPrescription.Do
  5834. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5835. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5836. //
  5837. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5838. //
  5839. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  5840. //
  5841. // var config []*models.HisXtDiagnoseConfig
  5842. // for _, item := range diagnosis_ids {
  5843. // id, _ := strconv.ParseInt(item, 10, 64)
  5844. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  5845. // config = append(config, &diagnosisConfig)
  5846. // }
  5847. //
  5848. // sickConfig, _ := service.FindSickById(sick_type)
  5849. //
  5850. //
  5851. // data := make(map[string]interface{})
  5852. // client := &http.Client{}
  5853. // data["psn_no"] = his.PsnNo
  5854. // data["mdtrt_id"] = his.Number
  5855. // data["doctor"] = roles.UserName
  5856. // data["department"] = department.Name
  5857. // data["org_name"] = miConfig.OrgName
  5858. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  5859. // data["doctor_id"] = doctor_info.DoctorNumber
  5860. // data["new_doctor_name"] = doctor_info.UserName
  5861. // data["fixmedins_code"] = miConfig.Code
  5862. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5863. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5864. // data["secret_key"] = miConfig.SecretKey
  5865. // data["sick_code"] = sickConfig.CountryCode
  5866. // data["sick_name"] = sickConfig.ClassName
  5867. // data["url"] = miConfig.Url
  5868. // data["ak"] = miConfig.AccessKey
  5869. // data["begin_time"] = begin_time
  5870. // data["cainfo"] = miConfig.Cainfo
  5871. // data["is_vaild"] = "0"
  5872. //
  5873. // data["dept"] = strconv.FormatInt(department.ID, 10)
  5874. // data["config"] = config
  5875. // bytesData, _ := json.Marshal(data)
  5876. //
  5877. // var req *http.Request
  5878. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  5879. // resp, _ := client.Do(req)
  5880. // defer resp.Body.Close()
  5881. // body, ioErr := ioutil.ReadAll(resp.Body)
  5882. // if ioErr != nil {
  5883. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5884. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5885. // return
  5886. // }
  5887. // var respJSON map[string]interface{}
  5888. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5889. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5890. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5891. // return
  5892. // }
  5893. //
  5894. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5895. // userJSONBytes, _ := json.Marshal(respJSON)
  5896. // fmt.Println("log")
  5897. // fmt.Println(string(userJSONBytes))
  5898. //
  5899. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5900. // utils.ErrorLog("解析失败:%v", err)
  5901. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5902. // return
  5903. // }
  5904. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  5905. // res2.Output = ressix10265.Output
  5906. // res2.ErrMsg = ressix10265.ErrMsg
  5907. // res2.Cainfo = ressix10265.Cainfo
  5908. // res2.WarnMsg = ressix10265.WarnMsg
  5909. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5910. // res2.Infcode = infocode
  5911. //
  5912. //}
  5913. func (c *HisApiController) Get4102() {
  5914. order_id, _ := c.GetInt64("order_id")
  5915. admin_user_id, _ := c.GetInt64("admin_user_id")
  5916. stas_type := c.GetString("stas_type")
  5917. order, _ := service.GetHisOrderByIDTwo(order_id)
  5918. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5919. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5920. var pp models.PublicParams
  5921. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5922. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5923. pp.FixmedinsName = miConfig.OrgName
  5924. pp.FixmedinsCode = miConfig.Code
  5925. pp.RequestUrl = miConfig.Url
  5926. pp.Cainfo = miConfig.Cainfo
  5927. pp.SecretKey = miConfig.SecretKey
  5928. pp.AccessKey = miConfig.AccessKey
  5929. pp.OpterName = curRoles.UserName
  5930. if miConfig.MdtrtareaAdmvs == "350500" {
  5931. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5932. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  5933. saveLog(result, request, "4102", "清单确认")
  5934. var dat map[string]interface{}
  5935. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5936. fmt.Println(dat)
  5937. } else {
  5938. fmt.Println(err)
  5939. }
  5940. var empty ResultFourteen
  5941. userJSONBytes, _ := json.Marshal(dat)
  5942. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5943. utils.ErrorLog("解析失败:%v", err)
  5944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5945. return
  5946. }
  5947. if empty.Infcode == 0 {
  5948. c.ServeSuccessJSON(map[string]interface{}{
  5949. "msg": "确认成功",
  5950. })
  5951. return
  5952. }
  5953. } else {
  5954. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5955. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  5956. result3, request3 := service.Jxyb4105(pp)
  5957. saveLog(result, request, "4102", "清单确认")
  5958. saveLog(result2, request2, "4103", "清单确认")
  5959. saveLog(result3, request3, "4105", "清单统计")
  5960. var dat map[string]interface{}
  5961. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5962. fmt.Println(dat)
  5963. } else {
  5964. fmt.Println(err)
  5965. }
  5966. var empty ResultFourteen
  5967. userJSONBytes, _ := json.Marshal(dat)
  5968. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5969. utils.ErrorLog("解析失败:%v", err)
  5970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5971. return
  5972. }
  5973. if empty.Infcode == 0 {
  5974. c.ServeSuccessJSON(map[string]interface{}{
  5975. "msg": "确认成功",
  5976. })
  5977. return
  5978. }
  5979. }
  5980. }
  5981. // 对账权限查询
  5982. func (c *HisApiController) Get3260() {
  5983. admin_user_id, _ := c.GetInt64("admin_user_id")
  5984. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5985. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5986. var api string
  5987. var res models.JSResult3260
  5988. if miConfig.MdtrtareaAdmvs == "320921" {
  5989. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5990. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5991. } else {
  5992. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5993. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5994. }
  5995. resp, requestErr := http.Get(api)
  5996. if requestErr != nil {
  5997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5998. return
  5999. }
  6000. body, ioErr := ioutil.ReadAll(resp.Body)
  6001. if ioErr != nil {
  6002. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6004. return
  6005. }
  6006. var respJSON map[string]interface{}
  6007. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6008. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6010. return
  6011. }
  6012. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6013. result, _ := json.Marshal(respJSON)
  6014. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6015. utils.ErrorLog("解析失败:%v", err)
  6016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6017. return
  6018. }
  6019. if res.Infcode == "0" {
  6020. c.ServeSuccessJSON(map[string]interface{}{
  6021. "result": res.Output.Data,
  6022. })
  6023. } else {
  6024. c.ServeSuccessJSON(map[string]interface{}{
  6025. "failed_code": -10,
  6026. "msg": res.ErrMsg,
  6027. })
  6028. return
  6029. }
  6030. }
  6031. func (c *HisApiController) Get3261() {
  6032. admin_user_id, _ := c.GetInt64("admin_user_id")
  6033. //month := c.GetString("month")
  6034. startTime := c.GetString("start_time")
  6035. //endTime, _ := c.GetString("end_time")
  6036. times := strings.Split(startTime, "-")
  6037. stmt_mon := times[0] + times[1]
  6038. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6039. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6040. var api string
  6041. var res models.JSResult3261
  6042. //var res10265 Result5301For10265
  6043. if miConfig.MdtrtareaAdmvs == "320921" {
  6044. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6045. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6046. } else {
  6047. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6048. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6049. }
  6050. resp, requestErr := http.Get(api)
  6051. if requestErr != nil {
  6052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6053. return
  6054. }
  6055. body, ioErr := ioutil.ReadAll(resp.Body)
  6056. if ioErr != nil {
  6057. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6059. return
  6060. }
  6061. var respJSON map[string]interface{}
  6062. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6063. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6065. return
  6066. }
  6067. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6068. result, _ := json.Marshal(respJSON)
  6069. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6070. utils.ErrorLog("解析失败:%v", err)
  6071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6072. return
  6073. }
  6074. if res.Infcode == "0" {
  6075. c.ServeSuccessJSON(map[string]interface{}{
  6076. "result": res.Output,
  6077. })
  6078. } else {
  6079. c.ServeSuccessJSON(map[string]interface{}{
  6080. "failed_code": -10,
  6081. "msg": res.ErrMsg,
  6082. })
  6083. return
  6084. }
  6085. }
  6086. type TempFun struct {
  6087. FundKey string
  6088. FundCode string
  6089. }
  6090. func (c *HisApiController) Get3262() {
  6091. admin_user_id, _ := c.GetInt64("admin_user_id")
  6092. startTime := c.GetString("start_time")
  6093. endTime := c.GetString("end_time")
  6094. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6095. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6096. //timeLayout := "2006-01-02"
  6097. //loc, _ := time.LoadLocation("Local")
  6098. //var theStartTIme int64
  6099. //if len(startTime) > 0 {
  6100. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  6101. // if err != nil {
  6102. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6103. // return
  6104. // }
  6105. // theStartTIme = theTime.Unix()
  6106. //}
  6107. //var theEndtTIme int64
  6108. //if len(endTime) > 0 {
  6109. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  6110. // if err != nil {
  6111. // utils.ErrorLog(err.Error())
  6112. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6113. // return
  6114. // }
  6115. // theEndtTIme = theTime.Unix()
  6116. //}
  6117. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6118. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6119. for _, team := range datas {
  6120. fmt.Println(team.PsnTime)
  6121. for _, team_two := range datas_two {
  6122. fmt.Println(team_two.PsnTime)
  6123. if team.FundKey == team_two.FundKey {
  6124. fmt.Println(team_two.PsnTime)
  6125. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  6126. fmt.Println(team.PsnTime)
  6127. }
  6128. }
  6129. }
  6130. fmt.Println("1111")
  6131. fmt.Println(datas)
  6132. fmt.Println("1111")
  6133. var twos []models.FixMonRecDetailFileInTwo
  6134. for _, team := range datas {
  6135. var two models.FixMonRecDetailFileInTwo
  6136. two.MedType = team.MedType
  6137. two.Insutype = team.Insutype
  6138. two.PsnType = team.PsnType
  6139. two.MedType = team.MedType
  6140. two.FixBlngAdmdvs = "999999"
  6141. two.InsuAdmdvs = "555555"
  6142. two.PsnTime = team.PsnTime
  6143. two.PsnCnt = team.PsnCnt
  6144. two.FundKey = team.FundKey
  6145. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6146. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6147. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6148. two.MedfeeSumAmt = ms
  6149. two.InscpAmt = ia
  6150. two.FundPaySumAmt = fps
  6151. twos = append(twos, two)
  6152. }
  6153. //startTime := c.GetString("start_time")
  6154. //endTime, _ := c.GetString("end_time")
  6155. times := strings.Split(startTime, "-")
  6156. stmt_mon := times[0] + times[1]
  6157. var funs []models.FundDetail
  6158. for _, item := range datas {
  6159. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6160. funs = append(funs, fun...)
  6161. }
  6162. var funInfos []models.Fund
  6163. //for _, item := range funs {
  6164. // var rf []models.FundInfo
  6165. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6166. // for _, subitem := range rf {
  6167. // var fund models.Fund
  6168. // fund.FundCode = subitem.FundPayType
  6169. // fund.FundName = subitem.FundPayTypeName
  6170. // fund.FundAmt = subitem.FundPayAmt
  6171. // fund.FundKey = item.FundKey
  6172. // fund.InsuAdmdvs = "555555"
  6173. // fund.FixBlngAdmdvs = "999999"
  6174. // funInfos = append(funInfos, fund)
  6175. // }
  6176. //}
  6177. var tempFuns []TempFun
  6178. for _, funInfo := range funInfos {
  6179. var tempFun TempFun
  6180. tempFun.FundKey = funInfo.FundKey
  6181. tempFun.FundCode = funInfo.FundCode
  6182. tempFuns = append(tempFuns, tempFun)
  6183. }
  6184. tempFuns = RemoveRepeatedFunElement(tempFuns)
  6185. fmt.Println(tempFuns)
  6186. var funInfosTwo []models.Fund
  6187. decimal.DivisionPrecision = 2
  6188. for _, item := range tempFuns {
  6189. var fund models.Fund
  6190. for _, subItem := range funInfos {
  6191. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  6192. fund.FundKey = subItem.FundKey
  6193. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6194. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6195. fund.FundName = subItem.FundName
  6196. fund.FundCode = subItem.FundCode
  6197. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6198. }
  6199. }
  6200. funInfosTwo = append(funInfosTwo, fund)
  6201. }
  6202. fmt.Println("funInfosTwo")
  6203. fmt.Println(funInfosTwo)
  6204. var upld_btch string
  6205. var empty models.JSResultEmpty
  6206. data := make(map[string]interface{})
  6207. data["org_name"] = miConfig.OrgName
  6208. data["doctor"] = curRoles.UserName
  6209. data["doctor_name"] = curRoles.UserName
  6210. data["fixmedins_code"] = miConfig.Code
  6211. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6212. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6213. data["secret_key"] = miConfig.SecretKey
  6214. data["url"] = miConfig.Url
  6215. data["ak"] = miConfig.AccessKey
  6216. data["cainfo"] = miConfig.Cainfo
  6217. data["datas"] = twos
  6218. data["fund"] = funInfosTwo
  6219. fmt.Println(twos)
  6220. month := time.Unix(1557042972, 0).Format("1")
  6221. year := time.Now().Format("2006")
  6222. month = time.Now().Format("01")
  6223. day := time.Now().Format("02")
  6224. hour := time.Now().Format("15")
  6225. min := time.Now().Format("04")
  6226. sec := time.Now().Format("05")
  6227. fix_fill_date := year + month + day + hour + min + sec
  6228. data["fix_fill_dept"] = miConfig.OrgName
  6229. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6230. data["fix_fill_psn"] = curRoles.UserName
  6231. data["fix_fill_date"] = fix_fill_date
  6232. data["stmt_loc"] = "2"
  6233. data["setl_mon"] = stmt_mon
  6234. upld_btch = "0"
  6235. data["upld_btch"] = upld_btch
  6236. //fmt.Println(data)
  6237. client := &http.Client{}
  6238. bytesData, _ := json.Marshal(data)
  6239. var req *http.Request
  6240. if miConfig.MdtrtareaAdmvs == "320921" {
  6241. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6242. } else {
  6243. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6244. }
  6245. resp, _ := client.Do(req)
  6246. defer resp.Body.Close()
  6247. body, ioErr := ioutil.ReadAll(resp.Body)
  6248. if ioErr != nil {
  6249. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6251. }
  6252. var respJSON map[string]interface{}
  6253. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6256. }
  6257. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6258. //fmt.Println(respJSON)
  6259. result, _ := json.Marshal(respJSON)
  6260. //fmt.Println(result)
  6261. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6262. utils.ErrorLog("解析失败:%v", err)
  6263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6264. }
  6265. if empty.Infcode != "0" {
  6266. c.ServeSuccessJSON(map[string]interface{}{
  6267. "failed_code": -10,
  6268. "msg": empty.ErrMsg,
  6269. })
  6270. return
  6271. } else {
  6272. c.ServeSuccessJSON(map[string]interface{}{
  6273. "msg": "上传成功",
  6274. })
  6275. return
  6276. }
  6277. }
  6278. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6279. newArr = make([]TempFun, 0)
  6280. for i := 0; i < len(arr); i++ {
  6281. repeat := false
  6282. for j := i + 1; j < len(arr); j++ {
  6283. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6284. repeat = true
  6285. break
  6286. }
  6287. }
  6288. if !repeat {
  6289. newArr = append(newArr, arr[i])
  6290. }
  6291. }
  6292. return
  6293. }
  6294. func (c *HisApiController) Get3263() {
  6295. admin_user_id, _ := c.GetInt64("admin_user_id")
  6296. startTime := c.GetString("start_time")
  6297. //endTime, _ := c.GetString("end_time")
  6298. times := strings.Split(startTime, "-")
  6299. setl_mon := times[0] + times[1]
  6300. upld_btch := "0"
  6301. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6302. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6303. var result3263 models.JSResult3263
  6304. data := make(map[string]interface{})
  6305. data["org_name"] = miConfig.OrgName
  6306. data["doctor"] = curRoles.UserName
  6307. data["doctor_name"] = curRoles.UserName
  6308. data["fixmedins_code"] = miConfig.Code
  6309. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6310. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6311. data["secret_key"] = miConfig.SecretKey
  6312. data["url"] = miConfig.Url
  6313. data["ak"] = miConfig.AccessKey
  6314. data["cainfo"] = miConfig.Cainfo
  6315. data["setl_mon"] = setl_mon
  6316. data["stmt_loc"] = "2"
  6317. data["upld_btch"] = upld_btch
  6318. client := &http.Client{}
  6319. bytesData, _ := json.Marshal(data)
  6320. var req *http.Request
  6321. if miConfig.MdtrtareaAdmvs == "320921" {
  6322. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6323. } else {
  6324. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6325. }
  6326. resp, _ := client.Do(req)
  6327. defer resp.Body.Close()
  6328. body, ioErr := ioutil.ReadAll(resp.Body)
  6329. if ioErr != nil {
  6330. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6332. }
  6333. var respJSON map[string]interface{}
  6334. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6337. }
  6338. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6339. fmt.Println(respJSON)
  6340. result, _ := json.Marshal(respJSON)
  6341. fmt.Println(result)
  6342. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6343. utils.ErrorLog("解析失败:%v", err)
  6344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6345. }
  6346. if result3263.Infcode != "0" {
  6347. c.ServeSuccessJSON(map[string]interface{}{
  6348. "failed_code": -10,
  6349. "msg": result3263.ErrMsg,
  6350. })
  6351. return
  6352. } else {
  6353. c.ServeSuccessJSON(map[string]interface{}{
  6354. "list": result3263.Output,
  6355. })
  6356. return
  6357. }
  6358. }
  6359. func (c *HisApiController) Get3264() {
  6360. admin_user_id, _ := c.GetInt64("admin_user_id")
  6361. startTime := c.GetString("start_time")
  6362. //endTime, _ := c.GetString("end_time")
  6363. times := strings.Split(startTime, "-")
  6364. setl_mon := times[0] + times[1]
  6365. upld_btch := "0"
  6366. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6367. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6368. //solidify_id := []
  6369. var result3263 models.JSResult3263
  6370. data := make(map[string]interface{})
  6371. data["org_name"] = miConfig.OrgName
  6372. data["doctor"] = curRoles.UserName
  6373. data["doctor_name"] = curRoles.UserName
  6374. data["fixmedins_code"] = miConfig.Code
  6375. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6376. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6377. data["secret_key"] = miConfig.SecretKey
  6378. data["url"] = miConfig.Url
  6379. data["ak"] = miConfig.AccessKey
  6380. data["cainfo"] = miConfig.Cainfo
  6381. data["setl_mon"] = setl_mon
  6382. data["stmt_loc"] = "2"
  6383. data["upld_btch"] = upld_btch
  6384. client := &http.Client{}
  6385. bytesData, _ := json.Marshal(data)
  6386. var req3263 *http.Request
  6387. if miConfig.MdtrtareaAdmvs == "320921" {
  6388. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6389. } else {
  6390. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6391. }
  6392. resp, _ := client.Do(req3263)
  6393. defer resp.Body.Close()
  6394. body, ioErr := ioutil.ReadAll(resp.Body)
  6395. if ioErr != nil {
  6396. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6398. }
  6399. var respJSON3263 map[string]interface{}
  6400. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6401. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6403. }
  6404. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6405. fmt.Println(respJSON3263)
  6406. result, _ := json.Marshal(respJSON3263)
  6407. fmt.Println(result)
  6408. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6409. utils.ErrorLog("解析失败:%v", err)
  6410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6411. }
  6412. var ids []string
  6413. for _, item := range result3263.Output {
  6414. ids = append(ids, item.SolidifyID)
  6415. }
  6416. var empty models.JSResultEmpty
  6417. data2 := make(map[string]interface{})
  6418. data2["org_name"] = miConfig.OrgName
  6419. data2["doctor"] = curRoles.UserName
  6420. data2["doctor_name"] = curRoles.UserName
  6421. data2["fixmedins_code"] = miConfig.Code
  6422. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6423. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6424. data2["secret_key"] = miConfig.SecretKey
  6425. data2["url"] = miConfig.Url
  6426. data2["ak"] = miConfig.AccessKey
  6427. data2["cainfo"] = miConfig.Cainfo
  6428. data2["setl_mon"] = setl_mon
  6429. data2["stmt_loc"] = "2"
  6430. data2["upld_btch"] = upld_btch
  6431. data2["solidify_id"] = ids
  6432. client2 := &http.Client{}
  6433. bytesData2, _ := json.Marshal(data2)
  6434. var req *http.Request
  6435. if miConfig.MdtrtareaAdmvs == "320921" {
  6436. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6437. } else {
  6438. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6439. }
  6440. resp2, _ := client2.Do(req)
  6441. defer resp.Body.Close()
  6442. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6443. if ioErr2 != nil {
  6444. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6446. }
  6447. var respJSON map[string]interface{}
  6448. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6449. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6451. }
  6452. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6453. fmt.Println(respJSON)
  6454. result2, _ := json.Marshal(respJSON)
  6455. fmt.Println(result2)
  6456. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6457. utils.ErrorLog("解析失败:%v", err)
  6458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6459. }
  6460. if empty.Infcode != "0" {
  6461. c.ServeSuccessJSON(map[string]interface{}{
  6462. "failed_code": -10,
  6463. "msg": empty.ErrMsg,
  6464. })
  6465. return
  6466. } else {
  6467. c.ServeSuccessJSON(map[string]interface{}{
  6468. "msg": "",
  6469. })
  6470. return
  6471. }
  6472. }
  6473. func (c *HisApiController) Get3265() {
  6474. admin_user_id, _ := c.GetInt64("admin_user_id")
  6475. startTime := c.GetString("start_time")
  6476. //endTime, _ := c.GetString("end_time")
  6477. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6478. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6479. times := strings.Split(startTime, "-")
  6480. setl_mon := times[0] + times[1]
  6481. var upld_btch string
  6482. upld_btch = "0"
  6483. //var empty models.JSResultEmpty
  6484. var result3265 models.JSResult3264
  6485. var result3263 models.JSResult3263
  6486. data2 := make(map[string]interface{})
  6487. data2["org_name"] = miConfig.OrgName
  6488. data2["doctor"] = curRoles.UserName
  6489. data2["doctor_name"] = curRoles.UserName
  6490. data2["fixmedins_code"] = miConfig.Code
  6491. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6492. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6493. data2["secret_key"] = miConfig.SecretKey
  6494. data2["url"] = miConfig.Url
  6495. data2["ak"] = miConfig.AccessKey
  6496. data2["cainfo"] = miConfig.Cainfo
  6497. data2["setl_mon"] = setl_mon
  6498. data2["stmt_loc"] = "2"
  6499. data2["upld_btch"] = upld_btch
  6500. client2 := &http.Client{}
  6501. bytesData2, _ := json.Marshal(data2)
  6502. var req3263 *http.Request
  6503. if miConfig.MdtrtareaAdmvs == "320921" {
  6504. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6505. } else {
  6506. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6507. }
  6508. resp2, _ := client2.Do(req3263)
  6509. defer resp2.Body.Close()
  6510. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6511. if ioErr2 != nil {
  6512. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6514. }
  6515. var respJSON3263 map[string]interface{}
  6516. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6519. }
  6520. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6521. fmt.Println(respJSON3263)
  6522. result2, _ := json.Marshal(respJSON3263)
  6523. fmt.Println(result2)
  6524. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6525. utils.ErrorLog("解析失败:%v", err)
  6526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6527. }
  6528. var ids []string
  6529. for _, item := range result3263.Output {
  6530. ids = append(ids, item.SolidifyID)
  6531. }
  6532. data := make(map[string]interface{})
  6533. data["org_name"] = miConfig.OrgName
  6534. data["doctor"] = curRoles.UserName
  6535. data["doctor_name"] = curRoles.UserName
  6536. data["fixmedins_code"] = miConfig.Code
  6537. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6538. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6539. data["secret_key"] = miConfig.SecretKey
  6540. data["url"] = miConfig.Url
  6541. data["ak"] = miConfig.AccessKey
  6542. data["cainfo"] = miConfig.Cainfo
  6543. data["setl_mon"] = setl_mon
  6544. data["solidify_id"] = ids
  6545. month := time.Unix(1557042972, 0).Format("1")
  6546. year := time.Now().Format("2006")
  6547. month = time.Now().Format("01")
  6548. day := time.Now().Format("02")
  6549. hour := time.Now().Format("15")
  6550. min := time.Now().Format("04")
  6551. sec := time.Now().Format("05")
  6552. fix_fill_date := year + month + day + hour + min + sec
  6553. data["fix_fill_dept"] = miConfig.OrgName
  6554. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6555. data["fix_fill_psn"] = curRoles.UserName
  6556. data["fix_fill_date"] = fix_fill_date
  6557. data["stmt_loc"] = "2"
  6558. data["upld_btch"] = upld_btch
  6559. client := &http.Client{}
  6560. bytesData, _ := json.Marshal(data)
  6561. var req *http.Request
  6562. if miConfig.MdtrtareaAdmvs == "320921" {
  6563. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6564. } else {
  6565. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6566. }
  6567. resp, _ := client.Do(req)
  6568. defer resp.Body.Close()
  6569. body, ioErr := ioutil.ReadAll(resp.Body)
  6570. if ioErr != nil {
  6571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6573. }
  6574. var respJSON map[string]interface{}
  6575. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6576. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6578. }
  6579. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6580. fmt.Println(respJSON)
  6581. result, _ := json.Marshal(respJSON)
  6582. fmt.Println(result)
  6583. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6584. utils.ErrorLog("解析失败:%v", err)
  6585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6586. }
  6587. if result3265.Infcode != "0" {
  6588. c.ServeSuccessJSON(map[string]interface{}{
  6589. "failed_code": -10,
  6590. "msg": result3265.ErrMsg,
  6591. })
  6592. return
  6593. } else {
  6594. c.ServeSuccessJSON(map[string]interface{}{
  6595. "info": result3265.Output,
  6596. })
  6597. return
  6598. }
  6599. }
  6600. func (c *HisApiController) Get3266() {
  6601. admin_user_id, _ := c.GetInt64("admin_user_id")
  6602. startTime := c.GetString("start_time")
  6603. //endTime, _ := c.GetString("end_time")
  6604. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6605. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6606. times := strings.Split(startTime, "-")
  6607. stmt_mon := times[0] + times[1]
  6608. var upld_btch string
  6609. //var empty models.JSResultEmpty
  6610. var result3265 models.JSResult3264
  6611. data := make(map[string]interface{})
  6612. data["org_name"] = miConfig.OrgName
  6613. data["doctor"] = curRoles.UserName
  6614. data["doctor_name"] = curRoles.UserName
  6615. data["fixmedins_code"] = miConfig.Code
  6616. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6617. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6618. data["secret_key"] = miConfig.SecretKey
  6619. data["url"] = miConfig.Url
  6620. data["ak"] = miConfig.AccessKey
  6621. data["cainfo"] = miConfig.Cainfo
  6622. data["setl_mon"] = stmt_mon
  6623. month := time.Unix(1557042972, 0).Format("1")
  6624. year := time.Now().Format("2006")
  6625. month = time.Now().Format("01")
  6626. day := time.Now().Format("02")
  6627. hour := time.Now().Format("15")
  6628. min := time.Now().Format("04")
  6629. sec := time.Now().Format("05")
  6630. fix_fill_date := year + month + day + hour + min + sec
  6631. data["fix_fill_dept"] = miConfig.OrgName
  6632. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6633. data["fix_fill_psn"] = curRoles.UserName
  6634. data["fix_fill_date"] = fix_fill_date
  6635. data["stmt_loc"] = "2"
  6636. upld_btch = "0"
  6637. data["upld_btch"] = upld_btch
  6638. client := &http.Client{}
  6639. bytesData, _ := json.Marshal(data)
  6640. var req *http.Request
  6641. if miConfig.MdtrtareaAdmvs == "320921" {
  6642. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6643. } else {
  6644. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6645. }
  6646. resp, _ := client.Do(req)
  6647. defer resp.Body.Close()
  6648. body, ioErr := ioutil.ReadAll(resp.Body)
  6649. if ioErr != nil {
  6650. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6652. }
  6653. var respJSON map[string]interface{}
  6654. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6655. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6657. }
  6658. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6659. fmt.Println(respJSON)
  6660. result, _ := json.Marshal(respJSON)
  6661. fmt.Println(result)
  6662. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6663. utils.ErrorLog("解析失败:%v", err)
  6664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6665. }
  6666. if result3265.Infcode != "0" {
  6667. c.ServeSuccessJSON(map[string]interface{}{
  6668. "failed_code": -10,
  6669. "msg": result3265.ErrMsg,
  6670. })
  6671. return
  6672. } else {
  6673. c.ServeSuccessJSON(map[string]interface{}{
  6674. "info": result3265.Output,
  6675. })
  6676. return
  6677. }
  6678. }
  6679. func (c *HisApiController) Get3267() {
  6680. admin_user_id, _ := c.GetInt64("admin_user_id")
  6681. startTime := c.GetString("start_time")
  6682. //endTime, _ := c.GetString("end_time")
  6683. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6684. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6685. times := strings.Split(startTime, "-")
  6686. setl_mon := times[0] + times[1]
  6687. var upld_btch string
  6688. //var empty models.JSResultEmpty
  6689. var result3265 models.JSResult3264
  6690. upld_btch = "0"
  6691. data := make(map[string]interface{})
  6692. data["org_name"] = miConfig.OrgName
  6693. data["doctor"] = curRoles.UserName
  6694. data["doctor_name"] = curRoles.UserName
  6695. data["fixmedins_code"] = miConfig.Code
  6696. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6697. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6698. data["secret_key"] = miConfig.SecretKey
  6699. data["url"] = miConfig.Url
  6700. data["ak"] = miConfig.AccessKey
  6701. data["cainfo"] = miConfig.Cainfo
  6702. data["setl_mon"] = setl_mon
  6703. data["stmt_loc"] = "2"
  6704. data["upld_btch"] = upld_btch
  6705. client := &http.Client{}
  6706. bytesData, _ := json.Marshal(data)
  6707. var req *http.Request
  6708. if miConfig.MdtrtareaAdmvs == "320921" {
  6709. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6710. } else {
  6711. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6712. }
  6713. resp, _ := client.Do(req)
  6714. defer resp.Body.Close()
  6715. body, ioErr := ioutil.ReadAll(resp.Body)
  6716. if ioErr != nil {
  6717. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6719. }
  6720. var respJSON map[string]interface{}
  6721. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6722. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6724. }
  6725. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6726. fmt.Println(respJSON)
  6727. result, _ := json.Marshal(respJSON)
  6728. fmt.Println(result)
  6729. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6730. utils.ErrorLog("解析失败:%v", err)
  6731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6732. }
  6733. if result3265.Infcode != "0" {
  6734. c.ServeSuccessJSON(map[string]interface{}{
  6735. "failed_code": -10,
  6736. "msg": result3265.ErrMsg,
  6737. })
  6738. return
  6739. } else {
  6740. c.ServeSuccessJSON(map[string]interface{}{
  6741. "info": result3265.Output.Data,
  6742. })
  6743. return
  6744. }
  6745. }
  6746. func (c *HisApiController) Get3268() {
  6747. admin_user_id, _ := c.GetInt64("admin_user_id")
  6748. startTime := c.GetString("start_time")
  6749. endTime := c.GetString("end_time")
  6750. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6751. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6752. times := strings.Split(startTime, "-")
  6753. setl_mon := times[0] + times[1]
  6754. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6755. var twos []models.FixMonRecDetailFileInTwo
  6756. var funs []models.FundDetail
  6757. for _, item := range datas {
  6758. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6759. funs = append(funs, fun...)
  6760. }
  6761. var funInfos []models.Fund
  6762. //for _, item := range funs {
  6763. // var rf []models.FundInfo
  6764. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6765. // for _, subitem := range rf {
  6766. // var fund models.Fund
  6767. // fund.FundCode = subitem.FundPayType
  6768. // fund.FundName = subitem.FundPayTypeName
  6769. // fund.FundAmt = subitem.FundPayAmt
  6770. // fund.FundKey = item.FundKey
  6771. // fund.InsuAdmdvs = "555555"
  6772. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  6773. // funInfos = append(funInfos, fund)
  6774. // }
  6775. //}
  6776. for _, team := range datas {
  6777. var two models.FixMonRecDetailFileInTwo
  6778. two.SetlDate = time.Now().Format("2006-01-02")
  6779. two.MedType = team.MedType
  6780. two.Insutype = team.Insutype
  6781. two.PsnType = team.PsnType
  6782. two.MedType = team.MedType
  6783. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  6784. two.InsuAdmdvs = team.InsuAdmdvs
  6785. two.PsnTime = team.PsnTime
  6786. two.PsnCnt = team.PsnCnt
  6787. two.FundKey = team.FundKey
  6788. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6789. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6790. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6791. two.MedfeeSumAmt = ms
  6792. two.InscpAmt = ia
  6793. two.FundPaySumAmt = fps
  6794. twos = append(twos, two)
  6795. }
  6796. var upld_btch string
  6797. upld_btch = "0"
  6798. var empty models.JSResultEmpty
  6799. data := make(map[string]interface{})
  6800. data["org_name"] = miConfig.OrgName
  6801. data["doctor"] = curRoles.UserName
  6802. data["doctor_name"] = curRoles.UserName
  6803. data["fixmedins_code"] = miConfig.Code
  6804. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6805. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6806. data["secret_key"] = miConfig.SecretKey
  6807. data["url"] = miConfig.Url
  6808. data["ak"] = miConfig.AccessKey
  6809. data["cainfo"] = miConfig.Cainfo
  6810. data["datas"] = twos
  6811. data["fund"] = funInfos
  6812. data["setl_mon"] = setl_mon
  6813. month := time.Unix(1557042972, 0).Format("1")
  6814. year := time.Now().Format("2006")
  6815. month = time.Now().Format("01")
  6816. day := time.Now().Format("02")
  6817. hour := time.Now().Format("15")
  6818. min := time.Now().Format("04")
  6819. sec := time.Now().Format("05")
  6820. fix_fill_date := year + month + day + hour + min + sec
  6821. data["fix_fill_dept"] = miConfig.OrgName
  6822. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6823. data["fix_fill_psn"] = curRoles.UserName
  6824. data["fix_fill_date"] = fix_fill_date
  6825. data["stmt_loc"] = "2"
  6826. data["upld_btch"] = upld_btch
  6827. client := &http.Client{}
  6828. bytesData, _ := json.Marshal(data)
  6829. var req *http.Request
  6830. if miConfig.MdtrtareaAdmvs == "320921" {
  6831. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6832. } else {
  6833. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6834. }
  6835. resp, _ := client.Do(req)
  6836. defer resp.Body.Close()
  6837. body, ioErr := ioutil.ReadAll(resp.Body)
  6838. if ioErr != nil {
  6839. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6841. }
  6842. var respJSON map[string]interface{}
  6843. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6844. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6846. }
  6847. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6848. fmt.Println(respJSON)
  6849. result, _ := json.Marshal(respJSON)
  6850. fmt.Println(result)
  6851. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6852. utils.ErrorLog("解析失败:%v", err)
  6853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6854. }
  6855. if empty.Infcode != "0" {
  6856. c.ServeSuccessJSON(map[string]interface{}{
  6857. "failed_code": -10,
  6858. "msg": empty.ErrMsg,
  6859. })
  6860. return
  6861. } else {
  6862. c.ServeSuccessJSON(map[string]interface{}{
  6863. "msg": "上传成功",
  6864. })
  6865. return
  6866. }
  6867. }
  6868. func (c *HisApiController) Get3269() {
  6869. admin_user_id, _ := c.GetInt64("admin_user_id")
  6870. startTime := c.GetString("start_time")
  6871. //endTime, _ := c.GetString("end_time")
  6872. times := strings.Split(startTime, "-")
  6873. setl_mon := times[0] + times[1]
  6874. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6875. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6876. var result3263 models.JSResult3263
  6877. data := make(map[string]interface{})
  6878. data["org_name"] = miConfig.OrgName
  6879. data["doctor"] = curRoles.UserName
  6880. data["doctor_name"] = curRoles.UserName
  6881. data["fixmedins_code"] = miConfig.Code
  6882. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6883. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6884. data["secret_key"] = miConfig.SecretKey
  6885. data["url"] = miConfig.Url
  6886. data["ak"] = miConfig.AccessKey
  6887. data["cainfo"] = miConfig.Cainfo
  6888. data["setl_mon"] = setl_mon
  6889. data["stmt_loc"] = "2"
  6890. client := &http.Client{}
  6891. bytesData, _ := json.Marshal(data)
  6892. var req *http.Request
  6893. if miConfig.MdtrtareaAdmvs == "320921" {
  6894. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6895. } else {
  6896. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6897. }
  6898. resp, _ := client.Do(req)
  6899. defer resp.Body.Close()
  6900. body, ioErr := ioutil.ReadAll(resp.Body)
  6901. if ioErr != nil {
  6902. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6904. }
  6905. var respJSON map[string]interface{}
  6906. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6907. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6909. }
  6910. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6911. fmt.Println(respJSON)
  6912. result, _ := json.Marshal(respJSON)
  6913. fmt.Println(result)
  6914. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6915. utils.ErrorLog("解析失败:%v", err)
  6916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6917. }
  6918. if result3263.Infcode != "0" {
  6919. c.ServeSuccessJSON(map[string]interface{}{
  6920. "failed_code": -10,
  6921. "msg": result3263.ErrMsg,
  6922. })
  6923. return
  6924. } else {
  6925. c.ServeSuccessJSON(map[string]interface{}{
  6926. "msg": "上传成功",
  6927. })
  6928. return
  6929. }
  6930. }
  6931. func (c *HisApiController) Get3270() {
  6932. admin_user_id, _ := c.GetInt64("admin_user_id")
  6933. startTime := c.GetString("start_time")
  6934. //endTime, _ := c.GetString("end_time")
  6935. times := strings.Split(startTime, "-")
  6936. setl_mon := times[0] + times[1]
  6937. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6938. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6939. var result3263 models.JSResult3263
  6940. data2 := make(map[string]interface{})
  6941. data2["org_name"] = miConfig.OrgName
  6942. data2["doctor"] = curRoles.UserName
  6943. data2["doctor_name"] = curRoles.UserName
  6944. data2["fixmedins_code"] = miConfig.Code
  6945. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6946. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6947. data2["secret_key"] = miConfig.SecretKey
  6948. data2["url"] = miConfig.Url
  6949. data2["ak"] = miConfig.AccessKey
  6950. data2["cainfo"] = miConfig.Cainfo
  6951. data2["setl_mon"] = setl_mon
  6952. data2["stmt_loc"] = "2"
  6953. client2 := &http.Client{}
  6954. bytesData2, _ := json.Marshal(data2)
  6955. var req3263 *http.Request
  6956. if miConfig.MdtrtareaAdmvs == "320921" {
  6957. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6958. } else {
  6959. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6960. }
  6961. resp2, _ := client2.Do(req3263)
  6962. defer resp2.Body.Close()
  6963. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6964. if ioErr2 != nil {
  6965. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6967. }
  6968. var respJSON3263 map[string]interface{}
  6969. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6970. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6972. }
  6973. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6974. fmt.Println(respJSON3263)
  6975. result2, _ := json.Marshal(respJSON3263)
  6976. fmt.Println(result2)
  6977. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6978. utils.ErrorLog("解析失败:%v", err)
  6979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6980. }
  6981. var ids []string
  6982. for _, item := range result3263.Output {
  6983. ids = append(ids, item.SolidifyID)
  6984. }
  6985. var result3264 models.JSResult3264
  6986. data := make(map[string]interface{})
  6987. data["org_name"] = miConfig.OrgName
  6988. data["doctor"] = curRoles.UserName
  6989. data["doctor_name"] = curRoles.UserName
  6990. data["fixmedins_code"] = miConfig.Code
  6991. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6992. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6993. data["secret_key"] = miConfig.SecretKey
  6994. data["url"] = miConfig.Url
  6995. data["ak"] = miConfig.AccessKey
  6996. data["cainfo"] = miConfig.Cainfo
  6997. data["setl_mon"] = setl_mon
  6998. data["stmt_loc"] = "2"
  6999. data["solidify_id"] = ids
  7000. client := &http.Client{}
  7001. bytesData, _ := json.Marshal(data)
  7002. var req *http.Request
  7003. if miConfig.MdtrtareaAdmvs == "320921" {
  7004. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7005. } else {
  7006. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7007. }
  7008. resp, _ := client.Do(req)
  7009. defer resp.Body.Close()
  7010. body, ioErr := ioutil.ReadAll(resp.Body)
  7011. if ioErr != nil {
  7012. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7014. }
  7015. var respJSON map[string]interface{}
  7016. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7017. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7019. }
  7020. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7021. fmt.Println(respJSON)
  7022. result, _ := json.Marshal(respJSON)
  7023. fmt.Println(result)
  7024. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  7025. utils.ErrorLog("解析失败:%v", err)
  7026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7027. }
  7028. if result3264.Infcode != "0" {
  7029. c.ServeSuccessJSON(map[string]interface{}{
  7030. "failed_code": -10,
  7031. "msg": result3264.ErrMsg,
  7032. })
  7033. return
  7034. } else {
  7035. c.ServeSuccessJSON(map[string]interface{}{
  7036. "info": result3264.Output,
  7037. })
  7038. return
  7039. }
  7040. }
  7041. func (c *HisApiController) Get3271() {
  7042. admin_user_id, _ := c.GetInt64("admin_user_id")
  7043. startTime := c.GetString("start_time")
  7044. //endTime, _ := c.GetString("end_time")
  7045. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7046. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7047. times := strings.Split(startTime, "-")
  7048. setl_mon := times[0] + times[1]
  7049. //var empty models.JSResultEmpty
  7050. var result3265 models.JSResult3264
  7051. var result3263 models.JSResult3263
  7052. data2 := make(map[string]interface{})
  7053. data2["org_name"] = miConfig.OrgName
  7054. data2["doctor"] = curRoles.UserName
  7055. data2["doctor_name"] = curRoles.UserName
  7056. data2["fixmedins_code"] = miConfig.Code
  7057. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7058. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7059. data2["secret_key"] = miConfig.SecretKey
  7060. data2["url"] = miConfig.Url
  7061. data2["ak"] = miConfig.AccessKey
  7062. data2["cainfo"] = miConfig.Cainfo
  7063. data2["setl_mon"] = setl_mon
  7064. data2["stmt_loc"] = "2"
  7065. client2 := &http.Client{}
  7066. bytesData2, _ := json.Marshal(data2)
  7067. var req3263 *http.Request
  7068. if miConfig.MdtrtareaAdmvs == "320921" {
  7069. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7070. } else {
  7071. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7072. }
  7073. resp2, _ := client2.Do(req3263)
  7074. defer resp2.Body.Close()
  7075. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7076. if ioErr2 != nil {
  7077. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7079. }
  7080. var respJSON3263 map[string]interface{}
  7081. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7082. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7084. }
  7085. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7086. fmt.Println(respJSON3263)
  7087. result2, _ := json.Marshal(respJSON3263)
  7088. fmt.Println(result2)
  7089. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7090. utils.ErrorLog("解析失败:%v", err)
  7091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7092. }
  7093. var ids []string
  7094. for _, item := range result3263.Output {
  7095. ids = append(ids, item.SolidifyID)
  7096. }
  7097. data := make(map[string]interface{})
  7098. data["org_name"] = miConfig.OrgName
  7099. data["doctor"] = curRoles.UserName
  7100. data["doctor_name"] = curRoles.UserName
  7101. data["fixmedins_code"] = miConfig.Code
  7102. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7103. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7104. data["secret_key"] = miConfig.SecretKey
  7105. data["url"] = miConfig.Url
  7106. data["ak"] = miConfig.AccessKey
  7107. data["cainfo"] = miConfig.Cainfo
  7108. data["setl_mon"] = setl_mon
  7109. data["solidify_id"] = ids
  7110. month := time.Unix(1557042972, 0).Format("1")
  7111. year := time.Now().Format("2006")
  7112. month = time.Now().Format("01")
  7113. day := time.Now().Format("02")
  7114. hour := time.Now().Format("15")
  7115. min := time.Now().Format("04")
  7116. sec := time.Now().Format("05")
  7117. fix_fill_date := year + month + day + hour + min + sec
  7118. data["fix_fill_dept"] = miConfig.OrgName
  7119. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7120. data["fix_fill_psn"] = curRoles.UserName
  7121. data["fix_fill_date"] = fix_fill_date
  7122. data["stmt_loc"] = "2"
  7123. client := &http.Client{}
  7124. bytesData, _ := json.Marshal(data)
  7125. var req *http.Request
  7126. if miConfig.MdtrtareaAdmvs == "320921" {
  7127. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7128. } else {
  7129. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7130. }
  7131. resp, _ := client.Do(req)
  7132. defer resp.Body.Close()
  7133. body, ioErr := ioutil.ReadAll(resp.Body)
  7134. if ioErr != nil {
  7135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7137. }
  7138. var respJSON map[string]interface{}
  7139. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7140. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7142. }
  7143. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7144. fmt.Println(respJSON)
  7145. result, _ := json.Marshal(respJSON)
  7146. fmt.Println(result)
  7147. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7148. utils.ErrorLog("解析失败:%v", err)
  7149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7150. }
  7151. if result3265.Infcode != "0" {
  7152. c.ServeSuccessJSON(map[string]interface{}{
  7153. "failed_code": -10,
  7154. "msg": result3265.ErrMsg,
  7155. })
  7156. return
  7157. } else {
  7158. c.ServeSuccessJSON(map[string]interface{}{
  7159. "info": result3265.Output.Data,
  7160. })
  7161. return
  7162. }
  7163. }
  7164. func (c *HisApiController) Get3272() {
  7165. admin_user_id, _ := c.GetInt64("admin_user_id")
  7166. startTime := c.GetString("start_time")
  7167. //endTime, _ := c.GetString("end_time")
  7168. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7169. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7170. times := strings.Split(startTime, "-")
  7171. setl_mon := times[0] + times[1]
  7172. var upld_btch string
  7173. //var empty models.JSResultEmpty
  7174. var result3265 models.JSResult3264
  7175. data := make(map[string]interface{})
  7176. data["org_name"] = miConfig.OrgName
  7177. data["doctor"] = curRoles.UserName
  7178. data["doctor_name"] = curRoles.UserName
  7179. data["fixmedins_code"] = miConfig.Code
  7180. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7181. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7182. data["secret_key"] = miConfig.SecretKey
  7183. data["url"] = miConfig.Url
  7184. data["ak"] = miConfig.AccessKey
  7185. data["cainfo"] = miConfig.Cainfo
  7186. data["setl_mon"] = setl_mon
  7187. month := time.Unix(1557042972, 0).Format("1")
  7188. year := time.Now().Format("2006")
  7189. month = time.Now().Format("01")
  7190. day := time.Now().Format("02")
  7191. hour := time.Now().Format("15")
  7192. min := time.Now().Format("04")
  7193. sec := time.Now().Format("05")
  7194. fix_fill_date := year + month + day + hour + min + sec
  7195. data["fix_fill_dept"] = miConfig.OrgName
  7196. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7197. data["fix_fill_psn"] = curRoles.UserName
  7198. data["fix_fill_date"] = fix_fill_date
  7199. data["stmt_loc"] = "2"
  7200. data["upld_btch"] = upld_btch
  7201. client := &http.Client{}
  7202. bytesData, _ := json.Marshal(data)
  7203. var req *http.Request
  7204. if miConfig.MdtrtareaAdmvs == "320921" {
  7205. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7206. } else {
  7207. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7208. }
  7209. resp, _ := client.Do(req)
  7210. defer resp.Body.Close()
  7211. body, ioErr := ioutil.ReadAll(resp.Body)
  7212. if ioErr != nil {
  7213. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7215. }
  7216. var respJSON map[string]interface{}
  7217. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7218. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7220. }
  7221. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7222. fmt.Println(respJSON)
  7223. result, _ := json.Marshal(respJSON)
  7224. fmt.Println(result)
  7225. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7226. utils.ErrorLog("解析失败:%v", err)
  7227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7228. }
  7229. if result3265.Infcode != "0" {
  7230. c.ServeSuccessJSON(map[string]interface{}{
  7231. "failed_code": -10,
  7232. "msg": result3265.ErrMsg,
  7233. })
  7234. return
  7235. } else {
  7236. c.ServeSuccessJSON(map[string]interface{}{
  7237. "info": result3265.Output,
  7238. })
  7239. return
  7240. }
  7241. }
  7242. func (c *HisApiController) Get3273() {
  7243. admin_user_id, _ := c.GetInt64("admin_user_id")
  7244. startTime := c.GetString("start_time")
  7245. //endTime, _ := c.GetString("end_time")
  7246. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7247. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7248. times := strings.Split(startTime, "-")
  7249. setl_mon := times[0] + times[1]
  7250. var result3265 models.JSResult3264
  7251. data := make(map[string]interface{})
  7252. data["org_name"] = miConfig.OrgName
  7253. data["doctor"] = curRoles.UserName
  7254. data["doctor_name"] = curRoles.UserName
  7255. data["fixmedins_code"] = miConfig.Code
  7256. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7257. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7258. data["secret_key"] = miConfig.SecretKey
  7259. data["url"] = miConfig.Url
  7260. data["ak"] = miConfig.AccessKey
  7261. data["cainfo"] = miConfig.Cainfo
  7262. data["setl_mon"] = setl_mon
  7263. data["stmt_loc"] = "2"
  7264. client := &http.Client{}
  7265. bytesData, _ := json.Marshal(data)
  7266. var req *http.Request
  7267. if miConfig.MdtrtareaAdmvs == "320921" {
  7268. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7269. } else {
  7270. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7271. }
  7272. resp, _ := client.Do(req)
  7273. defer resp.Body.Close()
  7274. body, ioErr := ioutil.ReadAll(resp.Body)
  7275. if ioErr != nil {
  7276. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7278. }
  7279. var respJSON map[string]interface{}
  7280. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7281. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7283. }
  7284. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7285. fmt.Println(respJSON)
  7286. result, _ := json.Marshal(respJSON)
  7287. fmt.Println(result)
  7288. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7289. utils.ErrorLog("解析失败:%v", err)
  7290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7291. }
  7292. if result3265.Infcode != "0" {
  7293. c.ServeSuccessJSON(map[string]interface{}{
  7294. "failed_code": -10,
  7295. "msg": result3265.ErrMsg,
  7296. })
  7297. return
  7298. } else {
  7299. c.ServeSuccessJSON(map[string]interface{}{
  7300. "info": result3265.Output.Data,
  7301. })
  7302. return
  7303. }
  7304. }
  7305. func (c *HisApiController) Get3274() {
  7306. //if miConfig.MdtrtareaAdmvs == "320921" {
  7307. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7308. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7309. // "&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
  7310. //
  7311. //} else {
  7312. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7313. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7314. // "&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
  7315. //
  7316. //}
  7317. }
  7318. func (c *HisApiController) Get3275() {
  7319. //if miConfig.MdtrtareaAdmvs == "320921" {
  7320. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7321. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7322. // "&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
  7323. //
  7324. //} else {
  7325. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7326. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7327. // "&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
  7328. //
  7329. //}
  7330. }
  7331. func (c *HisApiController) Get3276() {
  7332. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7333. //month := c.GetString("month")
  7334. //
  7335. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7336. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7337. //var api string
  7338. //var res Result5301
  7339. //
  7340. //if miConfig.MdtrtareaAdmvs == "320921" {
  7341. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7342. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7343. //} else {
  7344. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7345. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7346. //}
  7347. //
  7348. //resp, requestErr := http.Get(api)
  7349. //if requestErr != nil {
  7350. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7351. // return
  7352. //}
  7353. //
  7354. //body, ioErr := ioutil.ReadAll(resp.Body)
  7355. //if ioErr != nil {
  7356. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7357. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7358. // return
  7359. //}
  7360. //var respJSON map[string]interface{}
  7361. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7362. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7363. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7364. // return
  7365. //}
  7366. //
  7367. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7368. //result, _ := json.Marshal(respJSON)
  7369. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7370. // utils.ErrorLog("解析失败:%v", err)
  7371. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7372. // return
  7373. //}
  7374. }
  7375. func (c *HisApiController) Get3277() {
  7376. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7377. //month := c.GetString("month")
  7378. //
  7379. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7380. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7381. //var api string
  7382. //var res Result5301
  7383. //
  7384. //if miConfig.MdtrtareaAdmvs == "320921" {
  7385. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7386. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7387. //} else {
  7388. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7389. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7390. //}
  7391. //
  7392. //resp, requestErr := http.Get(api)
  7393. //if requestErr != nil {
  7394. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7395. // return
  7396. //}
  7397. //
  7398. //body, ioErr := ioutil.ReadAll(resp.Body)
  7399. //if ioErr != nil {
  7400. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7401. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7402. // return
  7403. //}
  7404. //var respJSON map[string]interface{}
  7405. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7406. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7407. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7408. // return
  7409. //}
  7410. //
  7411. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7412. //result, _ := json.Marshal(respJSON)
  7413. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7414. // utils.ErrorLog("解析失败:%v", err)
  7415. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7416. // return
  7417. //}
  7418. }
  7419. //func (c *HisApiController) GetCFYLJG001() {
  7420. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7421. // patient_id, _ := c.GetInt64("patient_id")
  7422. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7423. // record_time := c.GetString("record_time")
  7424. // admin_user_id = 3626
  7425. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7426. // psn, _ := service.GetPsnByPatientId(patient_id)
  7427. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7428. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7429. // var cFYLJG001 models.CFYLJG001
  7430. //
  7431. // timeLayout := "2006-01-02"
  7432. // loc, _ := time.LoadLocation("Local")
  7433. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7434. // if err != nil {
  7435. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7436. // return
  7437. // }
  7438. // recordDateTime := theTime.Unix()
  7439. // prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7440. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7441. //
  7442. // //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7443. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7444. //
  7445. // //dept, _ := service.GetDepartMentDetail(info.Departments)
  7446. //
  7447. // for _, item := range prescriptions {
  7448. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7449. // if his.IdCardType == 1 {
  7450. // bas := strings.Split(psn.CardInfo, "|")
  7451. // basNumber := bas[1]
  7452. // fmt.Println(basNumber)
  7453. // card_sn := bas[3]
  7454. // card_no := bas[2]
  7455. // cFYLJG001.MdtrtCertType = "03"
  7456. // cFYLJG001.CardSn = card_sn
  7457. // cFYLJG001.MdtrtCertNo = card_no
  7458. // cFYLJG001.EcToken = ""
  7459. // cFYLJG001.AuthNo = ""
  7460. // } else if his.IdCardType == 2 {
  7461. // cFYLJG001.MdtrtCertType = "02"
  7462. // cFYLJG001.CardSn = ""
  7463. // cFYLJG001.MdtrtCertNo = his.IdCardNo
  7464. // cFYLJG001.EcToken = ""
  7465. // cFYLJG001.AuthNo = ""
  7466. // } else if his.IdCardType == 4 {
  7467. // cFYLJG001.MdtrtCertType = "01"
  7468. // cFYLJG001.CardSn = ""
  7469. // cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7470. // cFYLJG001.EcToken = psn.VerifyNumber
  7471. // cFYLJG001.AuthNo = ""
  7472. // }
  7473. // cFYLJG001.BizTypeCode = "01"
  7474. // cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7475. // cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7476. // cFYLJG001.RxTypeCode = "1"
  7477. // tempTime := time.Unix(item.PreTime, 0)
  7478. // timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7479. // cFYLJG001.PrscTime = timeFormatOne
  7480. // var count float64
  7481. // if item.Type == 1 {
  7482. // for _, sumItem := range item.HisDoctorAdviceInfo {
  7483. // count = count + sumItem.PrescribingNumber
  7484. // }
  7485. // }
  7486. // cFYLJG001.RxDrugCnt = count
  7487. // cFYLJG001.ValiDays = "5"
  7488. // ts := time.Unix(item.PreTime, 0)
  7489. // record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  7490. // tempTime3 := time.Unix(record_time2, 0)
  7491. // timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7492. // cFYLJG001.ValiEndTime = timeFormat3
  7493. // cFYLJG001.RxCotnFlag = "0"
  7494. // for _, subItem := range item.HisDoctorAdviceInfo {
  7495. // var drug models.RxDrug
  7496. // drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7497. // drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7498. // drug.RxItemTypeCode = "11"
  7499. //
  7500. // drug.DrugDosform = "乳膏剂" //TODO
  7501. // if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7502. // drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7503. // }
  7504. //
  7505. // drug.MedcWayDscr = subItem.DeliveryWay
  7506. //
  7507. // tempTime2 := time.Unix(subItem.StartTime, 0)
  7508. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7509. // drug.MedcBegntime = timeFormatTwo
  7510. // if subItem.Day > 0 {
  7511. // ts := time.Unix(subItem.StartTime, 0)
  7512. // record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7513. // tempTime4 := time.Unix(record_time, 0)
  7514. // timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7515. // drug.MedcEndtime = timeFormat5
  7516. // } else {
  7517. // tempTime2 := time.Unix(subItem.StartTime, 0)
  7518. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7519. // drug.MedcEndtime = timeFormatTwo
  7520. // }
  7521. //
  7522. // drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7523. // drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7524. // drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7525. // drug.DrugCnt = subItem.PrescribingNumber
  7526. // drug.DrugDosunt = subItem.PrescribingNumberUnit
  7527. // drug.DrugGenname = subItem.AdviceName
  7528. // drug.MedcWayCodg = subItem.DeliveryWay
  7529. // //drug.DrugTotlcnt = subItem.PrescribingNumber
  7530. // drug.SinDoscnt = subItem.SingleDose
  7531. // drug.SinDosunt = subItem.SingleDoseUnit
  7532. // drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7533. // drug.UsedFrquName = subItem.ExecutionFrequency
  7534. // drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7535. // drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7536. // drug.HospApprFlag = "1"
  7537. // cFYLJG001.List = append(cFYLJG001.List, drug)
  7538. // }
  7539. // cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7540. // cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  7541. // cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7542. // cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7543. // cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7544. // cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7545. // cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7546. // cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7547. // cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7548. // cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7549. // cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7550. // cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7551. // cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7552. // cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7553. // cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7554. // cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7555. // cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7556. // cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7557. // cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7558. // cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7559. // cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7560. // cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7561. // cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7562. // cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7563. // tempTime2 := time.Now().Unix()
  7564. // tempTime6 := time.Unix(tempTime2, 0)
  7565. // timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7566. // cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7567. // cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  7568. // cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7569. // cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  7570. // cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  7571. //
  7572. // //memo := make(map[string]interface{})
  7573. // //inputData := make(map[string]interface{}, 0)
  7574. //
  7575. // //type MyData struct {
  7576. // // Insutype string `json:"insutype"`
  7577. // //}
  7578. // //
  7579. // // data := MyData{
  7580. // // Insutype: his.Insutype,
  7581. // //}
  7582. // //
  7583. //
  7584. // diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7585. // var config []*models.HisXtDiagnoseConfig
  7586. // for _, item := range diagnosis_ids {
  7587. // id, _ := strconv.ParseInt(item, 10, 64)
  7588. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  7589. // config = append(config, &diagnosisConfig)
  7590. // }
  7591. // for index, subitem := range config {
  7592. // if index == 0 {
  7593. // var dia models.DiseInfo
  7594. // dia.DiagType = "1"
  7595. // dia.MaindiagFlag = "1"
  7596. // dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7597. // dia.DiagCode = subitem.CountryCode
  7598. // dia.DiagName = subitem.ClassName
  7599. // dia.DiagDept = "肾内科"
  7600. // dia.DiagDrNo = doctor.DoctorNumber
  7601. // dia.DiagDrName = doctor.UserName
  7602. // tempTime3 := time.Unix(item.PreTime, 0)
  7603. // timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7604. // dia.DiagTime = timeFormatTwo
  7605. // cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7606. // } else {
  7607. // var dia models.DiseInfo
  7608. // dia.DiagType = "1"
  7609. // dia.MaindiagFlag = "0"
  7610. // dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7611. // dia.DiagCode = subitem.CountryCode
  7612. // dia.DiagName = subitem.ClassName
  7613. // dia.DiagDept = "肾内科"
  7614. // dia.DiagDrNo = doctor.DoctorNumber
  7615. // dia.DiagDrName = doctor.UserName
  7616. // tempTime3 := time.Unix(item.PreTime, 0)
  7617. // timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7618. // dia.DiagTime = timeFormatTwo
  7619. // cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7620. // }
  7621. // }
  7622. // if miConfig.MdtrtareaAdmvs == "340699" {
  7623. // //result, request := service.GetAHCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7624. // //saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7625. //
  7626. // } else {
  7627. // result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7628. // saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7629. //
  7630. // }
  7631. //
  7632. // var res ResultCFYLJG001
  7633. // var respJSON2 map[string]interface{}
  7634. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7635. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7636. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7637. // return
  7638. // }
  7639. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7640. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7641. // utils.ErrorLog("解析失败:%v", err)
  7642. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7643. // return
  7644. // }
  7645. // if res.Infcode == -1 {
  7646. // c.ServeSuccessJSON(map[string]interface{}{
  7647. // "failed_code": -10,
  7648. // "msg": res.ErrMsg,
  7649. // })
  7650. // return
  7651. //
  7652. // } else {
  7653. // var flow models.HisPrescriptionFlow
  7654. // flow.Ctime = time.Now().Unix()
  7655. // flow.SignDigest = ""
  7656. // flow.RxTraceCode = res.Output.RxTraceCode
  7657. // flow.HiRxno = res.Output.HiRxno
  7658. // flow.MID = his.Number
  7659. // flow.Status = 1
  7660. // flow.DCode = doctor_info.DoctorNumber
  7661. // flow.OriginalRxFile = ""
  7662. // flow.OriginalValue = ""
  7663. // flow.SignCertDn = ""
  7664. // flow.UserOrgId = 10454
  7665. // flow.SignCertSn = ""
  7666. // flow.Mtime = time.Now().Unix()
  7667. //
  7668. // service.Createflow(&flow)
  7669. // c.ServeSuccessJSON(map[string]interface{}{
  7670. // "msg": "上传成功",
  7671. // })
  7672. // }
  7673. // }
  7674. //}
  7675. //func (c *HisApiController) GetCFYLJG002() {
  7676. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7677. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7678. // record_time := c.GetString("record_time")
  7679. // admin_user_id = 3626
  7680. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7681. // //id, _ := c.GetInt64("id")
  7682. // admin_user_id = 3626
  7683. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7684. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7685. //
  7686. // flow, _ := service.Getflowtwo(his.Number)
  7687. // //his, _ := service.GetHisPatientByNumber(flow.MID)
  7688. // //record_time := c.GetString("record_time")
  7689. // patient_id, _ := c.GetInt64("patient_id")
  7690. // //patient_id = 23834
  7691. // //record_time = "2023-09-18"
  7692. // timeLayout := "2006-01-02"
  7693. // loc, _ := time.LoadLocation("Local")
  7694. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7695. // if err != nil {
  7696. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7697. // return
  7698. // }
  7699. // recordDateTime := theTime.Unix()
  7700. // //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7701. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7702. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7703. //
  7704. // dept, _ := service.GetDepartMentDetail(info.Departments)
  7705. //
  7706. // inputData := make(map[string]interface{})
  7707. // inputData["rxTraceCode"] = flow.RxTraceCode
  7708. // inputData["hiRxno"] = flow.HiRxno
  7709. // inputData["mdtrtId"] = flow.MID
  7710. // inputData["patnName"] = his.PsnName
  7711. // inputData["psnCertType"] = his.PsnCertType
  7712. // inputData["certno"] = his.Certno
  7713. // inputData["fixmedinsName"] = miConfig.OrgName
  7714. // inputData["fixmedinsCode"] = miConfig.Code
  7715. // inputData["drCode"] = doctor_info.DoctorNumber
  7716. // inputData["prscDrName"] = doctor_info.UserName
  7717. // inputData["pharDeptName"] = dept.Name
  7718. // inputData["pharDeptCode"] = dept.Number
  7719. // inputData["pharProfttlCodg"] = dept.Name
  7720. // inputData["pharProfttlName"] = ""
  7721. // inputData["pharCode"] = "HY440309002107"
  7722. // inputData["pharCertType"] = "01"
  7723. // inputData["pharCertno"] = "430482199408260023"
  7724. // inputData["pharName"] = "彭斯遥"
  7725. // inputData["pharPracCertNo"] = ""
  7726. // tempTime2 := time.Unix(info.Ctime, 0)
  7727. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7728. // inputData["pharChkTime"] = timeFormatTwo
  7729. //
  7730. // bytesData, _ := json.Marshal(inputData)
  7731. // fmt.Println(string(bytesData))
  7732. // encoded := base64.StdEncoding.EncodeToString(bytesData)
  7733. // pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  7734. // if err != nil {
  7735. // fmt.Println("Error reading PDF file:", err)
  7736. // return
  7737. // }
  7738. //
  7739. // // 将 PDF 文件内容进行 Base64 编码
  7740. // rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  7741. //
  7742. // fmt.Println(err)
  7743. //
  7744. // if miConfig.MdtrtareaAdmvs == "340699" {
  7745. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7746. // //saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7747. //
  7748. // } else {
  7749. // result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7750. // //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  7751. // saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7752. //
  7753. // }
  7754. //
  7755. // var res2 Result002
  7756. // var respJSON2 map[string]interface{}
  7757. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7758. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7759. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7760. // return
  7761. // }
  7762. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7763. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7764. // utils.ErrorLog("解析失败:%v", err)
  7765. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7766. // return
  7767. // }
  7768. // if res2.Infcode == 0 {
  7769. // flow.Ctime = time.Now().Unix()
  7770. // flow.SignDigest = res2.Output.SignDigest
  7771. // flow.RxFile = res2.Output.RxFile
  7772. // flow.MID = his.Number
  7773. // flow.Status = 1
  7774. // flow.DCode = doctor_info.DoctorNumber
  7775. // flow.OriginalRxFile = rx_encoded
  7776. // flow.OriginalValue = encoded
  7777. // flow.SignCertDn = res2.Output.SignCertDn
  7778. // flow.SignCertSn = res2.Output.SignCertSn
  7779. // flow.Mtime = time.Now().Unix()
  7780. // service.Saveflow(flow)
  7781. // c.ServeSuccessJSON(map[string]interface{}{
  7782. // "msg": "预签名成功",
  7783. // })
  7784. // } else {
  7785. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7786. // return
  7787. // }
  7788. //}
  7789. //func (c *HisApiController) GetCFYLJG003() {
  7790. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7791. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7792. // record_time := c.GetString("record_time")
  7793. // admin_user_id = 3626
  7794. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7795. // //id, _ := c.GetInt64("id")
  7796. // admin_user_id = 3626
  7797. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7798. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7799. //
  7800. // flow, _ := service.Getflowtwo(his.Number)
  7801. // //id = 3
  7802. // patient_id, _ := c.GetInt64("patient_id")
  7803. // //patient_id = 23834
  7804. // //record_time = "2023-09-18"
  7805. // timeLayout := "2006-01-02"
  7806. // loc, _ := time.LoadLocation("Local")
  7807. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7808. // if err != nil {
  7809. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7810. // return
  7811. // }
  7812. // recordDateTime := theTime.Unix()
  7813. // //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7814. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7815. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7816. // dept, _ := service.GetDepartMentDetail(info.Departments)
  7817. //
  7818. // //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  7819. //
  7820. // var cFYLJG003 models.CFYLJG003
  7821. //
  7822. // cFYLJG003.RxTraceCode = flow.RxTraceCode
  7823. // cFYLJG003.HiRxno = flow.HiRxno
  7824. // cFYLJG003.MdtrtID = flow.MID
  7825. // cFYLJG003.PatnName = his.Name
  7826. // cFYLJG003.Certno = his.Certno
  7827. // cFYLJG003.FixmedinsName = miConfig.OrgName
  7828. // cFYLJG003.FixmedinsCode = miConfig.Code
  7829. //
  7830. // cFYLJG003.DrCode = doctor_info.DoctorNumber
  7831. // cFYLJG003.PrscDrName = doctor_info.UserName
  7832. // cFYLJG003.PharDeptName = dept.Name
  7833. // cFYLJG003.PharDeptCode = dept.Number
  7834. // cFYLJG003.PharCode = "HY440309002107"
  7835. // cFYLJG003.PharCertType = "01"
  7836. // cFYLJG003.PharCertno = "430482199408260023"
  7837. // cFYLJG003.PharName = "彭斯遥"
  7838. // cFYLJG003.PsnCertType = "01"
  7839. // cFYLJG003.RxFile = flow.RxFile
  7840. // cFYLJG003.SignDigest = flow.SignDigest
  7841. // cFYLJG003.FixmedinsCode = miConfig.Code
  7842. // cFYLJG003.PsnCertType = "01"
  7843. // cFYLJG003.PharProfttlCodg = dept.Name
  7844. // //inputData["pharProfttlCodg"] =dept.Name
  7845. //
  7846. // tempTime2 := time.Unix(info.Ctime, 0)
  7847. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7848. // cFYLJG003.PharChkTime = timeFormatTwo
  7849. //
  7850. // if miConfig.MdtrtareaAdmvs == "340699" {
  7851. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7852. // //result, request := service.GetAHCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7853. // //saveLog(result, request, "GetAHCFYLJG003", "GetAHCFYLJG003")
  7854. // } else {
  7855. // result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7856. // saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  7857. //
  7858. // }
  7859. //
  7860. // var res ResultCFYLJG003
  7861. // var respJSON2 map[string]interface{}
  7862. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7863. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7864. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7865. // return
  7866. // }
  7867. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7868. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7869. // utils.ErrorLog("解析失败:%v", err)
  7870. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7871. // return
  7872. // }
  7873. // if res.Infcode == -1 {
  7874. // c.ServeSuccessJSON(map[string]interface{}{
  7875. // "failed_code": -10,
  7876. // "msg": res.ErrMsg,
  7877. // })
  7878. // return
  7879. // } else {
  7880. // c.ServeSuccessJSON(map[string]interface{}{
  7881. // "info": res.Output,
  7882. // })
  7883. // }
  7884. //
  7885. //}
  7886. //func (c *HisApiController) GetCFYLJG004() {
  7887. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7888. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7889. // record_time := c.GetString("record_time")
  7890. // admin_user_id = 3626
  7891. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7892. // //id, _ := c.GetInt64("id")
  7893. // admin_user_id = 3626
  7894. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7895. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7896. //
  7897. // flow, _ := service.Getflowtwo(his.Number)
  7898. // //id = 3
  7899. // patient_id, _ := c.GetInt64("patient_id")
  7900. // //patient_id = 23834
  7901. // //record_time = "2023-09-18"
  7902. // timeLayout := "2006-01-02"
  7903. // loc, _ := time.LoadLocation("Local")
  7904. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7905. // if err != nil {
  7906. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7907. // return
  7908. // }
  7909. // recordDateTime := theTime.Unix()
  7910. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7911. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7912. // var cFYLJG004 models.CFYLJG004
  7913. // cFYLJG004.HiRxno = flow.HiRxno
  7914. // cFYLJG004.FixmedinsCode = miConfig.Code
  7915. // cFYLJG004.UndoDrCertno = doctor_info.IdCard
  7916. // cFYLJG004.UndoDrCertType = "01"
  7917. // cFYLJG004.UndoRea = "撤销处方"
  7918. // cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  7919. // cFYLJG004.UndoDrName = doctor_info.UserName
  7920. // cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  7921. //
  7922. // if miConfig.MdtrtareaAdmvs == "340699" {
  7923. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7924. // //result, request := service.GetAHCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7925. // //saveLog(result, request, "GetAHCFYLJG004", "GetAHCFYLJG004")
  7926. //
  7927. // } else {
  7928. // result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  7929. // saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  7930. //
  7931. // }
  7932. //
  7933. // var res ResultCFYLJG004
  7934. // var respJSON2 map[string]interface{}
  7935. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7936. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7937. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7938. // return
  7939. // }
  7940. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7941. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7942. // utils.ErrorLog("解析失败:%v", err)
  7943. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7944. // return
  7945. // }
  7946. // if res.Infcode == -1 {
  7947. // c.ServeSuccessJSON(map[string]interface{}{
  7948. // "failed_code": -10,
  7949. // "msg": res.ErrMsg,
  7950. // })
  7951. // return
  7952. // } else {
  7953. // flow.Status = 0
  7954. // service.Saveflow(flow)
  7955. // c.ServeSuccessJSON(map[string]interface{}{
  7956. // "msg": "撤销成功",
  7957. // })
  7958. // return
  7959. //
  7960. // }
  7961. //}
  7962. //func (c *HisApiController) GetCFYLJG005() {
  7963. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7964. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7965. // //record_time := c.GetString("record_time")
  7966. // admin_user_id = 3626
  7967. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7968. // //id, _ := c.GetInt64("id")
  7969. // admin_user_id = 3626
  7970. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7971. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7972. //
  7973. // flow, _ := service.Getflowtwo(his.Number)
  7974. // //id = 3
  7975. // var cFYLJG005 models.CFYLJG005
  7976. //
  7977. // //patient_id, _ := c.GetInt64("patient_id")
  7978. // cFYLJG005.HiRxno = flow.HiRxno
  7979. // cFYLJG005.MdtrtID = flow.MID
  7980. // cFYLJG005.EcToken = ""
  7981. // cFYLJG005.PsnName = his.Name
  7982. // cFYLJG005.PsnCertType = "01"
  7983. // cFYLJG005.Certno = his.IdCardNo
  7984. //
  7985. // if miConfig.MdtrtareaAdmvs == "340699" {
  7986. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7987. //
  7988. // //result, request := service.GetAHCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7989. // //saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7990. //
  7991. // } else {
  7992. // result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7993. // saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7994. //
  7995. // }
  7996. //
  7997. // var res ResultCFYLJG005
  7998. // var respJSON2 map[string]interface{}
  7999. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8000. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8001. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8002. // return
  8003. // }
  8004. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8005. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8006. // utils.ErrorLog("解析失败:%v", err)
  8007. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8008. // return
  8009. // }
  8010. // if res.Infcode == -1 {
  8011. // c.ServeSuccessJSON(map[string]interface{}{
  8012. // "failed_code": -10,
  8013. // "msg": res.ErrMsg,
  8014. // })
  8015. // return
  8016. // } else {
  8017. // c.ServeSuccessJSON(map[string]interface{}{
  8018. // "info": res.Output,
  8019. // })
  8020. // return
  8021. // }
  8022. //}
  8023. //func (c *HisApiController) GetCFYLJG006() {
  8024. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8025. // his_patient_id, _ := c.GetInt64("his_patient_id")
  8026. // admin_user_id = 3626
  8027. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8028. // //id, _ := c.GetInt64("id")
  8029. // admin_user_id = 3626
  8030. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8031. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8032. //
  8033. // flow, _ := service.Getflowtwo(his.Number)
  8034. // //id = 3
  8035. // patient_id, _ := c.GetInt64("patient_id")
  8036. // var cFYLJG006 models.CFYLJG006
  8037. // patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8038. // cFYLJG006.HiRxno = flow.HiRxno
  8039. // cFYLJG006.MdtrtID = flow.MID
  8040. // cFYLJG006.PsnName = patient.Name
  8041. // cFYLJG006.PsnCertType = "01"
  8042. // cFYLJG006.Certno = patient.IdCardNo
  8043. //
  8044. // if miConfig.MdtrtareaAdmvs == "340699" {
  8045. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8046. //
  8047. // result, request := service.GetAHCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8048. // saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8049. // } else {
  8050. // result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8051. // saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8052. // }
  8053. //
  8054. // var res ResultCFYLJG006
  8055. // var respJSON2 map[string]interface{}
  8056. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8057. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8058. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8059. // return
  8060. // }
  8061. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8062. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8063. // utils.ErrorLog("解析失败:%v", err)
  8064. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8065. // return
  8066. // }
  8067. // if res.Infcode == -1 {
  8068. // c.ServeSuccessJSON(map[string]interface{}{
  8069. // "failed_code": -10,
  8070. // "msg": res.ErrMsg,
  8071. // })
  8072. // return
  8073. // } else {
  8074. // c.ServeSuccessJSON(map[string]interface{}{
  8075. // "info": res.Output,
  8076. // })
  8077. // return
  8078. // }
  8079. //}
  8080. //func (c *HisApiController) GetCFYLJG007() {
  8081. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8082. // his_patient_id, _ := c.GetInt64("his_patient_id")
  8083. // admin_user_id = 3626
  8084. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8085. // //id, _ := c.GetInt64("id")
  8086. // admin_user_id = 3626
  8087. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8088. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8089. //
  8090. // flow, _ := service.Getflowtwo(his.Number)
  8091. // //id = 3
  8092. // patient_id, _ := c.GetInt64("patient_id")
  8093. // var cFYLJG007 models.CFYLJG007
  8094. // patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8095. // //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8096. //
  8097. // cFYLJG007.HiRxno = flow.HiRxno
  8098. // cFYLJG007.MdtrtID = flow.MID
  8099. // cFYLJG007.PsnNo = his.PsnNo
  8100. // cFYLJG007.PsnCertType = "01"
  8101. // cFYLJG007.Certno = patient.IdCardNo
  8102. // cFYLJG007.PsnName = patient.Name
  8103. //
  8104. // if miConfig.MdtrtareaAdmvs == "340699" {
  8105. // result, request := service.GetAHCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8106. // saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8107. // } else {
  8108. // result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8109. // saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8110. // }
  8111. //
  8112. // var res ResultCFYLJG007
  8113. // var respJSON2 map[string]interface{}
  8114. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8115. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8116. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8117. // return
  8118. // }
  8119. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8120. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8121. // utils.ErrorLog("解析失败:%v", err)
  8122. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8123. // return
  8124. // }
  8125. // if res.Infcode == -1 {
  8126. // c.ServeSuccessJSON(map[string]interface{}{
  8127. // "failed_code": -10,
  8128. // "msg": res.ErrMsg,
  8129. // })
  8130. // return
  8131. // } else {
  8132. // c.ServeSuccessJSON(map[string]interface{}{
  8133. // "info": res,
  8134. // })
  8135. // return
  8136. // }
  8137. //}
  8138. //
  8139. //func (c *HisApiController) GetCFYLJG008() {
  8140. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8141. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8142. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8143. // var cFYLJG008 models.CFYLJG008
  8144. // //id, _ := c.GetInt64("id")
  8145. // patient_id, _ := c.GetInt64("patient_id")
  8146. // //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8147. // //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8148. // //id = 3
  8149. // //flow, _ := service.Getflow(id)
  8150. // //his, _ := service.GetHisPatientByNumber(flow.MID)
  8151. //
  8152. // //
  8153. // //admin_user_id, _ := c.GetInt64("admin_user_id")
  8154. // //patient_id, _ := c.GetInt64("patient_id")
  8155. // //his_patient_id, _ := c.GetInt64("his_patient_id")
  8156. // record_time := c.GetString("record_time")
  8157. //
  8158. // admin_user_id = 3626
  8159. // patient_id = 19424
  8160. // //his_patient_id = 263947
  8161. // record_time = "2023-08-29"
  8162. //
  8163. // timeLayout := "2006-01-02"
  8164. // loc, _ := time.LoadLocation("Local")
  8165. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8166. // if err != nil {
  8167. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8168. // return
  8169. // }
  8170. // recordDateTime := theTime.Unix()
  8171. // prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8172. //
  8173. // cFYLJG008.FixmedinsName = ""
  8174. // cFYLJG008.Lat = ""
  8175. // cFYLJG008.Lng = ""
  8176. // cFYLJG008.OrderType = "1"
  8177. // cFYLJG008.PoolareaNo = ""
  8178. // cFYLJG008.Lng = ""
  8179. // cFYLJG008.PageNum = 1
  8180. // cFYLJG008.PageSize = 10
  8181. // var MPI models.MedinsProdInvChgDDTO
  8182. // MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8183. // MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8184. // cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8185. //
  8186. // if miConfig.MdtrtareaAdmvs == "340699" {
  8187. // result, request := service.GetAHCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8188. // saveLog(result, request, "GetAHCFYLJG008", "GetAHCFYLJG008")
  8189. //
  8190. // } else {
  8191. // result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8192. // saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8193. //
  8194. // var res ResultCFYLJG008
  8195. // var respJSON2 map[string]interface{}
  8196. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8197. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8198. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8199. // return
  8200. // }
  8201. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8202. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8203. // utils.ErrorLog("解析失败:%v", err)
  8204. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8205. // return
  8206. // }
  8207. // if res.Infcode == -1 {
  8208. // c.ServeSuccessJSON(map[string]interface{}{
  8209. // "failed_code": -10,
  8210. // "msg": res.ErrMsg,
  8211. // })
  8212. // return
  8213. // } else {
  8214. // c.ServeSuccessJSON(map[string]interface{}{
  8215. // "info": res.Output,
  8216. // })
  8217. // return
  8218. // }
  8219. // }
  8220. //
  8221. //}
  8222. func (c *HisApiController) GetBL4201A() {
  8223. order_id, _ := c.GetInt64("order_id")
  8224. admin_user_id, _ := c.GetInt64("admin_user_id")
  8225. order, _ := service.GetHisOrderByIDTwo(order_id)
  8226. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8227. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8228. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8229. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8230. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8231. department, _ := service.GetDepartMentDetail(his.Departments)
  8232. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8233. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8234. if order.ID == 0 {
  8235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8236. return
  8237. }
  8238. var struct4201A models.Struct4201A
  8239. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8240. for _, items := range order_info {
  8241. memo := make(map[string]interface{})
  8242. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8243. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8244. fsiOPFLD.MedType = "14"
  8245. fsiOPFLD.BkkpSn = items.FeedetlSn
  8246. fsiOPFLD.FixmedinsCode = miConfig.Code
  8247. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8248. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8249. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8250. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8251. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8252. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8253. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8254. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8255. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8256. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8257. fsiOPFLD.BilgDeptName = department.Name
  8258. fsiOPFLD.BilgDeptCodg = department.Number
  8259. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8260. fsiOPFLD.BilgDrName = doctor.UserName
  8261. fsiOPFLD.MedChrgitmType = "09"
  8262. memo["hosp_appr_flag"] = "1"
  8263. memo["invoice_no"] = order.MdtrtId
  8264. memo["memo"] = "自费"
  8265. bytesData, _ := json.Marshal(memo)
  8266. fsiOPFLD.Memo = string(bytesData)
  8267. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8268. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8269. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8270. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8271. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8272. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8273. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8274. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8275. fsiOPFLD.BilgDeptName = department.Name
  8276. fsiOPFLD.BilgDeptCodg = department.Number
  8277. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8278. fsiOPFLD.BilgDrName = doctor.UserName
  8279. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8280. case 0:
  8281. break
  8282. case 1:
  8283. fsiOPFLD.MedChrgitmType = "14"
  8284. break
  8285. case 2:
  8286. fsiOPFLD.MedChrgitmType = "05"
  8287. break
  8288. case 3:
  8289. fsiOPFLD.MedChrgitmType = "03"
  8290. break
  8291. case 4:
  8292. fsiOPFLD.MedChrgitmType = "03"
  8293. break
  8294. case 5:
  8295. fsiOPFLD.MedChrgitmType = "08"
  8296. break
  8297. case 6:
  8298. fsiOPFLD.MedChrgitmType = "14"
  8299. break
  8300. case 7:
  8301. fsiOPFLD.MedChrgitmType = "14"
  8302. break
  8303. case 8:
  8304. fsiOPFLD.MedChrgitmType = "03"
  8305. break
  8306. case 9:
  8307. fsiOPFLD.MedChrgitmType = "14"
  8308. break
  8309. case 10:
  8310. fsiOPFLD.MedChrgitmType = "14"
  8311. break
  8312. case 11:
  8313. fsiOPFLD.MedChrgitmType = "06"
  8314. break
  8315. case 12:
  8316. fsiOPFLD.MedChrgitmType = "12"
  8317. break
  8318. case 13:
  8319. fsiOPFLD.MedChrgitmType = "01"
  8320. break
  8321. case 14:
  8322. fsiOPFLD.MedChrgitmType = "04"
  8323. break
  8324. case 15:
  8325. fsiOPFLD.MedChrgitmType = "14"
  8326. break
  8327. }
  8328. memo["hosp_appr_flag"] = "1"
  8329. memo["invoice_no"] = order.MdtrtId
  8330. memo["memo"] = "自费"
  8331. bytesData, _ := json.Marshal(memo)
  8332. fsiOPFLD.Memo = string(bytesData)
  8333. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8334. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8335. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8336. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8337. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8338. fsiOPFLD.BilgDeptName = department.Name
  8339. fsiOPFLD.BilgDeptCodg = department.Number
  8340. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8341. fsiOPFLD.BilgDrName = doctor.UserName
  8342. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8343. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8344. fsiOPFLD.MedChrgitmType = "08"
  8345. memo["hosp_appr_flag"] = "1"
  8346. memo["invoice_no"] = order.MdtrtId
  8347. memo["memo"] = "自费"
  8348. bytesData, _ := json.Marshal(memo)
  8349. fsiOPFLD.Memo = string(bytesData)
  8350. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8351. }
  8352. }
  8353. }
  8354. for _, items := range order_info_two {
  8355. memo := make(map[string]interface{})
  8356. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8357. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8358. fsiOPFLD.MedType = "14"
  8359. fsiOPFLD.BkkpSn = items.FeedetlSn
  8360. fsiOPFLD.FixmedinsCode = miConfig.Code
  8361. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8362. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8363. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8364. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8365. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8366. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8367. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8368. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8369. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8370. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8371. fsiOPFLD.BilgDeptName = department.Name
  8372. fsiOPFLD.BilgDeptCodg = department.Number
  8373. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8374. fsiOPFLD.BilgDrName = doctor.UserName
  8375. fsiOPFLD.MedChrgitmType = "09"
  8376. memo["hosp_appr_flag"] = "1"
  8377. memo["invoice_no"] = order.MdtrtId
  8378. memo["memo"] = "自费"
  8379. bytesData, _ := json.Marshal(memo)
  8380. fsiOPFLD.Memo = string(bytesData)
  8381. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8382. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8383. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8384. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8385. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8386. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8387. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8388. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8389. fsiOPFLD.BilgDeptName = department.Name
  8390. fsiOPFLD.BilgDeptCodg = department.Number
  8391. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8392. fsiOPFLD.BilgDrName = doctor.UserName
  8393. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8394. case 0:
  8395. break
  8396. case 1:
  8397. fsiOPFLD.MedChrgitmType = "14"
  8398. break
  8399. case 2:
  8400. fsiOPFLD.MedChrgitmType = "05"
  8401. break
  8402. case 3:
  8403. fsiOPFLD.MedChrgitmType = "03"
  8404. break
  8405. case 4:
  8406. fsiOPFLD.MedChrgitmType = "03"
  8407. break
  8408. case 5:
  8409. fsiOPFLD.MedChrgitmType = "08"
  8410. break
  8411. case 6:
  8412. fsiOPFLD.MedChrgitmType = "14"
  8413. break
  8414. case 7:
  8415. fsiOPFLD.MedChrgitmType = "14"
  8416. break
  8417. case 8:
  8418. fsiOPFLD.MedChrgitmType = "03"
  8419. break
  8420. case 9:
  8421. fsiOPFLD.MedChrgitmType = "14"
  8422. break
  8423. case 10:
  8424. fsiOPFLD.MedChrgitmType = "14"
  8425. break
  8426. case 11:
  8427. fsiOPFLD.MedChrgitmType = "06"
  8428. break
  8429. case 12:
  8430. fsiOPFLD.MedChrgitmType = "12"
  8431. break
  8432. case 13:
  8433. fsiOPFLD.MedChrgitmType = "01"
  8434. break
  8435. case 14:
  8436. fsiOPFLD.MedChrgitmType = "04"
  8437. break
  8438. case 15:
  8439. fsiOPFLD.MedChrgitmType = "14"
  8440. break
  8441. }
  8442. memo["hosp_appr_flag"] = "1"
  8443. memo["invoice_no"] = order.MdtrtId
  8444. memo["memo"] = "自费"
  8445. bytesData, _ := json.Marshal(memo)
  8446. fsiOPFLD.Memo = string(bytesData)
  8447. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8448. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8449. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8450. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8451. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8452. fsiOPFLD.BilgDeptName = department.Name
  8453. fsiOPFLD.BilgDeptCodg = department.Number
  8454. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8455. fsiOPFLD.BilgDrName = doctor.UserName
  8456. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8457. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8458. fsiOPFLD.MedChrgitmType = "08"
  8459. memo["hosp_appr_flag"] = "1"
  8460. memo["invoice_no"] = order.MdtrtId
  8461. memo["memo"] = "自费"
  8462. bytesData, _ := json.Marshal(memo)
  8463. fsiOPFLD.Memo = string(bytesData)
  8464. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8465. }
  8466. }
  8467. }
  8468. fmt.Println(fsiOPFLDs)
  8469. struct4201A.Fopfd = fsiOPFLDs
  8470. fmt.Println(struct4201A.Fopfd)
  8471. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8472. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8473. var res2 ResultSix
  8474. var respJSON2 map[string]interface{}
  8475. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8476. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8478. return
  8479. }
  8480. userJSONBytes2, _ := json.Marshal(respJSON2)
  8481. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8482. utils.ErrorLog("解析失败:%v", err)
  8483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8484. return
  8485. }
  8486. if res2.Infcode != 0 {
  8487. c.ServeSuccessJSON(map[string]interface{}{
  8488. "failed_code": -10,
  8489. "msg": res2.ErrMsg,
  8490. })
  8491. return
  8492. } else {
  8493. order.IsUploadOrderInfo = 1
  8494. service.UpdateOrder(order)
  8495. c.ServeSuccessJSON(map[string]interface{}{
  8496. "msg": "上传成功",
  8497. })
  8498. }
  8499. }
  8500. func (c *HisApiController) Get3103() {
  8501. admin_user_id, _ := c.GetInt64("admin_user_id")
  8502. warm_type, _ := c.GetInt64("warm_type")
  8503. fk_state, _ := c.GetInt64("fk_state")
  8504. warm_ids := c.GetString("warm_ids")
  8505. desc := c.GetString("desc")
  8506. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8507. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8508. result, requestLog := service.Gdyb3103(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, warm_type, warm_ids, fk_state, desc)
  8509. saveLog(result, requestLog, "3103", "反馈")
  8510. var res2 ResultSix3103
  8511. var respJSON2 map[string]interface{}
  8512. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8513. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8515. return
  8516. }
  8517. userJSONBytes2, _ := json.Marshal(respJSON2)
  8518. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8519. utils.ErrorLog("解析失败:%v", err)
  8520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8521. return
  8522. }
  8523. if res2.Infcode != 0 {
  8524. c.ServeSuccessJSON(map[string]interface{}{
  8525. "failed_code": -10,
  8526. "msg": res2.ErrMsg,
  8527. })
  8528. return
  8529. } else {
  8530. c.ServeSuccessJSON(map[string]interface{}{
  8531. "msg": "反馈成功",
  8532. })
  8533. return
  8534. }
  8535. }
  8536. func (c *HisApiController) Get4201A() {
  8537. order_id, _ := c.GetInt64("order_id")
  8538. admin_user_id, _ := c.GetInt64("admin_user_id")
  8539. order, _ := service.GetHisOrderByIDTwo(order_id)
  8540. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8541. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8542. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8543. //order_info = append(order_info, order_info_two...)
  8544. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8545. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8546. department, _ := service.GetDepartMentDetail(his.Departments)
  8547. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8548. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8549. if order.ID == 0 {
  8550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8551. return
  8552. }
  8553. var struct4201A models.Struct4201A
  8554. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8555. for _, items := range order_info {
  8556. memo := make(map[string]interface{})
  8557. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8558. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8559. fsiOPFLD.MedType = "14"
  8560. fsiOPFLD.BkkpSn = items.FeedetlSn
  8561. fsiOPFLD.FixmedinsCode = miConfig.Code
  8562. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8563. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8564. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8565. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8566. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8567. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8568. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8569. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8570. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8571. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8572. fsiOPFLD.BilgDeptName = department.Name
  8573. fsiOPFLD.BilgDeptCodg = department.Number
  8574. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8575. fsiOPFLD.BilgDrName = doctor.UserName
  8576. fsiOPFLD.MedChrgitmType = "09"
  8577. memo["hosp_appr_flag"] = "1"
  8578. memo["invoice_no"] = order.MdtrtId
  8579. memo["memo"] = "自费"
  8580. bytesData, _ := json.Marshal(memo)
  8581. fsiOPFLD.Memo = string(bytesData)
  8582. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8583. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8584. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8585. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8586. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8587. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8588. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8589. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8590. fsiOPFLD.BilgDeptName = department.Name
  8591. fsiOPFLD.BilgDeptCodg = department.Number
  8592. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8593. fsiOPFLD.BilgDrName = doctor.UserName
  8594. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8595. case 0:
  8596. break
  8597. case 1:
  8598. fsiOPFLD.MedChrgitmType = "14"
  8599. break
  8600. case 2:
  8601. fsiOPFLD.MedChrgitmType = "05"
  8602. break
  8603. case 3:
  8604. fsiOPFLD.MedChrgitmType = "03"
  8605. break
  8606. case 4:
  8607. fsiOPFLD.MedChrgitmType = "03"
  8608. break
  8609. case 5:
  8610. fsiOPFLD.MedChrgitmType = "08"
  8611. break
  8612. case 6:
  8613. fsiOPFLD.MedChrgitmType = "14"
  8614. break
  8615. case 7:
  8616. fsiOPFLD.MedChrgitmType = "14"
  8617. break
  8618. case 8:
  8619. fsiOPFLD.MedChrgitmType = "03"
  8620. break
  8621. case 9:
  8622. fsiOPFLD.MedChrgitmType = "14"
  8623. break
  8624. case 10:
  8625. fsiOPFLD.MedChrgitmType = "14"
  8626. break
  8627. case 11:
  8628. fsiOPFLD.MedChrgitmType = "06"
  8629. break
  8630. case 12:
  8631. fsiOPFLD.MedChrgitmType = "12"
  8632. break
  8633. case 13:
  8634. fsiOPFLD.MedChrgitmType = "01"
  8635. break
  8636. case 14:
  8637. fsiOPFLD.MedChrgitmType = "04"
  8638. break
  8639. case 15:
  8640. fsiOPFLD.MedChrgitmType = "14"
  8641. break
  8642. }
  8643. memo["hosp_appr_flag"] = "1"
  8644. memo["invoice_no"] = order.MdtrtId
  8645. memo["memo"] = "自费"
  8646. bytesData, _ := json.Marshal(memo)
  8647. fsiOPFLD.Memo = string(bytesData)
  8648. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8649. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8650. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8651. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8652. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8653. fsiOPFLD.BilgDeptName = department.Name
  8654. fsiOPFLD.BilgDeptCodg = department.Number
  8655. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8656. fsiOPFLD.BilgDrName = doctor.UserName
  8657. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8658. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8659. fsiOPFLD.MedChrgitmType = "08"
  8660. memo["hosp_appr_flag"] = "1"
  8661. memo["invoice_no"] = order.MdtrtId
  8662. memo["memo"] = "自费"
  8663. bytesData, _ := json.Marshal(memo)
  8664. fsiOPFLD.Memo = string(bytesData)
  8665. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8666. }
  8667. }
  8668. }
  8669. for _, items := range order_info_two {
  8670. memo := make(map[string]interface{})
  8671. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8672. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8673. fsiOPFLD.MedType = "14"
  8674. fsiOPFLD.BkkpSn = items.FeedetlSn
  8675. fsiOPFLD.FixmedinsCode = miConfig.Code
  8676. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8677. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8678. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8679. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8680. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8681. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8682. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8683. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8684. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8685. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8686. fsiOPFLD.BilgDeptName = department.Name
  8687. fsiOPFLD.BilgDeptCodg = department.Number
  8688. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8689. fsiOPFLD.BilgDrName = doctor.UserName
  8690. fsiOPFLD.MedChrgitmType = "09"
  8691. memo["hosp_appr_flag"] = "1"
  8692. memo["invoice_no"] = order.MdtrtId
  8693. memo["memo"] = "自费"
  8694. bytesData, _ := json.Marshal(memo)
  8695. fsiOPFLD.Memo = string(bytesData)
  8696. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8697. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8698. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8699. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8700. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8701. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8702. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8703. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8704. fsiOPFLD.BilgDeptName = department.Name
  8705. fsiOPFLD.BilgDeptCodg = department.Number
  8706. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8707. fsiOPFLD.BilgDrName = doctor.UserName
  8708. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8709. case 0:
  8710. break
  8711. case 1:
  8712. fsiOPFLD.MedChrgitmType = "14"
  8713. break
  8714. case 2:
  8715. fsiOPFLD.MedChrgitmType = "05"
  8716. break
  8717. case 3:
  8718. fsiOPFLD.MedChrgitmType = "03"
  8719. break
  8720. case 4:
  8721. fsiOPFLD.MedChrgitmType = "03"
  8722. break
  8723. case 5:
  8724. fsiOPFLD.MedChrgitmType = "08"
  8725. break
  8726. case 6:
  8727. fsiOPFLD.MedChrgitmType = "14"
  8728. break
  8729. case 7:
  8730. fsiOPFLD.MedChrgitmType = "14"
  8731. break
  8732. case 8:
  8733. fsiOPFLD.MedChrgitmType = "03"
  8734. break
  8735. case 9:
  8736. fsiOPFLD.MedChrgitmType = "14"
  8737. break
  8738. case 10:
  8739. fsiOPFLD.MedChrgitmType = "14"
  8740. break
  8741. case 11:
  8742. fsiOPFLD.MedChrgitmType = "06"
  8743. break
  8744. case 12:
  8745. fsiOPFLD.MedChrgitmType = "12"
  8746. break
  8747. case 13:
  8748. fsiOPFLD.MedChrgitmType = "01"
  8749. break
  8750. case 14:
  8751. fsiOPFLD.MedChrgitmType = "04"
  8752. break
  8753. case 15:
  8754. fsiOPFLD.MedChrgitmType = "14"
  8755. break
  8756. }
  8757. memo["hosp_appr_flag"] = "1"
  8758. memo["invoice_no"] = order.MdtrtId
  8759. memo["memo"] = "自费"
  8760. bytesData, _ := json.Marshal(memo)
  8761. fsiOPFLD.Memo = string(bytesData)
  8762. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8763. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8764. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8765. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8766. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8767. fsiOPFLD.BilgDeptName = department.Name
  8768. fsiOPFLD.BilgDeptCodg = department.Number
  8769. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8770. fsiOPFLD.BilgDrName = doctor.UserName
  8771. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8772. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8773. fsiOPFLD.MedChrgitmType = "08"
  8774. memo["hosp_appr_flag"] = "1"
  8775. memo["invoice_no"] = order.MdtrtId
  8776. memo["memo"] = "自费"
  8777. bytesData, _ := json.Marshal(memo)
  8778. fsiOPFLD.Memo = string(bytesData)
  8779. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8780. }
  8781. }
  8782. }
  8783. fmt.Println(fsiOPFLDs)
  8784. struct4201A.Fopfd = fsiOPFLDs
  8785. fmt.Println(struct4201A.Fopfd)
  8786. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8787. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8788. var res2 ResultSix
  8789. var respJSON2 map[string]interface{}
  8790. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8791. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8793. return
  8794. }
  8795. userJSONBytes2, _ := json.Marshal(respJSON2)
  8796. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8797. utils.ErrorLog("解析失败:%v", err)
  8798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8799. return
  8800. }
  8801. if res2.Infcode != 0 {
  8802. c.ServeSuccessJSON(map[string]interface{}{
  8803. "failed_code": -10,
  8804. "msg": res2.ErrMsg,
  8805. })
  8806. return
  8807. } else {
  8808. order.IsUploadOrderInfo = 1
  8809. service.UpdateOrder(order)
  8810. c.ServeSuccessJSON(map[string]interface{}{
  8811. "msg": "上传成功",
  8812. })
  8813. }
  8814. }
  8815. func (c *HisApiController) Get4202() {
  8816. order_id, _ := c.GetInt64("order_id")
  8817. admin_user_id, _ := c.GetInt64("admin_user_id")
  8818. order, _ := service.GetHisOrderByIDTwo(order_id)
  8819. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8820. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8821. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8822. if order.ID == 0 {
  8823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8824. return
  8825. }
  8826. var struct4202 models.Struct4202
  8827. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8828. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8829. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8830. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8831. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8832. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8833. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  8834. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  8835. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8836. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8837. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8838. var config []*models.HisXtDiagnoseConfig
  8839. for _, item := range diagnosis_ids {
  8840. id, _ := strconv.ParseInt(item, 10, 64)
  8841. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8842. config = append(config, &diagnosisConfig)
  8843. }
  8844. var tempDiaginfos []models.OwnPayPatnDiagListD
  8845. for index, item := range config {
  8846. if index == 0 {
  8847. var tempDiaginfo models.OwnPayPatnDiagListD
  8848. tempDiaginfo.InoutDiagType = "1"
  8849. tempDiaginfo.DiagCode = item.CountryCode
  8850. tempDiaginfo.DiagName = item.CountryContentName
  8851. tempDiaginfo.DiagType = "1"
  8852. tempDiaginfo.DiagSrtNo = "1"
  8853. tempDiaginfo.MaindiagFlag = "1"
  8854. tempDiaginfo.ValiFlag = "1"
  8855. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8856. } else {
  8857. var tempDiaginfo models.OwnPayPatnDiagListD
  8858. tempDiaginfo.DiagCode = item.CountryCode
  8859. tempDiaginfo.DiagName = item.CountryContentName
  8860. tempDiaginfo.DiagType = "2"
  8861. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8862. tempDiaginfo.MaindiagFlag = "0"
  8863. tempDiaginfo.ValiFlag = "1"
  8864. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8865. }
  8866. }
  8867. struct4202.ODiagListD = tempDiaginfos
  8868. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  8869. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  8870. var res2 ResultSix
  8871. var respJSON2 map[string]interface{}
  8872. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8873. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8875. return
  8876. }
  8877. userJSONBytes2, _ := json.Marshal(respJSON2)
  8878. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8879. utils.ErrorLog("解析失败:%v", err)
  8880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8881. return
  8882. }
  8883. if res2.Infcode != 0 {
  8884. c.ServeSuccessJSON(map[string]interface{}{
  8885. "failed_code": -10,
  8886. "msg": res2.ErrMsg,
  8887. })
  8888. return
  8889. } else {
  8890. order.IsUploadDiagnose = 1
  8891. service.UpdateOrder(order)
  8892. c.ServeSuccessJSON(map[string]interface{}{
  8893. "msg": "上传成功",
  8894. })
  8895. }
  8896. }
  8897. func (c *HisApiController) Get4203() {
  8898. admin_user_id, _ := c.GetInt64("admin_user_id")
  8899. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8900. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8901. order_id, _ := c.GetInt64("order_id")
  8902. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8903. number := ""
  8904. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8905. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8906. if his.ID == 0 {
  8907. number = hospital.Number
  8908. } else {
  8909. number = his.Number
  8910. }
  8911. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  8912. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  8913. var res2 ResultSix
  8914. var respJSON2 map[string]interface{}
  8915. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8918. return
  8919. }
  8920. userJSONBytes2, _ := json.Marshal(respJSON2)
  8921. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8922. utils.ErrorLog("解析失败:%v", err)
  8923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8924. return
  8925. }
  8926. if res2.Infcode != 0 {
  8927. c.ServeSuccessJSON(map[string]interface{}{
  8928. "failed_code": -10,
  8929. "msg": res2.ErrMsg,
  8930. })
  8931. return
  8932. } else {
  8933. order.IsUploadSuccess = 1
  8934. service.UpdateOrderTwo(order)
  8935. c.ServeSuccessJSON(map[string]interface{}{
  8936. "msg": "上传成功",
  8937. })
  8938. }
  8939. }
  8940. func (c *HisApiController) Get4205() {
  8941. order_id, _ := c.GetInt64("order_id")
  8942. admin_user_id, _ := c.GetInt64("admin_user_id")
  8943. fapiao_code := c.GetString("fapiao_code")
  8944. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8945. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8946. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8947. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8948. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  8949. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8950. //order_info = append(order_info, order_info_two...)
  8951. department, _ := service.GetDepartMentDetail(his.Departments)
  8952. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8953. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8954. if order.ID == 0 {
  8955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8956. return
  8957. }
  8958. var struct4201A models.Struct4201A
  8959. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8960. for _, items := range order_info {
  8961. memo := make(map[string]interface{})
  8962. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8963. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8964. fsiOPFLD.MedType = pre.MedType
  8965. fsiOPFLD.FixmedinsCode = miConfig.Code
  8966. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8967. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8968. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8969. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8970. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8971. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8972. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8973. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  8974. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8975. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8976. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8977. fsiOPFLD.BilgDeptName = department.Name
  8978. fsiOPFLD.BilgDeptCodg = department.Number
  8979. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8980. fsiOPFLD.BilgDrName = doctor.UserName
  8981. fsiOPFLD.MedChrgitmType = "09"
  8982. memo["hosp_appr_flag"] = "1"
  8983. memo["invoice_no"] = fapiao_code
  8984. memo["memo"] = "自费"
  8985. bytesData, _ := json.Marshal(memo)
  8986. fsiOPFLD.Memo = string(bytesData)
  8987. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8988. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8989. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8990. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8991. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8992. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8993. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8994. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8995. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8996. fsiOPFLD.BilgDeptName = department.Name
  8997. fsiOPFLD.BilgDeptCodg = department.Number
  8998. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8999. fsiOPFLD.BilgDrName = doctor.UserName
  9000. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9001. case 0:
  9002. break
  9003. case 1:
  9004. fsiOPFLD.MedChrgitmType = "14"
  9005. break
  9006. case 2:
  9007. fsiOPFLD.MedChrgitmType = "05"
  9008. break
  9009. case 3:
  9010. fsiOPFLD.MedChrgitmType = "03"
  9011. break
  9012. case 4:
  9013. fsiOPFLD.MedChrgitmType = "03"
  9014. break
  9015. case 5:
  9016. fsiOPFLD.MedChrgitmType = "08"
  9017. break
  9018. case 6:
  9019. fsiOPFLD.MedChrgitmType = "14"
  9020. break
  9021. case 7:
  9022. fsiOPFLD.MedChrgitmType = "14"
  9023. break
  9024. case 8:
  9025. fsiOPFLD.MedChrgitmType = "03"
  9026. break
  9027. case 9:
  9028. fsiOPFLD.MedChrgitmType = "14"
  9029. break
  9030. case 10:
  9031. fsiOPFLD.MedChrgitmType = "14"
  9032. break
  9033. case 11:
  9034. fsiOPFLD.MedChrgitmType = "06"
  9035. break
  9036. case 12:
  9037. fsiOPFLD.MedChrgitmType = "12"
  9038. break
  9039. case 13:
  9040. fsiOPFLD.MedChrgitmType = "01"
  9041. break
  9042. case 14:
  9043. fsiOPFLD.MedChrgitmType = "04"
  9044. break
  9045. case 15:
  9046. fsiOPFLD.MedChrgitmType = "14"
  9047. break
  9048. }
  9049. memo["hosp_appr_flag"] = "1"
  9050. memo["invoice_no"] = fapiao_code
  9051. memo["memo"] = "自费"
  9052. bytesData, _ := json.Marshal(memo)
  9053. fsiOPFLD.Memo = string(bytesData)
  9054. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9055. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9056. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9057. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9058. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9059. fsiOPFLD.BilgDeptName = department.Name
  9060. fsiOPFLD.BilgDeptCodg = department.Number
  9061. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9062. fsiOPFLD.BilgDrName = doctor.UserName
  9063. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9064. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9065. fsiOPFLD.MedChrgitmType = "08"
  9066. memo["hosp_appr_flag"] = "1"
  9067. memo["invoice_no"] = fapiao_code
  9068. memo["memo"] = "自费"
  9069. bytesData, _ := json.Marshal(memo)
  9070. fsiOPFLD.Memo = string(bytesData)
  9071. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9072. }
  9073. }
  9074. }
  9075. for _, items := range order_info_two {
  9076. memo := make(map[string]interface{})
  9077. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9078. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9079. fsiOPFLD.MedType = pre.MedType
  9080. fsiOPFLD.BkkpSn = items.FeedetlSn
  9081. fsiOPFLD.FixmedinsCode = miConfig.Code
  9082. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9083. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9084. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9085. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9086. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9087. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9088. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9089. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9090. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9091. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9092. fsiOPFLD.BilgDeptName = department.Name
  9093. fsiOPFLD.BilgDeptCodg = department.Number
  9094. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9095. fsiOPFLD.BilgDrName = doctor.UserName
  9096. fsiOPFLD.MedChrgitmType = "09"
  9097. memo["hosp_appr_flag"] = "1"
  9098. memo["invoice_no"] = fapiao_code
  9099. memo["memo"] = "自费"
  9100. bytesData, _ := json.Marshal(memo)
  9101. fsiOPFLD.Memo = string(bytesData)
  9102. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9103. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9104. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9105. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9106. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9107. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9108. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9109. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9110. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9111. fsiOPFLD.BilgDeptName = department.Name
  9112. fsiOPFLD.BilgDeptCodg = department.Number
  9113. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9114. fsiOPFLD.BilgDrName = doctor.UserName
  9115. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9116. case 0:
  9117. break
  9118. case 1:
  9119. fsiOPFLD.MedChrgitmType = "14"
  9120. break
  9121. case 2:
  9122. fsiOPFLD.MedChrgitmType = "05"
  9123. break
  9124. case 3:
  9125. fsiOPFLD.MedChrgitmType = "03"
  9126. break
  9127. case 4:
  9128. fsiOPFLD.MedChrgitmType = "03"
  9129. break
  9130. case 5:
  9131. fsiOPFLD.MedChrgitmType = "08"
  9132. break
  9133. case 6:
  9134. fsiOPFLD.MedChrgitmType = "14"
  9135. break
  9136. case 7:
  9137. fsiOPFLD.MedChrgitmType = "14"
  9138. break
  9139. case 8:
  9140. fsiOPFLD.MedChrgitmType = "03"
  9141. break
  9142. case 9:
  9143. fsiOPFLD.MedChrgitmType = "14"
  9144. break
  9145. case 10:
  9146. fsiOPFLD.MedChrgitmType = "14"
  9147. break
  9148. case 11:
  9149. fsiOPFLD.MedChrgitmType = "06"
  9150. break
  9151. case 12:
  9152. fsiOPFLD.MedChrgitmType = "12"
  9153. break
  9154. case 13:
  9155. fsiOPFLD.MedChrgitmType = "01"
  9156. break
  9157. case 14:
  9158. fsiOPFLD.MedChrgitmType = "04"
  9159. break
  9160. case 15:
  9161. fsiOPFLD.MedChrgitmType = "14"
  9162. break
  9163. }
  9164. memo["hosp_appr_flag"] = "1"
  9165. memo["invoice_no"] = fapiao_code
  9166. memo["memo"] = "自费"
  9167. bytesData, _ := json.Marshal(memo)
  9168. fsiOPFLD.Memo = string(bytesData)
  9169. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9170. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9171. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9172. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9173. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9174. fsiOPFLD.BilgDeptName = department.Name
  9175. fsiOPFLD.BilgDeptCodg = department.Number
  9176. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9177. fsiOPFLD.BilgDrName = doctor.UserName
  9178. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9179. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9180. fsiOPFLD.MedChrgitmType = "08"
  9181. memo["hosp_appr_flag"] = "1"
  9182. memo["invoice_no"] = fapiao_code
  9183. memo["memo"] = "自费"
  9184. bytesData, _ := json.Marshal(memo)
  9185. fsiOPFLD.Memo = string(bytesData)
  9186. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9187. }
  9188. }
  9189. }
  9190. fmt.Println(fsiOPFLDs)
  9191. struct4201A.Fopfd = fsiOPFLDs
  9192. fmt.Println(struct4201A.Fopfd)
  9193. var struct4202 models.Struct4202
  9194. timeLayout := "2006-01-02 15:04:05"
  9195. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9196. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9197. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9198. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9199. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9200. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9201. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9202. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9203. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9204. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9205. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9206. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9207. var config []*models.HisXtDiagnoseConfig
  9208. for _, item := range diagnosis_ids {
  9209. id, _ := strconv.ParseInt(item, 10, 64)
  9210. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9211. config = append(config, &diagnosisConfig)
  9212. }
  9213. var tempDiaginfos []models.OwnPayPatnDiagListD
  9214. for index, item := range config {
  9215. if index == 0 {
  9216. var tempDiaginfo models.OwnPayPatnDiagListD
  9217. tempDiaginfo.InoutDiagType = "1"
  9218. tempDiaginfo.DiagCode = item.CountryCode
  9219. tempDiaginfo.DiagName = item.CountryContentName
  9220. tempDiaginfo.DiagType = "1"
  9221. tempDiaginfo.DiagSrtNo = "1"
  9222. tempDiaginfo.MaindiagFlag = "1"
  9223. tempDiaginfo.ValiFlag = "1"
  9224. tempDiaginfo.DiagDrName = doctor.UserName
  9225. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9226. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9227. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9228. } else {
  9229. var tempDiaginfo models.OwnPayPatnDiagListD
  9230. tempDiaginfo.DiagCode = item.CountryCode
  9231. tempDiaginfo.DiagName = item.CountryContentName
  9232. tempDiaginfo.DiagType = "2"
  9233. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9234. tempDiaginfo.MaindiagFlag = "0"
  9235. tempDiaginfo.ValiFlag = "1"
  9236. tempDiaginfo.DiagDrName = doctor.UserName
  9237. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9238. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9239. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9240. }
  9241. }
  9242. struct4202.ODiagListD = tempDiaginfos
  9243. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  9244. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  9245. var res2 ResultSix
  9246. var respJSON2 map[string]interface{}
  9247. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9248. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9250. return
  9251. }
  9252. userJSONBytes2, _ := json.Marshal(respJSON2)
  9253. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9254. utils.ErrorLog("解析失败:%v", err)
  9255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9256. return
  9257. }
  9258. if res2.Infcode != 0 {
  9259. c.ServeSuccessJSON(map[string]interface{}{
  9260. "failed_code": -10,
  9261. "msg": res2.ErrMsg,
  9262. })
  9263. return
  9264. } else {
  9265. order.IsUploadDiagnose = 1
  9266. order.IsUploadOrderInfo = 1
  9267. service.UpdateOrderTwo(order)
  9268. c.ServeSuccessJSON(map[string]interface{}{
  9269. "msg": "上传成功",
  9270. })
  9271. }
  9272. }
  9273. func (c *HisApiController) Get4207() {
  9274. admin_user_id, _ := c.GetInt64("admin_user_id")
  9275. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9276. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9277. order_id, _ := c.GetInt64("order_id")
  9278. order, _ := service.GetHisOrderByIDTwo(order_id)
  9279. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9280. var struct4207 models.Struct4207
  9281. struct4207.PageNum = "1"
  9282. struct4207.PageSize = "1000"
  9283. struct4207.FixmedinsCode = miConfig.Code
  9284. struct4207.FixmedinsMdtrtID = order.Number
  9285. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  9286. saveLog(result, requestLog, "4207", "查询")
  9287. var res2 ResultSix
  9288. var respJSON2 map[string]interface{}
  9289. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9290. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9292. return
  9293. }
  9294. userJSONBytes2, _ := json.Marshal(respJSON2)
  9295. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9296. utils.ErrorLog("解析失败:%v", err)
  9297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9298. return
  9299. }
  9300. if res2.Infcode != 0 {
  9301. c.ServeSuccessJSON(map[string]interface{}{
  9302. "failed_code": -10,
  9303. "msg": res2.ErrMsg,
  9304. })
  9305. return
  9306. } else {
  9307. c.ServeSuccessJSON(map[string]interface{}{
  9308. "msg": "查询成功",
  9309. })
  9310. }
  9311. }
  9312. func (c *HisApiController) Get4208() {
  9313. admin_user_id, _ := c.GetInt64("admin_user_id")
  9314. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9315. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9316. order_id, _ := c.GetInt64("order_id")
  9317. order, _ := service.GetHisOrderByIDTwo(order_id)
  9318. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9319. var struct4208 models.Struct4208
  9320. struct4208.PageNum = "1"
  9321. struct4208.PageSize = "1000"
  9322. struct4208.PsnCertType = "01"
  9323. struct4208.Certno = his.Certno
  9324. struct4208.MedType = order.MedType
  9325. struct4208.PsnName = his.Name
  9326. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  9327. saveLog(result, requestLog, "4208", "查询")
  9328. var res2 ResultSix
  9329. var respJSON2 map[string]interface{}
  9330. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9331. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9333. return
  9334. }
  9335. userJSONBytes2, _ := json.Marshal(respJSON2)
  9336. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9337. utils.ErrorLog("解析失败:%v", err)
  9338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9339. return
  9340. }
  9341. if res2.Infcode != 0 {
  9342. c.ServeSuccessJSON(map[string]interface{}{
  9343. "failed_code": -10,
  9344. "msg": res2.ErrMsg,
  9345. })
  9346. return
  9347. } else {
  9348. c.ServeSuccessJSON(map[string]interface{}{
  9349. "msg": "查询成功",
  9350. })
  9351. }
  9352. }
  9353. func (c *HisApiController) Get4209() {
  9354. admin_user_id, _ := c.GetInt64("admin_user_id")
  9355. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9356. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9357. order_id, _ := c.GetInt64("order_id")
  9358. order, _ := service.GetHisOrderByIDTwo(order_id)
  9359. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9360. var struct4209 models.Struct4209
  9361. struct4209.FixmedinsMdtrtID = order.Number
  9362. struct4209.FixmedinsCode = miConfig.Code
  9363. struct4209.PageSize = "1000"
  9364. struct4209.PageNum = "1"
  9365. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  9366. saveLog(result, requestLog, "4209", "查询")
  9367. var res2 ResultSix
  9368. var respJSON2 map[string]interface{}
  9369. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9370. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9372. return
  9373. }
  9374. userJSONBytes2, _ := json.Marshal(respJSON2)
  9375. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9376. utils.ErrorLog("解析失败:%v", err)
  9377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9378. return
  9379. }
  9380. if res2.Infcode != 0 {
  9381. c.ServeSuccessJSON(map[string]interface{}{
  9382. "failed_code": -10,
  9383. "msg": res2.ErrMsg,
  9384. })
  9385. return
  9386. } else {
  9387. c.ServeSuccessJSON(map[string]interface{}{
  9388. "msg": "查询成功",
  9389. })
  9390. }
  9391. }
  9392. type Result3101 struct {
  9393. Infcode string `json:"infcode"`
  9394. InfRefmsgid string `json:"inf_refmsgid"`
  9395. RefmsgTime string `json:"refmsg_time"`
  9396. RespondTime string `json:"respond_time"`
  9397. Enctype string `json:"enctype"`
  9398. Signtype string `json:"signtype"`
  9399. ErrMsg string `json:"err_msg"`
  9400. Output struct {
  9401. Result []struct {
  9402. JudgeResultDetailDtos []struct {
  9403. VolaItemType string `json:"vola_item_type"`
  9404. MdtrtID string `json:"mdtrt_id"`
  9405. JrdID string `json:"jrd_id"`
  9406. PatnID string `json:"patn_id"`
  9407. RxID string `json:"rx_id"`
  9408. VolaAmt interface{} `json:"vola_amt"`
  9409. } `json:"judge_result_detail_dtos"`
  9410. RuleID string `json:"rule_id"`
  9411. VolaEvid string `json:"vola_evid"`
  9412. MdtrtID string `json:"mdtrt_id"`
  9413. RuleName string `json:"rule_name"`
  9414. VolaAmtStas string `json:"vola_amt_stas"`
  9415. JrID string `json:"jr_id"`
  9416. PatnID string `json:"patn_id"`
  9417. SevDeg string `json:"sev_deg"`
  9418. VolaAmt float64 `json:"vola_amt"`
  9419. VolaBhvrType string `json:"vola_bhvr_type"`
  9420. VolaCont string `json:"vola_cont"`
  9421. } `json:"result"`
  9422. } `json:"output"`
  9423. }
  9424. type Resultgd3101 struct {
  9425. Infcode int64 `json:"infcode"`
  9426. InfRefmsgid string `json:"inf_refmsgid"`
  9427. RefmsgTime string `json:"refmsg_time"`
  9428. RespondTime string `json:"respond_time"`
  9429. Enctype string `json:"enctype"`
  9430. Signtype string `json:"signtype"`
  9431. ErrMsg string `json:"err_msg"`
  9432. Output struct {
  9433. Result []struct {
  9434. JudgeResultDetailDtos []struct {
  9435. VolaItemType string `json:"vola_item_type"`
  9436. MdtrtID string `json:"mdtrt_id"`
  9437. JrdID string `json:"jrd_id"`
  9438. PatnID string `json:"patn_id"`
  9439. RxID string `json:"rx_id"`
  9440. VolaAmt interface{} `json:"vola_amt"`
  9441. } `json:"judge_result_detail_dtos"`
  9442. RuleID string `json:"rule_id"`
  9443. VolaEvid string `json:"vola_evid"`
  9444. MdtrtID string `json:"mdtrt_id"`
  9445. RuleName string `json:"rule_name"`
  9446. VolaAmtStas string `json:"vola_amt_stas"`
  9447. JrID string `json:"jr_id"`
  9448. PatnID string `json:"patn_id"`
  9449. SevDeg string `json:"sev_deg"`
  9450. VolaAmt float64 `json:"vola_amt"`
  9451. VolaBhvrType string `json:"vola_bhvr_type"`
  9452. VolaCont string `json:"vola_cont"`
  9453. } `json:"result"`
  9454. } `json:"output"`
  9455. }
  9456. func (c *HisApiController) ReadEleToken() {
  9457. admin_user_id, _ := c.GetInt64("admin_user_id")
  9458. his_patient_id, _ := c.GetInt64("his_patient_id")
  9459. adminUser := c.GetAdminUserInfo()
  9460. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9461. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9462. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9463. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9464. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9465. if len(tokens) > 0 {
  9466. c.ServeSuccessJSON(map[string]interface{}{
  9467. "msg": "读取成功",
  9468. })
  9469. } else {
  9470. c.ServeSuccessJSON(map[string]interface{}{
  9471. "failed_code": -10,
  9472. "msg": "读取失败",
  9473. })
  9474. }
  9475. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9476. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9477. if len(tokens) > 0 {
  9478. c.ServeSuccessJSON(map[string]interface{}{
  9479. "msg": "读取成功",
  9480. })
  9481. } else {
  9482. c.ServeSuccessJSON(map[string]interface{}{
  9483. "failed_code": -10,
  9484. "msg": "读取失败",
  9485. })
  9486. }
  9487. } else if miConfig.MdtrtareaAdmvs == "340699" {
  9488. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9489. if len(tokens) > 0 {
  9490. c.ServeSuccessJSON(map[string]interface{}{
  9491. "msg": "读取成功",
  9492. })
  9493. } else {
  9494. c.ServeSuccessJSON(map[string]interface{}{
  9495. "failed_code": -10,
  9496. "msg": "读取失败",
  9497. })
  9498. }
  9499. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9500. var api string
  9501. 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 +
  9502. "&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"
  9503. resp, requestErr := http.Get(api)
  9504. if requestErr != nil {
  9505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9506. }
  9507. body, ioErr := ioutil.ReadAll(resp.Body)
  9508. if ioErr != nil {
  9509. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9511. }
  9512. var respJSON map[string]interface{}
  9513. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9514. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9516. return
  9517. }
  9518. var status string
  9519. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9520. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9521. var token string
  9522. var res ResultTwo //1101结果
  9523. var res10265 ResultTwo10265 //1101结果
  9524. if status == "0" { //读卡成功
  9525. var card_info string //卡信息
  9526. var busi_card_info string
  9527. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9528. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9529. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9530. fmt.Println(card_info)
  9531. fmt.Println(busi_card_info)
  9532. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9533. result, _ := json.Marshal(respJSON)
  9534. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9535. utils.ErrorLog("解析失败:%v", err)
  9536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9537. return
  9538. }
  9539. res.ErrMsg = res10265.ErrMsg
  9540. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9541. res.Infcode = infocode
  9542. res.Output = res10265.Output
  9543. res.InfRefmsgid = res10265.InfRefmsgid
  9544. if res.Infcode == 0 {
  9545. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9546. if err == gorm.ErrRecordNotFound {
  9547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9548. return
  9549. } else if err != nil {
  9550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9551. return
  9552. } else {
  9553. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9554. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9555. infoStr := string(Iinfos)
  9556. idetinfoStr := string(Idetinfos)
  9557. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  9558. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9559. psn := &models.HisPsn{
  9560. PsnNo: res.Output.Baseinfo.PsnNo,
  9561. PatientId: patient.ID,
  9562. Certno: res.Output.Baseinfo.Certno,
  9563. Gend: res.Output.Baseinfo.Gend,
  9564. Naty: res.Output.Baseinfo.Naty,
  9565. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9566. PsnName: res.Output.Baseinfo.PsnName,
  9567. Age: float64(age),
  9568. Brdy: b,
  9569. Idetinfo: idetinfoStr,
  9570. Insuinfo: infoStr,
  9571. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9572. CardInfo: card_info,
  9573. VerifyNumber: token,
  9574. IdCardType: 4,
  9575. }
  9576. var rf []*ResultFive
  9577. json.Unmarshal([]byte(infoStr), &rf)
  9578. var insutypes []*ResultFive
  9579. var insutype string
  9580. var is390 int = 0
  9581. var is310 int = 0
  9582. for _, item := range rf {
  9583. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9584. insutypes = append(insutypes, item)
  9585. }
  9586. }
  9587. if len(insutypes) == 1 {
  9588. insutype = insutypes[0].Insutype
  9589. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9590. } else {
  9591. for _, i := range insutypes {
  9592. if i.Insutype == "390" {
  9593. is390 = 1
  9594. }
  9595. if i.Insutype == "310" {
  9596. is310 = 1
  9597. }
  9598. }
  9599. }
  9600. if is390 == 1 {
  9601. insutype = "390"
  9602. }
  9603. if is310 == 1 {
  9604. insutype = "310"
  9605. }
  9606. if len(insutypes) == 0 {
  9607. insutype = "310"
  9608. }
  9609. service.CreateHisPsn(psn)
  9610. c.ServeSuccessJSON(map[string]interface{}{
  9611. "patient": patient,
  9612. "number": token,
  9613. "insutype": insutype,
  9614. })
  9615. }
  9616. } else {
  9617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9618. return
  9619. }
  9620. } else { //读卡失败
  9621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9622. return
  9623. }
  9624. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9625. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  9626. if len(errMsg) == 0 {
  9627. type ELeData struct {
  9628. Data struct {
  9629. IdNo string `json:"idNo"`
  9630. IdType string `json:"idType"`
  9631. UserName string `json:"userName"`
  9632. EcToken string `json:"ecToken"`
  9633. InsuOrg string `json:"insuOrg"`
  9634. Gender string `json:"gender"`
  9635. Birthday string `json:"birthday"`
  9636. Nationality string `json:"nationality"`
  9637. Email string `json:"email"`
  9638. Extra string `json:"extra"`
  9639. } `json:"data"`
  9640. Code int `json:"code"`
  9641. Message string `json:"message"`
  9642. }
  9643. var ele ELeData
  9644. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9645. if err != nil {
  9646. utils.ErrorLog("解析失败:%v", err)
  9647. }
  9648. token := ele.Data.EcToken
  9649. if len(token) > 0 {
  9650. psn := &models.HisPsn{
  9651. PsnNo: his.PsnNo,
  9652. Age: 0,
  9653. PatientId: his.PatientId,
  9654. Certno: his.Certno,
  9655. Brdy: his.Brdy,
  9656. Gend: his.Gend,
  9657. Naty: his.Naty,
  9658. PsnCertType: his.PsnCertType,
  9659. PsnName: his.PsnName,
  9660. Idetinfo: his.Idetinfo,
  9661. Insuinfo: his.Iinfo,
  9662. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9663. CardInfo: outPutInfo,
  9664. VerifyNumber: token,
  9665. }
  9666. service.CreateHisPsn(psn)
  9667. }
  9668. if len(token) > 0 {
  9669. c.ServeSuccessJSON(map[string]interface{}{
  9670. "msg": "读取成功",
  9671. })
  9672. } else {
  9673. c.ServeSuccessJSON(map[string]interface{}{
  9674. "failed_code": -10,
  9675. "msg": "读取失败",
  9676. })
  9677. }
  9678. }
  9679. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9680. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9681. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9682. type ELeData struct {
  9683. Data struct {
  9684. IdNo string `json:"idNo"`
  9685. IdType string `json:"idType"`
  9686. UserName string `json:"userName"`
  9687. EcToken string `json:"ecToken"`
  9688. InsuOrg string `json:"insuOrg"`
  9689. Gender string `json:"gender"`
  9690. Birthday string `json:"birthday"`
  9691. Nationality string `json:"nationality"`
  9692. Email string `json:"email"`
  9693. Extra string `json:"extra"`
  9694. } `json:"data"`
  9695. Code int `json:"code"`
  9696. Message string `json:"message"`
  9697. }
  9698. var ele ELeData
  9699. err := json.Unmarshal([]byte(result), &ele)
  9700. if err != nil {
  9701. utils.ErrorLog("解析失败:%v", err)
  9702. }
  9703. token := ele.Data.EcToken
  9704. token = Remove0000(token)
  9705. fmt.Println(ele.Data.UserName)
  9706. 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)
  9707. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9708. var res ResultTwo
  9709. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9710. utils.ErrorLog("解析失败:%v", err)
  9711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9712. return
  9713. }
  9714. if res.Infcode == 0 {
  9715. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9716. if err == gorm.ErrRecordNotFound {
  9717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9718. return
  9719. } else if err != nil {
  9720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9721. return
  9722. } else {
  9723. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9724. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9725. infoStr := string(Iinfos)
  9726. idetinfoStr := string(Idetinfos)
  9727. psn := &models.HisPsn{
  9728. PsnNo: res.Output.Baseinfo.PsnNo,
  9729. PatientId: patient.ID,
  9730. Certno: res.Output.Baseinfo.Certno,
  9731. Gend: res.Output.Baseinfo.Gend,
  9732. Naty: res.Output.Baseinfo.Naty,
  9733. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9734. PsnName: res.Output.Baseinfo.PsnName,
  9735. Idetinfo: idetinfoStr,
  9736. Insuinfo: infoStr,
  9737. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9738. CardInfo: "",
  9739. VerifyNumber: token,
  9740. }
  9741. service.CreateHisPsn(psn)
  9742. c.ServeSuccessJSON(map[string]interface{}{
  9743. "patient": patient,
  9744. "number": token,
  9745. })
  9746. }
  9747. } else {
  9748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9749. return
  9750. }
  9751. } else if miConfig.MdtrtareaAdmvs == "361025" {
  9752. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9753. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9754. type ELeData struct {
  9755. Data struct {
  9756. IdNo string `json:"idNo"`
  9757. IdType string `json:"idType"`
  9758. UserName string `json:"userName"`
  9759. EcToken string `json:"ecToken"`
  9760. InsuOrg string `json:"insuOrg"`
  9761. Gender string `json:"gender"`
  9762. Birthday string `json:"birthday"`
  9763. Nationality string `json:"nationality"`
  9764. Email string `json:"email"`
  9765. Extra string `json:"extra"`
  9766. } `json:"data"`
  9767. Code int `json:"code"`
  9768. Message string `json:"message"`
  9769. }
  9770. var ele ELeData
  9771. err := json.Unmarshal([]byte(result), &ele)
  9772. if err != nil {
  9773. utils.ErrorLog("解析失败:%v", err)
  9774. }
  9775. token := ele.Data.EcToken
  9776. token = Remove0000(token)
  9777. fmt.Println(ele.Data.UserName)
  9778. 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)
  9779. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9780. var res ResultTwo
  9781. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9782. utils.ErrorLog("解析失败:%v", err)
  9783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9784. return
  9785. }
  9786. if res.Infcode == 0 {
  9787. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9788. if err == gorm.ErrRecordNotFound {
  9789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9790. return
  9791. } else if err != nil {
  9792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9793. return
  9794. } else {
  9795. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9796. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9797. infoStr := string(Iinfos)
  9798. idetinfoStr := string(Idetinfos)
  9799. psn := &models.HisPsn{
  9800. PsnNo: res.Output.Baseinfo.PsnNo,
  9801. PatientId: patient.ID,
  9802. Certno: res.Output.Baseinfo.Certno,
  9803. Gend: res.Output.Baseinfo.Gend,
  9804. Naty: res.Output.Baseinfo.Naty,
  9805. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9806. PsnName: res.Output.Baseinfo.PsnName,
  9807. Idetinfo: idetinfoStr,
  9808. Insuinfo: infoStr,
  9809. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9810. CardInfo: "",
  9811. VerifyNumber: token,
  9812. }
  9813. service.CreateHisPsn(psn)
  9814. c.ServeSuccessJSON(map[string]interface{}{
  9815. "patient": patient,
  9816. "number": token,
  9817. })
  9818. }
  9819. } else {
  9820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9821. return
  9822. }
  9823. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9824. //if initFlag == 0 {
  9825. //c.TestGetJiangXiBasBaseInit()
  9826. //}
  9827. //if initEleFlag == 0 {
  9828. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9829. //}
  9830. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  9831. utils.ErrorLog("解析失败:%v", json_result)
  9832. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9833. type ELeData struct {
  9834. Data struct {
  9835. IdNo string `json:"idNo"`
  9836. IdType string `json:"idType"`
  9837. UserName string `json:"userName"`
  9838. EcToken string `json:"ecToken"`
  9839. InsuOrg string `json:"insuOrg"`
  9840. Gender string `json:"gender"`
  9841. Birthday string `json:"birthday"`
  9842. Nationality string `json:"nationality"`
  9843. Email string `json:"email"`
  9844. Extra string `json:"extra"`
  9845. } `json:"data"`
  9846. Code int `json:"code"`
  9847. Message string `json:"message"`
  9848. }
  9849. var ele ELeData
  9850. err := json.Unmarshal([]byte(json_result), &ele)
  9851. if err != nil {
  9852. utils.ErrorLog("解析失败:%v", err)
  9853. }
  9854. token := ele.Data.EcToken
  9855. token = Remove0000(token)
  9856. //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)
  9857. 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)
  9858. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9859. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9860. var res ResultTwo
  9861. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9862. utils.ErrorLog("解析失败:%v", err)
  9863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9864. return
  9865. }
  9866. if res.Infcode == 0 {
  9867. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9868. if err == gorm.ErrRecordNotFound {
  9869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9870. return
  9871. } else if err != nil {
  9872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9873. return
  9874. } else {
  9875. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9876. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9877. infoStr := string(Iinfos)
  9878. idetinfoStr := string(Idetinfos)
  9879. psn := &models.HisPsn{
  9880. PsnNo: res.Output.Baseinfo.PsnNo,
  9881. PatientId: patient.ID,
  9882. Certno: res.Output.Baseinfo.Certno,
  9883. Gend: res.Output.Baseinfo.Gend,
  9884. Naty: res.Output.Baseinfo.Naty,
  9885. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9886. PsnName: res.Output.Baseinfo.PsnName,
  9887. Idetinfo: idetinfoStr,
  9888. Insuinfo: infoStr,
  9889. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9890. CardInfo: "",
  9891. VerifyNumber: token,
  9892. InsuplcAdmdvs: ele.Data.InsuOrg,
  9893. }
  9894. service.CreateHisPsn(psn)
  9895. c.ServeSuccessJSON(map[string]interface{}{
  9896. "patient": patient,
  9897. "number": token,
  9898. })
  9899. }
  9900. } else {
  9901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9902. return
  9903. }
  9904. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9905. res := c.GetoleInfo()
  9906. if res.Infcode == 0 {
  9907. var result string
  9908. if res.Output.MdtrtCertType == "01" {
  9909. 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)
  9910. } else if res.Output.MdtrtCertType == "02" {
  9911. 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)
  9912. } else if res.Output.MdtrtCertType == "03" {
  9913. 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)
  9914. }
  9915. var dat map[string]interface{}
  9916. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9917. fmt.Println(dat)
  9918. } else {
  9919. fmt.Println(err)
  9920. }
  9921. userJSONBytes, _ := json.Marshal(dat)
  9922. var res2 ResultTwo
  9923. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9924. utils.ErrorLog("解析失败:%v", err)
  9925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9926. return
  9927. }
  9928. if res2.Infcode == 0 {
  9929. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9930. if err == gorm.ErrRecordNotFound {
  9931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9932. return
  9933. } else if err != nil {
  9934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9935. return
  9936. } else {
  9937. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9938. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9939. infoStr := string(Iinfos)
  9940. idetinfoStr := string(Idetinfos)
  9941. var rf []*ResultFive
  9942. json.Unmarshal([]byte(infoStr), &rf)
  9943. var insutypes []*ResultFive
  9944. var insutype string
  9945. var is390 int = 0
  9946. var is310 int = 0
  9947. //var insuplc_admdvs string
  9948. for _, item := range rf {
  9949. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9950. insutypes = append(insutypes, item)
  9951. }
  9952. }
  9953. if len(insutypes) == 1 {
  9954. insutype = insutypes[0].Insutype
  9955. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9956. } else {
  9957. for _, i := range insutypes {
  9958. if i.Insutype == "390" {
  9959. is390 = 1
  9960. }
  9961. if i.Insutype == "310" {
  9962. is310 = 1
  9963. }
  9964. }
  9965. }
  9966. if is390 == 1 {
  9967. insutype = "390"
  9968. }
  9969. if is310 == 1 {
  9970. insutype = "310"
  9971. }
  9972. if len(insutypes) == 0 {
  9973. insutype = "310"
  9974. }
  9975. psn := &models.HisPsn{
  9976. PsnNo: res2.Output.Baseinfo.PsnNo,
  9977. PatientId: patient.ID,
  9978. Certno: res2.Output.Baseinfo.Certno,
  9979. Gend: res2.Output.Baseinfo.Gend,
  9980. Naty: res2.Output.Baseinfo.Naty,
  9981. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9982. PsnName: res2.Output.Baseinfo.PsnName,
  9983. Idetinfo: idetinfoStr,
  9984. Insuinfo: infoStr,
  9985. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9986. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9987. VerifyNumber: res.Output.EcToken,
  9988. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9989. }
  9990. service.CreateHisPsn(psn)
  9991. c.ServeSuccessJSON(map[string]interface{}{
  9992. "patient": patient,
  9993. "number": res.Output.CardNo,
  9994. "insutype": insutype,
  9995. })
  9996. }
  9997. } else {
  9998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9999. return
  10000. }
  10001. } else {
  10002. c.ServeSuccessJSON(map[string]interface{}{
  10003. "failed_code": -10,
  10004. "msg": res.ErrMsg,
  10005. })
  10006. }
  10007. } else {
  10008. //if initFlag == 0 {
  10009. // c.TestGetBasBaseInit()
  10010. //}
  10011. //token := c.GetEleBaseInfo()
  10012. //token = Remove0000(token)
  10013. type ELeData struct {
  10014. Code string `json:"code"`
  10015. Data struct {
  10016. Aac002 string `json:"aac002"`
  10017. Aaz500 string `json:"aaz500"`
  10018. ActCardNo string `json:"actCardNo"`
  10019. Bab520 string `json:"bab520"`
  10020. Bkz543 string `json:"bkz543"`
  10021. BusinessType string `json:"businessType"`
  10022. CertfCodg string `json:"certfCodg"`
  10023. EcIndexNo string `json:"ecIndexNo"`
  10024. EcToken string `json:"ecToken"`
  10025. ID0000 string `json:"id0000"`
  10026. IDNo string `json:"idNo"`
  10027. IDType string `json:"idType"`
  10028. Idcode string `json:"idcode"`
  10029. IdentityToken string `json:"identity_token"`
  10030. InsuOrg string `json:"insuOrg"`
  10031. OfficeID string `json:"officeId"`
  10032. OfficeName string `json:"officeName"`
  10033. OperatorID string `json:"operatorId"`
  10034. OperatorName string `json:"operatorName"`
  10035. OrgID string `json:"orgId"`
  10036. UserName string `json:"userName"`
  10037. } `json:"data"`
  10038. Infno interface{} `json:"infno"`
  10039. Message string `json:"message"`
  10040. OrgID string `json:"orgId"`
  10041. TransType string `json:"transType"`
  10042. }
  10043. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10044. fmt.Println(result)
  10045. outPutInfo := Remove0000(result)
  10046. fmt.Println(outPutInfo)
  10047. var ele ELeData
  10048. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10049. if err != nil {
  10050. utils.ErrorLog("解析失败:%v", err)
  10051. }
  10052. token := ele.Data.EcToken
  10053. var result2 string
  10054. var requestLog2 string
  10055. if len(token) > 0 {
  10056. if strings.Contains(ele.Data.IDNo, "HKG") {
  10057. 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)
  10058. } else {
  10059. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  10060. }
  10061. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10062. var res ResultTwo
  10063. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10064. utils.ErrorLog("解析失败:%v", err)
  10065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10066. return
  10067. }
  10068. if res.Infcode == 0 {
  10069. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10070. if err == gorm.ErrRecordNotFound {
  10071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10072. return
  10073. } else if err != nil {
  10074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10075. return
  10076. } else {
  10077. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10078. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10079. infoStr := string(Iinfos)
  10080. idetinfoStr := string(Idetinfos)
  10081. psn := &models.HisPsn{
  10082. PsnNo: res.Output.Baseinfo.PsnNo,
  10083. PatientId: patient.ID,
  10084. Certno: res.Output.Baseinfo.Certno,
  10085. Gend: res.Output.Baseinfo.Gend,
  10086. Naty: res.Output.Baseinfo.Naty,
  10087. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10088. PsnName: res.Output.Baseinfo.PsnName,
  10089. Idetinfo: idetinfoStr,
  10090. Insuinfo: infoStr,
  10091. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10092. CardInfo: "",
  10093. VerifyNumber: token,
  10094. }
  10095. service.CreateHisPsn(psn)
  10096. c.ServeSuccessJSON(map[string]interface{}{
  10097. "msg": "读取成功",
  10098. })
  10099. }
  10100. } else {
  10101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10102. return
  10103. }
  10104. } else {
  10105. c.ServeSuccessJSON(map[string]interface{}{
  10106. "failed_code": -10,
  10107. "msg": "读取失败",
  10108. })
  10109. }
  10110. }
  10111. }
  10112. func (c *HisApiController) ReadEleFace() {
  10113. admin_user_id, _ := c.GetInt64("admin_user_id")
  10114. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10115. adminUser := c.GetAdminUserInfo()
  10116. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10117. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10118. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10119. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10120. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10121. if len(tokens) > 0 {
  10122. c.ServeSuccessJSON(map[string]interface{}{
  10123. "msg": "读取成功",
  10124. })
  10125. } else {
  10126. c.ServeSuccessJSON(map[string]interface{}{
  10127. "failed_code": -10,
  10128. "msg": "读取失败",
  10129. })
  10130. }
  10131. }
  10132. }
  10133. func (c *HisApiController) Get9001() {
  10134. adminUser := c.GetAdminUserInfo()
  10135. admin_user_id, _ := c.GetInt64("admin_user_id")
  10136. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10137. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10138. if miConfig.MdtrtareaAdmvs == "350500" {
  10139. service.GetFjAuthorizationInfo(miConfig.Code)
  10140. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10141. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10142. var dat map[string]interface{}
  10143. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10144. fmt.Println(dat)
  10145. } else {
  10146. fmt.Println(err)
  10147. }
  10148. userJSONBytes, _ := json.Marshal(dat)
  10149. var res models.Result9001
  10150. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10151. utils.ErrorLog("解析失败:%v", err)
  10152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10153. return
  10154. }
  10155. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10156. fmt.Println(miConfig.SecretKey)
  10157. var res models.Result9001Two
  10158. 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 +
  10159. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10160. resp, requestErr := http.Get(api)
  10161. if requestErr != nil {
  10162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10163. return
  10164. }
  10165. body, ioErr := ioutil.ReadAll(resp.Body)
  10166. if ioErr != nil {
  10167. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10169. return
  10170. }
  10171. var respJSON map[string]interface{}
  10172. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10173. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10175. return
  10176. }
  10177. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10178. if status == "0" {
  10179. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10180. c.ServeSuccessJSON(map[string]interface{}{
  10181. "failed_code": -10,
  10182. "msg": err_msg,
  10183. })
  10184. return
  10185. }
  10186. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10187. result, _ := json.Marshal(respJSON)
  10188. fmt.Println("log")
  10189. fmt.Println(string(result))
  10190. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10191. utils.ErrorLog("解析失败:%v", err)
  10192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10193. return
  10194. }
  10195. if res.Infcode == 0 {
  10196. sign := models.HisSignIn{
  10197. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10198. SignNo: res.Output.Signinoutb.SignNo,
  10199. SignTime: "",
  10200. Ctime: time.Now().Unix(),
  10201. Mtime: time.Now().Unix(),
  10202. Status: 1,
  10203. InputLog: "",
  10204. OutputLog: "",
  10205. FixmedinsCode: miConfig.Code,
  10206. }
  10207. err := service.CreateSignIn(&sign)
  10208. if err == nil {
  10209. c.ServeSuccessJSON(map[string]interface{}{
  10210. "msg": "签到成功",
  10211. })
  10212. }
  10213. } else {
  10214. c.ServeSuccessJSON(map[string]interface{}{
  10215. "failed_code": -10,
  10216. "msg": res.ErrMsg,
  10217. })
  10218. return
  10219. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10220. //return
  10221. }
  10222. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10223. fmt.Println(miConfig.SecretKey)
  10224. var res models.Result9001Two
  10225. 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 +
  10226. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10227. resp, requestErr := http.Get(api)
  10228. if requestErr != nil {
  10229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10230. return
  10231. }
  10232. body, ioErr := ioutil.ReadAll(resp.Body)
  10233. if ioErr != nil {
  10234. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10236. return
  10237. }
  10238. var respJSON map[string]interface{}
  10239. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10240. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10242. return
  10243. }
  10244. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10245. if status == "0" {
  10246. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10247. c.ServeSuccessJSON(map[string]interface{}{
  10248. "failed_code": -10,
  10249. "msg": err_msg,
  10250. })
  10251. return
  10252. }
  10253. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10254. result, _ := json.Marshal(respJSON)
  10255. fmt.Println("log")
  10256. fmt.Println(string(result))
  10257. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10258. utils.ErrorLog("解析失败:%v", err)
  10259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10260. return
  10261. }
  10262. if res.Infcode == 0 {
  10263. sign := models.HisSignIn{
  10264. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10265. SignNo: res.Output.Signinoutb.SignNo,
  10266. SignTime: "",
  10267. Ctime: time.Now().Unix(),
  10268. Mtime: time.Now().Unix(),
  10269. Status: 1,
  10270. InputLog: "",
  10271. OutputLog: "",
  10272. FixmedinsCode: miConfig.Code,
  10273. }
  10274. err := service.CreateSignIn(&sign)
  10275. if err == nil {
  10276. c.ServeSuccessJSON(map[string]interface{}{
  10277. "msg": "签到成功",
  10278. })
  10279. }
  10280. } else {
  10281. c.ServeSuccessJSON(map[string]interface{}{
  10282. "failed_code": -10,
  10283. "msg": res.ErrMsg,
  10284. })
  10285. return
  10286. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10287. //return
  10288. }
  10289. } else {
  10290. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  10291. var dat map[string]interface{}
  10292. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10293. fmt.Println(dat)
  10294. } else {
  10295. fmt.Println(err)
  10296. }
  10297. userJSONBytes, _ := json.Marshal(dat)
  10298. var res models.Result9001
  10299. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10300. utils.ErrorLog("解析失败:%v", err)
  10301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10302. return
  10303. }
  10304. if res.Infcode == 0 {
  10305. sign := models.HisSignIn{
  10306. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10307. SignNo: res.Output.Signinoutb.SignNo,
  10308. SignTime: res.Output.Signinoutb.SignTime,
  10309. Ctime: time.Now().Unix(),
  10310. Mtime: time.Now().Unix(),
  10311. Status: 1,
  10312. InputLog: "",
  10313. OutputLog: "",
  10314. FixmedinsCode: miConfig.Code,
  10315. }
  10316. err := service.CreateSignIn(&sign)
  10317. if err == nil {
  10318. c.ServeSuccessJSON(map[string]interface{}{
  10319. "msg": "签到成功",
  10320. })
  10321. }
  10322. }
  10323. }
  10324. }
  10325. 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) {
  10326. var res Result3101
  10327. adminUser := c.GetAdminUserInfo()
  10328. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10329. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10330. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10331. //record_time := c.GetString("record_time")
  10332. //trig_scen := c.GetString("trig_scen")
  10333. timeLayout := "2006-01-02"
  10334. loc, _ := time.LoadLocation("Local")
  10335. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10336. if err != nil {
  10337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10338. return res
  10339. }
  10340. recordDateTime := theTime.Unix()
  10341. var patientPrescription models.HisPrescriptionInfo
  10342. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10343. //if patientPrescription.ID == 0 {
  10344. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10345. //}
  10346. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10347. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10348. //
  10349. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10350. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10351. var pp models.PublicParams
  10352. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10353. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10354. pp.FixmedinsName = miConfig.OrgName
  10355. pp.FixmedinsCode = miConfig.Code
  10356. pp.RequestUrl = miConfig.Url
  10357. pp.Cainfo = miConfig.Cainfo
  10358. pp.SecretKey = miConfig.SecretKey
  10359. pp.AccessKey = miConfig.AccessKey
  10360. pp.OpterName = roles.UserName
  10361. var config []*models.HisXtDiagnoseConfig
  10362. for _, item := range diagnosis_ids {
  10363. id, _ := strconv.ParseInt(item, 10, 64)
  10364. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10365. config = append(config, &diagnosisConfig)
  10366. }
  10367. var pd models.PatientDtos
  10368. pd.PatnID = his.PsnNo
  10369. pd.PatnName = his.Name
  10370. pd.Gend = his.Gend
  10371. pd.Brdy = his.Brdy
  10372. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10373. pd.CurrMdtrtID = his.Number
  10374. var fed models.FsiEncounterDtos
  10375. fed.MdtrtID = his.Number
  10376. fed.MedinsID = miConfig.Code
  10377. fed.MedinsName = miConfig.OrgName
  10378. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10379. fed.MedMdtrtType = "1"
  10380. fed.MedinsType = "1"
  10381. fed.MedinsLv = "11"
  10382. tm := time.Unix(his.RecordDate, 0)
  10383. s_tm := tm.Format("2006-01-02 15:04:05")
  10384. fed.AdmDate = s_tm
  10385. fed.DscgDate = s_tm
  10386. fed.DscgMainDiseCodg = config[0].CountryCode
  10387. fed.DscgMainDiseName = config[0].CountryContentName
  10388. //诊断信息
  10389. var fdds []*models.FsiDiagnoseDtos
  10390. for index, item := range config {
  10391. if index == 0 {
  10392. var fdd models.FsiDiagnoseDtos
  10393. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10394. fdd.InoutDiseType = "1"
  10395. fdd.MaindiseFlag = "1"
  10396. fdd.DiseDate = s_tm
  10397. fdd.DiasSrtNo = "1"
  10398. fdd.DiseName = item.CountryContentName
  10399. fdd.DiseCodg = item.CountryCode
  10400. fdds = append(fdds, &fdd)
  10401. } else {
  10402. var fdd models.FsiDiagnoseDtos
  10403. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10404. fdd.InoutDiseType = "1"
  10405. fdd.MaindiseFlag = "1"
  10406. fdd.DiseDate = s_tm
  10407. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10408. fdd.DiseName = item.CountryContentName
  10409. fdd.DiseCodg = item.CountryCode
  10410. fdds = append(fdds, &fdd)
  10411. }
  10412. }
  10413. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10414. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  10415. fed.AdmDeptName = de.Name
  10416. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  10417. fed.DscgDeptName = de.Name
  10418. fed.MedMdtrtType = "1"
  10419. fed.MedType = "11"
  10420. //if his.Insutype == "390" {
  10421. // fed.MedType = "1402"
  10422. //} else {
  10423. // fed.MedType = "9933"
  10424. //}
  10425. var orders []*models.FsiOrderDtos
  10426. if trig_scen == "2" {
  10427. //处方医嘱信息
  10428. for _, item := range prescriptions {
  10429. for _, subItem := range item.HisDoctorAdviceInfo {
  10430. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10431. var order models.FsiOrderDtos
  10432. order.RxID = strconv.FormatInt(item.ID, 10)
  10433. order.Rxno = strconv.FormatInt(item.ID, 10)
  10434. order.LongDrordFlag = "0"
  10435. order.HilistType = "1"
  10436. order.ChrgType = "1"
  10437. order.DrordBhvr = "-"
  10438. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10439. order.HosplistName = subItem.BaseDrugLib.DrugName
  10440. order.HilistLv = "1"
  10441. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10442. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10443. order.HosplistName = subItem.BaseDrugLib.DrugName
  10444. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10445. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10446. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10447. order.OwnpayAmt = ""
  10448. order.SelfpayAmt = ""
  10449. order.Spec = ""
  10450. order.SpecUnt = ""
  10451. order.DrordBegnDate = s_tm
  10452. order.DrordStopDate = ""
  10453. order.DrordDrCodg = doctor_info.DoctorNumber
  10454. order.DrordDeptName = department.Name
  10455. order.DrordDeptCodg = department.Number
  10456. order.DrordDrName = doctor_info.UserName
  10457. order.DrordDrProfttl = "234"
  10458. order.CurrDrordFlag = "1"
  10459. orders = append(orders, &order)
  10460. }
  10461. }
  10462. for _, subItem := range item.HisPrescriptionProject {
  10463. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10464. var order models.FsiOrderDtos
  10465. order.RxID = strconv.FormatInt(item.ID, 10)
  10466. order.Rxno = strconv.FormatInt(item.ID, 10)
  10467. order.LongDrordFlag = "0"
  10468. order.HilistType = "1"
  10469. order.ChrgType = "1"
  10470. order.DrordBhvr = "-"
  10471. order.HilistCode = subItem.HisProject.MedicalCode
  10472. order.HosplistName = subItem.HisProject.ProjectName
  10473. order.HilistLv = "1"
  10474. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10475. order.HosplistCode = subItem.HisProject.MedicalCode
  10476. order.HosplistName = subItem.HisProject.ProjectName
  10477. order.Cnt = subItem.Count
  10478. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10479. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10480. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10481. order.OwnpayAmt = ""
  10482. order.SelfpayAmt = ""
  10483. order.Spec = ""
  10484. order.SpecUnt = ""
  10485. order.DrordBegnDate = s_tm
  10486. order.DrordStopDate = ""
  10487. order.DrordDrCodg = doctor_info.DoctorNumber
  10488. order.DrordDeptName = department.Name
  10489. order.DrordDeptCodg = department.Number
  10490. order.DrordDrName = doctor_info.UserName
  10491. order.DrordDrProfttl = "234"
  10492. order.CurrDrordFlag = "1"
  10493. orders = append(orders, &order)
  10494. }
  10495. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10496. var order models.FsiOrderDtos
  10497. order.RxID = strconv.FormatInt(item.ID, 10)
  10498. order.Rxno = strconv.FormatInt(item.ID, 10)
  10499. order.LongDrordFlag = "0"
  10500. order.HilistType = "1"
  10501. order.ChrgType = "1"
  10502. order.DrordBhvr = "-"
  10503. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10504. order.HosplistName = subItem.GoodInfo.GoodName
  10505. order.HilistLv = "1"
  10506. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10507. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10508. order.HosplistName = subItem.GoodInfo.GoodName
  10509. order.Cnt = subItem.Count
  10510. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10511. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10512. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10513. order.OwnpayAmt = ""
  10514. order.SelfpayAmt = ""
  10515. order.Spec = ""
  10516. order.SpecUnt = ""
  10517. order.DrordBegnDate = s_tm
  10518. order.DrordStopDate = ""
  10519. order.DrordDrCodg = doctor_info.DoctorNumber
  10520. order.DrordDeptName = department.Name
  10521. order.DrordDeptCodg = department.Number
  10522. order.DrordDrName = doctor_info.UserName
  10523. order.DrordDrProfttl = "234"
  10524. order.CurrDrordFlag = "1"
  10525. orders = append(orders, &order)
  10526. }
  10527. }
  10528. }
  10529. //处方医嘱信息
  10530. }
  10531. fed.MatnStas = "0"
  10532. fed.MedfeeSumamt = "0"
  10533. fed.OwnpayAmt = "0"
  10534. fed.SelfpayAmt = "0"
  10535. fed.AcctPayamt = "0"
  10536. fed.MaAmt = "0"
  10537. fed.HifpPayamt = "0"
  10538. fed.SetlTotlnum = "1"
  10539. fed.Insutype = his.Insutype
  10540. fed.ReimFlag = "0"
  10541. fed.OutSetlFlag = "0"
  10542. var fopd []*models.FsiOperationDtosData
  10543. data := make(map[string]interface{})
  10544. data["fed"] = fed
  10545. data["fdd"] = fdds
  10546. data["fod"] = orders
  10547. data["pd"] = pd
  10548. data["pp"] = pp
  10549. data["fopd"] = fopd
  10550. data["trig_scen"] = trig_scen
  10551. fmt.Println(data)
  10552. fmt.Println(fed)
  10553. fmt.Println(fdds)
  10554. fmt.Println(orders)
  10555. fmt.Println(pd)
  10556. fmt.Println(pp)
  10557. fmt.Println(fopd)
  10558. client := &http.Client{}
  10559. bytesData, _ := json.Marshal(data)
  10560. var req *http.Request
  10561. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10562. if miConfig.MdtrtareaAdmvs == "320921" {
  10563. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10564. } else {
  10565. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10566. }
  10567. resp, _ := client.Do(req)
  10568. defer resp.Body.Close()
  10569. body, ioErr := ioutil.ReadAll(resp.Body)
  10570. if ioErr != nil {
  10571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10573. return res
  10574. }
  10575. var respJSON map[string]interface{}
  10576. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10577. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10579. return res
  10580. }
  10581. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10582. fmt.Println(respJSON)
  10583. result, _ := json.Marshal(respJSON)
  10584. fmt.Println(result)
  10585. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10586. utils.ErrorLog("解析失败:%v", err)
  10587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10588. return res
  10589. }
  10590. return res
  10591. } else {
  10592. //if miConfig.MdtrtareaAdmvs == "441202" {
  10593. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10594. saveLog(output, input, "3101", "事前")
  10595. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10596. utils.ErrorLog("解析失败:%v", err)
  10597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10598. return
  10599. }
  10600. return res
  10601. //}
  10602. }
  10603. }
  10604. 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) {
  10605. adminUser := c.GetAdminUserInfo()
  10606. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10607. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10608. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10609. //record_time := c.GetString("record_time")
  10610. //trig_scen := c.GetString("trig_scen")
  10611. timeLayout := "2006-01-02"
  10612. loc, _ := time.LoadLocation("Local")
  10613. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10614. if err != nil {
  10615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10616. return res
  10617. }
  10618. recordDateTime := theTime.Unix()
  10619. var patientPrescription models.HisPrescriptionInfo
  10620. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10621. if patientPrescription.ID == 0 {
  10622. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10623. }
  10624. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10625. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10626. //
  10627. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10628. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10629. var pp models.PublicParams
  10630. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10631. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10632. pp.FixmedinsName = miConfig.OrgName
  10633. pp.FixmedinsCode = miConfig.Code
  10634. pp.RequestUrl = miConfig.Url
  10635. pp.Cainfo = miConfig.Cainfo
  10636. pp.SecretKey = miConfig.SecretKey
  10637. pp.AccessKey = miConfig.AccessKey
  10638. pp.OpterName = roles.UserName
  10639. var config []*models.HisXtDiagnoseConfig
  10640. for _, item := range diagnosis_ids {
  10641. id, _ := strconv.ParseInt(item, 10, 64)
  10642. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10643. config = append(config, &diagnosisConfig)
  10644. }
  10645. var pd models.PatientDtos
  10646. pd.PatnID = his.PsnNo
  10647. pd.PatnName = his.Name
  10648. pd.Gend = his.Gend
  10649. pd.Brdy = his.Brdy
  10650. pd.Poolarea = his.InsuplcAdmdvs
  10651. pd.CurrMdtrtID = his.Number
  10652. var fed models.FsiEncounterDtos
  10653. fed.MdtrtID = his.Number
  10654. fed.MedinsID = miConfig.Code
  10655. fed.MedinsName = miConfig.OrgName
  10656. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10657. fed.MedMdtrtType = "1"
  10658. fed.MedinsType = "1"
  10659. fed.MedinsLv = "11"
  10660. tm := time.Unix(his.RecordDate, 0)
  10661. s_tm := tm.Format("2006-01-02 15:04:05")
  10662. fed.AdmDate = s_tm
  10663. fed.DscgDate = s_tm
  10664. fed.DscgMainDiseCodg = config[0].CountryCode
  10665. fed.DscgMainDiseName = config[0].CountryContentName
  10666. //诊断信息
  10667. var fdds []*models.FsiDiagnoseDtos
  10668. for index, item := range config {
  10669. if index == 0 {
  10670. var fdd models.FsiDiagnoseDtos
  10671. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10672. fdd.InoutDiseType = "1"
  10673. fdd.MaindiseFlag = "1"
  10674. fdd.DiseDate = s_tm
  10675. fdd.DiasSrtNo = "1"
  10676. fdd.DiseName = item.CountryContentName
  10677. fdd.DiseCodg = item.CountryCode
  10678. fdds = append(fdds, &fdd)
  10679. } else {
  10680. var fdd models.FsiDiagnoseDtos
  10681. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10682. fdd.InoutDiseType = "1"
  10683. fdd.MaindiseFlag = "1"
  10684. fdd.DiseDate = s_tm
  10685. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10686. fdd.DiseName = item.CountryContentName
  10687. fdd.DiseCodg = item.CountryCode
  10688. fdds = append(fdds, &fdd)
  10689. }
  10690. }
  10691. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10692. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10693. fed.AdmDeptName = department.Name
  10694. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10695. fed.DscgDeptName = department.Name
  10696. fed.MedMdtrtType = "1"
  10697. fed.MedType = "11"
  10698. //if his.Insutype == "390" {
  10699. // fed.MedType = "1402"
  10700. //} else {
  10701. // fed.MedType = "9933"
  10702. //}
  10703. var orders []*models.FsiOrderDtos
  10704. if trig_scen == "2" {
  10705. //处方医嘱信息
  10706. for _, item := range prescriptions {
  10707. for _, subItem := range item.HisDoctorAdviceInfo {
  10708. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10709. var order models.FsiOrderDtos
  10710. order.RxID = strconv.FormatInt(item.ID, 10)
  10711. order.Rxno = strconv.FormatInt(item.ID, 10)
  10712. order.LongDrordFlag = "0"
  10713. order.HilistType = "1"
  10714. order.ChrgType = "1"
  10715. order.DrordBhvr = "-"
  10716. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10717. order.HosplistName = subItem.BaseDrugLib.DrugName
  10718. order.HilistLv = "1"
  10719. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10720. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10721. order.HosplistName = subItem.BaseDrugLib.DrugName
  10722. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10723. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10724. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10725. order.OwnpayAmt = ""
  10726. order.SelfpayAmt = ""
  10727. order.Spec = ""
  10728. order.SpecUnt = ""
  10729. order.DrordBegnDate = s_tm
  10730. order.DrordStopDate = ""
  10731. order.DrordDrCodg = doctor_info.DoctorNumber
  10732. order.DrordDeptName = department.Name
  10733. order.DrordDeptCodg = department.Number
  10734. order.DrordDrName = doctor_info.UserName
  10735. order.DrordDrProfttl = "234"
  10736. order.CurrDrordFlag = "1"
  10737. orders = append(orders, &order)
  10738. }
  10739. }
  10740. for _, subItem := range item.HisPrescriptionProject {
  10741. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10742. var order models.FsiOrderDtos
  10743. order.RxID = strconv.FormatInt(item.ID, 10)
  10744. order.Rxno = strconv.FormatInt(item.ID, 10)
  10745. order.LongDrordFlag = "0"
  10746. order.HilistType = "1"
  10747. order.ChrgType = "1"
  10748. order.DrordBhvr = "-"
  10749. order.HilistCode = subItem.HisProject.MedicalCode
  10750. order.HosplistName = subItem.HisProject.ProjectName
  10751. order.HilistLv = "1"
  10752. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10753. order.HosplistCode = subItem.HisProject.MedicalCode
  10754. order.HosplistName = subItem.HisProject.ProjectName
  10755. order.Cnt = subItem.Count
  10756. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10757. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10758. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10759. order.OwnpayAmt = ""
  10760. order.SelfpayAmt = ""
  10761. order.Spec = ""
  10762. order.SpecUnt = ""
  10763. order.DrordBegnDate = s_tm
  10764. order.DrordStopDate = ""
  10765. order.DrordDrCodg = doctor_info.DoctorNumber
  10766. order.DrordDeptName = department.Name
  10767. order.DrordDeptCodg = department.Number
  10768. order.DrordDrName = doctor_info.UserName
  10769. order.DrordDrProfttl = "234"
  10770. order.CurrDrordFlag = "1"
  10771. orders = append(orders, &order)
  10772. }
  10773. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10774. var order models.FsiOrderDtos
  10775. order.RxID = strconv.FormatInt(item.ID, 10)
  10776. order.Rxno = strconv.FormatInt(item.ID, 10)
  10777. order.LongDrordFlag = "0"
  10778. order.HilistType = "1"
  10779. order.ChrgType = "1"
  10780. order.DrordBhvr = "-"
  10781. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10782. order.HosplistName = subItem.GoodInfo.GoodName
  10783. order.HilistLv = "1"
  10784. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10785. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10786. order.HosplistName = subItem.GoodInfo.GoodName
  10787. order.Cnt = subItem.Count
  10788. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10789. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10790. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10791. order.OwnpayAmt = ""
  10792. order.SelfpayAmt = ""
  10793. order.Spec = ""
  10794. order.SpecUnt = ""
  10795. order.DrordBegnDate = s_tm
  10796. order.DrordStopDate = ""
  10797. order.DrordDrCodg = doctor_info.DoctorNumber
  10798. order.DrordDeptName = department.Name
  10799. order.DrordDeptCodg = department.Number
  10800. order.DrordDrName = doctor_info.UserName
  10801. order.DrordDrProfttl = "234"
  10802. order.CurrDrordFlag = "1"
  10803. orders = append(orders, &order)
  10804. }
  10805. }
  10806. }
  10807. //处方医嘱信息
  10808. }
  10809. fed.MatnStas = "0"
  10810. fed.MedfeeSumamt = "0"
  10811. fed.OwnpayAmt = "0"
  10812. fed.SelfpayAmt = "0"
  10813. fed.AcctPayamt = "0"
  10814. fed.MaAmt = "0"
  10815. fed.HifpPayamt = "0"
  10816. fed.SetlTotlnum = "1"
  10817. fed.Insutype = his.Insutype
  10818. fed.ReimFlag = "0"
  10819. fed.OutSetlFlag = "0"
  10820. var fopd []*models.FsiOperationDtosData
  10821. data := make(map[string]interface{})
  10822. data["fed"] = fed
  10823. data["fdd"] = fdds
  10824. data["fod"] = orders
  10825. data["pd"] = pd
  10826. data["pp"] = pp
  10827. data["fopd"] = fopd
  10828. data["trig_scen"] = trig_scen
  10829. fmt.Println(data)
  10830. fmt.Println(fed)
  10831. fmt.Println(fdds)
  10832. fmt.Println(orders)
  10833. fmt.Println(pd)
  10834. fmt.Println(pp)
  10835. fmt.Println(fopd)
  10836. client := &http.Client{}
  10837. bytesData, _ := json.Marshal(data)
  10838. var req *http.Request
  10839. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10840. if miConfig.MdtrtareaAdmvs == "320921" {
  10841. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10842. } else {
  10843. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10844. }
  10845. resp, _ := client.Do(req)
  10846. defer resp.Body.Close()
  10847. body, ioErr := ioutil.ReadAll(resp.Body)
  10848. if ioErr != nil {
  10849. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10851. return res
  10852. }
  10853. var respJSON map[string]interface{}
  10854. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10855. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10857. return res
  10858. }
  10859. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10860. fmt.Println(respJSON)
  10861. result, _ := json.Marshal(respJSON)
  10862. fmt.Println(result)
  10863. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10864. utils.ErrorLog("解析失败:%v", err)
  10865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10866. return res
  10867. }
  10868. return res
  10869. } else {
  10870. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10871. saveLog(output, input, "3101", "事前")
  10872. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10873. utils.ErrorLog("解析失败:%v", err)
  10874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10875. return
  10876. }
  10877. return res
  10878. }
  10879. return res
  10880. }
  10881. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  10882. ////patient_id, _ := c.GetInt64("patient_id")
  10883. //order_id, _ := c.GetInt64("order_id")
  10884. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  10885. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  10886. //trig_scen := c.GetString("trig_scen")
  10887. adminUser := c.GetAdminUserInfo()
  10888. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10889. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10890. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10891. record_time := c.GetString("record_time")
  10892. order, _ := service.GetHisOrderByID(order_id)
  10893. psn_info, _ := service.GetPsnByPatientId(patient_id)
  10894. timeLayout := "2006-01-02"
  10895. loc, _ := time.LoadLocation("Local")
  10896. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10897. if err != nil {
  10898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10899. return
  10900. }
  10901. recordDateTime := theTime.Unix()
  10902. var patientPrescription models.HisPrescriptionInfo
  10903. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10904. if patientPrescription.ID == 0 {
  10905. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10906. }
  10907. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10908. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10909. //
  10910. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10911. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10912. var pp models.PublicParams
  10913. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10914. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10915. pp.FixmedinsName = miConfig.OrgName
  10916. pp.FixmedinsCode = miConfig.Code
  10917. pp.RequestUrl = miConfig.Url
  10918. pp.Cainfo = miConfig.Cainfo
  10919. pp.SecretKey = miConfig.SecretKey
  10920. pp.AccessKey = miConfig.AccessKey
  10921. pp.OpterName = roles.UserName
  10922. var config []*models.HisXtDiagnoseConfig
  10923. for _, item := range diagnosis_ids {
  10924. id, _ := strconv.ParseInt(item, 10, 64)
  10925. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10926. config = append(config, &diagnosisConfig)
  10927. }
  10928. var pd models.PatientDtos
  10929. pd.PatnID = his.PsnNo
  10930. pd.PatnName = his.Name
  10931. pd.Gend = his.Gend
  10932. pd.Brdy = psn_info.Brdy
  10933. pd.Poolarea = his.InsuplcAdmdvs
  10934. pd.CurrMdtrtID = his.Number
  10935. var fed models.FsiEncounterDtos
  10936. fed.MdtrtID = his.Number
  10937. fed.MedinsID = miConfig.Code
  10938. fed.MedinsName = miConfig.OrgName
  10939. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10940. fed.MedMdtrtType = "1"
  10941. fed.MedinsType = "1"
  10942. fed.MedinsLv = "11"
  10943. tm := time.Unix(his.RecordDate, 0)
  10944. s_tm := tm.Format("2006-01-02 15:04:05")
  10945. fed.AdmDate = s_tm
  10946. fed.DscgDate = s_tm
  10947. fed.DscgMainDiseCodg = config[0].CountryCode
  10948. fed.DscgMainDiseName = config[0].CountryContentName
  10949. //诊断信息
  10950. var fdds []*models.FsiDiagnoseDtos
  10951. for index, item := range config {
  10952. if index == 0 {
  10953. var fdd models.FsiDiagnoseDtos
  10954. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10955. fdd.InoutDiseType = "1"
  10956. fdd.MaindiseFlag = "1"
  10957. fdd.DiseDate = s_tm
  10958. fdd.DiasSrtNo = "1"
  10959. fdd.DiseName = item.CountryContentName
  10960. fdd.DiseCodg = item.CountryCode
  10961. fdds = append(fdds, &fdd)
  10962. } else {
  10963. var fdd models.FsiDiagnoseDtos
  10964. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10965. fdd.InoutDiseType = "1"
  10966. fdd.MaindiseFlag = "1"
  10967. fdd.DiseDate = s_tm
  10968. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10969. fdd.DiseName = item.CountryContentName
  10970. fdd.DiseCodg = item.CountryCode
  10971. fdds = append(fdds, &fdd)
  10972. }
  10973. }
  10974. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10975. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10976. fed.AdmDeptName = department.Name
  10977. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10978. fed.DscgDeptName = department.Name
  10979. fed.MedType = order.MedType
  10980. //处方医嘱信息
  10981. var orders []*models.FsiOrderDtos
  10982. //for _, item := range prescriptions {
  10983. // for _, subItem := range item.HisDoctorAdviceInfo {
  10984. // var order models.FsiOrderDtos
  10985. // order.RxID = strconv.FormatInt(item.ID, 10)
  10986. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10987. // order.LongDrordFlag = "0"
  10988. // order.HilistType = "1"
  10989. // order.ChrgType = "1"
  10990. // order.DrordBhvr = "-"
  10991. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10992. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10993. // order.HilistLv = "1"
  10994. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10995. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10996. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10997. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  10998. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10999. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11000. // order.OwnpayAmt = ""
  11001. // order.SelfpayAmt = ""
  11002. // order.Spec = ""
  11003. // order.SpecUnt = ""
  11004. // order.DrordBegnDate = s_tm
  11005. // order.DrordStopDate = ""
  11006. // order.DrordDrCodg = "1"
  11007. // order.DrordDeptName = department.Name
  11008. // order.DrordDrCodg = "1"
  11009. // order.DrordDrName = doctor_info.UserName
  11010. // order.DrordDrProfttl = ""
  11011. // order.CurrDrordFlag = "1"
  11012. // orders = append(orders, &order)
  11013. // }
  11014. // for _, subItem := range item.HisPrescriptionProject {
  11015. // if subItem.Type == 2 {
  11016. // var order models.FsiOrderDtos
  11017. // order.RxID = strconv.FormatInt(item.ID, 10)
  11018. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11019. // order.LongDrordFlag = "0"
  11020. // order.HilistType = "1"
  11021. // order.ChrgType = "1"
  11022. // order.DrordBhvr = "-"
  11023. // order.HilistCode = subItem.HisProject.MedicalCode
  11024. // order.HosplistName = subItem.HisProject.ProjectName
  11025. // order.HilistLv = "1"
  11026. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11027. // order.HosplistCode = subItem.HisProject.MedicalCode
  11028. // order.HosplistName = subItem.HisProject.ProjectName
  11029. // order.Cnt = subItem.Count
  11030. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11031. //
  11032. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11033. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11034. // order.OwnpayAmt = ""
  11035. // order.SelfpayAmt = ""
  11036. // order.Spec = ""
  11037. // order.SpecUnt = ""
  11038. // order.DrordBegnDate = s_tm
  11039. // order.DrordStopDate = ""
  11040. // order.DrordDrCodg = "1"
  11041. // order.DrordDeptName = department.Name
  11042. // order.DrordDrCodg = "1"
  11043. // order.DrordDrName = doctor_info.UserName
  11044. // order.DrordDrProfttl = ""
  11045. // order.CurrDrordFlag = "1"
  11046. // orders = append(orders, &order)
  11047. //
  11048. // }
  11049. // if subItem.Type == 3 {
  11050. //
  11051. // var order models.FsiOrderDtos
  11052. // order.RxID = strconv.FormatInt(item.ID, 10)
  11053. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11054. // order.LongDrordFlag = "0"
  11055. // order.HilistType = "1"
  11056. // order.ChrgType = "1"
  11057. // order.DrordBhvr = "-"
  11058. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11059. // order.HosplistName = subItem.GoodInfo.GoodName
  11060. // order.HilistLv = "1"
  11061. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11062. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11063. // order.HosplistName = subItem.GoodInfo.GoodName
  11064. // order.Cnt = subItem.Count
  11065. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11066. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11067. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11068. // order.OwnpayAmt = ""
  11069. // order.SelfpayAmt = ""
  11070. // order.Spec = ""
  11071. // order.SpecUnt = ""
  11072. // order.DrordBegnDate = s_tm
  11073. // order.DrordStopDate = ""
  11074. // order.DrordDrCodg = "1"
  11075. // order.DrordDeptName = department.Name
  11076. // order.DrordDrCodg = "1"
  11077. // order.DrordDrName = doctor_info.UserName
  11078. // order.DrordDrProfttl = ""
  11079. // order.CurrDrordFlag = "1"
  11080. // orders = append(orders, &order)
  11081. //
  11082. // }
  11083. // }
  11084. //}
  11085. for _, item := range prescriptions {
  11086. for _, subItem := range item.HisDoctorAdviceInfo {
  11087. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11088. var order models.FsiOrderDtos
  11089. order.RxID = strconv.FormatInt(item.ID, 10)
  11090. order.Rxno = strconv.FormatInt(item.ID, 10)
  11091. order.LongDrordFlag = "0"
  11092. order.HilistType = "1"
  11093. order.ChrgType = "1"
  11094. order.DrordBhvr = "-"
  11095. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11096. order.HosplistName = subItem.BaseDrugLib.DrugName
  11097. order.HilistLv = "1"
  11098. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11099. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11100. order.HosplistName = subItem.BaseDrugLib.DrugName
  11101. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11102. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11103. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11104. order.OwnpayAmt = ""
  11105. order.SelfpayAmt = ""
  11106. order.Spec = ""
  11107. order.SpecUnt = ""
  11108. order.DrordBegnDate = s_tm
  11109. order.DrordStopDate = ""
  11110. order.DrordDrCodg = doctor_info.DoctorNumber
  11111. order.DrordDeptName = department.Name
  11112. order.DrordDeptCodg = department.Number
  11113. order.DrordDrName = doctor_info.UserName
  11114. order.DrordDrProfttl = "234"
  11115. order.CurrDrordFlag = "1"
  11116. orders = append(orders, &order)
  11117. }
  11118. }
  11119. for _, subItem := range item.HisPrescriptionProject {
  11120. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11121. var order models.FsiOrderDtos
  11122. order.RxID = strconv.FormatInt(item.ID, 10)
  11123. order.Rxno = strconv.FormatInt(item.ID, 10)
  11124. order.LongDrordFlag = "0"
  11125. order.HilistType = "1"
  11126. order.ChrgType = "1"
  11127. order.DrordBhvr = "-"
  11128. order.HilistCode = subItem.HisProject.MedicalCode
  11129. order.HosplistName = subItem.HisProject.ProjectName
  11130. order.HilistLv = "1"
  11131. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11132. order.HosplistCode = subItem.HisProject.MedicalCode
  11133. order.HosplistName = subItem.HisProject.ProjectName
  11134. order.Cnt = subItem.Count
  11135. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11136. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11137. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11138. order.OwnpayAmt = ""
  11139. order.SelfpayAmt = ""
  11140. order.Spec = ""
  11141. order.SpecUnt = ""
  11142. order.DrordBegnDate = s_tm
  11143. order.DrordStopDate = ""
  11144. order.DrordDrCodg = doctor_info.DoctorNumber
  11145. order.DrordDeptName = department.Name
  11146. order.DrordDeptCodg = department.Number
  11147. order.DrordDrName = doctor_info.UserName
  11148. order.DrordDrProfttl = "234"
  11149. order.CurrDrordFlag = "1"
  11150. orders = append(orders, &order)
  11151. }
  11152. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11153. var order models.FsiOrderDtos
  11154. order.RxID = strconv.FormatInt(item.ID, 10)
  11155. order.Rxno = strconv.FormatInt(item.ID, 10)
  11156. order.LongDrordFlag = "0"
  11157. order.HilistType = "1"
  11158. order.ChrgType = "1"
  11159. order.DrordBhvr = "0"
  11160. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11161. order.HosplistName = subItem.GoodInfo.GoodName
  11162. order.HilistLv = "1"
  11163. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11164. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11165. order.HosplistName = subItem.GoodInfo.GoodName
  11166. order.Cnt = subItem.Count
  11167. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11168. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11169. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11170. order.OwnpayAmt = ""
  11171. order.SelfpayAmt = ""
  11172. order.Spec = ""
  11173. order.SpecUnt = ""
  11174. order.DrordBegnDate = s_tm
  11175. order.DrordStopDate = ""
  11176. order.DrordDrCodg = doctor_info.DoctorNumber
  11177. order.DrordDeptName = department.Name
  11178. order.DrordDeptCodg = department.Number
  11179. order.DrordDrName = doctor_info.UserName
  11180. order.DrordDrProfttl = "234"
  11181. order.CurrDrordFlag = "1"
  11182. orders = append(orders, &order)
  11183. }
  11184. }
  11185. }
  11186. //处方医嘱信息
  11187. fed.MatnStas = "0"
  11188. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11189. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11190. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11191. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11192. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11193. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11194. fed.SetlTotlnum = "1"
  11195. fed.Insutype = his.Insutype
  11196. fed.ReimFlag = "0"
  11197. fed.OutSetlFlag = "0"
  11198. var fopd []*models.FsiOperationDtosData
  11199. data := make(map[string]interface{})
  11200. data["fed"] = fed
  11201. data["fdd"] = fdds
  11202. data["fod"] = orders
  11203. data["pd"] = pd
  11204. data["pp"] = pp
  11205. data["fopd"] = fopd
  11206. data["trig_scen"] = trig_scen
  11207. client := &http.Client{}
  11208. bytesData, _ := json.Marshal(data)
  11209. var req *http.Request
  11210. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11211. if miConfig.MdtrtareaAdmvs == "320921" {
  11212. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11213. } else {
  11214. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11215. }
  11216. resp, _ := client.Do(req)
  11217. defer resp.Body.Close()
  11218. body, ioErr := ioutil.ReadAll(resp.Body)
  11219. if ioErr != nil {
  11220. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11222. return res
  11223. }
  11224. var respJSON map[string]interface{}
  11225. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11226. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11228. return res
  11229. }
  11230. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11231. result, _ := json.Marshal(respJSON)
  11232. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11233. utils.ErrorLog("解析失败:%v", err)
  11234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11235. return res
  11236. }
  11237. return res
  11238. } else {
  11239. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11240. saveLog(output, input, "3102", "事中")
  11241. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11242. utils.ErrorLog("解析失败:%v", err)
  11243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11244. return
  11245. }
  11246. return res
  11247. }
  11248. return res
  11249. }
  11250. 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) {
  11251. var res Resultgd3101
  11252. adminUser := c.GetAdminUserInfo()
  11253. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11254. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11255. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11256. //record_time := c.GetString("record_time")
  11257. //trig_scen := c.GetString("trig_scen")
  11258. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11259. //psn_info, _ := service.GetPatientId(patient_id)
  11260. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11261. timeLayout := "2006-01-02"
  11262. loc, _ := time.LoadLocation("Local")
  11263. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11264. if err != nil {
  11265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11266. return res
  11267. }
  11268. recordDateTime := theTime.Unix()
  11269. var patientPrescription models.HisPrescriptionInfo
  11270. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11271. //if patientPrescription.ID == 0 {
  11272. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11273. //}
  11274. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11275. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11276. //
  11277. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11278. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11279. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11280. var pp models.PublicParams
  11281. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11282. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11283. pp.FixmedinsName = miConfig.OrgName
  11284. pp.FixmedinsCode = miConfig.Code
  11285. pp.RequestUrl = miConfig.Url
  11286. pp.Cainfo = miConfig.Cainfo
  11287. pp.SecretKey = miConfig.SecretKey
  11288. pp.AccessKey = miConfig.AccessKey
  11289. pp.OpterName = roles.UserName
  11290. var config []*models.HisXtDiagnoseConfig
  11291. for _, item := range diagnosis_ids {
  11292. id, _ := strconv.ParseInt(item, 10, 64)
  11293. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11294. config = append(config, &diagnosisConfig)
  11295. }
  11296. var pd models.PatientDtos
  11297. pd.PatnID = his.PsnNo
  11298. pd.PatnName = his.Name
  11299. pd.Gend = his.Gend
  11300. pd.Brdy = str
  11301. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11302. pd.CurrMdtrtID = his.Number
  11303. var fed models.FsiEncounterDtos
  11304. fed.MdtrtID = his.Number
  11305. fed.MedinsID = miConfig.Code
  11306. fed.MedinsName = miConfig.OrgName
  11307. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11308. fed.MedMdtrtType = "1"
  11309. fed.MedinsType = "1"
  11310. fed.MedinsLv = "11"
  11311. tm := time.Unix(his.RecordDate, 0)
  11312. s_tm := tm.Format("2006-01-02 15:04:05")
  11313. fed.AdmDate = s_tm
  11314. fed.DscgDate = s_tm
  11315. fed.DscgMainDiseCodg = config[0].CountryCode
  11316. fed.DscgMainDiseName = config[0].CountryContentName
  11317. //诊断信息
  11318. var fdds []*models.FsiDiagnoseDtos
  11319. for index, item := range config {
  11320. if index == 0 {
  11321. var fdd models.FsiDiagnoseDtos
  11322. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11323. fdd.InoutDiseType = "1"
  11324. fdd.MaindiseFlag = "1"
  11325. fdd.DiseDate = s_tm
  11326. fdd.DiasSrtNo = "1"
  11327. fdd.DiseName = item.CountryContentName
  11328. fdd.DiseCodg = item.CountryCode
  11329. fdds = append(fdds, &fdd)
  11330. } else {
  11331. var fdd models.FsiDiagnoseDtos
  11332. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11333. fdd.InoutDiseType = "1"
  11334. fdd.MaindiseFlag = "1"
  11335. fdd.DiseDate = s_tm
  11336. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11337. fdd.DiseName = item.CountryContentName
  11338. fdd.DiseCodg = item.CountryCode
  11339. fdds = append(fdds, &fdd)
  11340. }
  11341. }
  11342. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11343. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11344. fed.AdmDeptName = de.Name
  11345. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11346. fed.DscgDeptName = de.Name
  11347. fed.MedMdtrtType = "1"
  11348. fed.MedType = "11"
  11349. //if his.Insutype == "390" {
  11350. // fed.MedType = "1402"
  11351. //} else {
  11352. // fed.MedType = "9933"
  11353. //}
  11354. var orders []*models.FsiOrderDtos
  11355. if trig_scen == "2" {
  11356. //处方医嘱信息
  11357. for _, item := range prescriptions {
  11358. for _, subItem := range item.HisDoctorAdviceInfo {
  11359. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11360. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11361. var order models.FsiOrderDtos
  11362. order.RxID = strconv.FormatInt(item.ID, 10)
  11363. order.Rxno = strconv.FormatInt(item.ID, 10)
  11364. order.LongDrordFlag = "0"
  11365. order.HilistType = "1"
  11366. order.ChrgType = "1"
  11367. order.DrordBhvr = "0"
  11368. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11369. order.HosplistName = subItem.BaseDrugLib.DrugName
  11370. order.HilistLv = "1"
  11371. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11372. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11373. order.HosplistName = subItem.BaseDrugLib.DrugName
  11374. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11375. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11376. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11377. order.OwnpayAmt = ""
  11378. order.SelfpayAmt = ""
  11379. order.Spec = spec
  11380. order.SpecUnt = subItem.PrescribingNumberUnit
  11381. order.DrordBegnDate = s_tm
  11382. order.DrordStopDate = ""
  11383. order.DrordDrCodg = doctor_info.DoctorNumber
  11384. order.DrordDeptName = department.Name
  11385. order.DrordDeptCodg = department.Number
  11386. order.DrordDrName = doctor_info.UserName
  11387. order.DrordDrProfttl = "234"
  11388. order.CurrDrordFlag = "1"
  11389. orders = append(orders, &order)
  11390. }
  11391. }
  11392. for _, subItem := range item.HisPrescriptionProject {
  11393. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11394. var order models.FsiOrderDtos
  11395. order.RxID = strconv.FormatInt(item.ID, 10)
  11396. order.Rxno = strconv.FormatInt(item.ID, 10)
  11397. order.LongDrordFlag = "0"
  11398. order.HilistType = "1"
  11399. order.ChrgType = "1"
  11400. order.DrordBhvr = "0"
  11401. order.HilistCode = subItem.HisProject.MedicalCode
  11402. order.HosplistName = subItem.HisProject.ProjectName
  11403. order.HilistLv = "1"
  11404. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11405. order.HosplistCode = subItem.HisProject.MedicalCode
  11406. order.HosplistName = subItem.HisProject.ProjectName
  11407. order.Cnt = subItem.Count
  11408. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11409. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11410. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11411. order.OwnpayAmt = ""
  11412. order.SelfpayAmt = ""
  11413. order.Spec = subItem.Unit
  11414. order.SpecUnt = subItem.Unit
  11415. order.DrordBegnDate = s_tm
  11416. order.DrordStopDate = ""
  11417. order.DrordDrCodg = doctor_info.DoctorNumber
  11418. order.DrordDeptName = department.Name
  11419. order.DrordDeptCodg = department.Number
  11420. order.DrordDrName = doctor_info.UserName
  11421. order.DrordDrProfttl = "234"
  11422. order.CurrDrordFlag = "1"
  11423. orders = append(orders, &order)
  11424. }
  11425. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11426. var order models.FsiOrderDtos
  11427. order.RxID = strconv.FormatInt(item.ID, 10)
  11428. order.Rxno = strconv.FormatInt(item.ID, 10)
  11429. order.LongDrordFlag = "0"
  11430. order.HilistType = "1"
  11431. order.ChrgType = "1"
  11432. order.DrordBhvr = "0"
  11433. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11434. order.HosplistName = subItem.GoodInfo.GoodName
  11435. order.HilistLv = "1"
  11436. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11437. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11438. order.HosplistName = subItem.GoodInfo.GoodName
  11439. order.Cnt = subItem.Count
  11440. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11441. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11442. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11443. order.OwnpayAmt = ""
  11444. order.SelfpayAmt = ""
  11445. order.Spec = subItem.GoodInfo.SpecificationName
  11446. order.SpecUnt = subItem.Unit
  11447. order.DrordBegnDate = s_tm
  11448. order.DrordStopDate = ""
  11449. order.DrordDrCodg = doctor_info.DoctorNumber
  11450. order.DrordDeptName = department.Name
  11451. order.DrordDeptCodg = department.Number
  11452. order.DrordDrName = doctor_info.UserName
  11453. order.DrordDrProfttl = "234"
  11454. order.CurrDrordFlag = "1"
  11455. orders = append(orders, &order)
  11456. }
  11457. }
  11458. }
  11459. //处方医嘱信息
  11460. }
  11461. fed.MatnStas = "0"
  11462. fed.MedfeeSumamt = "0"
  11463. fed.OwnpayAmt = "0"
  11464. fed.SelfpayAmt = "0"
  11465. fed.AcctPayamt = "0"
  11466. fed.MaAmt = "0"
  11467. fed.HifpPayamt = "0"
  11468. fed.SetlTotlnum = "1"
  11469. fed.Insutype = his.Insutype
  11470. fed.ReimFlag = "0"
  11471. fed.OutSetlFlag = "0"
  11472. var fopd []*models.FsiOperationDtosData
  11473. data := make(map[string]interface{})
  11474. data["fed"] = fed
  11475. data["fdd"] = fdds
  11476. data["fod"] = orders
  11477. data["pd"] = pd
  11478. data["pp"] = pp
  11479. data["fopd"] = fopd
  11480. data["trig_scen"] = trig_scen
  11481. fmt.Println(data)
  11482. fmt.Println(fed)
  11483. fmt.Println(fdds)
  11484. fmt.Println(orders)
  11485. fmt.Println(pd)
  11486. fmt.Println(pp)
  11487. fmt.Println(fopd)
  11488. client := &http.Client{}
  11489. bytesData, _ := json.Marshal(data)
  11490. var req *http.Request
  11491. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11492. if miConfig.MdtrtareaAdmvs == "320921" {
  11493. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11494. } else {
  11495. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11496. }
  11497. resp, _ := client.Do(req)
  11498. defer resp.Body.Close()
  11499. body, ioErr := ioutil.ReadAll(resp.Body)
  11500. if ioErr != nil {
  11501. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11503. return res
  11504. }
  11505. var respJSON map[string]interface{}
  11506. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11509. return res
  11510. }
  11511. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11512. fmt.Println(respJSON)
  11513. result, _ := json.Marshal(respJSON)
  11514. fmt.Println(result)
  11515. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11516. utils.ErrorLog("解析失败:%v", err)
  11517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11518. return res
  11519. }
  11520. return res
  11521. } else {
  11522. //if miConfig.MdtrtareaAdmvs == "441202" {
  11523. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11524. saveLog(output, input, "3101", "事前")
  11525. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11526. utils.ErrorLog("解析失败:%v", err)
  11527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11528. return
  11529. }
  11530. return res
  11531. //}
  11532. }
  11533. }
  11534. 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) {
  11535. adminUser := c.GetAdminUserInfo()
  11536. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11537. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11538. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11539. //record_time := c.GetString("record_time")
  11540. //trig_scen := c.GetString("trig_scen")
  11541. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11542. timeLayout := "2006-01-02"
  11543. loc, _ := time.LoadLocation("Local")
  11544. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11545. if err != nil {
  11546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11547. return res
  11548. }
  11549. recordDateTime := theTime.Unix()
  11550. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11551. var patientPrescription models.HisPrescriptionInfo
  11552. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11553. if patientPrescription.ID == 0 {
  11554. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11555. }
  11556. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11557. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11558. //
  11559. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11560. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11561. var pp models.PublicParams
  11562. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11563. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11564. pp.FixmedinsName = miConfig.OrgName
  11565. pp.FixmedinsCode = miConfig.Code
  11566. pp.RequestUrl = miConfig.Url
  11567. pp.Cainfo = miConfig.Cainfo
  11568. pp.SecretKey = miConfig.SecretKey
  11569. pp.AccessKey = miConfig.AccessKey
  11570. pp.OpterName = roles.UserName
  11571. var config []*models.HisXtDiagnoseConfig
  11572. for _, item := range diagnosis_ids {
  11573. id, _ := strconv.ParseInt(item, 10, 64)
  11574. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11575. config = append(config, &diagnosisConfig)
  11576. }
  11577. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11578. var pd models.PatientDtos
  11579. pd.PatnID = his.PsnNo
  11580. pd.PatnName = his.Name
  11581. pd.Gend = his.Gend
  11582. pd.Brdy = str
  11583. pd.Poolarea = his.InsuplcAdmdvs
  11584. pd.CurrMdtrtID = his.Number
  11585. var fed models.FsiEncounterDtos
  11586. fed.MdtrtID = his.Number
  11587. fed.MedinsID = miConfig.Code
  11588. fed.MedinsName = miConfig.OrgName
  11589. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11590. fed.MedMdtrtType = "1"
  11591. fed.MedinsType = "1"
  11592. fed.MedinsLv = "11"
  11593. tm := time.Unix(his.RecordDate, 0)
  11594. s_tm := tm.Format("2006-01-02 15:04:05")
  11595. fed.AdmDate = s_tm
  11596. fed.DscgDate = s_tm
  11597. fed.DscgMainDiseCodg = config[0].CountryCode
  11598. fed.DscgMainDiseName = config[0].CountryContentName
  11599. //诊断信息
  11600. var fdds []*models.FsiDiagnoseDtos
  11601. for index, item := range config {
  11602. if index == 0 {
  11603. var fdd models.FsiDiagnoseDtos
  11604. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11605. fdd.InoutDiseType = "1"
  11606. fdd.MaindiseFlag = "1"
  11607. fdd.DiseDate = s_tm
  11608. fdd.DiasSrtNo = "1"
  11609. fdd.DiseName = item.CountryContentName
  11610. fdd.DiseCodg = item.CountryCode
  11611. fdds = append(fdds, &fdd)
  11612. } else {
  11613. var fdd models.FsiDiagnoseDtos
  11614. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11615. fdd.InoutDiseType = "1"
  11616. fdd.MaindiseFlag = "1"
  11617. fdd.DiseDate = s_tm
  11618. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11619. fdd.DiseName = item.CountryContentName
  11620. fdd.DiseCodg = item.CountryCode
  11621. fdds = append(fdds, &fdd)
  11622. }
  11623. }
  11624. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11625. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11626. fed.AdmDeptName = department.Name
  11627. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11628. fed.DscgDeptName = department.Name
  11629. fed.MedMdtrtType = "1"
  11630. fed.MedType = "11"
  11631. //if his.Insutype == "390" {
  11632. // fed.MedType = "1402"
  11633. //} else {
  11634. // fed.MedType = "9933"
  11635. //}
  11636. var orders []*models.FsiOrderDtos
  11637. if trig_scen == "2" {
  11638. //处方医嘱信息
  11639. for _, item := range prescriptions {
  11640. for _, subItem := range item.HisDoctorAdviceInfo {
  11641. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11642. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11643. var order models.FsiOrderDtos
  11644. order.RxID = strconv.FormatInt(item.ID, 10)
  11645. order.Rxno = strconv.FormatInt(item.ID, 10)
  11646. order.LongDrordFlag = "0"
  11647. order.HilistType = "1"
  11648. order.ChrgType = "1"
  11649. order.DrordBhvr = "0"
  11650. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11651. order.HosplistName = subItem.BaseDrugLib.DrugName
  11652. order.HilistLv = "1"
  11653. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11654. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11655. order.HosplistName = subItem.BaseDrugLib.DrugName
  11656. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11657. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11658. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11659. order.OwnpayAmt = ""
  11660. order.SelfpayAmt = ""
  11661. order.Spec = spec
  11662. order.SpecUnt = subItem.PrescribingNumberUnit
  11663. order.DrordBegnDate = s_tm
  11664. order.DrordStopDate = ""
  11665. order.DrordDrCodg = doctor_info.DoctorNumber
  11666. order.DrordDeptName = department.Name
  11667. order.DrordDeptCodg = department.Number
  11668. order.DrordDrName = doctor_info.UserName
  11669. order.DrordDrProfttl = "234"
  11670. order.CurrDrordFlag = "1"
  11671. orders = append(orders, &order)
  11672. }
  11673. }
  11674. for _, subItem := range item.HisPrescriptionProject {
  11675. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11676. var order models.FsiOrderDtos
  11677. order.RxID = strconv.FormatInt(item.ID, 10)
  11678. order.Rxno = strconv.FormatInt(item.ID, 10)
  11679. order.LongDrordFlag = "0"
  11680. order.HilistType = "1"
  11681. order.ChrgType = "1"
  11682. order.DrordBhvr = "0"
  11683. order.HilistCode = subItem.HisProject.MedicalCode
  11684. order.HosplistName = subItem.HisProject.ProjectName
  11685. order.HilistLv = "1"
  11686. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11687. order.HosplistCode = subItem.HisProject.MedicalCode
  11688. order.HosplistName = subItem.HisProject.ProjectName
  11689. order.Cnt = subItem.Count
  11690. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11691. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11692. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11693. order.OwnpayAmt = ""
  11694. order.SelfpayAmt = ""
  11695. order.Spec = subItem.Unit
  11696. order.SpecUnt = subItem.Unit
  11697. order.DrordBegnDate = s_tm
  11698. order.DrordStopDate = ""
  11699. order.DrordDrCodg = doctor_info.DoctorNumber
  11700. order.DrordDeptName = department.Name
  11701. order.DrordDeptCodg = department.Number
  11702. order.DrordDrName = doctor_info.UserName
  11703. order.DrordDrProfttl = "234"
  11704. order.CurrDrordFlag = "1"
  11705. orders = append(orders, &order)
  11706. }
  11707. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11708. var order models.FsiOrderDtos
  11709. order.RxID = strconv.FormatInt(item.ID, 10)
  11710. order.Rxno = strconv.FormatInt(item.ID, 10)
  11711. order.LongDrordFlag = "0"
  11712. order.HilistType = "1"
  11713. order.ChrgType = "1"
  11714. order.DrordBhvr = "0"
  11715. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11716. order.HosplistName = subItem.GoodInfo.GoodName
  11717. order.HilistLv = "1"
  11718. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11719. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11720. order.HosplistName = subItem.GoodInfo.GoodName
  11721. order.Cnt = subItem.Count
  11722. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11723. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11724. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11725. order.OwnpayAmt = ""
  11726. order.SelfpayAmt = ""
  11727. order.Spec = subItem.GoodInfo.SpecificationName
  11728. order.SpecUnt = subItem.Unit
  11729. order.DrordBegnDate = s_tm
  11730. order.DrordStopDate = ""
  11731. order.DrordDrCodg = doctor_info.DoctorNumber
  11732. order.DrordDeptName = department.Name
  11733. order.DrordDeptCodg = department.Number
  11734. order.DrordDrName = doctor_info.UserName
  11735. order.DrordDrProfttl = "234"
  11736. order.CurrDrordFlag = "1"
  11737. orders = append(orders, &order)
  11738. }
  11739. }
  11740. }
  11741. //处方医嘱信息
  11742. }
  11743. fed.MatnStas = "0"
  11744. fed.MedfeeSumamt = "0"
  11745. fed.OwnpayAmt = "0"
  11746. fed.SelfpayAmt = "0"
  11747. fed.AcctPayamt = "0"
  11748. fed.MaAmt = "0"
  11749. fed.HifpPayamt = "0"
  11750. fed.SetlTotlnum = "1"
  11751. fed.Insutype = his.Insutype
  11752. fed.ReimFlag = "0"
  11753. fed.OutSetlFlag = "0"
  11754. var fopd []*models.FsiOperationDtosData
  11755. data := make(map[string]interface{})
  11756. data["fed"] = fed
  11757. data["fdd"] = fdds
  11758. data["fod"] = orders
  11759. data["pd"] = pd
  11760. data["pp"] = pp
  11761. data["fopd"] = fopd
  11762. data["trig_scen"] = trig_scen
  11763. fmt.Println(data)
  11764. fmt.Println(fed)
  11765. fmt.Println(fdds)
  11766. fmt.Println(orders)
  11767. fmt.Println(pd)
  11768. fmt.Println(pp)
  11769. fmt.Println(fopd)
  11770. client := &http.Client{}
  11771. bytesData, _ := json.Marshal(data)
  11772. var req *http.Request
  11773. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11774. if miConfig.MdtrtareaAdmvs == "320921" {
  11775. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11776. } else {
  11777. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11778. }
  11779. resp, _ := client.Do(req)
  11780. defer resp.Body.Close()
  11781. body, ioErr := ioutil.ReadAll(resp.Body)
  11782. if ioErr != nil {
  11783. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11785. return res
  11786. }
  11787. var respJSON map[string]interface{}
  11788. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11789. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11791. return res
  11792. }
  11793. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11794. fmt.Println(respJSON)
  11795. result, _ := json.Marshal(respJSON)
  11796. fmt.Println(result)
  11797. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11798. utils.ErrorLog("解析失败:%v", err)
  11799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11800. return res
  11801. }
  11802. return res
  11803. } else {
  11804. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11805. saveLog(output, input, "3101", "事前")
  11806. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11807. utils.ErrorLog("解析失败:%v", err)
  11808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11809. return
  11810. }
  11811. return res
  11812. }
  11813. return res
  11814. }
  11815. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  11816. adminUser := c.GetAdminUserInfo()
  11817. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11818. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11819. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11820. record_time := c.GetString("record_time")
  11821. order, _ := service.GetHisOrderByID(order_id)
  11822. timeLayout := "2006-01-02"
  11823. loc, _ := time.LoadLocation("Local")
  11824. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11825. if err != nil {
  11826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11827. return
  11828. }
  11829. recordDateTime := theTime.Unix()
  11830. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11831. var patientPrescription models.HisPrescriptionInfo
  11832. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11833. if patientPrescription.ID == 0 {
  11834. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11835. }
  11836. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11837. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11838. //
  11839. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11840. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11841. var pp models.PublicParams
  11842. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11843. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11844. pp.FixmedinsName = miConfig.OrgName
  11845. pp.FixmedinsCode = miConfig.Code
  11846. pp.RequestUrl = miConfig.Url
  11847. pp.Cainfo = miConfig.Cainfo
  11848. pp.SecretKey = miConfig.SecretKey
  11849. pp.AccessKey = miConfig.AccessKey
  11850. pp.OpterName = roles.UserName
  11851. var config []*models.HisXtDiagnoseConfig
  11852. for _, item := range diagnosis_ids {
  11853. id, _ := strconv.ParseInt(item, 10, 64)
  11854. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11855. config = append(config, &diagnosisConfig)
  11856. }
  11857. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11858. var pd models.PatientDtos
  11859. pd.PatnID = his.PsnNo
  11860. pd.PatnName = his.Name
  11861. pd.Gend = his.Gend
  11862. pd.Brdy = str
  11863. pd.Poolarea = his.InsuplcAdmdvs
  11864. pd.CurrMdtrtID = his.Number
  11865. var fed models.FsiEncounterDtos
  11866. fed.MdtrtID = his.Number
  11867. fed.MedinsID = miConfig.Code
  11868. fed.MedinsName = miConfig.OrgName
  11869. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11870. fed.MedMdtrtType = "1"
  11871. fed.MedinsType = "1"
  11872. fed.MedinsLv = "11"
  11873. tm := time.Unix(his.RecordDate, 0)
  11874. s_tm := tm.Format("2006-01-02 15:04:05")
  11875. fed.AdmDate = s_tm
  11876. fed.DscgDate = s_tm
  11877. fed.DscgMainDiseCodg = config[0].CountryCode
  11878. fed.DscgMainDiseName = config[0].CountryContentName
  11879. //诊断信息
  11880. var fdds []*models.FsiDiagnoseDtos
  11881. for index, item := range config {
  11882. if index == 0 {
  11883. var fdd models.FsiDiagnoseDtos
  11884. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11885. fdd.InoutDiseType = "1"
  11886. fdd.MaindiseFlag = "1"
  11887. fdd.DiseDate = s_tm
  11888. fdd.DiasSrtNo = "1"
  11889. fdd.DiseName = item.CountryContentName
  11890. fdd.DiseCodg = item.CountryCode
  11891. fdds = append(fdds, &fdd)
  11892. } else {
  11893. var fdd models.FsiDiagnoseDtos
  11894. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11895. fdd.InoutDiseType = "1"
  11896. fdd.MaindiseFlag = "1"
  11897. fdd.DiseDate = s_tm
  11898. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11899. fdd.DiseName = item.CountryContentName
  11900. fdd.DiseCodg = item.CountryCode
  11901. fdds = append(fdds, &fdd)
  11902. }
  11903. }
  11904. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11905. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11906. fed.AdmDeptName = department.Name
  11907. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11908. fed.DscgDeptName = department.Name
  11909. fed.MedType = order.MedType
  11910. //处方医嘱信息
  11911. var orders []*models.FsiOrderDtos
  11912. //for _, item := range prescriptions {
  11913. // for _, subItem := range item.HisDoctorAdviceInfo {
  11914. // var order models.FsiOrderDtos
  11915. // order.RxID = strconv.FormatInt(item.ID, 10)
  11916. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11917. // order.LongDrordFlag = "0"
  11918. // order.HilistType = "1"
  11919. // order.ChrgType = "1"
  11920. // order.DrordBhvr = "-"
  11921. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11922. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11923. // order.HilistLv = "1"
  11924. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11925. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11926. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11927. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11928. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11929. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11930. // order.OwnpayAmt = ""
  11931. // order.SelfpayAmt = ""
  11932. // order.Spec = ""
  11933. // order.SpecUnt = ""
  11934. // order.DrordBegnDate = s_tm
  11935. // order.DrordStopDate = ""
  11936. // order.DrordDrCodg = "1"
  11937. // order.DrordDeptName = department.Name
  11938. // order.DrordDrCodg = "1"
  11939. // order.DrordDrName = doctor_info.UserName
  11940. // order.DrordDrProfttl = ""
  11941. // order.CurrDrordFlag = "1"
  11942. // orders = append(orders, &order)
  11943. // }
  11944. // for _, subItem := range item.HisPrescriptionProject {
  11945. // if subItem.Type == 2 {
  11946. // var order models.FsiOrderDtos
  11947. // order.RxID = strconv.FormatInt(item.ID, 10)
  11948. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11949. // order.LongDrordFlag = "0"
  11950. // order.HilistType = "1"
  11951. // order.ChrgType = "1"
  11952. // order.DrordBhvr = "-"
  11953. // order.HilistCode = subItem.HisProject.MedicalCode
  11954. // order.HosplistName = subItem.HisProject.ProjectName
  11955. // order.HilistLv = "1"
  11956. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11957. // order.HosplistCode = subItem.HisProject.MedicalCode
  11958. // order.HosplistName = subItem.HisProject.ProjectName
  11959. // order.Cnt = subItem.Count
  11960. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11961. //
  11962. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11963. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11964. // order.OwnpayAmt = ""
  11965. // order.SelfpayAmt = ""
  11966. // order.Spec = ""
  11967. // order.SpecUnt = ""
  11968. // order.DrordBegnDate = s_tm
  11969. // order.DrordStopDate = ""
  11970. // order.DrordDrCodg = "1"
  11971. // order.DrordDeptName = department.Name
  11972. // order.DrordDrCodg = "1"
  11973. // order.DrordDrName = doctor_info.UserName
  11974. // order.DrordDrProfttl = ""
  11975. // order.CurrDrordFlag = "1"
  11976. // orders = append(orders, &order)
  11977. //
  11978. // }
  11979. // if subItem.Type == 3 {
  11980. //
  11981. // var order models.FsiOrderDtos
  11982. // order.RxID = strconv.FormatInt(item.ID, 10)
  11983. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11984. // order.LongDrordFlag = "0"
  11985. // order.HilistType = "1"
  11986. // order.ChrgType = "1"
  11987. // order.DrordBhvr = "-"
  11988. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11989. // order.HosplistName = subItem.GoodInfo.GoodName
  11990. // order.HilistLv = "1"
  11991. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11992. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11993. // order.HosplistName = subItem.GoodInfo.GoodName
  11994. // order.Cnt = subItem.Count
  11995. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11996. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11997. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11998. // order.OwnpayAmt = ""
  11999. // order.SelfpayAmt = ""
  12000. // order.Spec = ""
  12001. // order.SpecUnt = ""
  12002. // order.DrordBegnDate = s_tm
  12003. // order.DrordStopDate = ""
  12004. // order.DrordDrCodg = "1"
  12005. // order.DrordDeptName = department.Name
  12006. // order.DrordDrCodg = "1"
  12007. // order.DrordDrName = doctor_info.UserName
  12008. // order.DrordDrProfttl = ""
  12009. // order.CurrDrordFlag = "1"
  12010. // orders = append(orders, &order)
  12011. //
  12012. // }
  12013. // }
  12014. //}
  12015. for _, item := range prescriptions {
  12016. for _, subItem := range item.HisDoctorAdviceInfo {
  12017. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12018. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12019. var order models.FsiOrderDtos
  12020. order.RxID = strconv.FormatInt(item.ID, 10)
  12021. order.Rxno = strconv.FormatInt(item.ID, 10)
  12022. order.LongDrordFlag = "0"
  12023. order.HilistType = "1"
  12024. order.ChrgType = "1"
  12025. order.DrordBhvr = "0"
  12026. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12027. order.HosplistName = subItem.BaseDrugLib.DrugName
  12028. order.HilistLv = "1"
  12029. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12030. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12031. order.HosplistName = subItem.BaseDrugLib.DrugName
  12032. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12033. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12034. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12035. order.OwnpayAmt = ""
  12036. order.SelfpayAmt = ""
  12037. order.Spec = spec
  12038. order.SpecUnt = subItem.PrescribingNumberUnit
  12039. order.DrordBegnDate = s_tm
  12040. order.DrordStopDate = ""
  12041. order.DrordDrCodg = doctor_info.DoctorNumber
  12042. order.DrordDeptName = department.Name
  12043. order.DrordDeptCodg = department.Number
  12044. order.DrordDrName = doctor_info.UserName
  12045. order.DrordDrProfttl = "234"
  12046. order.CurrDrordFlag = "1"
  12047. orders = append(orders, &order)
  12048. }
  12049. }
  12050. for _, subItem := range item.HisPrescriptionProject {
  12051. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12052. var order models.FsiOrderDtos
  12053. order.RxID = strconv.FormatInt(item.ID, 10)
  12054. order.Rxno = strconv.FormatInt(item.ID, 10)
  12055. order.LongDrordFlag = "0"
  12056. order.HilistType = "1"
  12057. order.ChrgType = "1"
  12058. order.DrordBhvr = "0"
  12059. order.HilistCode = subItem.HisProject.MedicalCode
  12060. order.HosplistName = subItem.HisProject.ProjectName
  12061. order.HilistLv = "1"
  12062. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12063. order.HosplistCode = subItem.HisProject.MedicalCode
  12064. order.HosplistName = subItem.HisProject.ProjectName
  12065. order.Cnt = subItem.Count
  12066. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12067. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12068. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12069. order.OwnpayAmt = ""
  12070. order.SelfpayAmt = ""
  12071. order.Spec = subItem.Unit
  12072. order.SpecUnt = subItem.Unit
  12073. order.DrordBegnDate = s_tm
  12074. order.DrordStopDate = ""
  12075. order.DrordDrCodg = doctor_info.DoctorNumber
  12076. order.DrordDeptName = department.Name
  12077. order.DrordDeptCodg = department.Number
  12078. order.DrordDrName = doctor_info.UserName
  12079. order.DrordDrProfttl = "234"
  12080. order.CurrDrordFlag = "1"
  12081. orders = append(orders, &order)
  12082. }
  12083. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12084. var order models.FsiOrderDtos
  12085. order.RxID = strconv.FormatInt(item.ID, 10)
  12086. order.Rxno = strconv.FormatInt(item.ID, 10)
  12087. order.LongDrordFlag = "0"
  12088. order.HilistType = "1"
  12089. order.ChrgType = "1"
  12090. order.DrordBhvr = "0"
  12091. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12092. order.HosplistName = subItem.GoodInfo.GoodName
  12093. order.HilistLv = "1"
  12094. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12095. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12096. order.HosplistName = subItem.GoodInfo.GoodName
  12097. order.Cnt = subItem.Count
  12098. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12099. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12100. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12101. order.OwnpayAmt = ""
  12102. order.SelfpayAmt = ""
  12103. order.Spec = subItem.GoodInfo.SpecificationName
  12104. order.SpecUnt = subItem.Unit
  12105. order.DrordBegnDate = s_tm
  12106. order.DrordStopDate = ""
  12107. order.DrordDrCodg = doctor_info.DoctorNumber
  12108. order.DrordDeptName = department.Name
  12109. order.DrordDeptCodg = department.Number
  12110. order.DrordDrName = doctor_info.UserName
  12111. order.DrordDrProfttl = "234"
  12112. order.CurrDrordFlag = "1"
  12113. orders = append(orders, &order)
  12114. }
  12115. }
  12116. }
  12117. //处方医嘱信息
  12118. fed.MatnStas = "0"
  12119. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  12120. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  12121. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  12122. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  12123. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  12124. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  12125. fed.SetlTotlnum = "1"
  12126. fed.Insutype = his.Insutype
  12127. fed.ReimFlag = "0"
  12128. fed.OutSetlFlag = "0"
  12129. var fopd []*models.FsiOperationDtosData
  12130. data := make(map[string]interface{})
  12131. data["fed"] = fed
  12132. data["fdd"] = fdds
  12133. data["fod"] = orders
  12134. data["pd"] = pd
  12135. data["pp"] = pp
  12136. data["fopd"] = fopd
  12137. data["trig_scen"] = trig_scen
  12138. client := &http.Client{}
  12139. bytesData, _ := json.Marshal(data)
  12140. var req *http.Request
  12141. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12142. if miConfig.MdtrtareaAdmvs == "320921" {
  12143. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12144. } else {
  12145. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12146. }
  12147. resp, _ := client.Do(req)
  12148. defer resp.Body.Close()
  12149. body, ioErr := ioutil.ReadAll(resp.Body)
  12150. if ioErr != nil {
  12151. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12153. return res
  12154. }
  12155. var respJSON map[string]interface{}
  12156. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12159. return res
  12160. }
  12161. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12162. result, _ := json.Marshal(respJSON)
  12163. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12164. utils.ErrorLog("解析失败:%v", err)
  12165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12166. return res
  12167. }
  12168. return res
  12169. } else {
  12170. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12171. saveLog(output, input, "3102", "事中")
  12172. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12173. utils.ErrorLog("解析失败:%v", err)
  12174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12175. return
  12176. }
  12177. return res
  12178. }
  12179. return res
  12180. }
  12181. func (c *HisApiController) Check() {
  12182. psn_no := c.GetString("psn_no")
  12183. in := c.GetString("in")
  12184. mt := c.GetString("mt")
  12185. baseParams := models.BaseParams{
  12186. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  12187. FixmedinsCode: "H15049901371",
  12188. InsuplcAdmdvs: "150499",
  12189. MdtrtareaAdmvs: "150499",
  12190. OrgName: "赤峰费森血液透析中心",
  12191. Doctor: "1111",
  12192. }
  12193. service.Gdyb2001(baseParams, psn_no, in, mt)
  12194. }
  12195. func (c *HisApiController) GetPsnNcdsInfo() {
  12196. admin_user_id, _ := c.GetInt64("admin_user_id")
  12197. patient_id, _ := c.GetInt64("patient_id")
  12198. //id, _ := c.GetInt64("id")
  12199. adminUser := c.GetAdminUserInfo()
  12200. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12201. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12202. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  12203. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12204. //psn_record, _ := service.GetP(id)
  12205. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12206. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  12207. //
  12208. //if psn_record.ID == 0 {
  12209. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12210. // return
  12211. //}
  12212. var res Result5301
  12213. var res10265 Result5301For10265
  12214. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12215. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12216. var api string
  12217. if miConfig.MdtrtareaAdmvs == "320921" {
  12218. 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 +
  12219. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12220. } else {
  12221. 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 +
  12222. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12223. }
  12224. resp, requestErr := http.Get(api)
  12225. if requestErr != nil {
  12226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12227. return
  12228. }
  12229. body, ioErr := ioutil.ReadAll(resp.Body)
  12230. if ioErr != nil {
  12231. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12233. return
  12234. }
  12235. var respJSON map[string]interface{}
  12236. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12237. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12239. return
  12240. }
  12241. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12242. result, _ := json.Marshal(respJSON)
  12243. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12244. utils.ErrorLog("解析失败:%v", err)
  12245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12246. return
  12247. }
  12248. res.ErrMsg = res10265.ErrMsg
  12249. res.Output = res10265.Output
  12250. res.InfRefmsgid = res10265.InfRefmsgid
  12251. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12252. res.Infcode = infocode
  12253. } else if miConfig.MdtrtareaAdmvs == "341203" {
  12254. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12255. var api string
  12256. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12257. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12258. resp, requestErr := http.Get(api)
  12259. if requestErr != nil {
  12260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12261. return
  12262. }
  12263. body, ioErr := ioutil.ReadAll(resp.Body)
  12264. if ioErr != nil {
  12265. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12267. return
  12268. }
  12269. var respJSON map[string]interface{}
  12270. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12273. return
  12274. }
  12275. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12276. if status == "0" {
  12277. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12278. c.ServeSuccessJSON(map[string]interface{}{
  12279. "failed_code": -10,
  12280. "msg": err_msg,
  12281. })
  12282. return
  12283. }
  12284. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12285. result, _ := json.Marshal(respJSON)
  12286. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12287. utils.ErrorLog("解析失败:%v", err)
  12288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12289. return
  12290. }
  12291. } else if miConfig.MdtrtareaAdmvs == "340699" {
  12292. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  12293. var api string
  12294. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12295. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12296. resp, requestErr := http.Get(api)
  12297. if requestErr != nil {
  12298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12299. return
  12300. }
  12301. body, ioErr := ioutil.ReadAll(resp.Body)
  12302. if ioErr != nil {
  12303. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12305. return
  12306. }
  12307. var respJSON map[string]interface{}
  12308. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12309. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12311. return
  12312. }
  12313. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12314. if status == "0" {
  12315. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12316. c.ServeSuccessJSON(map[string]interface{}{
  12317. "failed_code": -10,
  12318. "msg": err_msg,
  12319. })
  12320. return
  12321. }
  12322. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12323. result, _ := json.Marshal(respJSON)
  12324. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12325. utils.ErrorLog("解析失败:%v", err)
  12326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12327. return
  12328. }
  12329. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12330. p, _ := service.GetHisPatientById(patient_id)
  12331. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12332. var dat map[string]interface{}
  12333. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12334. fmt.Println(dat)
  12335. } else {
  12336. fmt.Println(err)
  12337. }
  12338. userJSONBytes, _ := json.Marshal(dat)
  12339. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12340. utils.ErrorLog("解析失败:%v", err)
  12341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12342. return
  12343. }
  12344. } else if miConfig.MdtrtareaAdmvs == "361025" {
  12345. p, _ := service.GetHisPatientById(patient_id)
  12346. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12347. var dat map[string]interface{}
  12348. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12349. fmt.Println(dat)
  12350. } else {
  12351. fmt.Println(err)
  12352. }
  12353. userJSONBytes, _ := json.Marshal(dat)
  12354. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12355. utils.ErrorLog("解析失败:%v", err)
  12356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12357. return
  12358. }
  12359. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12360. p, _ := service.GetHisPatientById(patient_id)
  12361. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12362. var dat map[string]interface{}
  12363. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12364. fmt.Println(dat)
  12365. } else {
  12366. fmt.Println(err)
  12367. }
  12368. userJSONBytes, _ := json.Marshal(dat)
  12369. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12370. utils.ErrorLog("解析失败:%v", err)
  12371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12372. return
  12373. }
  12374. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12375. p, _ := service.GetHisPatientById(patient_id)
  12376. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12377. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12378. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12379. resp, requestErr := http.Get(api)
  12380. if requestErr != nil {
  12381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12382. return
  12383. }
  12384. body, ioErr := ioutil.ReadAll(resp.Body)
  12385. if ioErr != nil {
  12386. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12388. return
  12389. }
  12390. var respJSON map[string]interface{}
  12391. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12392. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12394. return
  12395. }
  12396. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12397. result, _ := json.Marshal(respJSON)
  12398. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12399. utils.ErrorLog("解析失败:%v", err)
  12400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12401. return
  12402. }
  12403. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12404. p, _ := service.GetHisPatientById(patient_id)
  12405. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  12406. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12407. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12408. resp, requestErr := http.Get(api)
  12409. if requestErr != nil {
  12410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12411. return
  12412. }
  12413. body, ioErr := ioutil.ReadAll(resp.Body)
  12414. if ioErr != nil {
  12415. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12417. return
  12418. }
  12419. var respJSON map[string]interface{}
  12420. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12421. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12423. return
  12424. }
  12425. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12426. result, _ := json.Marshal(respJSON)
  12427. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12428. utils.ErrorLog("解析失败:%v", err)
  12429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12430. return
  12431. }
  12432. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12433. p, _ := service.GetHisPatientById(patient_id)
  12434. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12435. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12436. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12437. resp, requestErr := http.Get(api)
  12438. if requestErr != nil {
  12439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12440. return
  12441. }
  12442. body, ioErr := ioutil.ReadAll(resp.Body)
  12443. if ioErr != nil {
  12444. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12446. return
  12447. }
  12448. var respJSON map[string]interface{}
  12449. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12450. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12452. return
  12453. }
  12454. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12455. result, _ := json.Marshal(respJSON)
  12456. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12457. utils.ErrorLog("解析失败:%v", err)
  12458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12459. return
  12460. }
  12461. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12462. p, _ := service.GetHisPatientById(patient_id)
  12463. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12464. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12465. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12466. resp, requestErr := http.Get(api)
  12467. if requestErr != nil {
  12468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12469. return
  12470. }
  12471. body, ioErr := ioutil.ReadAll(resp.Body)
  12472. if ioErr != nil {
  12473. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12475. return
  12476. }
  12477. var respJSON map[string]interface{}
  12478. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12479. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12481. return
  12482. }
  12483. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12484. result, _ := json.Marshal(respJSON)
  12485. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12486. utils.ErrorLog("解析失败:%v", err)
  12487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12488. return
  12489. }
  12490. } else if miConfig.MdtrtareaAdmvs == "421300" {
  12491. p, _ := service.GetHisPatientById(patient_id)
  12492. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12493. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12494. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12495. resp, requestErr := http.Get(api)
  12496. if requestErr != nil {
  12497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12498. return
  12499. }
  12500. body, ioErr := ioutil.ReadAll(resp.Body)
  12501. if ioErr != nil {
  12502. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12504. return
  12505. }
  12506. var respJSON map[string]interface{}
  12507. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12508. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12510. return
  12511. }
  12512. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12513. result, _ := json.Marshal(respJSON)
  12514. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12515. utils.ErrorLog("解析失败:%v", err)
  12516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12517. return
  12518. }
  12519. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12520. p, _ := service.GetHisPatientById(patient_id)
  12521. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  12522. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12523. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12524. resp, requestErr := http.Get(api)
  12525. if requestErr != nil {
  12526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12527. return
  12528. }
  12529. body, ioErr := ioutil.ReadAll(resp.Body)
  12530. if ioErr != nil {
  12531. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12533. return
  12534. }
  12535. var respJSON map[string]interface{}
  12536. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12539. return
  12540. }
  12541. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12542. result, _ := json.Marshal(respJSON)
  12543. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12544. utils.ErrorLog("解析失败:%v", err)
  12545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12546. return
  12547. }
  12548. } else {
  12549. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  12550. var dat map[string]interface{}
  12551. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12552. fmt.Println(dat)
  12553. } else {
  12554. fmt.Println(err)
  12555. }
  12556. userJSONBytes, _ := json.Marshal(dat)
  12557. if miConfig.Code == "H15049901371" {
  12558. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12559. utils.ErrorLog("解析失败:%v", err)
  12560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12561. return
  12562. }
  12563. res.InfRefmsgid = res10265.InfRefmsgid
  12564. res.Output = res10265.Output
  12565. res.ErrMsg = res10265.ErrMsg
  12566. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12567. res.Infcode = infocode
  12568. } else {
  12569. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12570. utils.ErrorLog("解析失败:%v", err)
  12571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12572. return
  12573. }
  12574. }
  12575. }
  12576. if res.Infcode == 0 {
  12577. c.ServeSuccessJSON(map[string]interface{}{
  12578. "result": res.Output.Result,
  12579. })
  12580. }
  12581. }
  12582. func (c *HisApiController) CheckInsutype() {
  12583. his_patient_id, _ := c.GetInt64("his_patient_id")
  12584. admin_user_id, _ := c.GetInt64("admin_user_id")
  12585. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12586. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12587. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12588. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  12589. var dat map[string]interface{}
  12590. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12591. fmt.Println(dat)
  12592. } else {
  12593. fmt.Println(err)
  12594. }
  12595. userJSONBytes, _ := json.Marshal(dat)
  12596. var res Result90100
  12597. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12598. utils.ErrorLog("解析失败:%v", err)
  12599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12600. return
  12601. }
  12602. if res.Infcode != 0 {
  12603. c.ServeSuccessJSON(map[string]interface{}{
  12604. "failed_code": -10,
  12605. "msg": res.ErrMsg,
  12606. })
  12607. return
  12608. } else {
  12609. fmt.Println(res)
  12610. }
  12611. }
  12612. func (c *HisApiController) CheckCardPWD() {
  12613. card_pwd := c.GetString("card_pwd")
  12614. his_patient_id, _ := c.GetInt64("his_patient_id")
  12615. admin_user_id, _ := c.GetInt64("admin_user_id")
  12616. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12617. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12618. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12619. psn, _ := service.GetPsnByPatientId(his.PatientId)
  12620. bas := strings.Split(psn.CardInfo, "|")
  12621. basNumber := bas[2]
  12622. if psn.InsuplcAdmdvs[:4] == "4403" {
  12623. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  12624. var dat map[string]interface{}
  12625. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12626. fmt.Println(dat)
  12627. } else {
  12628. fmt.Println(err)
  12629. }
  12630. userJSONBytes, _ := json.Marshal(dat)
  12631. var res Result90991
  12632. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12633. utils.ErrorLog("解析失败:%v", err)
  12634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12635. return
  12636. }
  12637. if res.Infcode != 0 {
  12638. c.ServeSuccessJSON(map[string]interface{}{
  12639. "failed_code": -10,
  12640. "msg": res.ErrMsg,
  12641. })
  12642. return
  12643. } else {
  12644. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  12645. var msg string
  12646. switch res.Output.Result.CardStat {
  12647. case "00":
  12648. msg = "未激活"
  12649. break
  12650. case "10":
  12651. msg = "激活"
  12652. break
  12653. case "20":
  12654. msg = "窗口挂失"
  12655. break
  12656. case "21":
  12657. msg = "电话挂失"
  12658. break
  12659. case "22":
  12660. msg = "单位网上申报挂失"
  12661. break
  12662. case "23":
  12663. msg = "保健办挂失"
  12664. break
  12665. case "24":
  12666. msg = "个人网上挂失"
  12667. break
  12668. case "25":
  12669. msg = "网上服务大厅挂失"
  12670. break
  12671. case "30":
  12672. msg = "注销"
  12673. break
  12674. case "40":
  12675. msg = "回收"
  12676. break
  12677. case "99":
  12678. msg = "制卡中(无效卡)"
  12679. break
  12680. }
  12681. c.ServeSuccessJSON(map[string]interface{}{
  12682. "failed_code": -10,
  12683. "msg": msg,
  12684. })
  12685. return
  12686. } else {
  12687. c.ServeSuccessJSON(map[string]interface{}{
  12688. "msg": "校验成功",
  12689. })
  12690. return
  12691. }
  12692. }
  12693. } else {
  12694. c.ServeSuccessJSON(map[string]interface{}{
  12695. "msg": "校验成功",
  12696. })
  12697. return
  12698. }
  12699. }
  12700. func (c *HisApiController) CheckCardPWDTwo() {
  12701. //card_pwd := c.GetString("card_pwd")
  12702. //his_patient_id, _ := c.GetInt64("his_patient_id")
  12703. admin_user_id, _ := c.GetInt64("admin_user_id")
  12704. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12705. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12706. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  12707. var dat map[string]interface{}
  12708. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12709. fmt.Println(dat)
  12710. } else {
  12711. fmt.Println(err)
  12712. }
  12713. userJSONBytes, _ := json.Marshal(dat)
  12714. var res Result90991
  12715. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12716. utils.ErrorLog("解析失败:%v", err)
  12717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12718. return
  12719. }
  12720. if res.Infcode != 0 {
  12721. c.ServeSuccessJSON(map[string]interface{}{
  12722. "failed_code": -10,
  12723. "msg": res.ErrMsg,
  12724. })
  12725. return
  12726. } else {
  12727. if res.Output.Result.SscnoCheckStat == "0" {
  12728. var msg string
  12729. switch res.Output.Result.CardStat {
  12730. case "00":
  12731. msg = "未激活"
  12732. break
  12733. case "10":
  12734. msg = "激活"
  12735. break
  12736. case "20":
  12737. msg = "窗口挂失"
  12738. break
  12739. case "21":
  12740. msg = "电话挂失"
  12741. break
  12742. case "22":
  12743. msg = "单位网上申报挂失"
  12744. break
  12745. case "23":
  12746. msg = "保健办挂失"
  12747. break
  12748. case "24":
  12749. msg = "个人网上挂失"
  12750. break
  12751. case "25":
  12752. msg = "网上服务大厅挂失"
  12753. break
  12754. case "30":
  12755. msg = "注销"
  12756. break
  12757. case "40":
  12758. msg = "回收"
  12759. break
  12760. case "99":
  12761. msg = "制卡中(无效卡)"
  12762. break
  12763. }
  12764. c.ServeSuccessJSON(map[string]interface{}{
  12765. "failed_code": -10,
  12766. "msg": msg,
  12767. })
  12768. return
  12769. } else {
  12770. c.ServeSuccessJSON(map[string]interface{}{
  12771. "msg": "校验成功",
  12772. })
  12773. return
  12774. }
  12775. }
  12776. }
  12777. type ELeCertData struct {
  12778. Data struct {
  12779. Extra string `json:"extra"`
  12780. IDNo string `json:"idNo"`
  12781. IDType string `json:"idType"`
  12782. EcToken string `json:"ecToken"`
  12783. InsuOrg string `json:"insuOrg"`
  12784. UserName string `json:"userName"`
  12785. EcIndexNo string `json:"ecIndexNo"`
  12786. Gender string `json:"gender"`
  12787. Birthday string `json:"birthday"`
  12788. Nationality string `json:"nationality"`
  12789. Email string `json:"email"`
  12790. } `json:"OutData"`
  12791. }
  12792. func (c *HisApiController) ReadCard() {
  12793. id_card_type, _ := c.GetInt64("id_card_type")
  12794. admin_user_id, _ := c.GetInt64("admin_user_id")
  12795. certificates, _ := c.GetInt64("certificates")
  12796. //
  12797. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  12798. id_card_no := c.GetString("id_card_no")
  12799. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12800. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12801. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12802. switch id_card_type {
  12803. case 1:
  12804. if miConfig.MdtrtareaAdmvs == "421300" {
  12805. var res ResultTwo
  12806. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12807. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12808. "&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)
  12809. resp, requestErr := http.Get(api)
  12810. if requestErr != nil {
  12811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12812. return
  12813. }
  12814. body, ioErr := ioutil.ReadAll(resp.Body)
  12815. if ioErr != nil {
  12816. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12818. return
  12819. }
  12820. var respJSON map[string]interface{}
  12821. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12822. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12824. return
  12825. }
  12826. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12827. result, _ := json.Marshal(respJSON)
  12828. fmt.Println("log")
  12829. fmt.Println(string(result))
  12830. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12831. utils.ErrorLog("解析失败:%v", err)
  12832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12833. return
  12834. }
  12835. if res.Infcode == 0 {
  12836. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12837. if err == gorm.ErrRecordNotFound {
  12838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12839. return
  12840. } else if err != nil {
  12841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12842. return
  12843. } else {
  12844. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12845. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12846. infoStr := string(Iinfos)
  12847. idetinfoStr := string(Idetinfos)
  12848. var rf []*ResultFive
  12849. json.Unmarshal([]byte(infoStr), &rf)
  12850. var insutypes []*ResultFive
  12851. var insutype string
  12852. var is390 int = 0
  12853. var is310 int = 0
  12854. for _, item := range rf {
  12855. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12856. insutypes = append(insutypes, item)
  12857. }
  12858. }
  12859. if len(insutypes) == 1 {
  12860. insutype = insutypes[0].Insutype
  12861. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12862. } else {
  12863. for _, i := range insutypes {
  12864. if i.Insutype == "390" {
  12865. is390 = 1
  12866. }
  12867. if i.Insutype == "310" {
  12868. is310 = 1
  12869. }
  12870. }
  12871. }
  12872. if is390 == 1 {
  12873. insutype = "390"
  12874. }
  12875. if is310 == 1 {
  12876. insutype = "310"
  12877. }
  12878. if len(insutypes) == 0 {
  12879. insutype = "390"
  12880. }
  12881. var insuplc_admdvs string
  12882. for _, item := range rf {
  12883. if item.Insutype == insutype {
  12884. insuplc_admdvs = item.InsuplcAdmdvs
  12885. }
  12886. }
  12887. if strings.Contains(insuplc_admdvs, "4213") {
  12888. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  12889. }
  12890. psn := &models.HisPsn{
  12891. PsnNo: res.Output.Baseinfo.PsnNo,
  12892. PatientId: patient.ID,
  12893. Certno: res.Output.Baseinfo.Certno,
  12894. Gend: res.Output.Baseinfo.Gend,
  12895. Naty: res.Output.Baseinfo.Naty,
  12896. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12897. PsnName: res.Output.Baseinfo.PsnName,
  12898. Idetinfo: idetinfoStr,
  12899. Insuinfo: infoStr,
  12900. InsuplcAdmdvs: insuplc_admdvs,
  12901. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12902. }
  12903. service.CreateHisPsn(psn)
  12904. c.ServeSuccessJSON(map[string]interface{}{
  12905. "patient": patient,
  12906. "number": res.Output.Baseinfo.Certno,
  12907. })
  12908. }
  12909. } else {
  12910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12911. return
  12912. }
  12913. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12914. var res ResultTwo
  12915. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  12916. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12917. "&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)
  12918. resp, requestErr := http.Get(api)
  12919. if requestErr != nil {
  12920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12921. return
  12922. }
  12923. body, ioErr := ioutil.ReadAll(resp.Body)
  12924. if ioErr != nil {
  12925. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12927. return
  12928. }
  12929. var respJSON map[string]interface{}
  12930. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12931. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12933. return
  12934. }
  12935. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12936. result, _ := json.Marshal(respJSON)
  12937. fmt.Println("log")
  12938. fmt.Println(string(result))
  12939. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12940. utils.ErrorLog("解析失败:%v", err)
  12941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12942. return
  12943. }
  12944. if res.Infcode == 0 {
  12945. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12946. if err == gorm.ErrRecordNotFound {
  12947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12948. return
  12949. } else if err != nil {
  12950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12951. return
  12952. } else {
  12953. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12954. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12955. infoStr := string(Iinfos)
  12956. idetinfoStr := string(Idetinfos)
  12957. psn := &models.HisPsn{
  12958. PsnNo: res.Output.Baseinfo.PsnNo,
  12959. PatientId: patient.ID,
  12960. Certno: res.Output.Baseinfo.Certno,
  12961. Gend: res.Output.Baseinfo.Gend,
  12962. Naty: res.Output.Baseinfo.Naty,
  12963. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12964. PsnName: res.Output.Baseinfo.PsnName,
  12965. Idetinfo: idetinfoStr,
  12966. Insuinfo: infoStr,
  12967. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12968. }
  12969. service.CreateHisPsn(psn)
  12970. var rf []*ResultFive
  12971. json.Unmarshal([]byte(infoStr), &rf)
  12972. var insutypes []*ResultFive
  12973. var insutype string
  12974. var is390 int = 0
  12975. var is310 int = 0
  12976. for _, item := range rf {
  12977. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12978. insutypes = append(insutypes, item)
  12979. }
  12980. }
  12981. if len(insutypes) == 1 {
  12982. insutype = insutypes[0].Insutype
  12983. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12984. } else {
  12985. for _, i := range insutypes {
  12986. if i.Insutype == "390" {
  12987. is390 = 1
  12988. }
  12989. if i.Insutype == "310" {
  12990. is310 = 1
  12991. }
  12992. }
  12993. }
  12994. if is390 == 1 {
  12995. insutype = "390"
  12996. }
  12997. if is310 == 1 {
  12998. insutype = "310"
  12999. }
  13000. if len(insutypes) == 0 {
  13001. insutype = "310"
  13002. }
  13003. c.ServeSuccessJSON(map[string]interface{}{
  13004. "patient": patient,
  13005. "number": res.Output.Baseinfo.Certno,
  13006. "insutype": insutype,
  13007. })
  13008. }
  13009. } else {
  13010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13011. return
  13012. }
  13013. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13014. var res ResultTwo
  13015. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13016. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13017. "&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)
  13018. resp, requestErr := http.Get(api)
  13019. if requestErr != nil {
  13020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13021. return
  13022. }
  13023. body, ioErr := ioutil.ReadAll(resp.Body)
  13024. if ioErr != nil {
  13025. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13027. return
  13028. }
  13029. var respJSON map[string]interface{}
  13030. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13031. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13033. return
  13034. }
  13035. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13036. result, _ := json.Marshal(respJSON)
  13037. fmt.Println("log")
  13038. fmt.Println(string(result))
  13039. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13040. utils.ErrorLog("解析失败:%v", err)
  13041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13042. return
  13043. }
  13044. if res.Infcode == 0 {
  13045. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13046. if err == gorm.ErrRecordNotFound {
  13047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13048. return
  13049. } else if err != nil {
  13050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13051. return
  13052. } else {
  13053. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13054. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13055. infoStr := string(Iinfos)
  13056. idetinfoStr := string(Idetinfos)
  13057. var rf []*ResultFive
  13058. json.Unmarshal([]byte(infoStr), &rf)
  13059. var insutypes []*ResultFive
  13060. var insutype string
  13061. var is390 int = 0
  13062. var is310 int = 0
  13063. for _, item := range rf {
  13064. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13065. insutypes = append(insutypes, item)
  13066. }
  13067. }
  13068. if len(insutypes) == 1 {
  13069. insutype = insutypes[0].Insutype
  13070. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13071. } else {
  13072. for _, i := range insutypes {
  13073. if i.Insutype == "390" {
  13074. is390 = 1
  13075. }
  13076. if i.Insutype == "310" {
  13077. is310 = 1
  13078. }
  13079. }
  13080. }
  13081. if is390 == 1 {
  13082. insutype = "390"
  13083. }
  13084. if is310 == 1 {
  13085. insutype = "310"
  13086. }
  13087. if len(insutypes) == 0 {
  13088. insutype = "390"
  13089. }
  13090. var insuplc_admdvs string
  13091. for _, item := range rf {
  13092. if item.Insutype == insutype {
  13093. insuplc_admdvs = item.InsuplcAdmdvs
  13094. }
  13095. }
  13096. psn := &models.HisPsn{
  13097. PsnNo: res.Output.Baseinfo.PsnNo,
  13098. PatientId: patient.ID,
  13099. Certno: res.Output.Baseinfo.Certno,
  13100. Gend: res.Output.Baseinfo.Gend,
  13101. Naty: res.Output.Baseinfo.Naty,
  13102. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13103. PsnName: res.Output.Baseinfo.PsnName,
  13104. Idetinfo: idetinfoStr,
  13105. Insuinfo: infoStr,
  13106. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13107. InsuplcAdmdvs: insuplc_admdvs,
  13108. }
  13109. service.CreateHisPsn(psn)
  13110. for _, item := range rf {
  13111. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13112. insutypes = append(insutypes, item)
  13113. }
  13114. }
  13115. if len(insutypes) == 1 {
  13116. insutype = insutypes[0].Insutype
  13117. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13118. } else {
  13119. for _, i := range insutypes {
  13120. if i.Insutype == "390" {
  13121. is390 = 1
  13122. }
  13123. if i.Insutype == "310" {
  13124. is310 = 1
  13125. }
  13126. }
  13127. }
  13128. if is390 == 1 {
  13129. insutype = "390"
  13130. }
  13131. if is310 == 1 {
  13132. insutype = "310"
  13133. }
  13134. if len(insutypes) == 0 {
  13135. insutype = "310"
  13136. }
  13137. c.ServeSuccessJSON(map[string]interface{}{
  13138. "patient": patient,
  13139. "number": res.Output.Baseinfo.Certno,
  13140. "insutype": insutype,
  13141. })
  13142. }
  13143. } else {
  13144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13145. return
  13146. }
  13147. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13148. var res ResultTwo
  13149. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  13150. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13151. "&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)
  13152. resp, requestErr := http.Get(api)
  13153. if requestErr != nil {
  13154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13155. return
  13156. }
  13157. body, ioErr := ioutil.ReadAll(resp.Body)
  13158. if ioErr != nil {
  13159. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13161. return
  13162. }
  13163. var respJSON map[string]interface{}
  13164. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13167. return
  13168. }
  13169. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13170. result, _ := json.Marshal(respJSON)
  13171. fmt.Println("log")
  13172. fmt.Println(string(result))
  13173. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13174. utils.ErrorLog("解析失败:%v", err)
  13175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13176. return
  13177. }
  13178. if res.Infcode == 0 {
  13179. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13180. if err == gorm.ErrRecordNotFound {
  13181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13182. return
  13183. } else if err != nil {
  13184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13185. return
  13186. } else {
  13187. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13188. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13189. infoStr := string(Iinfos)
  13190. idetinfoStr := string(Idetinfos)
  13191. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13192. psn := &models.HisPsn{
  13193. PsnNo: res.Output.Baseinfo.PsnNo,
  13194. PatientId: patient.ID,
  13195. Certno: res.Output.Baseinfo.Certno,
  13196. Brdy: b,
  13197. Age: float64(age),
  13198. Gend: res.Output.Baseinfo.Gend,
  13199. Naty: res.Output.Baseinfo.Naty,
  13200. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13201. PsnName: res.Output.Baseinfo.PsnName,
  13202. Idetinfo: idetinfoStr,
  13203. Insuinfo: infoStr,
  13204. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13205. }
  13206. service.CreateHisPsn(psn)
  13207. var rf []*ResultFive
  13208. json.Unmarshal([]byte(infoStr), &rf)
  13209. var insutypes []*ResultFive
  13210. var insutype string
  13211. var is390 int = 0
  13212. var is310 int = 0
  13213. for _, item := range rf {
  13214. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13215. insutypes = append(insutypes, item)
  13216. }
  13217. }
  13218. if len(insutypes) == 1 {
  13219. insutype = insutypes[0].Insutype
  13220. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13221. } else {
  13222. for _, i := range insutypes {
  13223. if i.Insutype == "390" {
  13224. is390 = 1
  13225. }
  13226. if i.Insutype == "310" {
  13227. is310 = 1
  13228. }
  13229. }
  13230. }
  13231. if is390 == 1 {
  13232. insutype = "390"
  13233. }
  13234. if is310 == 1 {
  13235. insutype = "310"
  13236. }
  13237. if len(insutypes) == 0 {
  13238. insutype = "310"
  13239. }
  13240. c.ServeSuccessJSON(map[string]interface{}{
  13241. "patient": patient,
  13242. "number": res.Output.Baseinfo.Certno,
  13243. "insutype": insutype,
  13244. })
  13245. }
  13246. } else {
  13247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13248. return
  13249. }
  13250. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13251. var api string
  13252. if miConfig.MdtrtareaAdmvs == "320921" {
  13253. 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 +
  13254. "&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
  13255. fmt.Println(api)
  13256. } else {
  13257. 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 +
  13258. "&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)
  13259. }
  13260. resp, requestErr := http.Get(api)
  13261. if requestErr != nil {
  13262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13263. return
  13264. }
  13265. body, ioErr := ioutil.ReadAll(resp.Body)
  13266. if ioErr != nil {
  13267. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13269. return
  13270. }
  13271. var respJSON map[string]interface{}
  13272. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13275. return
  13276. }
  13277. var status string
  13278. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13279. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13280. //console.log()
  13281. fmt.Println("type===")
  13282. fmt.Println(card_type)
  13283. var token string
  13284. var res ResultTwo //1101结果
  13285. var res10265 ResultTwo10265 //1101结果
  13286. var card_info string //卡信息
  13287. var busi_card_info string
  13288. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13289. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13290. if status == "0" { //读卡成功
  13291. if card_type == "1" {
  13292. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13293. result, _ := json.Marshal(respJSON)
  13294. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13295. utils.ErrorLog("解析失败:%v", err)
  13296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13297. return
  13298. }
  13299. res.ErrMsg = res10265.ErrMsg
  13300. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13301. res.Infcode = infocode
  13302. res.Output = res10265.Output
  13303. res.InfRefmsgid = res10265.InfRefmsgid
  13304. } else {
  13305. //var card_info string //卡信息
  13306. //var busi_card_info string
  13307. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13308. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13309. //fmt.Println(card_info)
  13310. //fmt.Println(busi_card_info)
  13311. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13312. result, _ := json.Marshal(respJSON)
  13313. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13314. utils.ErrorLog("解析失败:%v", err)
  13315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13316. return
  13317. }
  13318. res.ErrMsg = res10265.ErrMsg
  13319. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13320. res.Infcode = infocode
  13321. res.Output = res10265.Output
  13322. res.InfRefmsgid = res10265.InfRefmsgid
  13323. }
  13324. if res.Infcode == 0 {
  13325. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13326. if err == gorm.ErrRecordNotFound {
  13327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13328. return
  13329. } else if err != nil {
  13330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13331. return
  13332. } else {
  13333. if card_type == "1" {
  13334. bas := strings.Split(card_info, "|")
  13335. basNumber := bas[2]
  13336. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13337. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13338. infoStr := string(Iinfos)
  13339. idetinfoStr := string(Idetinfos)
  13340. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13341. psn := &models.HisPsn{
  13342. PsnNo: res.Output.Baseinfo.PsnNo,
  13343. PatientId: patient.ID,
  13344. Certno: res.Output.Baseinfo.Certno,
  13345. Brdy: b,
  13346. Age: float64(age),
  13347. Gend: res.Output.Baseinfo.Gend,
  13348. Naty: res.Output.Baseinfo.Naty,
  13349. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13350. PsnName: res.Output.Baseinfo.PsnName,
  13351. Idetinfo: idetinfoStr,
  13352. Insuinfo: infoStr,
  13353. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13354. CardInfo: card_info,
  13355. VerifyNumber: busi_card_info,
  13356. }
  13357. service.CreateHisPsn(psn)
  13358. var rf []*ResultFive
  13359. json.Unmarshal([]byte(infoStr), &rf)
  13360. var insutypes []*ResultFive
  13361. var insutype string
  13362. var is390 int = 0
  13363. var is310 int = 0
  13364. for _, item := range rf {
  13365. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13366. insutypes = append(insutypes, item)
  13367. }
  13368. }
  13369. if len(insutypes) == 1 {
  13370. insutype = insutypes[0].Insutype
  13371. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13372. } else {
  13373. for _, i := range insutypes {
  13374. if i.Insutype == "390" {
  13375. is390 = 1
  13376. }
  13377. if i.Insutype == "310" {
  13378. is310 = 1
  13379. }
  13380. }
  13381. }
  13382. if is390 == 1 {
  13383. insutype = "390"
  13384. }
  13385. if is310 == 1 {
  13386. insutype = "310"
  13387. }
  13388. if len(insutypes) == 0 {
  13389. insutype = "310"
  13390. }
  13391. c.ServeSuccessJSON(map[string]interface{}{
  13392. "patient": patient,
  13393. "number": basNumber,
  13394. "insutype": insutype,
  13395. })
  13396. } else {
  13397. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13398. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13399. infoStr := string(Iinfos)
  13400. idetinfoStr := string(Idetinfos)
  13401. psn := &models.HisPsn{
  13402. PsnNo: res.Output.Baseinfo.PsnNo,
  13403. PatientId: patient.ID,
  13404. Certno: res.Output.Baseinfo.Certno,
  13405. Gend: res.Output.Baseinfo.Gend,
  13406. Naty: res.Output.Baseinfo.Naty,
  13407. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13408. PsnName: res.Output.Baseinfo.PsnName,
  13409. Idetinfo: idetinfoStr,
  13410. Insuinfo: infoStr,
  13411. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13412. CardInfo: card_info,
  13413. VerifyNumber: token,
  13414. }
  13415. service.CreateHisPsn(psn)
  13416. c.ServeSuccessJSON(map[string]interface{}{
  13417. "patient": patient,
  13418. "number": token,
  13419. })
  13420. }
  13421. }
  13422. } else {
  13423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13424. return
  13425. }
  13426. } else { //读卡失败
  13427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13428. return
  13429. }
  13430. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13431. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  13432. cardnum = DeleteExtraSpaceTwo(cardnum)
  13433. cardCode = DeleteExtraSpaceTwo(cardCode)
  13434. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  13435. name = DeleteExtraSpaceTwo(name)
  13436. errmsg = DeleteExtraSpaceTwo(errmsg)
  13437. cardnum = Remove0000(cardnum)
  13438. cardCode = Remove0000(cardCode)
  13439. id_card_no = Remove0000(id_card_no)
  13440. name = Remove0000(name)
  13441. errmsg = Remove0000(errmsg)
  13442. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  13443. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  13444. //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)
  13445. //fmt.Println(result2)
  13446. //fmt.Println(requestLog2)
  13447. //fmt.Println(errMsgLog2)
  13448. 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)
  13449. saveLog(result, requestLog, "1101", "获取人员信息")
  13450. fmt.Println(errMsgLog)
  13451. if len(errMsgLog) > 0 {
  13452. } else {
  13453. var dat map[string]interface{}
  13454. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13455. fmt.Println(dat)
  13456. } else {
  13457. fmt.Println(err)
  13458. }
  13459. userJSONBytes, _ := json.Marshal(dat)
  13460. var res ResultTwo
  13461. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13462. utils.ErrorLog("解析失败:%v", err)
  13463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13464. return
  13465. }
  13466. res.ErrMsg = errMsgLog
  13467. if res.Infcode == 0 {
  13468. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13469. if err == gorm.ErrRecordNotFound {
  13470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13471. return
  13472. } else if err != nil {
  13473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13474. return
  13475. } else {
  13476. fmt.Println(res)
  13477. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13478. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13479. infoStr := string(Iinfos)
  13480. idetinfoStr := string(Idetinfos)
  13481. var rf []*ResultFive
  13482. json.Unmarshal([]byte(infoStr), &rf)
  13483. var insutypes []*ResultFive
  13484. var insutype string
  13485. var is390 int = 0
  13486. var is310 int = 0
  13487. for _, item := range rf {
  13488. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13489. insutypes = append(insutypes, item)
  13490. }
  13491. }
  13492. if len(insutypes) == 1 {
  13493. insutype = insutypes[0].Insutype
  13494. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13495. } else {
  13496. for _, i := range insutypes {
  13497. if i.Insutype == "390" {
  13498. is390 = 1
  13499. }
  13500. if i.Insutype == "310" {
  13501. is310 = 1
  13502. }
  13503. }
  13504. }
  13505. if is390 == 1 {
  13506. insutype = "390"
  13507. }
  13508. if is310 == 1 {
  13509. insutype = "310"
  13510. }
  13511. if len(insutypes) == 0 {
  13512. insutype = "390"
  13513. }
  13514. var insuplc_admdvs string
  13515. for _, item := range rf {
  13516. if item.Insutype == insutype {
  13517. insuplc_admdvs = item.InsuplcAdmdvs
  13518. }
  13519. }
  13520. psn := &models.HisPsn{
  13521. PsnNo: res.Output.Baseinfo.PsnNo,
  13522. PatientId: patient.ID,
  13523. Certno: res.Output.Baseinfo.Certno,
  13524. Gend: res.Output.Baseinfo.Gend,
  13525. Naty: res.Output.Baseinfo.Naty,
  13526. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13527. PsnName: res.Output.Baseinfo.PsnName,
  13528. Idetinfo: idetinfoStr,
  13529. Insuinfo: infoStr,
  13530. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13531. CardInfo: basStr,
  13532. VerifyNumber: "",
  13533. InsuplcAdmdvs: insuplc_admdvs,
  13534. }
  13535. service.CreateHisPsn(psn)
  13536. c.ServeSuccessJSON(map[string]interface{}{
  13537. "patient": patient,
  13538. "number": cardnum,
  13539. "insutype": insutype,
  13540. })
  13541. }
  13542. } else {
  13543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13544. return
  13545. }
  13546. }
  13547. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13548. fmt.Println(initFlag)
  13549. fmt.Println("initFlag")
  13550. if initFlag == 0 {
  13551. c.TestGetJiangXiBasBaseInit()
  13552. }
  13553. basStr := c.GetBasBaseInfo()
  13554. if len(basStr) == 0 {
  13555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13556. return
  13557. }
  13558. fmt.Println(basStr)
  13559. bas := strings.Split(basStr, "|")
  13560. basNumber := bas[1]
  13561. fmt.Println(basNumber)
  13562. card_sn := bas[3]
  13563. fmt.Println(card_sn)
  13564. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13565. 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)
  13566. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13567. var dat map[string]interface{}
  13568. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13569. fmt.Println(dat)
  13570. } else {
  13571. fmt.Println(err)
  13572. }
  13573. userJSONBytes, _ := json.Marshal(dat)
  13574. var res ResultTwo
  13575. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13576. utils.ErrorLog("解析失败:%v", err)
  13577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13578. return
  13579. }
  13580. if res.Infcode == 0 {
  13581. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13582. if err == gorm.ErrRecordNotFound {
  13583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13584. return
  13585. } else if err != nil {
  13586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13587. return
  13588. } else {
  13589. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13590. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13591. infoStr := string(Iinfos)
  13592. idetinfoStr := string(Idetinfos)
  13593. var rf []*ResultFive
  13594. json.Unmarshal([]byte(infoStr), &rf)
  13595. var insutypes []*ResultFive
  13596. var insutype string
  13597. var is390 int = 0
  13598. var is310 int = 0
  13599. var insuplc_admdvs string
  13600. for _, item := range rf {
  13601. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13602. insutypes = append(insutypes, item)
  13603. }
  13604. }
  13605. if len(insutypes) == 1 {
  13606. insutype = insutypes[0].Insutype
  13607. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13608. } else {
  13609. for _, i := range insutypes {
  13610. if i.Insutype == "390" {
  13611. is390 = 1
  13612. }
  13613. if i.Insutype == "310" {
  13614. is310 = 1
  13615. }
  13616. }
  13617. }
  13618. if is390 == 1 {
  13619. insutype = "390"
  13620. }
  13621. if is310 == 1 {
  13622. insutype = "310"
  13623. }
  13624. if len(insutypes) == 0 {
  13625. insutype = "310"
  13626. }
  13627. for _, item := range rf {
  13628. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13629. insuplc_admdvs = item.InsuplcAdmdvs
  13630. }
  13631. }
  13632. psn := &models.HisPsn{
  13633. PsnNo: res.Output.Baseinfo.PsnNo,
  13634. PatientId: patient.ID,
  13635. Certno: res.Output.Baseinfo.Certno,
  13636. Gend: res.Output.Baseinfo.Gend,
  13637. Naty: res.Output.Baseinfo.Naty,
  13638. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13639. PsnName: res.Output.Baseinfo.PsnName,
  13640. Idetinfo: idetinfoStr,
  13641. Insuinfo: infoStr,
  13642. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13643. CardInfo: basStr,
  13644. InsuplcAdmdvs: insuplc_admdvs,
  13645. VerifyNumber: "",
  13646. }
  13647. service.CreateHisPsn(psn)
  13648. c.ServeSuccessJSON(map[string]interface{}{
  13649. "patient": patient,
  13650. "number": basNumber,
  13651. "insutype": insutype,
  13652. })
  13653. }
  13654. } else {
  13655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13656. return
  13657. }
  13658. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13659. basStr := c.GetBasBaseInfo22222()
  13660. fmt.Println(basStr)
  13661. if len(basStr) == 0 {
  13662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13663. return
  13664. }
  13665. fmt.Println(basStr)
  13666. bas := strings.Split(basStr, "|")
  13667. basNumber := bas[2] //卡号
  13668. card_sn := bas[3] //
  13669. id_card_No := bas[1] //卡号
  13670. fmt.Println(basNumber)
  13671. fmt.Println(card_sn)
  13672. fmt.Println(id_card_No)
  13673. var patient service.Patients
  13674. if len(id_card_No) == 0 {
  13675. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13676. } else {
  13677. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13678. }
  13679. result, _ := service.Jxyb1101bycard(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, patient.Name, patient.IdCardNo)
  13680. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13681. var dat map[string]interface{}
  13682. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13683. fmt.Println(dat)
  13684. } else {
  13685. fmt.Println(err)
  13686. }
  13687. userJSONBytes, _ := json.Marshal(dat)
  13688. var res ResultTwo
  13689. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13690. utils.ErrorLog("解析失败:%v", err)
  13691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13692. return
  13693. }
  13694. if res.Infcode == 0 {
  13695. var pateint2 service.Patients
  13696. var err error
  13697. if len(id_card_No) == 0 {
  13698. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13699. } else {
  13700. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13701. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13702. }
  13703. if err == gorm.ErrRecordNotFound {
  13704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13705. return
  13706. } else if err != nil {
  13707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13708. return
  13709. } else {
  13710. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13711. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13712. infoStr := string(Iinfos)
  13713. idetinfoStr := string(Idetinfos)
  13714. var rf []*ResultFive
  13715. json.Unmarshal([]byte(infoStr), &rf)
  13716. var insutypes []*ResultFive
  13717. var insutype string
  13718. var is390 int = 0
  13719. var is310 int = 0
  13720. var insuplc_admdvs string
  13721. for _, item := range rf {
  13722. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13723. insutypes = append(insutypes, item)
  13724. }
  13725. }
  13726. if len(insutypes) == 1 {
  13727. insutype = insutypes[0].Insutype
  13728. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13729. } else {
  13730. for _, i := range insutypes {
  13731. if i.Insutype == "390" {
  13732. is390 = 1
  13733. }
  13734. if i.Insutype == "310" {
  13735. is310 = 1
  13736. }
  13737. }
  13738. }
  13739. if is390 == 1 {
  13740. insutype = "390"
  13741. }
  13742. if is310 == 1 {
  13743. insutype = "310"
  13744. }
  13745. if len(insutypes) == 0 {
  13746. insutype = "310"
  13747. }
  13748. for _, item := range rf {
  13749. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13750. insuplc_admdvs = item.InsuplcAdmdvs
  13751. }
  13752. }
  13753. psn := &models.HisPsn{
  13754. PsnNo: res.Output.Baseinfo.PsnNo,
  13755. PatientId: pateint2.ID,
  13756. Certno: res.Output.Baseinfo.Certno,
  13757. Gend: res.Output.Baseinfo.Gend,
  13758. Naty: res.Output.Baseinfo.Naty,
  13759. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13760. PsnName: res.Output.Baseinfo.PsnName,
  13761. Idetinfo: idetinfoStr,
  13762. Insuinfo: infoStr,
  13763. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13764. CardInfo: basStr,
  13765. InsuplcAdmdvs: insuplc_admdvs,
  13766. VerifyNumber: "",
  13767. }
  13768. service.CreateHisPsn(psn)
  13769. c.ServeSuccessJSON(map[string]interface{}{
  13770. "patient": patient,
  13771. "number": basNumber,
  13772. "insutype": insutype,
  13773. })
  13774. }
  13775. } else {
  13776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13777. return
  13778. }
  13779. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13780. fmt.Println(initFlag)
  13781. fmt.Println("initFlag")
  13782. if initFlag == 0 {
  13783. c.TestGetHnBasBaseInit()
  13784. }
  13785. basStr := c.GetBasBaseInfo()
  13786. if len(basStr) == 0 {
  13787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13788. return
  13789. }
  13790. fmt.Println(basStr)
  13791. bas := strings.Split(basStr, "|")
  13792. basNumber := bas[1]
  13793. fmt.Println(basNumber)
  13794. card_sn := bas[3]
  13795. card_no := bas[2]
  13796. fmt.Println(card_sn)
  13797. name := bas[4]
  13798. name = ConvertToString(name, "gbk", "utf-8")
  13799. 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)
  13800. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13801. var dat map[string]interface{}
  13802. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13803. fmt.Println(dat)
  13804. } else {
  13805. fmt.Println(err)
  13806. }
  13807. userJSONBytes, _ := json.Marshal(dat)
  13808. var res ResultTwo
  13809. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13810. utils.ErrorLog("解析失败:%v", err)
  13811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13812. return
  13813. }
  13814. if res.Infcode == 0 {
  13815. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13816. if err == gorm.ErrRecordNotFound {
  13817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13818. return
  13819. } else if err != nil {
  13820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13821. return
  13822. } else {
  13823. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13824. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13825. infoStr := string(Iinfos)
  13826. idetinfoStr := string(Idetinfos)
  13827. psn := &models.HisPsn{
  13828. PsnNo: res.Output.Baseinfo.PsnNo,
  13829. PatientId: patient.ID,
  13830. Certno: res.Output.Baseinfo.Certno,
  13831. Gend: res.Output.Baseinfo.Gend,
  13832. Naty: res.Output.Baseinfo.Naty,
  13833. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13834. PsnName: res.Output.Baseinfo.PsnName,
  13835. Idetinfo: idetinfoStr,
  13836. Insuinfo: infoStr,
  13837. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13838. CardInfo: basStr,
  13839. VerifyNumber: "",
  13840. }
  13841. service.CreateHisPsn(psn)
  13842. var rf []*ResultFive
  13843. json.Unmarshal([]byte(infoStr), &rf)
  13844. var insutypes []*ResultFive
  13845. var insutype string
  13846. var is390 int = 0
  13847. var is310 int = 0
  13848. for _, item := range rf {
  13849. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13850. insutypes = append(insutypes, item)
  13851. }
  13852. }
  13853. if len(insutypes) == 1 {
  13854. insutype = insutypes[0].Insutype
  13855. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13856. } else {
  13857. for _, i := range insutypes {
  13858. if i.Insutype == "390" {
  13859. is390 = 1
  13860. }
  13861. if i.Insutype == "310" {
  13862. is310 = 1
  13863. }
  13864. }
  13865. }
  13866. if is390 == 1 {
  13867. insutype = "390"
  13868. }
  13869. if is310 == 1 {
  13870. insutype = "310"
  13871. }
  13872. if len(insutypes) == 0 {
  13873. insutype = "310"
  13874. }
  13875. c.ServeSuccessJSON(map[string]interface{}{
  13876. "patient": patient,
  13877. "number": basNumber,
  13878. "insutype": insutype,
  13879. })
  13880. }
  13881. } else {
  13882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13883. return
  13884. }
  13885. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13886. var api string
  13887. 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 +
  13888. "&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
  13889. fmt.Println(api)
  13890. resp, requestErr := http.Get(api)
  13891. if requestErr != nil {
  13892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13893. return
  13894. }
  13895. body, ioErr := ioutil.ReadAll(resp.Body)
  13896. if ioErr != nil {
  13897. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13899. return
  13900. }
  13901. var respJSON map[string]interface{}
  13902. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13903. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13905. return
  13906. }
  13907. var res ResultTwo //1101结果
  13908. var res10265 ResultTwo10265 //1101结果
  13909. var card_info string //卡信息
  13910. token := respJSON["data"].(map[string]interface{})["token"].(string)
  13911. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13912. result, _ := json.Marshal(respJSON)
  13913. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13914. utils.ErrorLog("解析失败:%v", err)
  13915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13916. return
  13917. }
  13918. res.ErrMsg = res10265.ErrMsg
  13919. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13920. res.Infcode = infocode
  13921. res.Output = res10265.Output
  13922. res.InfRefmsgid = res10265.InfRefmsgid
  13923. if res.Infcode == 0 {
  13924. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13925. if err == gorm.ErrRecordNotFound {
  13926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13927. return
  13928. } else if err != nil {
  13929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13930. return
  13931. } else {
  13932. bas := strings.Split(card_info, "|")
  13933. basNumber := bas[2]
  13934. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13935. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13936. infoStr := string(Iinfos)
  13937. idetinfoStr := string(Idetinfos)
  13938. psn := &models.HisPsn{
  13939. PsnNo: res.Output.Baseinfo.PsnNo,
  13940. PatientId: patient.ID,
  13941. Certno: res.Output.Baseinfo.Certno,
  13942. Gend: res.Output.Baseinfo.Gend,
  13943. Naty: res.Output.Baseinfo.Naty,
  13944. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13945. PsnName: res.Output.Baseinfo.PsnName,
  13946. Idetinfo: idetinfoStr,
  13947. Insuinfo: infoStr,
  13948. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13949. CardInfo: card_info,
  13950. VerifyNumber: token,
  13951. }
  13952. service.CreateHisPsn(psn)
  13953. var rf []*ResultFive
  13954. json.Unmarshal([]byte(infoStr), &rf)
  13955. var insutypes []*ResultFive
  13956. var insutype string
  13957. var is390 int = 0
  13958. var is310 int = 0
  13959. for _, item := range rf {
  13960. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13961. insutypes = append(insutypes, item)
  13962. }
  13963. }
  13964. if len(insutypes) == 1 {
  13965. insutype = insutypes[0].Insutype
  13966. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13967. } else {
  13968. for _, i := range insutypes {
  13969. if i.Insutype == "390" {
  13970. is390 = 1
  13971. }
  13972. if i.Insutype == "310" {
  13973. is310 = 1
  13974. }
  13975. }
  13976. }
  13977. if is390 == 1 {
  13978. insutype = "390"
  13979. }
  13980. if is310 == 1 {
  13981. insutype = "310"
  13982. }
  13983. if len(insutypes) == 0 {
  13984. insutype = "310"
  13985. }
  13986. c.ServeSuccessJSON(map[string]interface{}{
  13987. "patient": patient,
  13988. "number": basNumber,
  13989. "insutype": insutype,
  13990. })
  13991. }
  13992. } else {
  13993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13994. return
  13995. }
  13996. } else if miConfig.MdtrtareaAdmvs == "450721" {
  13997. res := c.GetoleInfo()
  13998. if res.Infcode == 0 {
  13999. var result string
  14000. if res.Output.MdtrtCertType == "01" {
  14001. 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)
  14002. } else if res.Output.MdtrtCertType == "02" {
  14003. 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)
  14004. } else if res.Output.MdtrtCertType == "03" {
  14005. 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)
  14006. }
  14007. var dat map[string]interface{}
  14008. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14009. fmt.Println(dat)
  14010. } else {
  14011. fmt.Println(err)
  14012. }
  14013. userJSONBytes, _ := json.Marshal(dat)
  14014. var res2 ResultTwo
  14015. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14016. utils.ErrorLog("解析失败:%v", err)
  14017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14018. return
  14019. }
  14020. if res2.Infcode == 0 {
  14021. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14022. if err == gorm.ErrRecordNotFound {
  14023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14024. return
  14025. } else if err != nil {
  14026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14027. return
  14028. } else {
  14029. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14030. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14031. infoStr := string(Iinfos)
  14032. idetinfoStr := string(Idetinfos)
  14033. var rf []*ResultFive
  14034. json.Unmarshal([]byte(infoStr), &rf)
  14035. var insutypes []*ResultFive
  14036. var insutype string
  14037. var is390 int = 0
  14038. var is310 int = 0
  14039. //var insuplc_admdvs string
  14040. for _, item := range rf {
  14041. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14042. insutypes = append(insutypes, item)
  14043. }
  14044. }
  14045. if len(insutypes) == 1 {
  14046. insutype = insutypes[0].Insutype
  14047. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14048. } else {
  14049. for _, i := range insutypes {
  14050. if i.Insutype == "390" {
  14051. is390 = 1
  14052. }
  14053. if i.Insutype == "310" {
  14054. is310 = 1
  14055. }
  14056. }
  14057. }
  14058. if is390 == 1 {
  14059. insutype = "390"
  14060. }
  14061. if is310 == 1 {
  14062. insutype = "310"
  14063. }
  14064. if len(insutypes) == 0 {
  14065. insutype = "310"
  14066. }
  14067. psn := &models.HisPsn{
  14068. PsnNo: res2.Output.Baseinfo.PsnNo,
  14069. PatientId: patient.ID,
  14070. Certno: res2.Output.Baseinfo.Certno,
  14071. Gend: res2.Output.Baseinfo.Gend,
  14072. Naty: res2.Output.Baseinfo.Naty,
  14073. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14074. PsnName: res2.Output.Baseinfo.PsnName,
  14075. Idetinfo: idetinfoStr,
  14076. Insuinfo: infoStr,
  14077. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14078. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14079. VerifyNumber: res.Output.EcToken,
  14080. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14081. }
  14082. if res.Output.MdtrtCertType == "01" {
  14083. psn.VerifyNumber = res.Output.EcToken
  14084. //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)
  14085. } else if res.Output.MdtrtCertType == "02" {
  14086. psn.VerifyNumber = res.Output.MdtrtCertNo
  14087. //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)
  14088. } else if res.Output.MdtrtCertType == "03" {
  14089. psn.VerifyNumber = res.Output.MdtrtCertNo
  14090. //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)
  14091. }
  14092. var balc float64
  14093. for _, item := range rf {
  14094. if item.Insutype == insutype {
  14095. balc = item.Balc
  14096. }
  14097. }
  14098. service.CreateHisPsn(psn)
  14099. c.ServeSuccessJSON(map[string]interface{}{
  14100. "patient": patient,
  14101. "number": res.Output.CardNo,
  14102. "insutype": insutype,
  14103. "blac": balc,
  14104. "desc": idetinfoStr,
  14105. })
  14106. }
  14107. } else {
  14108. c.ServeSuccessJSON(map[string]interface{}{
  14109. "failed_code": -10,
  14110. "msg": res2.ErrMsg,
  14111. })
  14112. }
  14113. } else {
  14114. c.ServeSuccessJSON(map[string]interface{}{
  14115. "failed_code": -10,
  14116. "msg": res.ErrMsg,
  14117. })
  14118. }
  14119. } else if miConfig.MdtrtareaAdmvs == "341203" {
  14120. var api string
  14121. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14122. "&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
  14123. fmt.Println(api)
  14124. resp, requestErr := http.Get(api)
  14125. if requestErr != nil {
  14126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14127. return
  14128. }
  14129. body, ioErr := ioutil.ReadAll(resp.Body)
  14130. if ioErr != nil {
  14131. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14133. return
  14134. }
  14135. var respJSON map[string]interface{}
  14136. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14139. return
  14140. }
  14141. var status string
  14142. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14143. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14144. //console.log()
  14145. fmt.Println("type===")
  14146. fmt.Println(card_type)
  14147. var token string
  14148. var res ResultTwo //1101结果
  14149. //var res10265 ResultTwoesultTwo10265 //1101结果
  14150. var card_info string //卡信息
  14151. var busi_card_info string
  14152. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14153. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14154. if status == "0" { //读卡成功
  14155. if card_type == "1" {
  14156. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14157. result, _ := json.Marshal(respJSON)
  14158. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14159. utils.ErrorLog("解析失败:%v", err)
  14160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14161. return
  14162. }
  14163. } else {
  14164. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14165. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14166. result, _ := json.Marshal(respJSON)
  14167. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14168. utils.ErrorLog("解析失败:%v", err)
  14169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14170. return
  14171. }
  14172. }
  14173. if res.Infcode == 0 {
  14174. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14175. if err == gorm.ErrRecordNotFound {
  14176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14177. return
  14178. } else if err != nil {
  14179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14180. return
  14181. } else {
  14182. if card_type == "1" {
  14183. bas := strings.Split(card_info, "|")
  14184. basNumber := bas[2]
  14185. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14186. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14187. infoStr := string(Iinfos)
  14188. idetinfoStr := string(Idetinfos)
  14189. psn := &models.HisPsn{
  14190. PsnNo: res.Output.Baseinfo.PsnNo,
  14191. PatientId: patient.ID,
  14192. Certno: res.Output.Baseinfo.Certno,
  14193. Gend: res.Output.Baseinfo.Gend,
  14194. Naty: res.Output.Baseinfo.Naty,
  14195. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14196. PsnName: res.Output.Baseinfo.PsnName,
  14197. Idetinfo: idetinfoStr,
  14198. Insuinfo: infoStr,
  14199. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14200. CardInfo: card_info,
  14201. VerifyNumber: busi_card_info,
  14202. }
  14203. service.CreateHisPsn(psn)
  14204. var rf []*ResultFive
  14205. json.Unmarshal([]byte(infoStr), &rf)
  14206. var insutypes []*ResultFive
  14207. var insutype string
  14208. var is390 int = 0
  14209. var is310 int = 0
  14210. for _, item := range rf {
  14211. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14212. insutypes = append(insutypes, item)
  14213. }
  14214. }
  14215. if len(insutypes) == 1 {
  14216. insutype = insutypes[0].Insutype
  14217. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14218. } else {
  14219. for _, i := range insutypes {
  14220. if i.Insutype == "390" {
  14221. is390 = 1
  14222. }
  14223. if i.Insutype == "310" {
  14224. is310 = 1
  14225. }
  14226. }
  14227. }
  14228. if is390 == 1 {
  14229. insutype = "390"
  14230. }
  14231. if is310 == 1 {
  14232. insutype = "310"
  14233. }
  14234. if len(insutypes) == 0 {
  14235. insutype = "310"
  14236. }
  14237. c.ServeSuccessJSON(map[string]interface{}{
  14238. "patient": patient,
  14239. "number": basNumber,
  14240. "insutype": insutype,
  14241. })
  14242. } else {
  14243. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14244. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14245. infoStr := string(Iinfos)
  14246. idetinfoStr := string(Idetinfos)
  14247. psn := &models.HisPsn{
  14248. PsnNo: res.Output.Baseinfo.PsnNo,
  14249. PatientId: patient.ID,
  14250. Certno: res.Output.Baseinfo.Certno,
  14251. Gend: res.Output.Baseinfo.Gend,
  14252. Naty: res.Output.Baseinfo.Naty,
  14253. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14254. PsnName: res.Output.Baseinfo.PsnName,
  14255. Idetinfo: idetinfoStr,
  14256. Insuinfo: infoStr,
  14257. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14258. CardInfo: card_info,
  14259. VerifyNumber: token,
  14260. }
  14261. service.CreateHisPsn(psn)
  14262. c.ServeSuccessJSON(map[string]interface{}{
  14263. "patient": patient,
  14264. "number": token,
  14265. })
  14266. }
  14267. }
  14268. } else {
  14269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14270. return
  14271. }
  14272. } else { //读卡失败
  14273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14274. return
  14275. }
  14276. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14277. var api string
  14278. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14279. "&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
  14280. fmt.Println(api)
  14281. resp, requestErr := http.Get(api)
  14282. if requestErr != nil {
  14283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14284. return
  14285. }
  14286. body, ioErr := ioutil.ReadAll(resp.Body)
  14287. if ioErr != nil {
  14288. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14290. return
  14291. }
  14292. var respJSON map[string]interface{}
  14293. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14294. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14296. return
  14297. }
  14298. var status string
  14299. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14300. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14301. //console.log()
  14302. fmt.Println("type===")
  14303. fmt.Println(card_type)
  14304. var token string
  14305. var res ResultTwo //1101结果
  14306. //var res10265 ResultTwoesultTwo10265 //1101结果
  14307. var card_info string //卡信息
  14308. //var busi_card_info string
  14309. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14310. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14311. if status == "0" { //读卡成功
  14312. if card_type == "1" {
  14313. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14314. result, _ := json.Marshal(respJSON)
  14315. fmt.Println(result)
  14316. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14317. utils.ErrorLog("解析失败:%v", err)
  14318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14319. return
  14320. }
  14321. fmt.Println(res)
  14322. } else {
  14323. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14324. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14325. result, _ := json.Marshal(respJSON)
  14326. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14327. utils.ErrorLog("解析失败:%v", err)
  14328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14329. return
  14330. }
  14331. }
  14332. if res.Infcode == 0 {
  14333. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14334. if err == gorm.ErrRecordNotFound {
  14335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14336. return
  14337. } else if err != nil {
  14338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14339. return
  14340. } else {
  14341. if card_type == "1" {
  14342. bas := strings.Split(card_info, "|")
  14343. basNumber := bas[2]
  14344. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14345. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14346. infoStr := string(Iinfos)
  14347. idetinfoStr := string(Idetinfos)
  14348. psn := &models.HisPsn{
  14349. PsnNo: res.Output.Baseinfo.PsnNo,
  14350. PatientId: patient.ID,
  14351. Certno: res.Output.Baseinfo.Certno,
  14352. Gend: res.Output.Baseinfo.Gend,
  14353. Naty: res.Output.Baseinfo.Naty,
  14354. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14355. PsnName: res.Output.Baseinfo.PsnName,
  14356. Idetinfo: idetinfoStr,
  14357. Insuinfo: infoStr,
  14358. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14359. CardInfo: card_info,
  14360. //VerifyNumber: busi_card_info,
  14361. }
  14362. service.CreateHisPsn(psn)
  14363. var rf []*ResultFive
  14364. json.Unmarshal([]byte(infoStr), &rf)
  14365. var insutypes []*ResultFive
  14366. var insutype string
  14367. var is390 int = 0
  14368. var is310 int = 0
  14369. for _, item := range rf {
  14370. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14371. insutypes = append(insutypes, item)
  14372. }
  14373. }
  14374. if len(insutypes) == 1 {
  14375. insutype = insutypes[0].Insutype
  14376. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14377. } else {
  14378. for _, i := range insutypes {
  14379. if i.Insutype == "390" {
  14380. is390 = 1
  14381. }
  14382. if i.Insutype == "310" {
  14383. is310 = 1
  14384. }
  14385. }
  14386. }
  14387. if is390 == 1 {
  14388. insutype = "390"
  14389. }
  14390. if is310 == 1 {
  14391. insutype = "310"
  14392. }
  14393. if len(insutypes) == 0 {
  14394. insutype = "310"
  14395. }
  14396. c.ServeSuccessJSON(map[string]interface{}{
  14397. "patient": patient,
  14398. "number": basNumber,
  14399. "insutype": insutype,
  14400. })
  14401. } else {
  14402. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14403. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14404. infoStr := string(Iinfos)
  14405. idetinfoStr := string(Idetinfos)
  14406. psn := &models.HisPsn{
  14407. PsnNo: res.Output.Baseinfo.PsnNo,
  14408. PatientId: patient.ID,
  14409. Certno: res.Output.Baseinfo.Certno,
  14410. Gend: res.Output.Baseinfo.Gend,
  14411. Naty: res.Output.Baseinfo.Naty,
  14412. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14413. PsnName: res.Output.Baseinfo.PsnName,
  14414. Idetinfo: idetinfoStr,
  14415. Insuinfo: infoStr,
  14416. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14417. CardInfo: card_info,
  14418. VerifyNumber: token,
  14419. }
  14420. service.CreateHisPsn(psn)
  14421. c.ServeSuccessJSON(map[string]interface{}{
  14422. "patient": patient,
  14423. "number": token,
  14424. })
  14425. }
  14426. }
  14427. } else {
  14428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14429. return
  14430. }
  14431. } else { //读卡失败
  14432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14433. return
  14434. }
  14435. } else {
  14436. if initFlag == 0 {
  14437. c.TestGetBasBaseInit()
  14438. }
  14439. basStr := c.GetBasBaseInfo()
  14440. if len(basStr) == 0 {
  14441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14442. return
  14443. }
  14444. fmt.Println(basStr)
  14445. bas := strings.Split(basStr, "|")
  14446. basNumber := bas[1]
  14447. fmt.Println(basNumber)
  14448. card_sn := bas[3]
  14449. fmt.Println(card_sn)
  14450. cardNumber := bas[2]
  14451. fmt.Println(cardNumber)
  14452. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  14453. var result string
  14454. if bas[0][:2] == "44" {
  14455. 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)
  14456. } else {
  14457. 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)
  14458. }
  14459. var dat map[string]interface{}
  14460. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14461. fmt.Println(dat)
  14462. } else {
  14463. fmt.Println(err)
  14464. }
  14465. userJSONBytes, _ := json.Marshal(dat)
  14466. var res ResultTwo
  14467. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14468. utils.ErrorLog("解析失败:%v", err)
  14469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14470. return
  14471. }
  14472. if res.Infcode == 0 {
  14473. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14474. if err == gorm.ErrRecordNotFound {
  14475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14476. return
  14477. } else if err != nil {
  14478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14479. return
  14480. } else {
  14481. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14482. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14483. infoStr := string(Iinfos)
  14484. idetinfoStr := string(Idetinfos)
  14485. var rf []*ResultFive
  14486. json.Unmarshal([]byte(infoStr), &rf)
  14487. var insutypes []*ResultFive
  14488. var insutype string
  14489. var is390 int = 0
  14490. var is310 int = 0
  14491. var insuplc_admdvs string
  14492. for _, item := range rf {
  14493. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14494. insutypes = append(insutypes, item)
  14495. }
  14496. }
  14497. if len(insutypes) == 1 {
  14498. insutype = insutypes[0].Insutype
  14499. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14500. } else {
  14501. for _, i := range insutypes {
  14502. if i.Insutype == "390" {
  14503. is390 = 1
  14504. }
  14505. if i.Insutype == "310" {
  14506. is310 = 1
  14507. }
  14508. }
  14509. }
  14510. if is390 == 1 {
  14511. insutype = "390"
  14512. }
  14513. if is310 == 1 {
  14514. insutype = "310"
  14515. }
  14516. if len(insutypes) == 0 {
  14517. insutype = "310"
  14518. }
  14519. for _, item := range rf {
  14520. if item.Insutype == insutype {
  14521. insuplc_admdvs = item.InsuplcAdmdvs
  14522. }
  14523. }
  14524. psn := &models.HisPsn{
  14525. PsnNo: res.Output.Baseinfo.PsnNo,
  14526. PatientId: patient.ID,
  14527. Certno: res.Output.Baseinfo.Certno,
  14528. Gend: res.Output.Baseinfo.Gend,
  14529. Naty: res.Output.Baseinfo.Naty,
  14530. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14531. PsnName: res.Output.Baseinfo.PsnName,
  14532. Idetinfo: idetinfoStr,
  14533. Insuinfo: infoStr,
  14534. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14535. CardInfo: basStr,
  14536. VerifyNumber: "",
  14537. InsuplcAdmdvs: insuplc_admdvs,
  14538. }
  14539. service.CreateHisPsn(psn)
  14540. c.ServeSuccessJSON(map[string]interface{}{
  14541. "patient": patient,
  14542. "number": basNumber,
  14543. })
  14544. }
  14545. } else {
  14546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14547. return
  14548. }
  14549. break
  14550. }
  14551. case 2:
  14552. if miConfig.MdtrtareaAdmvs == "430800" {
  14553. if initFlag == 0 {
  14554. c.TestGetHnBasBaseInit()
  14555. }
  14556. SFZStr := c.GetSFZBaseInfo()
  14557. if len(SFZStr) == 0 {
  14558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14559. return
  14560. }
  14561. fmt.Println(SFZStr)
  14562. id_card_str := strings.Split(SFZStr, "^")
  14563. card_no := id_card_str[0]
  14564. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14565. //name := id_card_str[1]
  14566. //name = ConvertToString(name, "gbk", "utf-8")
  14567. 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)
  14568. var dat map[string]interface{}
  14569. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14570. fmt.Println(dat)
  14571. } else {
  14572. fmt.Println(err)
  14573. }
  14574. userJSONBytes, _ := json.Marshal(dat)
  14575. var res ResultTwo
  14576. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14577. utils.ErrorLog("解析失败:%v", err)
  14578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14579. return
  14580. }
  14581. if res.Infcode == 0 {
  14582. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14583. if err == gorm.ErrRecordNotFound {
  14584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14585. return
  14586. } else if err != nil {
  14587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14588. return
  14589. } else {
  14590. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14591. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14592. infoStr := string(Iinfos)
  14593. idetinfoStr := string(Idetinfos)
  14594. var rf []*ResultFive
  14595. json.Unmarshal([]byte(infoStr), &rf)
  14596. var insutypes []*ResultFive
  14597. var insutype string
  14598. var is390 int = 0
  14599. var is310 int = 0
  14600. for _, item := range rf {
  14601. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14602. insutypes = append(insutypes, item)
  14603. }
  14604. }
  14605. if len(insutypes) == 1 {
  14606. insutype = insutypes[0].Insutype
  14607. } else {
  14608. for _, i := range insutypes {
  14609. if i.Insutype == "390" {
  14610. is390 = 1
  14611. }
  14612. if i.Insutype == "310" {
  14613. is310 = 1
  14614. }
  14615. }
  14616. }
  14617. if is390 == 1 {
  14618. insutype = "390"
  14619. }
  14620. if is310 == 1 {
  14621. insutype = "310"
  14622. }
  14623. if len(insutypes) == 0 {
  14624. insutype = "310"
  14625. }
  14626. var InsuplcAdmdvs string
  14627. for _, item := range rf {
  14628. if item.Insutype == insutype {
  14629. InsuplcAdmdvs = item.InsuplcAdmdvs
  14630. }
  14631. }
  14632. psn := &models.HisPsn{
  14633. PsnNo: res.Output.Baseinfo.PsnNo,
  14634. PatientId: patient.ID,
  14635. Certno: res.Output.Baseinfo.Certno,
  14636. Gend: res.Output.Baseinfo.Gend,
  14637. Naty: res.Output.Baseinfo.Naty,
  14638. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14639. PsnName: res.Output.Baseinfo.PsnName,
  14640. Idetinfo: idetinfoStr,
  14641. Insuinfo: infoStr,
  14642. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14643. CardInfo: SFZStr,
  14644. VerifyNumber: "",
  14645. InsuplcAdmdvs: InsuplcAdmdvs,
  14646. }
  14647. service.CreateHisPsn(psn)
  14648. c.ServeSuccessJSON(map[string]interface{}{
  14649. "patient": patient,
  14650. "number": card_no,
  14651. "insutype": insutype,
  14652. })
  14653. }
  14654. } else {
  14655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14656. return
  14657. }
  14658. } else if miConfig.MdtrtareaAdmvs == "420200" {
  14659. var res ResultTwo
  14660. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  14661. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14662. "&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)
  14663. resp, requestErr := http.Get(api)
  14664. if requestErr != nil {
  14665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14666. return
  14667. }
  14668. body, ioErr := ioutil.ReadAll(resp.Body)
  14669. if ioErr != nil {
  14670. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14672. return
  14673. }
  14674. var respJSON map[string]interface{}
  14675. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14676. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14678. return
  14679. }
  14680. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14681. result, _ := json.Marshal(respJSON)
  14682. fmt.Println("log")
  14683. fmt.Println(string(result))
  14684. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14685. utils.ErrorLog("解析失败:%v", err)
  14686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14687. return
  14688. }
  14689. if res.Infcode == 0 {
  14690. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14691. if err == gorm.ErrRecordNotFound {
  14692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14693. return
  14694. } else if err != nil {
  14695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14696. return
  14697. } else {
  14698. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14699. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14700. infoStr := string(Iinfos)
  14701. idetinfoStr := string(Idetinfos)
  14702. psn := &models.HisPsn{
  14703. PsnNo: res.Output.Baseinfo.PsnNo,
  14704. PatientId: patient.ID,
  14705. Certno: res.Output.Baseinfo.Certno,
  14706. Gend: res.Output.Baseinfo.Gend,
  14707. Naty: res.Output.Baseinfo.Naty,
  14708. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14709. PsnName: res.Output.Baseinfo.PsnName,
  14710. Idetinfo: idetinfoStr,
  14711. Insuinfo: infoStr,
  14712. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14713. }
  14714. service.CreateHisPsn(psn)
  14715. c.ServeSuccessJSON(map[string]interface{}{
  14716. "patient": patient,
  14717. "number": res.Output.Baseinfo.Certno,
  14718. })
  14719. }
  14720. } else {
  14721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14722. return
  14723. }
  14724. } else if miConfig.MdtrtareaAdmvs == "421182" {
  14725. var res ResultTwo
  14726. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14727. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14728. "&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)
  14729. resp, requestErr := http.Get(api)
  14730. if requestErr != nil {
  14731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14732. return
  14733. }
  14734. body, ioErr := ioutil.ReadAll(resp.Body)
  14735. if ioErr != nil {
  14736. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14738. return
  14739. }
  14740. var respJSON map[string]interface{}
  14741. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14742. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14744. return
  14745. }
  14746. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14747. result, _ := json.Marshal(respJSON)
  14748. fmt.Println("log")
  14749. fmt.Println(string(result))
  14750. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14751. utils.ErrorLog("解析失败:%v", err)
  14752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14753. return
  14754. }
  14755. if res.Infcode == 0 {
  14756. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14757. if err == gorm.ErrRecordNotFound {
  14758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14759. return
  14760. } else if err != nil {
  14761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14762. return
  14763. } else {
  14764. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14765. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14766. infoStr := string(Iinfos)
  14767. idetinfoStr := string(Idetinfos)
  14768. psn := &models.HisPsn{
  14769. PsnNo: res.Output.Baseinfo.PsnNo,
  14770. PatientId: patient.ID,
  14771. Certno: res.Output.Baseinfo.Certno,
  14772. Gend: res.Output.Baseinfo.Gend,
  14773. Naty: res.Output.Baseinfo.Naty,
  14774. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14775. PsnName: res.Output.Baseinfo.PsnName,
  14776. Idetinfo: idetinfoStr,
  14777. Insuinfo: infoStr,
  14778. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14779. }
  14780. service.CreateHisPsn(psn)
  14781. c.ServeSuccessJSON(map[string]interface{}{
  14782. "patient": patient,
  14783. "number": res.Output.Baseinfo.Certno,
  14784. })
  14785. }
  14786. } else {
  14787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14788. return
  14789. }
  14790. } else if miConfig.MdtrtareaAdmvs == "420902" {
  14791. var res ResultTwo
  14792. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14793. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14794. "&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)
  14795. resp, requestErr := http.Get(api)
  14796. if requestErr != nil {
  14797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14798. return
  14799. }
  14800. body, ioErr := ioutil.ReadAll(resp.Body)
  14801. if ioErr != nil {
  14802. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14804. return
  14805. }
  14806. var respJSON map[string]interface{}
  14807. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14810. return
  14811. }
  14812. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14813. result, _ := json.Marshal(respJSON)
  14814. fmt.Println("log")
  14815. fmt.Println(string(result))
  14816. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14817. utils.ErrorLog("解析失败:%v", err)
  14818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14819. return
  14820. }
  14821. if res.Infcode == 0 {
  14822. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14823. if err == gorm.ErrRecordNotFound {
  14824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14825. return
  14826. } else if err != nil {
  14827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14828. return
  14829. } else {
  14830. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14831. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14832. infoStr := string(Iinfos)
  14833. idetinfoStr := string(Idetinfos)
  14834. var rf []*ResultFive
  14835. json.Unmarshal([]byte(infoStr), &rf)
  14836. var insutypes []*ResultFive
  14837. var insutype string
  14838. var is390 int = 0
  14839. var is310 int = 0
  14840. for _, item := range rf {
  14841. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14842. insutypes = append(insutypes, item)
  14843. }
  14844. }
  14845. if len(insutypes) == 1 {
  14846. insutype = insutypes[0].Insutype
  14847. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14848. } else {
  14849. for _, i := range insutypes {
  14850. if i.Insutype == "390" {
  14851. is390 = 1
  14852. }
  14853. if i.Insutype == "310" {
  14854. is310 = 1
  14855. }
  14856. }
  14857. }
  14858. if is390 == 1 {
  14859. insutype = "390"
  14860. }
  14861. if is310 == 1 {
  14862. insutype = "310"
  14863. }
  14864. if len(insutypes) == 0 {
  14865. insutype = "390"
  14866. }
  14867. var insuplc_admdvs string
  14868. for _, item := range rf {
  14869. if item.Insutype == insutype {
  14870. insuplc_admdvs = item.InsuplcAdmdvs
  14871. }
  14872. }
  14873. psn := &models.HisPsn{
  14874. PsnNo: res.Output.Baseinfo.PsnNo,
  14875. PatientId: patient.ID,
  14876. Certno: res.Output.Baseinfo.Certno,
  14877. Gend: res.Output.Baseinfo.Gend,
  14878. Naty: res.Output.Baseinfo.Naty,
  14879. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14880. PsnName: res.Output.Baseinfo.PsnName,
  14881. Idetinfo: idetinfoStr,
  14882. Insuinfo: infoStr,
  14883. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14884. InsuplcAdmdvs: insuplc_admdvs,
  14885. }
  14886. service.CreateHisPsn(psn)
  14887. c.ServeSuccessJSON(map[string]interface{}{
  14888. "patient": patient,
  14889. "number": res.Output.Baseinfo.Certno,
  14890. })
  14891. }
  14892. } else {
  14893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14894. return
  14895. }
  14896. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14897. res := c.GetoleInfo()
  14898. if res.Infcode == 0 {
  14899. var result string
  14900. if res.Output.MdtrtCertType == "01" {
  14901. 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)
  14902. } else if res.Output.MdtrtCertType == "02" {
  14903. 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)
  14904. } else if res.Output.MdtrtCertType == "03" {
  14905. 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)
  14906. }
  14907. var dat map[string]interface{}
  14908. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14909. fmt.Println(dat)
  14910. } else {
  14911. fmt.Println(err)
  14912. }
  14913. userJSONBytes, _ := json.Marshal(dat)
  14914. var res2 ResultTwo
  14915. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14916. utils.ErrorLog("解析失败:%v", err)
  14917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14918. return
  14919. }
  14920. if res2.Infcode == 0 {
  14921. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14922. if err == gorm.ErrRecordNotFound {
  14923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14924. return
  14925. } else if err != nil {
  14926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14927. return
  14928. } else {
  14929. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14930. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14931. infoStr := string(Iinfos)
  14932. idetinfoStr := string(Idetinfos)
  14933. var rf []*ResultFive
  14934. json.Unmarshal([]byte(infoStr), &rf)
  14935. var insutypes []*ResultFive
  14936. var insutype string
  14937. var is390 int = 0
  14938. var is310 int = 0
  14939. //var insuplc_admdvs string
  14940. for _, item := range rf {
  14941. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14942. insutypes = append(insutypes, item)
  14943. }
  14944. }
  14945. if len(insutypes) == 1 {
  14946. insutype = insutypes[0].Insutype
  14947. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14948. } else {
  14949. for _, i := range insutypes {
  14950. if i.Insutype == "390" {
  14951. is390 = 1
  14952. }
  14953. if i.Insutype == "310" {
  14954. is310 = 1
  14955. }
  14956. }
  14957. }
  14958. if is390 == 1 {
  14959. insutype = "390"
  14960. }
  14961. if is310 == 1 {
  14962. insutype = "310"
  14963. }
  14964. if len(insutypes) == 0 {
  14965. insutype = "310"
  14966. }
  14967. psn := &models.HisPsn{
  14968. PsnNo: res2.Output.Baseinfo.PsnNo,
  14969. PatientId: patient.ID,
  14970. //Brdy: res2.Output.Baseinfo.Brdy,
  14971. Certno: res2.Output.Baseinfo.Certno,
  14972. Gend: res2.Output.Baseinfo.Gend,
  14973. Naty: res2.Output.Baseinfo.Naty,
  14974. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14975. PsnName: res2.Output.Baseinfo.PsnName,
  14976. Idetinfo: idetinfoStr,
  14977. Insuinfo: infoStr,
  14978. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14979. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14980. VerifyNumber: res.Output.EcToken,
  14981. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14982. }
  14983. service.CreateHisPsn(psn)
  14984. var balc float64
  14985. for _, item := range rf {
  14986. if item.Insutype == insutype {
  14987. balc = item.Balc
  14988. }
  14989. }
  14990. c.ServeSuccessJSON(map[string]interface{}{
  14991. "patient": patient,
  14992. "number": res.Output.CardNo,
  14993. "insutype": insutype,
  14994. "blac": balc,
  14995. "desc": idetinfoStr,
  14996. })
  14997. }
  14998. } else {
  14999. c.ServeSuccessJSON(map[string]interface{}{
  15000. "failed_code": -10,
  15001. "msg": res2.ErrMsg,
  15002. })
  15003. }
  15004. } else {
  15005. c.ServeSuccessJSON(map[string]interface{}{
  15006. "failed_code": -10,
  15007. "msg": res.ErrMsg,
  15008. })
  15009. }
  15010. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15011. var insuplc_admdvs string
  15012. if len(patient.InsuplcAdmdvs) > 0 {
  15013. insuplc_admdvs = patient.InsuplcAdmdvs
  15014. } else {
  15015. if len(insuplc_admdvs_str) > 0 {
  15016. insuplc_admdvs = insuplc_admdvs_str
  15017. } else {
  15018. insuplc_admdvs = miConfig.InsuplcAdmdvs
  15019. }
  15020. }
  15021. //请求内网数据
  15022. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  15023. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15024. "&insuplc_admdvs=" + insuplc_admdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(2, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&name=" + patient.Name + "&token=" + ""
  15025. resp, requestErr := http.Get(api)
  15026. if requestErr != nil {
  15027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15028. return
  15029. }
  15030. body, ioErr := ioutil.ReadAll(resp.Body)
  15031. if ioErr != nil {
  15032. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15034. return
  15035. }
  15036. var respJSON map[string]interface{}
  15037. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15038. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15040. return
  15041. }
  15042. status := respJSON["data"].(map[string]interface{})["status"].(string)
  15043. if status == "0" {
  15044. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  15045. c.ServeSuccessJSON(map[string]interface{}{
  15046. "failed_code": -10,
  15047. "msg": err_msg,
  15048. })
  15049. return
  15050. }
  15051. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15052. var res ResultTwo
  15053. result, _ := json.Marshal(respJSON)
  15054. fmt.Println("log")
  15055. fmt.Println(string(result))
  15056. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15057. utils.ErrorLog("解析失败:%v", err)
  15058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15059. return
  15060. }
  15061. if res.Infcode == 0 {
  15062. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15063. if err == gorm.ErrRecordNotFound {
  15064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15065. return
  15066. } else if err != nil {
  15067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15068. return
  15069. } else {
  15070. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15071. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15072. infoStr := string(Iinfos)
  15073. idetinfoStr := string(Idetinfos)
  15074. psn := &models.HisPsn{
  15075. PsnNo: res.Output.Baseinfo.PsnNo,
  15076. PatientId: patient.ID,
  15077. Certno: res.Output.Baseinfo.Certno,
  15078. Gend: res.Output.Baseinfo.Gend,
  15079. Naty: res.Output.Baseinfo.Naty,
  15080. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15081. PsnName: res.Output.Baseinfo.PsnName,
  15082. Idetinfo: idetinfoStr,
  15083. Insuinfo: infoStr,
  15084. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15085. }
  15086. service.CreateHisPsn(psn)
  15087. var rf []*ResultFive
  15088. json.Unmarshal([]byte(infoStr), &rf)
  15089. var insutypes []*ResultFive
  15090. var is390 int = 0
  15091. var is310 int = 0
  15092. var insutype string
  15093. for _, item := range rf {
  15094. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15095. insutypes = append(insutypes, item)
  15096. }
  15097. }
  15098. if len(insutypes) == 1 {
  15099. insutype = insutypes[0].Insutype
  15100. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15101. } else {
  15102. for _, i := range insutypes {
  15103. if i.Insutype == "390" {
  15104. is390 = 1
  15105. }
  15106. if i.Insutype == "310" {
  15107. is310 = 1
  15108. }
  15109. }
  15110. }
  15111. if is390 == 1 {
  15112. insutype = "390"
  15113. }
  15114. if is310 == 1 {
  15115. insutype = "310"
  15116. }
  15117. if len(insutypes) == 0 {
  15118. insutype = "390"
  15119. }
  15120. c.ServeSuccessJSON(map[string]interface{}{
  15121. "patient": patient,
  15122. "insutype": insutype,
  15123. "number": res.Output.Baseinfo.Certno,
  15124. "info": res,
  15125. })
  15126. }
  15127. } else {
  15128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15129. return
  15130. }
  15131. } else {
  15132. SFZStr := c.GetSFZBaseInfo()
  15133. id_card_str := strings.Split(SFZStr, "^")
  15134. id_card_number := id_card_str[0]
  15135. card_sn := ""
  15136. 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)
  15137. var dat map[string]interface{}
  15138. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15139. fmt.Println(dat)
  15140. } else {
  15141. fmt.Println(err)
  15142. }
  15143. userJSONBytes, _ := json.Marshal(dat)
  15144. var res ResultTwo
  15145. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15146. utils.ErrorLog("解析失败:%v", err)
  15147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15148. return
  15149. }
  15150. if res.Infcode == 0 {
  15151. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  15152. if err == gorm.ErrRecordNotFound {
  15153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15154. return
  15155. } else if err != nil {
  15156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15157. return
  15158. } else {
  15159. c.ServeSuccessJSON(map[string]interface{}{
  15160. "patient": patient,
  15161. "number": id_card_number,
  15162. })
  15163. }
  15164. } else {
  15165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15166. return
  15167. }
  15168. }
  15169. break
  15170. case 3:
  15171. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15172. var api string
  15173. if miConfig.MdtrtareaAdmvs == "320921" {
  15174. 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 +
  15175. "&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
  15176. fmt.Println(api)
  15177. } else {
  15178. 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 +
  15179. "&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)
  15180. }
  15181. resp, requestErr := http.Get(api)
  15182. if requestErr != nil {
  15183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15184. return
  15185. }
  15186. body, ioErr := ioutil.ReadAll(resp.Body)
  15187. if ioErr != nil {
  15188. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15190. return
  15191. }
  15192. var respJSON map[string]interface{}
  15193. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15194. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15196. return
  15197. }
  15198. var status string
  15199. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15200. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15201. var token string
  15202. var res ResultTwo //1101结果
  15203. var res10265 ResultTwo10265 //1101结果
  15204. var card_info string //卡信息
  15205. var busi_card_info string
  15206. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15207. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15208. if status == "0" { //读卡成功
  15209. if card_type == "1" {
  15210. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15211. result, _ := json.Marshal(respJSON)
  15212. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15213. utils.ErrorLog("解析失败:%v", err)
  15214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15215. return
  15216. }
  15217. res.ErrMsg = res10265.ErrMsg
  15218. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15219. res.Infcode = infocode
  15220. res.Output = res10265.Output
  15221. res.InfRefmsgid = res10265.InfRefmsgid
  15222. } else {
  15223. //var card_info string //卡信息
  15224. //var busi_card_info string
  15225. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15226. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15227. //fmt.Println(card_info)
  15228. //fmt.Println(busi_card_info)
  15229. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15230. result, _ := json.Marshal(respJSON)
  15231. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15232. utils.ErrorLog("解析失败:%v", err)
  15233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15234. return
  15235. }
  15236. res.ErrMsg = res10265.ErrMsg
  15237. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15238. res.Infcode = infocode
  15239. res.Output = res10265.Output
  15240. res.InfRefmsgid = res10265.InfRefmsgid
  15241. }
  15242. if res.Infcode == 0 {
  15243. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15244. if err == gorm.ErrRecordNotFound {
  15245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15246. return
  15247. } else if err != nil {
  15248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15249. return
  15250. } else {
  15251. if card_type == "1" {
  15252. bas := strings.Split(card_info, "|")
  15253. basNumber := bas[2]
  15254. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15255. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15256. infoStr := string(Iinfos)
  15257. idetinfoStr := string(Idetinfos)
  15258. psn := &models.HisPsn{
  15259. PsnNo: res.Output.Baseinfo.PsnNo,
  15260. PatientId: patient.ID,
  15261. Certno: res.Output.Baseinfo.Certno,
  15262. //Brdy: res.Output.Baseinfo.Brdy,
  15263. Gend: res.Output.Baseinfo.Gend,
  15264. Naty: res.Output.Baseinfo.Naty,
  15265. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15266. PsnName: res.Output.Baseinfo.PsnName,
  15267. Idetinfo: idetinfoStr,
  15268. Insuinfo: infoStr,
  15269. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15270. CardInfo: card_info,
  15271. VerifyNumber: busi_card_info,
  15272. }
  15273. service.CreateHisPsn(psn)
  15274. c.ServeSuccessJSON(map[string]interface{}{
  15275. "patient": patient,
  15276. "number": basNumber,
  15277. })
  15278. } else {
  15279. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15280. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15281. infoStr := string(Iinfos)
  15282. idetinfoStr := string(Idetinfos)
  15283. psn := &models.HisPsn{
  15284. PsnNo: res.Output.Baseinfo.PsnNo,
  15285. PatientId: patient.ID,
  15286. Certno: res.Output.Baseinfo.Certno,
  15287. Gend: res.Output.Baseinfo.Gend,
  15288. Naty: res.Output.Baseinfo.Naty,
  15289. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15290. PsnName: res.Output.Baseinfo.PsnName,
  15291. Idetinfo: idetinfoStr,
  15292. Insuinfo: infoStr,
  15293. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15294. CardInfo: card_info,
  15295. VerifyNumber: token,
  15296. }
  15297. service.CreateHisPsn(psn)
  15298. var rf []*ResultFive
  15299. json.Unmarshal([]byte(infoStr), &rf)
  15300. var insutypes []*ResultFive
  15301. var insutype string
  15302. var is390 int = 0
  15303. var is310 int = 0
  15304. for _, item := range rf {
  15305. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15306. insutypes = append(insutypes, item)
  15307. }
  15308. }
  15309. if len(insutypes) == 1 {
  15310. insutype = insutypes[0].Insutype
  15311. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15312. } else {
  15313. for _, i := range insutypes {
  15314. if i.Insutype == "390" {
  15315. is390 = 1
  15316. }
  15317. if i.Insutype == "310" {
  15318. is310 = 1
  15319. }
  15320. }
  15321. }
  15322. if is390 == 1 {
  15323. insutype = "390"
  15324. }
  15325. if is310 == 1 {
  15326. insutype = "310"
  15327. }
  15328. if len(insutypes) == 0 {
  15329. insutype = "310"
  15330. }
  15331. c.ServeSuccessJSON(map[string]interface{}{
  15332. "patient": patient,
  15333. "number": token,
  15334. "insutype": insutype,
  15335. })
  15336. }
  15337. }
  15338. } else {
  15339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15340. return
  15341. }
  15342. } else { //读卡失败
  15343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15344. return
  15345. }
  15346. }
  15347. break
  15348. case 4:
  15349. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15350. var api string
  15351. if miConfig.MdtrtareaAdmvs == "320921" {
  15352. 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 +
  15353. "&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
  15354. fmt.Println(api)
  15355. } else {
  15356. 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 +
  15357. "&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)
  15358. }
  15359. resp, requestErr := http.Get(api)
  15360. if requestErr != nil {
  15361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15362. return
  15363. }
  15364. body, ioErr := ioutil.ReadAll(resp.Body)
  15365. if ioErr != nil {
  15366. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15368. return
  15369. }
  15370. var respJSON map[string]interface{}
  15371. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15372. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15374. return
  15375. }
  15376. var status string
  15377. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15378. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15379. var token string
  15380. var res ResultTwo //1101结果
  15381. var res10265 ResultTwo10265 //1101结果
  15382. if status == "0" { //读卡成功
  15383. var card_info string //卡信息
  15384. var busi_card_info string
  15385. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15386. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15387. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15388. fmt.Println(card_info)
  15389. fmt.Println(busi_card_info)
  15390. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15391. result, _ := json.Marshal(respJSON)
  15392. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15393. utils.ErrorLog("解析失败:%v", err)
  15394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15395. return
  15396. }
  15397. res.ErrMsg = res10265.ErrMsg
  15398. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15399. res.Infcode = infocode
  15400. res.Output = res10265.Output
  15401. res.InfRefmsgid = res10265.InfRefmsgid
  15402. if res.Infcode == 0 {
  15403. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15404. if err == gorm.ErrRecordNotFound {
  15405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15406. return
  15407. } else if err != nil {
  15408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15409. return
  15410. } else {
  15411. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15412. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15413. infoStr := string(Iinfos)
  15414. idetinfoStr := string(Idetinfos)
  15415. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  15416. psn := &models.HisPsn{
  15417. PsnNo: res.Output.Baseinfo.PsnNo,
  15418. PatientId: patient.ID,
  15419. Certno: res.Output.Baseinfo.Certno,
  15420. Brdy: b,
  15421. Age: float64(age),
  15422. //Brdy: res.Output.Baseinfo.Brdy,
  15423. Gend: res.Output.Baseinfo.Gend,
  15424. Naty: res.Output.Baseinfo.Naty,
  15425. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15426. PsnName: res.Output.Baseinfo.PsnName,
  15427. Idetinfo: idetinfoStr,
  15428. Insuinfo: infoStr,
  15429. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15430. CardInfo: card_info,
  15431. VerifyNumber: token,
  15432. }
  15433. var rf []*ResultFive
  15434. json.Unmarshal([]byte(infoStr), &rf)
  15435. var insutypes []*ResultFive
  15436. var insutype string
  15437. var is390 int = 0
  15438. var is310 int = 0
  15439. for _, item := range rf {
  15440. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15441. insutypes = append(insutypes, item)
  15442. }
  15443. }
  15444. if len(insutypes) == 1 {
  15445. insutype = insutypes[0].Insutype
  15446. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15447. } else {
  15448. for _, i := range insutypes {
  15449. if i.Insutype == "390" {
  15450. is390 = 1
  15451. }
  15452. if i.Insutype == "310" {
  15453. is310 = 1
  15454. }
  15455. }
  15456. }
  15457. if is390 == 1 {
  15458. insutype = "390"
  15459. }
  15460. if is310 == 1 {
  15461. insutype = "310"
  15462. }
  15463. if len(insutypes) == 0 {
  15464. insutype = "310"
  15465. }
  15466. service.CreateHisPsn(psn)
  15467. c.ServeSuccessJSON(map[string]interface{}{
  15468. "patient": patient,
  15469. "number": token,
  15470. "insutype": insutype,
  15471. })
  15472. }
  15473. } else {
  15474. c.ServeSuccessJSON(map[string]interface{}{
  15475. "failed_code": -10,
  15476. "msg": res.ErrMsg,
  15477. })
  15478. }
  15479. } else { //读卡失败
  15480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15481. return
  15482. }
  15483. } else if miConfig.MdtrtareaAdmvs == "341203" {
  15484. var api string
  15485. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15486. "&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
  15487. resp, requestErr := http.Get(api)
  15488. if requestErr != nil {
  15489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15490. return
  15491. }
  15492. body, ioErr := ioutil.ReadAll(resp.Body)
  15493. if ioErr != nil {
  15494. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15496. return
  15497. }
  15498. var respJSON map[string]interface{}
  15499. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15500. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15502. return
  15503. }
  15504. var status string
  15505. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15506. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15507. var token string
  15508. var res ResultTwo //1101结果
  15509. if status == "1" { //读卡成功
  15510. var card_info string //卡信息
  15511. var busi_card_info string
  15512. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15513. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15514. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15515. fmt.Println(card_info)
  15516. fmt.Println(busi_card_info)
  15517. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15518. result, _ := json.Marshal(respJSON)
  15519. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15520. utils.ErrorLog("解析失败:%v", err)
  15521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15522. return
  15523. }
  15524. if res.Infcode == 0 {
  15525. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15526. if err == gorm.ErrRecordNotFound {
  15527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15528. return
  15529. } else if err != nil {
  15530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15531. return
  15532. } else {
  15533. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15534. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15535. infoStr := string(Iinfos)
  15536. idetinfoStr := string(Idetinfos)
  15537. psn := &models.HisPsn{
  15538. PsnNo: res.Output.Baseinfo.PsnNo,
  15539. PatientId: patient.ID,
  15540. Certno: res.Output.Baseinfo.Certno,
  15541. Gend: res.Output.Baseinfo.Gend,
  15542. Naty: res.Output.Baseinfo.Naty,
  15543. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15544. PsnName: res.Output.Baseinfo.PsnName,
  15545. Idetinfo: idetinfoStr,
  15546. Insuinfo: infoStr,
  15547. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15548. CardInfo: card_info,
  15549. VerifyNumber: token,
  15550. }
  15551. var rf []*ResultFive
  15552. json.Unmarshal([]byte(infoStr), &rf)
  15553. var insutypes []*ResultFive
  15554. var insutype string
  15555. var is390 int = 0
  15556. var is310 int = 0
  15557. for _, item := range rf {
  15558. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15559. insutypes = append(insutypes, item)
  15560. }
  15561. }
  15562. if len(insutypes) == 1 {
  15563. insutype = insutypes[0].Insutype
  15564. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15565. } else {
  15566. for _, i := range insutypes {
  15567. if i.Insutype == "390" {
  15568. is390 = 1
  15569. }
  15570. if i.Insutype == "310" {
  15571. is310 = 1
  15572. }
  15573. }
  15574. }
  15575. if is390 == 1 {
  15576. insutype = "390"
  15577. }
  15578. if is310 == 1 {
  15579. insutype = "310"
  15580. }
  15581. if len(insutypes) == 0 {
  15582. insutype = "310"
  15583. }
  15584. service.CreateHisPsn(psn)
  15585. c.ServeSuccessJSON(map[string]interface{}{
  15586. "patient": patient,
  15587. "number": token,
  15588. "insutype": insutype,
  15589. })
  15590. }
  15591. } else {
  15592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15593. return
  15594. }
  15595. } else { //读卡失败
  15596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15597. return
  15598. }
  15599. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15600. var api string
  15601. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15602. "&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
  15603. resp, requestErr := http.Get(api)
  15604. if requestErr != nil {
  15605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15606. return
  15607. }
  15608. body, ioErr := ioutil.ReadAll(resp.Body)
  15609. if ioErr != nil {
  15610. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15612. return
  15613. }
  15614. var respJSON map[string]interface{}
  15615. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15616. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15618. return
  15619. }
  15620. var status string
  15621. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15622. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15623. var token string
  15624. var res ResultTwo //1101结果
  15625. if status == "1" { //读卡成功
  15626. var card_info string //卡信息
  15627. var busi_card_info string
  15628. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15629. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15630. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15631. fmt.Println(card_info)
  15632. fmt.Println(busi_card_info)
  15633. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15634. result, _ := json.Marshal(respJSON)
  15635. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15636. utils.ErrorLog("解析失败:%v", err)
  15637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15638. return
  15639. }
  15640. if res.Infcode == 0 {
  15641. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15642. if err == gorm.ErrRecordNotFound {
  15643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15644. return
  15645. } else if err != nil {
  15646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15647. return
  15648. } else {
  15649. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15650. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15651. infoStr := string(Iinfos)
  15652. idetinfoStr := string(Idetinfos)
  15653. psn := &models.HisPsn{
  15654. PsnNo: res.Output.Baseinfo.PsnNo,
  15655. PatientId: patient.ID,
  15656. Certno: res.Output.Baseinfo.Certno,
  15657. Gend: res.Output.Baseinfo.Gend,
  15658. Naty: res.Output.Baseinfo.Naty,
  15659. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15660. PsnName: res.Output.Baseinfo.PsnName,
  15661. Idetinfo: idetinfoStr,
  15662. Insuinfo: infoStr,
  15663. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15664. CardInfo: card_info,
  15665. VerifyNumber: token,
  15666. }
  15667. var rf []*ResultFive
  15668. json.Unmarshal([]byte(infoStr), &rf)
  15669. var insutypes []*ResultFive
  15670. var insutype string
  15671. var is390 int = 0
  15672. var is310 int = 0
  15673. for _, item := range rf {
  15674. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15675. insutypes = append(insutypes, item)
  15676. }
  15677. }
  15678. if len(insutypes) == 1 {
  15679. insutype = insutypes[0].Insutype
  15680. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15681. } else {
  15682. for _, i := range insutypes {
  15683. if i.Insutype == "390" {
  15684. is390 = 1
  15685. }
  15686. if i.Insutype == "310" {
  15687. is310 = 1
  15688. }
  15689. }
  15690. }
  15691. if is390 == 1 {
  15692. insutype = "390"
  15693. }
  15694. if is310 == 1 {
  15695. insutype = "310"
  15696. }
  15697. if len(insutypes) == 0 {
  15698. insutype = "310"
  15699. }
  15700. service.CreateHisPsn(psn)
  15701. c.ServeSuccessJSON(map[string]interface{}{
  15702. "patient": patient,
  15703. "number": token,
  15704. "insutype": insutype,
  15705. })
  15706. }
  15707. } else {
  15708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15709. return
  15710. }
  15711. } else { //读卡失败
  15712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15713. return
  15714. }
  15715. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15716. //idNo := c.GetString("idNo")
  15717. //userName := c.GetString("userName")
  15718. //ecToken := c.GetString("ecToken")
  15719. //insuOrg := c.GetString("insuOrg")
  15720. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  15721. utils.ErrorLog("解析失败:%v", json_result)
  15722. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15723. type ELeData struct {
  15724. Data struct {
  15725. IdNo string `json:"idNo"`
  15726. IdType string `json:"idType"`
  15727. UserName string `json:"userName"`
  15728. EcToken string `json:"ecToken"`
  15729. InsuOrg string `json:"insuOrg"`
  15730. Gender string `json:"gender"`
  15731. Birthday string `json:"birthday"`
  15732. Nationality string `json:"nationality"`
  15733. Email string `json:"email"`
  15734. Extra string `json:"extra"`
  15735. } `json:"data"`
  15736. Code int `json:"code"`
  15737. Message string `json:"message"`
  15738. }
  15739. var ele ELeData
  15740. err := json.Unmarshal([]byte(json_result), &ele)
  15741. if err != nil {
  15742. utils.ErrorLog("解析失败:%v", err)
  15743. }
  15744. token := ele.Data.EcToken
  15745. token = Remove0000(token)
  15746. 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)
  15747. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15748. var res ResultTwo
  15749. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15750. utils.ErrorLog("解析失败:%v", err)
  15751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15752. return
  15753. }
  15754. if res.Infcode == 0 {
  15755. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15756. if err == gorm.ErrRecordNotFound {
  15757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15758. return
  15759. } else if err != nil {
  15760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15761. return
  15762. } else {
  15763. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15764. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15765. infoStr := string(Iinfos)
  15766. idetinfoStr := string(Idetinfos)
  15767. psn := &models.HisPsn{
  15768. PsnNo: res.Output.Baseinfo.PsnNo,
  15769. PatientId: patient.ID,
  15770. Certno: res.Output.Baseinfo.Certno,
  15771. Gend: res.Output.Baseinfo.Gend,
  15772. Naty: res.Output.Baseinfo.Naty,
  15773. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15774. PsnName: res.Output.Baseinfo.PsnName,
  15775. Idetinfo: idetinfoStr,
  15776. Insuinfo: infoStr,
  15777. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15778. CardInfo: "",
  15779. Stage: "1",
  15780. VerifyNumber: token,
  15781. InsuplcAdmdvs: ele.Data.InsuOrg,
  15782. }
  15783. service.CreateHisPsn(psn)
  15784. var rf []*ResultFive
  15785. json.Unmarshal([]byte(infoStr), &rf)
  15786. var insutypes []*ResultFive
  15787. var insutype string
  15788. var is390 int = 0
  15789. var is310 int = 0
  15790. for _, item := range rf {
  15791. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15792. insutypes = append(insutypes, item)
  15793. }
  15794. }
  15795. if len(insutypes) == 1 {
  15796. insutype = insutypes[0].Insutype
  15797. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15798. } else {
  15799. for _, i := range insutypes {
  15800. if i.Insutype == "390" {
  15801. is390 = 1
  15802. }
  15803. if i.Insutype == "310" {
  15804. is310 = 1
  15805. }
  15806. }
  15807. }
  15808. if is390 == 1 {
  15809. insutype = "390"
  15810. }
  15811. if is310 == 1 {
  15812. insutype = "310"
  15813. }
  15814. if len(insutypes) == 0 {
  15815. insutype = "310"
  15816. }
  15817. c.ServeSuccessJSON(map[string]interface{}{
  15818. "patient": patient,
  15819. "number": token,
  15820. "insutype": insutype,
  15821. })
  15822. }
  15823. } else {
  15824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15825. return
  15826. }
  15827. } else if miConfig.MdtrtareaAdmvs == "360302" {
  15828. //if initFlag == 0 {
  15829. //c.TestGetJiangXiBasBaseInit()
  15830. //}
  15831. //if initEleFlag == 0 {
  15832. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15833. //}
  15834. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15835. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15836. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15837. type ELeData struct {
  15838. Data struct {
  15839. IdNo string `json:"idNo"`
  15840. IdType string `json:"idType"`
  15841. UserName string `json:"userName"`
  15842. EcToken string `json:"ecToken"`
  15843. InsuOrg string `json:"insuOrg"`
  15844. Gender string `json:"gender"`
  15845. Birthday string `json:"birthday"`
  15846. Nationality string `json:"nationality"`
  15847. Email string `json:"email"`
  15848. Extra string `json:"extra"`
  15849. } `json:"data"`
  15850. Code int `json:"code"`
  15851. Message string `json:"message"`
  15852. }
  15853. var ele ELeData
  15854. err := json.Unmarshal([]byte(result), &ele)
  15855. if err != nil {
  15856. utils.ErrorLog("解析失败:%v", err)
  15857. }
  15858. token := ele.Data.EcToken
  15859. token = Remove0000(token)
  15860. 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)
  15861. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15862. var res ResultTwo
  15863. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15864. utils.ErrorLog("解析失败:%v", err)
  15865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15866. return
  15867. }
  15868. if res.Infcode == 0 {
  15869. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15870. if err == gorm.ErrRecordNotFound {
  15871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15872. return
  15873. } else if err != nil {
  15874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15875. return
  15876. } else {
  15877. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15878. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15879. infoStr := string(Iinfos)
  15880. idetinfoStr := string(Idetinfos)
  15881. psn := &models.HisPsn{
  15882. PsnNo: res.Output.Baseinfo.PsnNo,
  15883. PatientId: patient.ID,
  15884. Certno: res.Output.Baseinfo.Certno,
  15885. Gend: res.Output.Baseinfo.Gend,
  15886. Naty: res.Output.Baseinfo.Naty,
  15887. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15888. PsnName: res.Output.Baseinfo.PsnName,
  15889. Idetinfo: idetinfoStr,
  15890. Insuinfo: infoStr,
  15891. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15892. CardInfo: "",
  15893. VerifyNumber: token,
  15894. InsuplcAdmdvs: ele.Data.InsuOrg,
  15895. }
  15896. service.CreateHisPsn(psn)
  15897. var rf []*ResultFive
  15898. json.Unmarshal([]byte(infoStr), &rf)
  15899. var insutypes []*ResultFive
  15900. var insutype string
  15901. var is390 int = 0
  15902. var is310 int = 0
  15903. for _, item := range rf {
  15904. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15905. insutypes = append(insutypes, item)
  15906. }
  15907. }
  15908. if len(insutypes) == 1 {
  15909. insutype = insutypes[0].Insutype
  15910. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15911. } else {
  15912. for _, i := range insutypes {
  15913. if i.Insutype == "390" {
  15914. is390 = 1
  15915. }
  15916. if i.Insutype == "310" {
  15917. is310 = 1
  15918. }
  15919. }
  15920. }
  15921. if is390 == 1 {
  15922. insutype = "390"
  15923. }
  15924. if is310 == 1 {
  15925. insutype = "310"
  15926. }
  15927. if len(insutypes) == 0 {
  15928. insutype = "310"
  15929. }
  15930. c.ServeSuccessJSON(map[string]interface{}{
  15931. "patient": patient,
  15932. "number": token,
  15933. "insutype": insutype,
  15934. })
  15935. }
  15936. } else {
  15937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15938. return
  15939. }
  15940. } else if miConfig.MdtrtareaAdmvs == "361025" {
  15941. //if initFlag == 0 {
  15942. //c.TestGetJiangXiBasBaseInit()
  15943. //}
  15944. //if initEleFlag == 0 {
  15945. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15946. //}
  15947. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15948. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15949. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15950. type ELeData struct {
  15951. Data struct {
  15952. IdNo string `json:"idNo"`
  15953. IdType string `json:"idType"`
  15954. UserName string `json:"userName"`
  15955. EcToken string `json:"ecToken"`
  15956. InsuOrg string `json:"insuOrg"`
  15957. Gender string `json:"gender"`
  15958. Birthday string `json:"birthday"`
  15959. Nationality string `json:"nationality"`
  15960. Email string `json:"email"`
  15961. Extra string `json:"extra"`
  15962. } `json:"data"`
  15963. Code int `json:"code"`
  15964. Message string `json:"message"`
  15965. }
  15966. var ele ELeData
  15967. err := json.Unmarshal([]byte(result), &ele)
  15968. if err != nil {
  15969. utils.ErrorLog("解析失败:%v", err)
  15970. }
  15971. token := ele.Data.EcToken
  15972. token = Remove0000(token)
  15973. 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)
  15974. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15975. var res ResultTwo
  15976. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15977. utils.ErrorLog("解析失败:%v", err)
  15978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15979. return
  15980. }
  15981. if res.Infcode == 0 {
  15982. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15983. if err == gorm.ErrRecordNotFound {
  15984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15985. return
  15986. } else if err != nil {
  15987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15988. return
  15989. } else {
  15990. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15991. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15992. infoStr := string(Iinfos)
  15993. idetinfoStr := string(Idetinfos)
  15994. psn := &models.HisPsn{
  15995. PsnNo: res.Output.Baseinfo.PsnNo,
  15996. PatientId: patient.ID,
  15997. Certno: res.Output.Baseinfo.Certno,
  15998. Gend: res.Output.Baseinfo.Gend,
  15999. Naty: res.Output.Baseinfo.Naty,
  16000. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16001. PsnName: res.Output.Baseinfo.PsnName,
  16002. Idetinfo: idetinfoStr,
  16003. Insuinfo: infoStr,
  16004. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16005. CardInfo: "",
  16006. VerifyNumber: token,
  16007. InsuplcAdmdvs: ele.Data.InsuOrg,
  16008. }
  16009. service.CreateHisPsn(psn)
  16010. var rf []*ResultFive
  16011. json.Unmarshal([]byte(infoStr), &rf)
  16012. var insutypes []*ResultFive
  16013. var insutype string
  16014. var is390 int = 0
  16015. var is310 int = 0
  16016. for _, item := range rf {
  16017. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16018. insutypes = append(insutypes, item)
  16019. }
  16020. }
  16021. if len(insutypes) == 1 {
  16022. insutype = insutypes[0].Insutype
  16023. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16024. } else {
  16025. for _, i := range insutypes {
  16026. if i.Insutype == "390" {
  16027. is390 = 1
  16028. }
  16029. if i.Insutype == "310" {
  16030. is310 = 1
  16031. }
  16032. }
  16033. }
  16034. if is390 == 1 {
  16035. insutype = "390"
  16036. }
  16037. if is310 == 1 {
  16038. insutype = "310"
  16039. }
  16040. if len(insutypes) == 0 {
  16041. insutype = "310"
  16042. }
  16043. c.ServeSuccessJSON(map[string]interface{}{
  16044. "patient": patient,
  16045. "number": token,
  16046. "insutype": insutype,
  16047. })
  16048. }
  16049. } else {
  16050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16051. return
  16052. }
  16053. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16054. //if initFlag == 0 {
  16055. c.TestGetJiangXiBasBaseInit()
  16056. //}
  16057. //if initEleFlag == 0 {
  16058. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16059. //}
  16060. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16061. type ELeData struct {
  16062. Data struct {
  16063. IdNo string `json:"idNo"`
  16064. IdType string `json:"idType"`
  16065. UserName string `json:"userName"`
  16066. EcToken string `json:"ecToken"`
  16067. InsuOrg string `json:"insuOrg"`
  16068. Gender string `json:"gender"`
  16069. Birthday string `json:"birthday"`
  16070. Nationality string `json:"nationality"`
  16071. Email string `json:"email"`
  16072. Extra string `json:"extra"`
  16073. } `json:"data"`
  16074. Code int `json:"code"`
  16075. Message string `json:"message"`
  16076. }
  16077. var ele ELeData
  16078. err := json.Unmarshal([]byte(json_result), &ele)
  16079. if err != nil {
  16080. utils.ErrorLog("解析失败:%v", err)
  16081. }
  16082. token := ele.Data.EcToken
  16083. token = Remove0000(token)
  16084. 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)
  16085. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16086. var res ResultTwo
  16087. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16088. utils.ErrorLog("解析失败:%v", err)
  16089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16090. return
  16091. }
  16092. if res.Infcode == 0 {
  16093. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16094. if err == gorm.ErrRecordNotFound {
  16095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16096. return
  16097. } else if err != nil {
  16098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16099. return
  16100. } else {
  16101. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16102. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16103. infoStr := string(Iinfos)
  16104. idetinfoStr := string(Idetinfos)
  16105. psn := &models.HisPsn{
  16106. PsnNo: res.Output.Baseinfo.PsnNo,
  16107. PatientId: patient.ID,
  16108. Certno: res.Output.Baseinfo.Certno,
  16109. Gend: res.Output.Baseinfo.Gend,
  16110. Naty: res.Output.Baseinfo.Naty,
  16111. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16112. PsnName: res.Output.Baseinfo.PsnName,
  16113. Idetinfo: idetinfoStr,
  16114. Insuinfo: infoStr,
  16115. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16116. CardInfo: "",
  16117. VerifyNumber: token,
  16118. }
  16119. service.CreateHisPsn(psn)
  16120. var rf []*ResultFive
  16121. json.Unmarshal([]byte(infoStr), &rf)
  16122. var insutypes []*ResultFive
  16123. var insutype string
  16124. var is390 int = 0
  16125. var is310 int = 0
  16126. for _, item := range rf {
  16127. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16128. insutypes = append(insutypes, item)
  16129. }
  16130. }
  16131. if len(insutypes) == 1 {
  16132. insutype = insutypes[0].Insutype
  16133. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16134. } else {
  16135. for _, i := range insutypes {
  16136. if i.Insutype == "390" {
  16137. is390 = 1
  16138. }
  16139. if i.Insutype == "310" {
  16140. is310 = 1
  16141. }
  16142. }
  16143. }
  16144. if is390 == 1 {
  16145. insutype = "390"
  16146. }
  16147. if is310 == 1 {
  16148. insutype = "310"
  16149. }
  16150. if len(insutypes) == 0 {
  16151. insutype = "310"
  16152. }
  16153. c.ServeSuccessJSON(map[string]interface{}{
  16154. "patient": patient,
  16155. "number": token,
  16156. "insutype": insutype,
  16157. })
  16158. }
  16159. } else {
  16160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16161. return
  16162. }
  16163. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16164. type ELeData struct {
  16165. Code string `json:"code"`
  16166. Data struct {
  16167. Aac002 string `json:"aac002"`
  16168. Aaz500 string `json:"aaz500"`
  16169. ActCardNo string `json:"actCardNo"`
  16170. Bab520 string `json:"bab520"`
  16171. Bkz543 string `json:"bkz543"`
  16172. BusinessType string `json:"businessType"`
  16173. CertfCodg string `json:"certfCodg"`
  16174. EcIndexNo string `json:"ecIndexNo"`
  16175. EcToken string `json:"ecToken"`
  16176. ID0000 string `json:"id0000"`
  16177. IDNo string `json:"idNo"`
  16178. IDType string `json:"idType"`
  16179. Idcode string `json:"idcode"`
  16180. IdentityToken string `json:"identity_token"`
  16181. InsuOrg string `json:"insuOrg"`
  16182. OfficeID string `json:"officeId"`
  16183. OfficeName string `json:"officeName"`
  16184. OperatorID string `json:"operatorId"`
  16185. OperatorName string `json:"operatorName"`
  16186. OrgID string `json:"orgId"`
  16187. UserName string `json:"userName"`
  16188. } `json:"data"`
  16189. Infno interface{} `json:"infno"`
  16190. Message string `json:"message"`
  16191. OrgID string `json:"orgId"`
  16192. TransType string `json:"transType"`
  16193. }
  16194. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  16195. outPutInfo = Remove0000(outPutInfo)
  16196. if len(outPutInfo) > 0 {
  16197. var ele ELeData
  16198. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16199. if err != nil {
  16200. utils.ErrorLog("解析失败:%v", err)
  16201. }
  16202. token := ele.Data.EcToken
  16203. fmt.Println(inputInfo)
  16204. fmt.Println(outPutInfo)
  16205. 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)
  16206. saveLog(result, requestLog, "1101", "获取人员信息")
  16207. var dat map[string]interface{}
  16208. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16209. fmt.Println(dat)
  16210. } else {
  16211. fmt.Println(err)
  16212. }
  16213. userJSONBytes, _ := json.Marshal(dat)
  16214. var res ResultTwo
  16215. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16216. utils.ErrorLog("解析失败:%v", err)
  16217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16218. return
  16219. }
  16220. res.ErrMsg = errMsgLog
  16221. if res.Infcode == 0 {
  16222. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16223. if err == gorm.ErrRecordNotFound {
  16224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16225. return
  16226. } else if err != nil {
  16227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16228. return
  16229. } else {
  16230. fmt.Println(res)
  16231. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16232. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16233. infoStr := string(Iinfos)
  16234. idetinfoStr := string(Idetinfos)
  16235. psn := &models.HisPsn{
  16236. PsnNo: res.Output.Baseinfo.PsnNo,
  16237. PatientId: patient.ID,
  16238. Certno: res.Output.Baseinfo.Certno,
  16239. Gend: res.Output.Baseinfo.Gend,
  16240. Naty: res.Output.Baseinfo.Naty,
  16241. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16242. PsnName: res.Output.Baseinfo.PsnName,
  16243. Idetinfo: idetinfoStr,
  16244. Insuinfo: infoStr,
  16245. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16246. CardInfo: outPutInfo,
  16247. VerifyNumber: token,
  16248. InsuplcAdmdvs: ele.Data.InsuOrg,
  16249. }
  16250. service.CreateHisPsn(psn)
  16251. var rf []*ResultFive
  16252. json.Unmarshal([]byte(infoStr), &rf)
  16253. var insutypes []*ResultFive
  16254. var insutype string
  16255. var is390 int = 0
  16256. var is310 int = 0
  16257. for _, item := range rf {
  16258. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16259. insutypes = append(insutypes, item)
  16260. }
  16261. }
  16262. if len(insutypes) == 1 {
  16263. insutype = insutypes[0].Insutype
  16264. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16265. } else {
  16266. for _, i := range insutypes {
  16267. if i.Insutype == "390" {
  16268. is390 = 1
  16269. }
  16270. if i.Insutype == "310" {
  16271. is310 = 1
  16272. }
  16273. }
  16274. }
  16275. if is390 == 1 {
  16276. insutype = "390"
  16277. }
  16278. if is310 == 1 {
  16279. insutype = "310"
  16280. }
  16281. if len(insutypes) == 0 {
  16282. insutype = "310"
  16283. }
  16284. c.ServeSuccessJSON(map[string]interface{}{
  16285. "patient": patient,
  16286. "number": token,
  16287. "insutype": insutype,
  16288. })
  16289. }
  16290. } else {
  16291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16292. return
  16293. }
  16294. }
  16295. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16296. var api string
  16297. 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 +
  16298. "&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
  16299. resp, requestErr := http.Get(api)
  16300. if requestErr != nil {
  16301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16302. return
  16303. }
  16304. body, ioErr := ioutil.ReadAll(resp.Body)
  16305. if ioErr != nil {
  16306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16308. return
  16309. }
  16310. var respJSON map[string]interface{}
  16311. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16314. return
  16315. }
  16316. var status string
  16317. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16318. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16319. var token string
  16320. var res ResultTwo //1101结果
  16321. var res10265 ResultTwo10265 //1101结果
  16322. if status == "0" { //读卡成功
  16323. var card_info string //卡信息
  16324. var busi_card_info string
  16325. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16326. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16327. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16328. fmt.Println(card_info)
  16329. fmt.Println(busi_card_info)
  16330. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16331. result, _ := json.Marshal(respJSON)
  16332. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16333. utils.ErrorLog("解析失败:%v", err)
  16334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16335. return
  16336. }
  16337. res.ErrMsg = res10265.ErrMsg
  16338. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16339. res.Infcode = infocode
  16340. res.Output = res10265.Output
  16341. res.InfRefmsgid = res10265.InfRefmsgid
  16342. if res.Infcode == 0 {
  16343. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16344. if err == gorm.ErrRecordNotFound {
  16345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16346. return
  16347. } else if err != nil {
  16348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16349. return
  16350. } else {
  16351. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16352. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16353. infoStr := string(Iinfos)
  16354. idetinfoStr := string(Idetinfos)
  16355. psn := &models.HisPsn{
  16356. PsnNo: res.Output.Baseinfo.PsnNo,
  16357. PatientId: patient.ID,
  16358. Certno: res.Output.Baseinfo.Certno,
  16359. Gend: res.Output.Baseinfo.Gend,
  16360. Naty: res.Output.Baseinfo.Naty,
  16361. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16362. PsnName: res.Output.Baseinfo.PsnName,
  16363. Idetinfo: idetinfoStr,
  16364. Insuinfo: infoStr,
  16365. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16366. CardInfo: card_info,
  16367. VerifyNumber: token,
  16368. }
  16369. var rf []*ResultFive
  16370. json.Unmarshal([]byte(infoStr), &rf)
  16371. var insutypes []*ResultFive
  16372. var insutype string
  16373. var is390 int = 0
  16374. var is310 int = 0
  16375. for _, item := range rf {
  16376. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16377. insutypes = append(insutypes, item)
  16378. }
  16379. }
  16380. if len(insutypes) == 1 {
  16381. insutype = insutypes[0].Insutype
  16382. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16383. } else {
  16384. for _, i := range insutypes {
  16385. if i.Insutype == "390" {
  16386. is390 = 1
  16387. }
  16388. if i.Insutype == "310" {
  16389. is310 = 1
  16390. }
  16391. }
  16392. }
  16393. if is390 == 1 {
  16394. insutype = "390"
  16395. }
  16396. if is310 == 1 {
  16397. insutype = "310"
  16398. }
  16399. if len(insutypes) == 0 {
  16400. insutype = "310"
  16401. }
  16402. service.CreateHisPsn(psn)
  16403. c.ServeSuccessJSON(map[string]interface{}{
  16404. "patient": patient,
  16405. "number": token,
  16406. "insutype": insutype,
  16407. })
  16408. }
  16409. } else {
  16410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16411. return
  16412. }
  16413. } else { //读卡失败
  16414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16415. return
  16416. }
  16417. } else if miConfig.MdtrtareaAdmvs == "450721" {
  16418. res := c.GetoleInfo()
  16419. if res.Infcode == 0 {
  16420. var result string
  16421. if res.Output.MdtrtCertType == "01" {
  16422. 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)
  16423. } else if res.Output.MdtrtCertType == "02" {
  16424. 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)
  16425. } else if res.Output.MdtrtCertType == "03" {
  16426. 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)
  16427. }
  16428. var dat map[string]interface{}
  16429. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16430. fmt.Println(dat)
  16431. } else {
  16432. fmt.Println(err)
  16433. }
  16434. userJSONBytes, _ := json.Marshal(dat)
  16435. var res2 ResultTwo
  16436. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  16437. utils.ErrorLog("解析失败:%v", err)
  16438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16439. return
  16440. }
  16441. if res2.Infcode == 0 {
  16442. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  16443. if err == gorm.ErrRecordNotFound {
  16444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16445. return
  16446. } else if err != nil {
  16447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16448. return
  16449. } else {
  16450. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  16451. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  16452. infoStr := string(Iinfos)
  16453. idetinfoStr := string(Idetinfos)
  16454. var rf []*ResultFive
  16455. json.Unmarshal([]byte(infoStr), &rf)
  16456. var insutypes []*ResultFive
  16457. var insutype string
  16458. var is390 int = 0
  16459. var is310 int = 0
  16460. //var insuplc_admdvs string
  16461. for _, item := range rf {
  16462. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16463. insutypes = append(insutypes, item)
  16464. }
  16465. }
  16466. if len(insutypes) == 1 {
  16467. insutype = insutypes[0].Insutype
  16468. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16469. } else {
  16470. for _, i := range insutypes {
  16471. if i.Insutype == "390" {
  16472. is390 = 1
  16473. }
  16474. if i.Insutype == "310" {
  16475. is310 = 1
  16476. }
  16477. }
  16478. }
  16479. if is390 == 1 {
  16480. insutype = "390"
  16481. }
  16482. if is310 == 1 {
  16483. insutype = "310"
  16484. }
  16485. if len(insutypes) == 0 {
  16486. insutype = "310"
  16487. }
  16488. psn := &models.HisPsn{
  16489. PsnNo: res2.Output.Baseinfo.PsnNo,
  16490. PatientId: patient.ID,
  16491. Certno: res2.Output.Baseinfo.Certno,
  16492. Gend: res2.Output.Baseinfo.Gend,
  16493. Naty: res2.Output.Baseinfo.Naty,
  16494. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  16495. PsnName: res2.Output.Baseinfo.PsnName,
  16496. Idetinfo: idetinfoStr,
  16497. Insuinfo: infoStr,
  16498. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16499. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  16500. VerifyNumber: res.Output.EcToken,
  16501. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  16502. }
  16503. if res.Output.MdtrtCertType == "01" {
  16504. psn.VerifyNumber = res.Output.EcToken
  16505. //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)
  16506. } else if res.Output.MdtrtCertType == "02" {
  16507. psn.VerifyNumber = res.Output.CardNo
  16508. //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)
  16509. } else if res.Output.MdtrtCertType == "03" {
  16510. psn.VerifyNumber = res.Output.MdtrtCertNo
  16511. //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)
  16512. }
  16513. service.CreateHisPsn(psn)
  16514. var balc float64
  16515. for _, item := range rf {
  16516. if item.Insutype == insutype {
  16517. balc = item.Balc
  16518. }
  16519. }
  16520. c.ServeSuccessJSON(map[string]interface{}{
  16521. "patient": patient,
  16522. "number": res.Output.CardNo,
  16523. "insutype": insutype,
  16524. "blac": balc,
  16525. "desc": idetinfoStr,
  16526. })
  16527. }
  16528. } else {
  16529. c.ServeSuccessJSON(map[string]interface{}{
  16530. "failed_code": -10,
  16531. "msg": res2.ErrMsg,
  16532. })
  16533. }
  16534. } else {
  16535. c.ServeSuccessJSON(map[string]interface{}{
  16536. "failed_code": -10,
  16537. "msg": res.ErrMsg,
  16538. })
  16539. }
  16540. } else if miConfig.MdtrtareaAdmvs == "420902" {
  16541. var res ResultTwo
  16542. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  16543. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16544. "&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)
  16545. resp, requestErr := http.Get(api)
  16546. if requestErr != nil {
  16547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16548. return
  16549. }
  16550. body, ioErr := ioutil.ReadAll(resp.Body)
  16551. if ioErr != nil {
  16552. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16554. return
  16555. }
  16556. var respJSON map[string]interface{}
  16557. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16558. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16560. return
  16561. }
  16562. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16563. result, _ := json.Marshal(respJSON)
  16564. fmt.Println("log")
  16565. fmt.Println(string(result))
  16566. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16567. utils.ErrorLog("解析失败:%v", err)
  16568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16569. return
  16570. }
  16571. if res.Infcode == 0 {
  16572. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16573. if err == gorm.ErrRecordNotFound {
  16574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16575. return
  16576. } else if err != nil {
  16577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16578. return
  16579. } else {
  16580. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16581. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16582. infoStr := string(Iinfos)
  16583. idetinfoStr := string(Idetinfos)
  16584. var rf []*ResultFive
  16585. json.Unmarshal([]byte(infoStr), &rf)
  16586. var insutypes []*ResultFive
  16587. var insutype string
  16588. var is390 int = 0
  16589. var is310 int = 0
  16590. for _, item := range rf {
  16591. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16592. insutypes = append(insutypes, item)
  16593. }
  16594. }
  16595. if len(insutypes) == 1 {
  16596. insutype = insutypes[0].Insutype
  16597. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16598. } else {
  16599. for _, i := range insutypes {
  16600. if i.Insutype == "390" {
  16601. is390 = 1
  16602. }
  16603. if i.Insutype == "310" {
  16604. is310 = 1
  16605. }
  16606. }
  16607. }
  16608. if is390 == 1 {
  16609. insutype = "390"
  16610. }
  16611. if is310 == 1 {
  16612. insutype = "310"
  16613. }
  16614. if len(insutypes) == 0 {
  16615. insutype = "390"
  16616. }
  16617. var insuplc_admdvs string
  16618. for _, item := range rf {
  16619. if item.Insutype == insutype {
  16620. insuplc_admdvs = item.InsuplcAdmdvs
  16621. }
  16622. }
  16623. psn := &models.HisPsn{
  16624. PsnNo: res.Output.Baseinfo.PsnNo,
  16625. PatientId: patient.ID,
  16626. Certno: res.Output.Baseinfo.Certno,
  16627. Gend: res.Output.Baseinfo.Gend,
  16628. Naty: res.Output.Baseinfo.Naty,
  16629. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16630. PsnName: res.Output.Baseinfo.PsnName,
  16631. Idetinfo: idetinfoStr,
  16632. Insuinfo: infoStr,
  16633. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16634. InsuplcAdmdvs: insuplc_admdvs,
  16635. }
  16636. service.CreateHisPsn(psn)
  16637. c.ServeSuccessJSON(map[string]interface{}{
  16638. "patient": patient,
  16639. "number": res.Output.Baseinfo.Certno,
  16640. })
  16641. }
  16642. } else {
  16643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16644. return
  16645. }
  16646. } else {
  16647. type ELeData struct {
  16648. Code string `json:"code"`
  16649. Data struct {
  16650. Aac002 string `json:"aac002"`
  16651. Aaz500 string `json:"aaz500"`
  16652. ActCardNo string `json:"actCardNo"`
  16653. Bab520 string `json:"bab520"`
  16654. Bkz543 string `json:"bkz543"`
  16655. BusinessType string `json:"businessType"`
  16656. CertfCodg string `json:"certfCodg"`
  16657. EcIndexNo string `json:"ecIndexNo"`
  16658. EcToken string `json:"ecToken"`
  16659. ID0000 string `json:"id0000"`
  16660. IDNo string `json:"idNo"`
  16661. IDType string `json:"idType"`
  16662. Idcode string `json:"idcode"`
  16663. IdentityToken string `json:"identity_token"`
  16664. InsuOrg string `json:"insuOrg"`
  16665. OfficeID string `json:"officeId"`
  16666. OfficeName string `json:"officeName"`
  16667. OperatorID string `json:"operatorId"`
  16668. OperatorName string `json:"operatorName"`
  16669. OrgID string `json:"orgId"`
  16670. UserName string `json:"userName"`
  16671. } `json:"data"`
  16672. Infno interface{} `json:"infno"`
  16673. Message string `json:"message"`
  16674. OrgID string `json:"orgId"`
  16675. TransType string `json:"transType"`
  16676. }
  16677. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  16678. fmt.Println(result)
  16679. outPutInfo := Remove0000(result)
  16680. fmt.Println(outPutInfo)
  16681. if len(outPutInfo) > 0 {
  16682. var ele ELeData
  16683. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16684. if err != nil {
  16685. utils.ErrorLog("解析失败:%v", err)
  16686. }
  16687. token := ele.Data.EcToken
  16688. fmt.Println(outPutInfo)
  16689. 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)
  16690. saveLog(result, requestLog, "1101", "获取人员信息")
  16691. var dat map[string]interface{}
  16692. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16693. fmt.Println(dat)
  16694. } else {
  16695. fmt.Println(err)
  16696. }
  16697. userJSONBytes, _ := json.Marshal(dat)
  16698. var res ResultTwo
  16699. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16700. utils.ErrorLog("解析失败:%v", err)
  16701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16702. return
  16703. }
  16704. if res.Infcode == 0 {
  16705. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16706. if err == gorm.ErrRecordNotFound {
  16707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16708. return
  16709. } else if err != nil {
  16710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16711. return
  16712. } else {
  16713. fmt.Println(res)
  16714. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16715. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16716. infoStr := string(Iinfos)
  16717. idetinfoStr := string(Idetinfos)
  16718. psn := &models.HisPsn{
  16719. PsnNo: res.Output.Baseinfo.PsnNo,
  16720. PatientId: patient.ID,
  16721. Certno: res.Output.Baseinfo.Certno,
  16722. Gend: res.Output.Baseinfo.Gend,
  16723. Naty: res.Output.Baseinfo.Naty,
  16724. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16725. PsnName: res.Output.Baseinfo.PsnName,
  16726. Idetinfo: idetinfoStr,
  16727. Insuinfo: infoStr,
  16728. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16729. CardInfo: outPutInfo,
  16730. VerifyNumber: token,
  16731. InsuplcAdmdvs: ele.Data.InsuOrg,
  16732. }
  16733. service.CreateHisPsn(psn)
  16734. var rf []*ResultFive
  16735. json.Unmarshal([]byte(infoStr), &rf)
  16736. var insutypes []*ResultFive
  16737. var insutype string
  16738. var is390 int = 0
  16739. var is310 int = 0
  16740. for _, item := range rf {
  16741. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16742. insutypes = append(insutypes, item)
  16743. }
  16744. }
  16745. if len(insutypes) == 1 {
  16746. insutype = insutypes[0].Insutype
  16747. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16748. } else {
  16749. for _, i := range insutypes {
  16750. if i.Insutype == "390" {
  16751. is390 = 1
  16752. }
  16753. if i.Insutype == "310" {
  16754. is310 = 1
  16755. }
  16756. }
  16757. }
  16758. if is390 == 1 {
  16759. insutype = "390"
  16760. }
  16761. if is310 == 1 {
  16762. insutype = "310"
  16763. }
  16764. if len(insutypes) == 0 {
  16765. insutype = "310"
  16766. }
  16767. c.ServeSuccessJSON(map[string]interface{}{
  16768. "patient": patient,
  16769. "number": token,
  16770. "insutype": insutype,
  16771. })
  16772. }
  16773. } else {
  16774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16775. return
  16776. }
  16777. }
  16778. //fmt.Println(result)
  16779. //
  16780. //if initFlag == 0 {
  16781. // c.TestGetBasBaseInit()
  16782. //}
  16783. //token := c.GetEleBaseInfo()
  16784. //
  16785. //token = Remove0000(token)
  16786. //
  16787. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  16788. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  16789. ////
  16790. //var res ResultTwo
  16791. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16792. // utils.ErrorLog("解析失败:%v", err)
  16793. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16794. // return
  16795. //}
  16796. //
  16797. //if res.Infcode == 0 {
  16798. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16799. // if err == gorm.ErrRecordNotFound {
  16800. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16801. // return
  16802. // } else if err != nil {
  16803. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16804. // return
  16805. //
  16806. // } else {
  16807. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16808. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16809. // infoStr := string(Iinfos)
  16810. // idetinfoStr := string(Idetinfos)
  16811. //
  16812. //
  16813. //
  16814. //
  16815. // var rf []*ResultFive
  16816. // json.Unmarshal([]byte(infoStr), &rf)
  16817. //
  16818. // var insutypes []*ResultFive
  16819. // var insutype string
  16820. // var is390 int = 0
  16821. // var is310 int = 0
  16822. // var insuplc_admdvs string
  16823. //
  16824. // for _, item := range rf {
  16825. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16826. // insutypes = append(insutypes, item)
  16827. // }
  16828. // }
  16829. //
  16830. // if len(insutypes) == 1 {
  16831. // insutype = insutypes[0].Insutype
  16832. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16833. // } else {
  16834. // for _, i := range insutypes {
  16835. // if i.Insutype == "390" {
  16836. // is390 = 1
  16837. // }
  16838. //
  16839. // if i.Insutype == "310" {
  16840. // is310 = 1
  16841. // }
  16842. // }
  16843. // }
  16844. // if is390 == 1 {
  16845. // insutype = "390"
  16846. // }
  16847. //
  16848. // if is310 == 1 {
  16849. // insutype = "310"
  16850. // }
  16851. // if len(insutypes) == 0 {
  16852. // insutype = "310"
  16853. // }
  16854. // for _, item := range rf {
  16855. // if item.Insutype == insutype {
  16856. // insuplc_admdvs = item.InsuplcAdmdvs
  16857. // }
  16858. // }
  16859. // psn := &models.HisPsn{
  16860. // PsnNo: res.Output.Baseinfo.PsnNo,
  16861. // Age: res.Output.Baseinfo.Age,
  16862. // PatientId: patient.ID,
  16863. // Certno: res.Output.Baseinfo.Certno,
  16864. // Brdy: res.Output.Baseinfo.Brdy,
  16865. // Gend: res.Output.Baseinfo.Gend,
  16866. // Naty: res.Output.Baseinfo.Naty,
  16867. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  16868. // PsnName: res.Output.Baseinfo.PsnName,
  16869. // Idetinfo: idetinfoStr,
  16870. // Insuinfo: infoStr,
  16871. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16872. // CardInfo: "",
  16873. // VerifyNumber: token,
  16874. // InsuplcAdmdvs: insuplc_admdvs,
  16875. // }
  16876. // service.CreateHisPsn(psn)
  16877. //
  16878. // c.ServeSuccessJSON(map[string]interface{}{
  16879. // "patient": patient,
  16880. // "number": token,
  16881. // })
  16882. // }
  16883. //} else {
  16884. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16885. // return
  16886. //}
  16887. }
  16888. break
  16889. case 5:
  16890. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16891. var api string
  16892. if miConfig.MdtrtareaAdmvs == "320921" {
  16893. 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 +
  16894. "&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
  16895. fmt.Println(api)
  16896. } else {
  16897. 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 +
  16898. "&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)
  16899. }
  16900. resp, requestErr := http.Get(api)
  16901. if requestErr != nil {
  16902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16903. return
  16904. }
  16905. body, ioErr := ioutil.ReadAll(resp.Body)
  16906. if ioErr != nil {
  16907. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16909. return
  16910. }
  16911. var respJSON map[string]interface{}
  16912. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16913. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16915. return
  16916. }
  16917. var status string
  16918. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16919. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16920. var token string
  16921. var res ResultTwo //1101结果
  16922. var res10265 ResultTwo10265 //1101结果
  16923. if status == "0" { //读卡成功
  16924. var card_info string //卡信息
  16925. //var busi_card_info string
  16926. var auth_info string
  16927. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16928. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16929. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16930. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  16931. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16932. result, _ := json.Marshal(respJSON)
  16933. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16934. utils.ErrorLog("解析失败:%v", err)
  16935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16936. return
  16937. }
  16938. res.ErrMsg = res10265.ErrMsg
  16939. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16940. res.Infcode = infocode
  16941. res.Output = res10265.Output
  16942. res.InfRefmsgid = res10265.InfRefmsgid
  16943. if res.Infcode == 0 {
  16944. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16945. if err == gorm.ErrRecordNotFound {
  16946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16947. return
  16948. } else if err != nil {
  16949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16950. return
  16951. } else {
  16952. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16953. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16954. infoStr := string(Iinfos)
  16955. idetinfoStr := string(Idetinfos)
  16956. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16957. psn := &models.HisPsn{
  16958. PsnNo: res.Output.Baseinfo.PsnNo,
  16959. PatientId: patient.ID,
  16960. Certno: res.Output.Baseinfo.Certno,
  16961. Gend: res.Output.Baseinfo.Gend,
  16962. Brdy: b,
  16963. Age: float64(age),
  16964. Naty: res.Output.Baseinfo.Naty,
  16965. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16966. PsnName: res.Output.Baseinfo.PsnName,
  16967. Idetinfo: idetinfoStr,
  16968. Insuinfo: infoStr,
  16969. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16970. CardInfo: card_info,
  16971. VerifyNumber: token,
  16972. AuthInfo: auth_info,
  16973. }
  16974. var rf []*ResultFive
  16975. json.Unmarshal([]byte(infoStr), &rf)
  16976. var insutypes []*ResultFive
  16977. var insutype string
  16978. var is390 int = 0
  16979. var is310 int = 0
  16980. for _, item := range rf {
  16981. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16982. insutypes = append(insutypes, item)
  16983. }
  16984. }
  16985. if len(insutypes) == 1 {
  16986. insutype = insutypes[0].Insutype
  16987. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16988. } else {
  16989. for _, i := range insutypes {
  16990. if i.Insutype == "390" {
  16991. is390 = 1
  16992. }
  16993. if i.Insutype == "310" {
  16994. is310 = 1
  16995. }
  16996. }
  16997. }
  16998. if is390 == 1 {
  16999. insutype = "390"
  17000. }
  17001. if is310 == 1 {
  17002. insutype = "310"
  17003. }
  17004. if len(insutypes) == 0 {
  17005. insutype = "310"
  17006. }
  17007. service.CreateHisPsn(psn)
  17008. c.ServeSuccessJSON(map[string]interface{}{
  17009. "patient": patient,
  17010. "number": token,
  17011. "insutype": insutype,
  17012. })
  17013. }
  17014. } else {
  17015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17016. return
  17017. }
  17018. } else { //读卡失败
  17019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17020. return
  17021. }
  17022. }
  17023. break
  17024. }
  17025. }
  17026. var initFlag int64 = 0
  17027. var initEleFlag int64 = 0
  17028. func (c *HisApiController) TestGetBasBaseInit() {
  17029. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17030. Iinit := DllDef.MustFindProc("Init")
  17031. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17032. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  17033. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  17034. if ret != 0 {
  17035. fmt.Println("SSCard的报错原因:", err)
  17036. fmt.Println("SSCard的运算结果为:", ret)
  17037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17038. return
  17039. }
  17040. result := int(ret)
  17041. fmt.Println("SSCard的运算结果为1:", result)
  17042. initFlag = 1
  17043. return
  17044. }
  17045. func (c *HisApiController) HandleJiangXiReadCard() {
  17046. fmt.Println("~~~~~~")
  17047. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17048. admin_user_id, _ := c.GetInt64("admin_user_id")
  17049. id_card_type, _ := c.GetInt64("id_card_type")
  17050. //certificates, _ := c.GetInt64("certificates")
  17051. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17052. if initFlag == 0 {
  17053. c.TestGetJiangXiBasBaseInit()
  17054. }
  17055. basStr := c.GetBasBaseInfo()
  17056. if len(basStr) == 0 {
  17057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17058. return
  17059. }
  17060. fmt.Println(basStr)
  17061. bas := strings.Split(basStr, "|")
  17062. basNumber := bas[1]
  17063. fmt.Println(basNumber)
  17064. card_sn := bas[3]
  17065. fmt.Println(card_sn)
  17066. 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, "")
  17067. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  17068. var dat map[string]interface{}
  17069. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17070. fmt.Println(dat)
  17071. } else {
  17072. fmt.Println(err)
  17073. }
  17074. userJSONBytes, _ := json.Marshal(dat)
  17075. var res ResultTwo
  17076. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17077. utils.ErrorLog("解析失败:%v", err)
  17078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17079. return
  17080. }
  17081. if res.Infcode == 0 {
  17082. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  17083. if err == gorm.ErrRecordNotFound {
  17084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17085. return
  17086. } else if err != nil {
  17087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17088. return
  17089. } else {
  17090. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17091. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17092. infoStr := string(Iinfos)
  17093. idetinfoStr := string(Idetinfos)
  17094. psn := &models.HisPsn{
  17095. PsnNo: res.Output.Baseinfo.PsnNo,
  17096. PatientId: patient.ID,
  17097. Certno: res.Output.Baseinfo.Certno,
  17098. Gend: res.Output.Baseinfo.Gend,
  17099. Naty: res.Output.Baseinfo.Naty,
  17100. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17101. PsnName: res.Output.Baseinfo.PsnName,
  17102. Idetinfo: idetinfoStr,
  17103. Insuinfo: infoStr,
  17104. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17105. CardInfo: basStr,
  17106. VerifyNumber: "",
  17107. }
  17108. service.CreateHisPsn(psn)
  17109. c.ServeSuccessJSON(map[string]interface{}{
  17110. "patient": patient,
  17111. "number": basNumber,
  17112. })
  17113. }
  17114. } else {
  17115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17116. return
  17117. }
  17118. }
  17119. func (c *HisApiController) TestGetHnBasBaseInit() {
  17120. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17121. Iinit := DllDef.MustFindProc("Init")
  17122. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17123. //http://10.77.211.236/CSB/hsa-fsi-1303
  17124. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  17125. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  17126. // 调用 Init 函数
  17127. 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"))))
  17128. //if ret != 0 {
  17129. fmt.Println("SSCard的报错原因:", err)
  17130. fmt.Println("SSCard的运算结果为:", ret)
  17131. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17132. // return
  17133. //}
  17134. result := int(ret)
  17135. fmt.Println("SSCard的运算结果为1:", result)
  17136. initFlag = 1
  17137. return
  17138. }
  17139. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  17140. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17141. Iinit := DllDef.MustFindProc("Init")
  17142. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17143. //http://10.77.211.236/CSB/hsa-fsi-1303
  17144. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  17145. if ret != 0 {
  17146. fmt.Println("SSCard的报错原因:", err)
  17147. fmt.Println("SSCard的运算结果为:", ret)
  17148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17149. return
  17150. }
  17151. result := int(ret)
  17152. fmt.Println("SSCard的运算结果为1:", result)
  17153. initFlag = 1
  17154. return
  17155. }
  17156. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  17157. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17158. Iinit := DllDef.MustFindProc("Init")
  17159. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17160. //http://10.77.211.236/CSB/hsa-fsi-1303
  17161. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  17162. if ret != 0 {
  17163. fmt.Println("SSCard的报错原因:", err)
  17164. fmt.Println("SSCard的运算结果为:", ret)
  17165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17166. return
  17167. }
  17168. result := int(ret)
  17169. fmt.Println("SSCard的运算结果为1:", result)
  17170. initFlag = 1
  17171. return
  17172. }
  17173. func (c *HisApiController) GetSFZBaseInfo() string {
  17174. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17175. readCard := DllDef.MustFindProc("ReadSFZ")
  17176. if readCard == nil {
  17177. fmt.Println("readcard is nil")
  17178. readCard = DllDef.MustFindProc("ReadSFZ")
  17179. }
  17180. str := make([]byte, 8096)
  17181. str1 := make([]byte, 8096)
  17182. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  17183. fmt.Println(r)
  17184. return Remove0000(string(str))
  17185. }
  17186. func (c *HisApiController) GetEleBaseInfo() string {
  17187. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17188. readCard := DllDef.MustFindProc("GetQRBase")
  17189. fmt.Println(readCard)
  17190. if readCard == nil {
  17191. fmt.Println("readcard is nil")
  17192. readCard = DllDef.MustFindProc("GetQRBase")
  17193. }
  17194. str := make([]byte, 1024)
  17195. str1 := make([]byte, 1024)
  17196. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17197. fmt.Println(ret2)
  17198. fmt.Println(string(str1))
  17199. fmt.Println(string(str))
  17200. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17201. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17202. if ret2 != 0 {
  17203. return ""
  17204. }
  17205. return string(str)
  17206. }
  17207. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17208. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17209. readCard := DllDef.MustFindProc("NationEcTrans")
  17210. fmt.Println(readCard)
  17211. fmt.Println("!!!!!")
  17212. pBusiCardInfo := make([]byte, 2048)
  17213. input := make(map[string]interface{})
  17214. inputData := make(map[string]interface{})
  17215. inputData["orgId"] = code
  17216. inputData["businessType"] = "01101"
  17217. inputData["operatorId"] = "1"
  17218. inputData["operatorName"] = "admin"
  17219. inputData["officeId"] = "001"
  17220. inputData["officeName"] = "血透室"
  17221. inputData["deviceType"] = ""
  17222. input["data"] = inputData
  17223. input["orgId"] = code
  17224. input["transType"] = "ec.query"
  17225. bytesData, _ := json.Marshal(input)
  17226. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  17227. fmt.Println(ret2)
  17228. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17229. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17230. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  17231. }
  17232. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17233. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17234. readCard := DllDef.MustFindProc("NationEcTrans")
  17235. fmt.Println(readCard)
  17236. fmt.Println("!!!!!")
  17237. pBusiCardInfo := make([]byte, 2048)
  17238. input := make(map[string]interface{})
  17239. inputData := make(map[string]interface{})
  17240. inputData["orgId"] = code
  17241. inputData["businessType"] = "01101"
  17242. inputData["operatorId"] = "9"
  17243. inputData["operatorName"] = "admin"
  17244. inputData["officeId"] = "001"
  17245. inputData["officeName"] = "血透室"
  17246. inputData["deviceType"] = ""
  17247. input["data"] = inputData
  17248. input["orgId"] = code
  17249. input["transType"] = "ec.query"
  17250. bytesData, _ := json.Marshal(input)
  17251. 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])))
  17252. fmt.Println(ret2)
  17253. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17254. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17255. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17256. }
  17257. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  17258. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17259. readCard := DllDef.MustFindProc("NationEcTrans")
  17260. fmt.Println(readCard)
  17261. fmt.Println("!!!!!")
  17262. pBusiCardInfo := make([]byte, 2048)
  17263. input := make(map[string]interface{})
  17264. inputData := make(map[string]interface{})
  17265. inputData["orgId"] = code
  17266. inputData["businessType"] = "01301"
  17267. inputData["operatorId"] = "9"
  17268. inputData["operatorName"] = "admin"
  17269. inputData["officeId"] = "001"
  17270. inputData["officeName"] = "血透室"
  17271. inputData["deviceType"] = ""
  17272. input["data"] = inputData
  17273. input["orgId"] = code
  17274. input["transType"] = "ec.query"
  17275. bytesData, _ := json.Marshal(input)
  17276. 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])))
  17277. fmt.Println(ret2)
  17278. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17279. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17280. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17281. }
  17282. func GetJxEleBaseInfo(org_id int64) string {
  17283. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17284. readCard := DllDef.MustFindProc("NationEcTrans")
  17285. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17286. if readCard == nil {
  17287. fmt.Println("readcard is nil")
  17288. readCard = DllDef.MustFindProc("NationEcTrans")
  17289. }
  17290. str1 := make([]byte, 1024)
  17291. data := make(map[string]interface{})
  17292. inputData := make(map[string]interface{})
  17293. inputData["orgId"] = miConfig.Code
  17294. inputData["businessType"] = "01101"
  17295. inputData["operatorId"] = "test001"
  17296. inputData["operatorName"] = "cn"
  17297. inputData["officeId"] = "32760"
  17298. inputData["officeName"] = "waike"
  17299. inputData["deviceType"] = ""
  17300. data["data"] = inputData
  17301. data["transType"] = "ec.query"
  17302. data["extra "] = ""
  17303. data["orgId"] = miConfig.Code
  17304. bytesData, _ := json.Marshal(data)
  17305. //bytesData, _ := json.Marshal(data)
  17306. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17307. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17308. fmt.Println(ret2)
  17309. fmt.Println(string(str1))
  17310. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17311. if ret2 != 0 {
  17312. return ""
  17313. }
  17314. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17315. }
  17316. //func GetJxEleBaseInfoTWO(org_id int64) string {
  17317. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  17318. // readCard := DllDef.MustFindProc("NationEcTrans")
  17319. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17320. //
  17321. // if readCard == nil {
  17322. // fmt.Println("readcard is nil")
  17323. // readCard = DllDef.MustFindProc("NationEcTrans")
  17324. // }
  17325. // str1 := make([]byte, 1024)
  17326. //
  17327. // data := make(map[string]interface{})
  17328. //
  17329. // inputData := make(map[string]interface{})
  17330. // inputData["orgId"] = miConfig.Code
  17331. // inputData["businessType"] = "01101"
  17332. // inputData["operatorId"] = "test001"
  17333. // inputData["operatorName"] = "cn"
  17334. // inputData["officeId"] = "32760"
  17335. // inputData["officeName"] = "waike"
  17336. // inputData["deviceType"] = ""
  17337. //
  17338. // data["data"] = inputData
  17339. // data["transType"] = "ec.query"
  17340. // data["extra "] = ""
  17341. // data["orgId"] = miConfig.Code
  17342. // bytesData, _ := json.Marshal(data)
  17343. // //bytesData, _ := json.Marshal(data)
  17344. //
  17345. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17346. //
  17347. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17348. // fmt.Println(ret2)
  17349. // fmt.Println(string(str1))
  17350. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17351. //
  17352. // if ret2 != 0 {
  17353. // return ""
  17354. // }
  17355. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17356. //}
  17357. func GetJxEleBaseInitInfo(org_id int64) string {
  17358. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17359. readCard := DllDef.MustFindProc("NationEcTrans")
  17360. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17361. if readCard == nil {
  17362. fmt.Println("readcard is nil")
  17363. readCard = DllDef.MustFindProc("NationEcTrans")
  17364. }
  17365. str1 := make([]byte, 2048)
  17366. data := make(map[string]interface{})
  17367. inputData := make(map[string]interface{})
  17368. inputData["orgId"] = miConfig.Code
  17369. inputData["businessType"] = "01101"
  17370. inputData["operatorId"] = "1"
  17371. inputData["operatorName"] = "huangchuang"
  17372. inputData["officeId"] = "101"
  17373. inputData["officeName"] = "xuetou"
  17374. inputData["deviceType"] = ""
  17375. data["data"] = inputData
  17376. data["transType"] = "ec.query"
  17377. data["orgId"] = miConfig.Code
  17378. bytesData, _ := json.Marshal(data)
  17379. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17380. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17381. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  17382. fmt.Println(ret2)
  17383. fmt.Println(string(str1))
  17384. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17385. if ret2 != 0 {
  17386. return ""
  17387. }
  17388. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  17389. initEleFlag = 1
  17390. }
  17391. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17392. }
  17393. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  17394. // // 构建命令
  17395. // cmd := exec.Command("python", "b.py")
  17396. //
  17397. // // 执行命令并等待完成
  17398. // output, err := cmd.CombinedOutput()
  17399. // if err != nil {
  17400. // fmt.Println("Error executing Python script:", err)
  17401. // return
  17402. // }
  17403. //
  17404. // // 打印Python脚本的输出
  17405. // fmt.Println(string(output))
  17406. //}
  17407. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  17408. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  17409. readCard := DllDef.MustFindProc("gxyb_call")
  17410. if readCard == nil {
  17411. fmt.Println("readcard is nil")
  17412. readCard = DllDef.MustFindProc("gxyb_call")
  17413. }
  17414. str := make([]byte, 1024)
  17415. str1 := make([]byte, 1024)
  17416. //data := make(map[string]interface{})
  17417. currentTime := time.Now()
  17418. // 格式化时间为 "YYYYMMDDHH24MISS"
  17419. formattedTime := currentTime.Format("20060102150405")
  17420. inputData := make(map[string]interface{})
  17421. inputData2 := make(map[string]interface{})
  17422. inputData["transNo"] = "1401"
  17423. inputData["transType"] = "passwordCheck"
  17424. inputData["timestamp"] = formattedTime
  17425. inputData2["fixmedinsCode"] = code
  17426. inputData2["psnNo"] = ""
  17427. inputData["data"] = inputData2
  17428. jsonBytes, err := json.Marshal(inputData)
  17429. if err != nil {
  17430. fmt.Println("Error encoding map to JSON:", err)
  17431. }
  17432. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17433. fmt.Println(string(str1))
  17434. fmt.Println(string(str))
  17435. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17436. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17437. if ret2 != 0 {
  17438. return ""
  17439. }
  17440. return string(str)
  17441. }
  17442. func (c *HisApiController) GetoleInfo() Response {
  17443. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  17444. defer ole.CoUninitialize()
  17445. // Replace with the ProgID or CLSID of your COM object
  17446. progID := "YinHai.XJ.Actual.Interface.New"
  17447. // Create COM object
  17448. unknown, err := oleutil.CreateObject(progID)
  17449. if err != nil {
  17450. fmt.Println("Unable to create COM object:", err)
  17451. }
  17452. defer unknown.Release()
  17453. // Query for the IDispatch interface
  17454. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  17455. if err != nil {
  17456. fmt.Println("Unable to get IDispatch interface:", err)
  17457. }
  17458. defer dispatch.Release()
  17459. // Prepare parameters
  17460. transNo := "1401"
  17461. transType := "passwordCheck"
  17462. timestamp := time.Now().Unix()
  17463. fixmedinsCode := "H45072101171"
  17464. psnNo := ""
  17465. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  17466. result2 := ""
  17467. // Call COM object's method using the IDispatch interface
  17468. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  17469. fmt.Println(resulr)
  17470. fmt.Println(result2)
  17471. if err != nil {
  17472. fmt.Println("调用COM对象方法失败:", err)
  17473. }
  17474. var response Response
  17475. err2 := json.Unmarshal([]byte(result2), &response)
  17476. if err2 != nil {
  17477. fmt.Println("解析JSON失败:", err)
  17478. }
  17479. return response
  17480. }
  17481. func (c *HisApiController) GetBasBaseInfo() string {
  17482. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17483. readCard := DllDef.MustFindProc("ReadCardBas")
  17484. if readCard == nil {
  17485. fmt.Println("readcard is nil")
  17486. readCard = DllDef.MustFindProc("ReadCardBas")
  17487. }
  17488. str := make([]byte, 1024)
  17489. str1 := make([]byte, 1024)
  17490. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17491. fmt.Println(string(str1))
  17492. fmt.Println(string(str))
  17493. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17494. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17495. if ret2 != 0 {
  17496. return ""
  17497. }
  17498. return string(str)
  17499. }
  17500. type Program struct {
  17501. FunctionID string `xml:"function_id"`
  17502. CardInfo string `xml:"cardinfo"`
  17503. User string `xml:"user"`
  17504. }
  17505. func (c *HisApiController) GetBasBaseInfo1111() string {
  17506. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  17507. readCard := DllDef.MustFindProc("ReadSICardInfo")
  17508. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  17509. if readCard == nil {
  17510. fmt.Println("readcard is nil")
  17511. readCard = DllDef.MustFindProc("ReadSICardInfo")
  17512. }
  17513. if readCard2 == nil {
  17514. fmt.Println("readcard is nil")
  17515. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  17516. }
  17517. str := make([]byte, 1024)
  17518. str1 := make([]byte, 1024)
  17519. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17520. str3 := make([]byte, 1024)
  17521. str4 := make([]byte, 1024)
  17522. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  17523. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17524. //if err != nil {
  17525. // fmt.Println("Error opening file:", err)
  17526. //}
  17527. //defer file.Close()
  17528. //
  17529. //var lastProgram Program
  17530. //scanner := bufio.NewScanner(file)
  17531. //inProgram := false
  17532. //
  17533. //for scanner.Scan() {
  17534. // line := scanner.Text()
  17535. // if strings.Contains(line, "<program>") {
  17536. // inProgram = true
  17537. // programXML := "<program>"
  17538. // for scanner.Scan() {
  17539. // line = scanner.Text()
  17540. // programXML += line
  17541. // if strings.Contains(line, "</program>") {
  17542. // programXML += "</program>"
  17543. // break
  17544. // }
  17545. // }
  17546. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17547. // // 解析成功,更新最后的 Program
  17548. // }
  17549. // inProgram = false
  17550. // }
  17551. //}
  17552. //
  17553. // fmt.Println("Error reading file:", inProgram)
  17554. //
  17555. //if err := scanner.Err(); err != nil {
  17556. // fmt.Println("Error reading file:", err)
  17557. //}
  17558. // 输出最后一次的 Program
  17559. //fmt.Printf("最后一次的 <program>:\n")
  17560. //fmt.Printf("<program>\n")
  17561. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17562. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17563. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17564. //fmt.Printf("</program>\n")
  17565. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17566. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17567. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17568. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17569. return ConvertToString(string(str), "gbk", "utf-8")
  17570. }
  17571. func (c *HisApiController) GetBasBaseInfo22222() string {
  17572. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17573. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17574. if readCard == nil {
  17575. fmt.Println("readcard is nil")
  17576. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17577. }
  17578. str := make([]byte, 1024)
  17579. str1 := make([]byte, 1024)
  17580. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  17581. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17582. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17583. //if err != nil {
  17584. // fmt.Println("Error opening file:", err)
  17585. //}
  17586. //defer file.Close()
  17587. //
  17588. //var lastProgram Program
  17589. //scanner := bufio.NewScanner(file)
  17590. //inProgram := false
  17591. //
  17592. //for scanner.Scan() {
  17593. // line := scanner.Text()
  17594. // if strings.Contains(line, "<program>") {
  17595. // inProgram = true
  17596. // programXML := "<program>"
  17597. // for scanner.Scan() {
  17598. // line = scanner.Text()
  17599. // programXML += line
  17600. // if strings.Contains(line, "</program>") {
  17601. // programXML += "</program>"
  17602. // break
  17603. // }
  17604. // }
  17605. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17606. // // 解析成功,更新最后的 Program
  17607. // }
  17608. // inProgram = false
  17609. // }
  17610. //}
  17611. //
  17612. // fmt.Println("Error reading file:", inProgram)
  17613. //
  17614. //if err := scanner.Err(); err != nil {
  17615. // fmt.Println("Error reading file:", err)
  17616. //}
  17617. // 输出最后一次的 Program
  17618. //fmt.Printf("最后一次的 <program>:\n")
  17619. //fmt.Printf("<program>\n")
  17620. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17621. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17622. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17623. //fmt.Printf("</program>\n")
  17624. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17625. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17626. return ConvertToString(string(str1), "gbk", "utf-8")
  17627. }
  17628. func (c *HisApiController) GetahBasBaseInfo() string {
  17629. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17630. readCard := DllDef.MustFindProc("iReadCardBas")
  17631. if readCard == nil {
  17632. fmt.Println("readcard is nil")
  17633. readCard = DllDef.MustFindProc("iReadCardBas")
  17634. }
  17635. //str := make([]byte, 1024)
  17636. str1 := make([]byte, 1024)
  17637. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17638. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17639. //if err != nil {
  17640. // fmt.Println("Error opening file:", err)
  17641. //}
  17642. //defer file.Close()
  17643. //
  17644. //var lastProgram Program
  17645. //scanner := bufio.NewScanner(file)
  17646. //inProgram := false
  17647. //
  17648. //for scanner.Scan() {
  17649. // line := scanner.Text()
  17650. // if strings.Contains(line, "<program>") {
  17651. // inProgram = true
  17652. // programXML := "<program>"
  17653. // for scanner.Scan() {
  17654. // line = scanner.Text()
  17655. // programXML += line
  17656. // if strings.Contains(line, "</program>") {
  17657. // programXML += "</program>"
  17658. // break
  17659. // }
  17660. // }
  17661. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17662. // // 解析成功,更新最后的 Program
  17663. // }
  17664. // inProgram = false
  17665. // }
  17666. //}
  17667. //
  17668. // fmt.Println("Error reading file:", inProgram)
  17669. //
  17670. //if err := scanner.Err(); err != nil {
  17671. // fmt.Println("Error reading file:", err)
  17672. //}
  17673. // 输出最后一次的 Program
  17674. //fmt.Printf("最后一次的 <program>:\n")
  17675. //fmt.Printf("<program>\n")
  17676. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17677. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17678. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17679. //fmt.Printf("</program>\n")
  17680. fmt.Println(string(str1))
  17681. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17682. if ret2 != 0 {
  17683. return ""
  17684. }
  17685. return string(str1)
  17686. }
  17687. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  17688. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  17689. readCard := DllDef.MustFindProc("read_cardinfo")
  17690. if readCard == nil {
  17691. fmt.Println("readcard is nil")
  17692. readCard = DllDef.MustFindProc("read_cardinfo")
  17693. }
  17694. str := make([]byte, 1024) //卡号
  17695. str1 := make([]byte, 1024) //卡识别码
  17696. str2 := make([]byte, 1024) //身份证号
  17697. str3 := make([]byte, 1024) //姓名
  17698. str4 := make([]byte, 1024) //错误信息
  17699. 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])))
  17700. fmt.Println(string(str1))
  17701. fmt.Println(string(str))
  17702. fmt.Println(string(str2))
  17703. fmt.Println(string(str3))
  17704. fmt.Println(string(str4))
  17705. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17706. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17707. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  17708. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17709. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17710. if ret2 != 0 {
  17711. return "", "", "", "", ""
  17712. }
  17713. return string(str), string(str1), string(str2), string(str3), string(str4)
  17714. }
  17715. type CustomFundPay struct {
  17716. FundPayType string `json:"fund_pay_type"`
  17717. FundPayamt float64 `json:"fund_payamt"`
  17718. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17719. }
  17720. //func (c *HisApiController) GetBatchSettleList() {
  17721. // start_time_str := c.GetString("start_time")
  17722. // //end_time_str := c.GetString("end_time")
  17723. // admin_user_id, _ := c.GetInt64("admin_user_id")
  17724. //
  17725. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  17726. //
  17727. // for _, item := range orders {
  17728. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  17729. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17730. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17731. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17732. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17733. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17734. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17735. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17736. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17737. //
  17738. // if order.ID == 0 {
  17739. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  17740. // return
  17741. // }
  17742. //
  17743. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17744. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17745. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17746. // //fmt.Println(count)
  17747. // //var zero string
  17748. // //number := count + 1
  17749. // //if number >= 1000 {
  17750. // // zero = "0000" + strconv.FormatInt(number, 10)
  17751. // //} else if number >= 10000 {
  17752. // // zero = "000" + strconv.FormatInt(number, 10)
  17753. // //} else if number >= 100000 {
  17754. // // zero = "00" + strconv.FormatInt(number, 10)
  17755. // //} else if number >= 1000000 {
  17756. // // zero = "0" + strconv.FormatInt(number, 10)
  17757. // //} else {
  17758. // // zero = strconv.FormatInt(number, 10)
  17759. // //}
  17760. // //fmt.Println(zero)
  17761. //
  17762. // struct4101 := service.Struct4101{
  17763. // PsnNo: order.PsnNo,
  17764. // MdtrtId: order.MdtrtId,
  17765. // SetlId: order.SetlId,
  17766. // PsnName: order.PsnName,
  17767. // Gend: order.Gend,
  17768. // Brdy: his.Brdy,
  17769. // Age: his.Age,
  17770. // Naty: order.Naty,
  17771. // PatnCertType: "01",
  17772. // Certno: order.Certno,
  17773. // Prfs: "90",
  17774. // ConerName: roles[0].UserName,
  17775. // PatnRlts: "99",
  17776. // ConerAddr: miConfig.OrgName,
  17777. // ConerTel: admin.Mobile,
  17778. // HiType: order.Insutype,
  17779. // Insuplc: miConfig.InsuplcAdmdvs,
  17780. // MaindiagFlag: "1",
  17781. // BillCode: order.SetlId,
  17782. // BillNo: order.SetlId,
  17783. // BizSn: order.Number,
  17784. // PsnSelfPay: order.PsnPartAmt,
  17785. // PsnOwnPay: order.PsnPartAmt,
  17786. // AcctPay: order.AcctPay,
  17787. // PsnCashpay: order.PsnCashPay,
  17788. // HiPaymtd: "1",
  17789. // Hsorg: miConfig.InsuplcAdmdvs,
  17790. // HsorgOpter: miConfig.InsuplcAdmdvs,
  17791. // MedinsFillPsn: curRoles.UserName,
  17792. // MedinsFillDept: miConfig.OrgName,
  17793. // IptMedType: "2",
  17794. // }
  17795. // struct4101.SetlBegnDate = order.SetlTime
  17796. // struct4101.SetlEndDate = order.SetlTime
  17797. // time_arr := strings.Split(order.SetlTime, " ")
  17798. // struct4101.AdmTime = time_arr[0]
  17799. // struct4101.AdmEndTime = time_arr[0]
  17800. //
  17801. // var rf []CustomFundPay
  17802. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  17803. //
  17804. // var tempFunPays []service.CustomStruct
  17805. // for _, item := range rf {
  17806. // var tempFunPay service.CustomStruct
  17807. // tempFunPay.FundPayamt = item.FundPayamt
  17808. // tempFunPay.FundPayType = item.FundPayType
  17809. // tempFunPays = append(tempFunPays, tempFunPay)
  17810. // }
  17811. // struct4101.CustomStruct = tempFunPays
  17812. //
  17813. // var tempDiaginfos []service.DiaginfoStructTwo
  17814. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  17815. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  17816. //
  17817. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  17818. // var config []*models.HisXtDiagnoseConfig
  17819. // for _, item := range diagnosis_ids {
  17820. // id, _ := strconv.ParseInt(item, 10, 64)
  17821. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  17822. // config = append(config, &diagnosisConfig)
  17823. // }
  17824. //
  17825. // for index, item := range config {
  17826. // if index == 0 {
  17827. // var tempDiaginfo service.DiaginfoStructTwo
  17828. // tempDiaginfo.DiagCode = item.CountryCode
  17829. // tempDiaginfo.DiagName = item.CountryContentName
  17830. // tempDiaginfo.DiagType = "1"
  17831. // tempDiaginfo.MaindiagFlag = "1"
  17832. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17833. // } else {
  17834. // var tempDiaginfo service.DiaginfoStructTwo
  17835. // tempDiaginfo.DiagCode = item.CountryCode
  17836. // tempDiaginfo.DiagName = item.CountryContentName
  17837. // tempDiaginfo.DiagType = "1"
  17838. // tempDiaginfo.MaindiagFlag = "0"
  17839. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17840. // }
  17841. // }
  17842. // struct4101.Diseinfo = tempDiaginfos
  17843. //
  17844. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  17845. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  17846. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  17847. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  17848. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  17849. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  17850. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  17851. //
  17852. // var iteminfo service.IteminfoStruct
  17853. //
  17854. // var bedCostTotal float64 = 0 //床位总费
  17855. // var bedCostSelfTotal float64 = 0 //床位自费
  17856. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  17857. //
  17858. // var operationCostTotal float64 = 0 //手术费
  17859. // var operationCostSelfTotal float64 = 0 //手术费
  17860. // var operationCostPartSelfTotal float64 = 0 //手术费
  17861. //
  17862. // var otherCostTotal float64 = 0 //其他费用
  17863. // var otherCostSelfTotal float64 = 0 //其他费用
  17864. // var otherCostPartSelfTotal float64 = 0 //其他费用
  17865. //
  17866. // var materialCostTotal float64 = 0 //材料费
  17867. // var materialCostSelfTotal float64 = 0 //材料费
  17868. // var materialCostPartSelfTotal float64 = 0 //材料费
  17869. //
  17870. // var westernMedicineCostTotal float64 = 0 //西药费
  17871. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  17872. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  17873. //
  17874. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  17875. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  17876. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  17877. //
  17878. // var checkCostTotal float64 = 0 //检查费
  17879. // var checkCostSelfTotal float64 = 0 //检查费
  17880. // var checkCostPartSelfTotal float64 = 0 //检查费
  17881. //
  17882. // var laboratoryCostTotal float64 = 0 //化验费
  17883. // var laboratoryCostSelfTotal float64 = 0 //化验费
  17884. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  17885. //
  17886. // var treatCostTotal float64 = 0 //治疗费用
  17887. // var treatCostSelfTotal float64 = 0 //治疗费用
  17888. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  17889. //
  17890. // decimal.DivisionPrecision = 2
  17891. //
  17892. // var bed_fulamt_ownpay_amt float64 = 0
  17893. // var operation_fulamt_ownpay_amt float64 = 0
  17894. // var other_fulamt_ownpay_amt float64 = 0
  17895. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  17896. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  17897. // var check_fulamt_ownpay_amt float64 = 0
  17898. // var material_fulamt_ownpay_amt float64 = 0
  17899. // var laboratory_fulamt_ownpay_amt float64 = 0
  17900. // var treat_fulamt_ownpay_amt float64 = 0
  17901. //
  17902. // var bed_claa_sunmfee float64 = 0
  17903. // var bed_clab_amt float64 = 0
  17904. // var bed_other_amt float64 = 0
  17905. //
  17906. // var operation_claa_sunmfee float64 = 0
  17907. // var operation_clab_amt float64 = 0
  17908. // var operation_other_amt float64 = 0
  17909. //
  17910. // var other_claa_sunmfee float64 = 0
  17911. // var other_clab_amt float64 = 0
  17912. // var other_other_amt float64 = 0
  17913. //
  17914. // var westernMedicine_claa_sunmfee float64 = 0
  17915. // var westernMedicine_clab_amt float64 = 0
  17916. // var westernMedicine_other_amt float64 = 0
  17917. //
  17918. // var chineseTraditional_claa_sunmfee float64 = 0
  17919. // var chineseTraditional_clab_amt float64 = 0
  17920. // var chineseTraditional_other_amt float64 = 0
  17921. //
  17922. // var check_claa_sunmfee float64 = 0
  17923. // var check_clab_amt float64 = 0
  17924. // var check_other_amt float64 = 0
  17925. //
  17926. // var material_claa_sunmfee float64 = 0
  17927. // var material_clab_amt float64 = 0
  17928. // var material_other_amt float64 = 0
  17929. //
  17930. // var laboratory_claa_sunmfee float64 = 0
  17931. // var laboratory_clab_amt float64 = 0
  17932. // var laboratory_other_amt float64 = 0
  17933. //
  17934. // var treat_claa_sunmfee float64 = 0
  17935. // var treat_clab_amt float64 = 0
  17936. // var treat_other_amt float64 = 0
  17937. //
  17938. // for _, item := range order.HisOrderInfo {
  17939. // if item.MedChrgitmType == "01" { //床位费
  17940. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17941. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17942. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17943. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17944. // if item.ChrgitmLv == "1" {
  17945. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17946. // }
  17947. // if item.ChrgitmLv == "2" {
  17948. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17949. //
  17950. // }
  17951. // if item.ChrgitmLv == "3" {
  17952. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17953. // }
  17954. //
  17955. // }
  17956. //
  17957. // if item.MedChrgitmType == "03" { //检查费
  17958. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17959. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17960. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17961. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17962. // if item.ChrgitmLv == "1" {
  17963. //
  17964. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17965. //
  17966. // }
  17967. // if item.ChrgitmLv == "2" {
  17968. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17969. //
  17970. // }
  17971. // if item.ChrgitmLv == "3" {
  17972. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17973. // }
  17974. // }
  17975. //
  17976. // if item.MedChrgitmType == "04" { //化验费
  17977. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17978. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17979. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17980. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17981. // if item.ChrgitmLv == "1" {
  17982. //
  17983. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17984. //
  17985. // }
  17986. // if item.ChrgitmLv == "2" {
  17987. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17988. //
  17989. // }
  17990. // if item.ChrgitmLv == "3" {
  17991. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17992. // }
  17993. // }
  17994. //
  17995. // if item.MedChrgitmType == "05" { //治疗费
  17996. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17997. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17998. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17999. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18000. // if item.ChrgitmLv == "1" {
  18001. //
  18002. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18003. //
  18004. // }
  18005. // if item.ChrgitmLv == "2" {
  18006. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18007. //
  18008. // }
  18009. // if item.ChrgitmLv == "3" {
  18010. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18011. // }
  18012. // }
  18013. //
  18014. // if item.MedChrgitmType == "06" { //手术费
  18015. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18016. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18017. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18018. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18019. //
  18020. // if item.ChrgitmLv == "1" {
  18021. //
  18022. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18023. //
  18024. // }
  18025. // if item.ChrgitmLv == "2" {
  18026. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18027. //
  18028. // }
  18029. // if item.ChrgitmLv == "3" {
  18030. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18031. // }
  18032. // }
  18033. //
  18034. // if item.MedChrgitmType == "08" { //材料费
  18035. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18036. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18037. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18038. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18039. // if item.ChrgitmLv == "1" {
  18040. //
  18041. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18042. //
  18043. // }
  18044. // if item.ChrgitmLv == "2" {
  18045. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18046. //
  18047. // }
  18048. // if item.ChrgitmLv == "3" {
  18049. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18050. // }
  18051. // }
  18052. //
  18053. // if item.MedChrgitmType == "09" { //西药费
  18054. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18055. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18056. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18057. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18058. // if item.ChrgitmLv == "1" {
  18059. //
  18060. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18061. //
  18062. // }
  18063. // if item.ChrgitmLv == "2" {
  18064. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18065. //
  18066. // }
  18067. // if item.ChrgitmLv == "3" {
  18068. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18069. // }
  18070. // }
  18071. //
  18072. // if item.MedChrgitmType == "11" { //中成费
  18073. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18074. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18075. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18076. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18077. // if item.ChrgitmLv == "1" {
  18078. //
  18079. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18080. //
  18081. // }
  18082. // if item.ChrgitmLv == "2" {
  18083. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18084. //
  18085. // }
  18086. // if item.ChrgitmLv == "3" {
  18087. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18088. // }
  18089. // }
  18090. //
  18091. // if item.MedChrgitmType == "14" { //其他费
  18092. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18093. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18094. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18095. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18096. // if item.ChrgitmLv == "1" {
  18097. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18098. //
  18099. // }
  18100. // if item.ChrgitmLv == "2" {
  18101. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18102. //
  18103. // }
  18104. // if item.ChrgitmLv == "3" {
  18105. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18106. // }
  18107. // }
  18108. //
  18109. // }
  18110. //
  18111. // var iteminfoStructs []service.IteminfoStruct
  18112. //
  18113. // if bedCostTotal != 0 {
  18114. // iteminfo.MedChrgitm = "01"
  18115. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18116. // iteminfo.Amt = bedCostTotal
  18117. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  18118. // iteminfo.ClabAmt = bed_clab_amt
  18119. // iteminfo.OthAmt = bed_other_amt
  18120. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18121. // }
  18122. //
  18123. // if checkCostTotal != 0 {
  18124. // iteminfo.MedChrgitm = "03"
  18125. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18126. // iteminfo.Amt = checkCostTotal
  18127. // iteminfo.ClaaSumfee = check_claa_sunmfee
  18128. // iteminfo.ClabAmt = check_clab_amt
  18129. // iteminfo.OthAmt = check_other_amt
  18130. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18131. //
  18132. // }
  18133. //
  18134. // if laboratoryCostTotal != 0 {
  18135. // iteminfo.MedChrgitm = "04"
  18136. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18137. // iteminfo.Amt = laboratoryCostTotal
  18138. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18139. // iteminfo.ClabAmt = laboratory_clab_amt
  18140. // iteminfo.OthAmt = laboratory_other_amt
  18141. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18142. //
  18143. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18144. //
  18145. // }
  18146. //
  18147. // if treatCostTotal != 0 {
  18148. // iteminfo.MedChrgitm = "05"
  18149. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18150. // iteminfo.Amt = treatCostTotal
  18151. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  18152. // iteminfo.ClabAmt = treat_clab_amt
  18153. // iteminfo.OthAmt = treat_other_amt
  18154. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18155. // //(struct4101.IteminfoStruct, iteminfo)
  18156. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18157. // }
  18158. //
  18159. // if operationCostTotal != 0 {
  18160. // iteminfo.MedChrgitm = "06"
  18161. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18162. // iteminfo.Amt = operationCostTotal
  18163. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  18164. // iteminfo.ClabAmt = operation_clab_amt
  18165. // iteminfo.OthAmt = operation_other_amt
  18166. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18167. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18168. // }
  18169. //
  18170. // if materialCostTotal != 0 {
  18171. // iteminfo.MedChrgitm = "08"
  18172. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18173. // iteminfo.Amt = materialCostTotal
  18174. // iteminfo.ClaaSumfee = material_claa_sunmfee
  18175. // iteminfo.ClabAmt = material_clab_amt
  18176. // iteminfo.OthAmt = material_other_amt
  18177. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18178. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18179. // }
  18180. //
  18181. // if westernMedicineCostTotal != 0 {
  18182. // iteminfo.MedChrgitm = "09"
  18183. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18184. // iteminfo.Amt = westernMedicineCostTotal
  18185. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18186. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18187. // iteminfo.OthAmt = westernMedicine_other_amt
  18188. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18189. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18190. //
  18191. // }
  18192. // if chineseTraditionalMedicineCostTotal != 0 {
  18193. // iteminfo.MedChrgitm = "11"
  18194. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18195. // iteminfo.Amt = westernMedicineCostTotal
  18196. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18197. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18198. // iteminfo.OthAmt = westernMedicine_other_amt
  18199. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18200. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18201. //
  18202. // }
  18203. // if otherCostTotal != 0 {
  18204. // iteminfo.MedChrgitm = "14"
  18205. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18206. // iteminfo.Amt = otherCostTotal
  18207. // iteminfo.ClaaSumfee = other_claa_sunmfee
  18208. // iteminfo.ClabAmt = other_clab_amt
  18209. // iteminfo.OthAmt = other_other_amt
  18210. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18211. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18212. //
  18213. // }
  18214. // struct4101.IteminfoStruct = iteminfoStructs
  18215. // struct4101.Ntly = "中国"
  18216. // struct4101.AdmCaty = "A03.06"
  18217. //
  18218. // struct4101.DoctorName = doctor.UserName
  18219. // struct4101.DoctorCode = doctor.DoctorNumber
  18220. //
  18221. // var res ResultSeventeen
  18222. //
  18223. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18224. // struct4101.BillCode = order.Number
  18225. // struct4101.BillNo = order.SetlId
  18226. // var resOther ResultSeventeenOther
  18227. // var pp models.PublicParams
  18228. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18229. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18230. // pp.FixmedinsName = miConfig.OrgName
  18231. // pp.FixmedinsCode = miConfig.Code
  18232. // pp.RequestUrl = miConfig.Url
  18233. // pp.Cainfo = miConfig.Cainfo
  18234. // pp.SecretKey = miConfig.SecretKey
  18235. // pp.AccessKey = miConfig.AccessKey
  18236. // pp.OpterName = curRoles.UserName
  18237. //
  18238. // client := &http.Client{}
  18239. // var req *http.Request
  18240. // data := make(map[string]interface{})
  18241. // data["struct4101"] = struct4101
  18242. // data["pp"] = pp
  18243. // bytesData, _ := json.Marshal(data)
  18244. // if miConfig.MdtrtareaAdmvs == "320921" {
  18245. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18246. // } else {
  18247. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18248. // }
  18249. // resp, _ := client.Do(req)
  18250. // defer resp.Body.Close()
  18251. // body, ioErr := ioutil.ReadAll(resp.Body)
  18252. // if ioErr != nil {
  18253. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18254. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18255. // return
  18256. // }
  18257. // var respJSON map[string]interface{}
  18258. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18259. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18260. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18261. // return
  18262. // }
  18263. //
  18264. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18265. // userJSONBytes, _ := json.Marshal(respJSON)
  18266. // fmt.Println("log")
  18267. // fmt.Println(string(userJSONBytes))
  18268. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18269. // utils.ErrorLog("解析失败:%v", err)
  18270. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18271. // return
  18272. // }
  18273. // res.InfRefmsgid = resOther.InfRefmsgid
  18274. // res.Output = resOther.Output
  18275. // res.ErrMsg = resOther.ErrMsg
  18276. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18277. // res.Infcode = infocode
  18278. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  18279. //
  18280. // var pp models.PublicParams
  18281. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18282. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18283. // pp.FixmedinsName = miConfig.OrgName
  18284. // pp.FixmedinsCode = miConfig.Code
  18285. // pp.RequestUrl = miConfig.Url
  18286. // pp.Cainfo = miConfig.Cainfo
  18287. // pp.SecretKey = miConfig.SecretKey
  18288. // pp.AccessKey = miConfig.AccessKey
  18289. // pp.OpterName = curRoles.UserName
  18290. // result, _ := service.Jxyb4101(struct4101, pp)
  18291. // var dat map[string]interface{}
  18292. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18293. // fmt.Println(dat)
  18294. // } else {
  18295. // fmt.Println(err)
  18296. // }
  18297. // userJSONBytes, _ := json.Marshal(dat)
  18298. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18299. // utils.ErrorLog("解析失败:%v", err)
  18300. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18301. // return
  18302. // }
  18303. //
  18304. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  18305. // var pp models.PublicParams
  18306. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18307. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18308. // pp.FixmedinsName = miConfig.OrgName
  18309. // pp.FixmedinsCode = miConfig.Code
  18310. // pp.RequestUrl = miConfig.Url
  18311. // pp.Cainfo = miConfig.Cainfo
  18312. // pp.SecretKey = miConfig.SecretKey
  18313. // pp.AccessKey = miConfig.AccessKey
  18314. // pp.OpterName = curRoles.UserName
  18315. // result, _ := service.Hnyb4101(struct4101, pp)
  18316. // var dat map[string]interface{}
  18317. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18318. // fmt.Println(dat)
  18319. // } else {
  18320. // fmt.Println(err)
  18321. // }
  18322. // userJSONBytes, _ := json.Marshal(dat)
  18323. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18324. // utils.ErrorLog("解析失败:%v", err)
  18325. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18326. // return
  18327. // }
  18328. //
  18329. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  18330. // var resOther ResultSeventeenOther
  18331. //
  18332. // var pp models.PublicParams
  18333. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18334. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18335. // pp.FixmedinsName = miConfig.OrgName
  18336. // pp.FixmedinsCode = miConfig.Code
  18337. // pp.RequestUrl = miConfig.Url
  18338. // pp.Cainfo = miConfig.Cainfo
  18339. // pp.SecretKey = miConfig.SecretKey
  18340. // pp.AccessKey = miConfig.AccessKey
  18341. // pp.OpterName = curRoles.UserName
  18342. // client := &http.Client{}
  18343. // var req *http.Request
  18344. // data := make(map[string]interface{})
  18345. // data["struct4101"] = struct4101
  18346. // data["pp"] = pp
  18347. // bytesData, _ := json.Marshal(data)
  18348. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18349. // resp, _ := client.Do(req)
  18350. // defer resp.Body.Close()
  18351. // body, ioErr := ioutil.ReadAll(resp.Body)
  18352. // if ioErr != nil {
  18353. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18354. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18355. // return
  18356. // }
  18357. // var respJSON map[string]interface{}
  18358. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18359. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18360. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18361. // return
  18362. // }
  18363. //
  18364. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18365. // userJSONBytes, _ := json.Marshal(respJSON)
  18366. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18367. // utils.ErrorLog("解析失败:%v", err)
  18368. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18369. // return
  18370. // }
  18371. // res.InfRefmsgid = resOther.InfRefmsgid
  18372. // res.Output = resOther.Output
  18373. // res.ErrMsg = resOther.ErrMsg
  18374. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18375. // res.Infcode = infocode
  18376. //
  18377. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  18378. // var pp models.PublicParams
  18379. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18380. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18381. // pp.FixmedinsName = miConfig.OrgName
  18382. // pp.FixmedinsCode = miConfig.Code
  18383. // pp.RequestUrl = miConfig.Url
  18384. // pp.Cainfo = miConfig.Cainfo
  18385. // pp.SecretKey = miConfig.SecretKey
  18386. // pp.AccessKey = miConfig.AccessKey
  18387. // pp.OpterName = curRoles.UserName
  18388. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18389. // fmt.Println(requestLog)
  18390. // fmt.Println(errMsgLog)
  18391. //
  18392. // saveLog(result, requestLog, "4101a", "上传清单")
  18393. //
  18394. // var dat map[string]interface{}
  18395. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18396. // fmt.Println(dat)
  18397. // } else {
  18398. // fmt.Println(err)
  18399. // }
  18400. // userJSONBytes, _ := json.Marshal(dat)
  18401. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18402. // utils.ErrorLog("解析失败:%v", err)
  18403. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18404. // return
  18405. // }
  18406. //
  18407. // } else {
  18408. //
  18409. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  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. //
  18424. // if res.Infcode != 0 {
  18425. // adminUser := c.GetAdminUserInfo()
  18426. // errlog := &models.HisOrderError{
  18427. // UserOrgId: adminUser.CurrentOrgId,
  18428. // Ctime: time.Now().Unix(),
  18429. // Mtime: time.Now().Unix(),
  18430. // ErrMsg: res.ErrMsg,
  18431. // Status: 1,
  18432. // PatientId: order.ID,
  18433. // Stage: 10265,
  18434. // }
  18435. // service.CreateErrMsgLog(errlog)
  18436. // continue
  18437. // } else {
  18438. // //order.FaPiaoNumber = zero
  18439. // //order.FaPiaoCode = last_order.FaPiaoCode
  18440. // //service.UpdateOrder(order)
  18441. // hisFundSettleListResult := &models.HisFundSettleListResult{
  18442. // Number: res.Output.SetlListId,
  18443. // Status: 1,
  18444. // Ctime: time.Now().Unix(),
  18445. // Mtime: time.Now().Unix(),
  18446. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18447. // IsUpload: 1,
  18448. // OrderId: order.ID,
  18449. // }
  18450. // service.CreateUploadRecord(hisFundSettleListResult)
  18451. // c.ServeSuccessJSON(map[string]interface{}{
  18452. // "msg": "上传成功",
  18453. // "result": hisFundSettleListResult,
  18454. // })
  18455. // continue
  18456. // }
  18457. // }
  18458. //}
  18459. func (c *HisApiController) GetbatchSettleList() {
  18460. //order_id, _ := c.GetInt64("order_id")
  18461. admin_user_id, _ := c.GetInt64("admin_user_id")
  18462. orders, _ := service.GetAllHisOrderTwo10485()
  18463. for _, item := range orders {
  18464. order, _ := service.GetHisOrderByIDTwo(item.ID)
  18465. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18466. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18467. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18468. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18469. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18470. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18471. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18472. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18473. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18474. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18475. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18476. //fmt.Println(count)
  18477. //var zero string
  18478. //number := count + 1
  18479. //if number >= 1000 {
  18480. // zero = "0000" + strconv.FormatInt(number, 10)
  18481. //} else if number >= 10000 {
  18482. // zero = "000" + strconv.FormatInt(number, 10)
  18483. //} else if number >= 100000 {
  18484. // zero = "00" + strconv.FormatInt(number, 10)
  18485. //} else if number >= 1000000 {
  18486. // zero = "0" + strconv.FormatInt(number, 10)
  18487. //} else {
  18488. // zero = strconv.FormatInt(number, 10)
  18489. //}
  18490. //fmt.Println(zero)
  18491. struct4101 := service.Struct4101{
  18492. PsnNo: order.PsnNo,
  18493. MdtrtId: order.MdtrtId,
  18494. SetlId: order.SetlId,
  18495. PsnName: order.PsnName,
  18496. Gend: order.Gend,
  18497. Brdy: his.Brdy,
  18498. Age: his.Age,
  18499. Naty: order.Naty,
  18500. PatnCertType: "01",
  18501. Certno: order.Certno,
  18502. Prfs: "90",
  18503. ConerName: roles[0].UserName,
  18504. PatnRlts: "99",
  18505. ConerAddr: miConfig.OrgName,
  18506. ConerTel: admin.Mobile,
  18507. HiType: order.Insutype,
  18508. Insuplc: miConfig.InsuplcAdmdvs,
  18509. MaindiagFlag: "1",
  18510. BillCode: order.SetlId,
  18511. BillNo: order.SetlId,
  18512. BizSn: order.Number,
  18513. PsnSelfPay: order.PsnPartAmt,
  18514. PsnOwnPay: order.PsnPartAmt,
  18515. AcctPay: order.AcctPay,
  18516. PsnCashpay: order.PsnCashPay,
  18517. HiPaymtd: "1",
  18518. Hsorg: miConfig.InsuplcAdmdvs,
  18519. HsorgOpter: miConfig.InsuplcAdmdvs,
  18520. MedinsFillPsn: curRoles.UserName,
  18521. MedinsFillDept: miConfig.OrgName,
  18522. IptMedType: "2",
  18523. }
  18524. struct4101.SetlBegnDate = order.SetlTime
  18525. struct4101.SetlEndDate = order.SetlTime
  18526. time_arr := strings.Split(order.SetlTime, " ")
  18527. struct4101.AdmTime = time_arr[0]
  18528. struct4101.AdmEndTime = time_arr[0]
  18529. //var rf []CustomFundPay
  18530. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18531. //
  18532. //var tempFunPays []service.CustomStruct
  18533. //for _, item := range rf {
  18534. // var tempFunPay service.CustomStruct
  18535. // tempFunPay.FundPayamt = item.FundPayamt
  18536. // tempFunPay.FundPayType = item.FundPayType
  18537. // tempFunPays = append(tempFunPays, tempFunPay)
  18538. //}
  18539. //struct4101.CustomStruct = tempFunPays
  18540. var tempDiaginfos []service.DiaginfoStructTwo
  18541. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18542. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18543. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18544. var config []*models.HisXtDiagnoseConfig
  18545. for _, item := range diagnosis_ids {
  18546. id, _ := strconv.ParseInt(item, 10, 64)
  18547. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18548. config = append(config, &diagnosisConfig)
  18549. }
  18550. for index, item := range config {
  18551. if index == 0 {
  18552. var tempDiaginfo service.DiaginfoStructTwo
  18553. tempDiaginfo.DiagCode = item.CountryCode
  18554. tempDiaginfo.DiagName = item.CountryContentName
  18555. tempDiaginfo.DiagType = "1"
  18556. tempDiaginfo.MaindiagFlag = "1"
  18557. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18558. } else {
  18559. var tempDiaginfo service.DiaginfoStructTwo
  18560. tempDiaginfo.DiagCode = item.CountryCode
  18561. tempDiaginfo.DiagName = item.CountryContentName
  18562. tempDiaginfo.DiagType = "1"
  18563. tempDiaginfo.MaindiagFlag = "0"
  18564. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18565. }
  18566. }
  18567. struct4101.Diseinfo = tempDiaginfos
  18568. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18569. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18570. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18571. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18572. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18573. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18574. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18575. var iteminfo service.IteminfoStruct
  18576. var bedCostTotal float64 = 0 //床位总费
  18577. var bedCostSelfTotal float64 = 0 //床位自费
  18578. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18579. var operationCostTotal float64 = 0 //手术费
  18580. var operationCostSelfTotal float64 = 0 //手术费
  18581. var operationCostPartSelfTotal float64 = 0 //手术费
  18582. var otherCostTotal float64 = 0 //其他费用
  18583. var otherCostSelfTotal float64 = 0 //其他费用
  18584. var otherCostPartSelfTotal float64 = 0 //其他费用
  18585. var materialCostTotal float64 = 0 //材料费
  18586. var materialCostSelfTotal float64 = 0 //材料费
  18587. var materialCostPartSelfTotal float64 = 0 //材料费
  18588. var westernMedicineCostTotal float64 = 0 //西药费
  18589. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18590. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18591. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18592. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18593. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18594. var checkCostTotal float64 = 0 //检查费
  18595. var checkCostSelfTotal float64 = 0 //检查费
  18596. var checkCostPartSelfTotal float64 = 0 //检查费
  18597. var laboratoryCostTotal float64 = 0 //化验费
  18598. var laboratoryCostSelfTotal float64 = 0 //化验费
  18599. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18600. var treatCostTotal float64 = 0 //治疗费用
  18601. var treatCostSelfTotal float64 = 0 //治疗费用
  18602. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18603. decimal.DivisionPrecision = 2
  18604. var bed_fulamt_ownpay_amt float64 = 0
  18605. var operation_fulamt_ownpay_amt float64 = 0
  18606. var other_fulamt_ownpay_amt float64 = 0
  18607. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18608. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18609. var check_fulamt_ownpay_amt float64 = 0
  18610. var material_fulamt_ownpay_amt float64 = 0
  18611. var laboratory_fulamt_ownpay_amt float64 = 0
  18612. var treat_fulamt_ownpay_amt float64 = 0
  18613. var bed_claa_sunmfee float64 = 0
  18614. var bed_clab_amt float64 = 0
  18615. var bed_other_amt float64 = 0
  18616. var operation_claa_sunmfee float64 = 0
  18617. var operation_clab_amt float64 = 0
  18618. var operation_other_amt float64 = 0
  18619. var other_claa_sunmfee float64 = 0
  18620. var other_clab_amt float64 = 0
  18621. var other_other_amt float64 = 0
  18622. var westernMedicine_claa_sunmfee float64 = 0
  18623. var westernMedicine_clab_amt float64 = 0
  18624. var westernMedicine_other_amt float64 = 0
  18625. var chineseTraditional_claa_sunmfee float64 = 0
  18626. var chineseTraditional_clab_amt float64 = 0
  18627. var chineseTraditional_other_amt float64 = 0
  18628. var check_claa_sunmfee float64 = 0
  18629. var check_clab_amt float64 = 0
  18630. var check_other_amt float64 = 0
  18631. var material_claa_sunmfee float64 = 0
  18632. var material_clab_amt float64 = 0
  18633. var material_other_amt float64 = 0
  18634. var laboratory_claa_sunmfee float64 = 0
  18635. var laboratory_clab_amt float64 = 0
  18636. var laboratory_other_amt float64 = 0
  18637. var treat_claa_sunmfee float64 = 0
  18638. var treat_clab_amt float64 = 0
  18639. var treat_other_amt float64 = 0
  18640. for _, item := range order.HisOrderInfo {
  18641. if item.MedChrgitmType == "01" { //床位费
  18642. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18643. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18644. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18645. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18646. if item.ChrgitmLv == "1" {
  18647. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18648. }
  18649. if item.ChrgitmLv == "2" {
  18650. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18651. }
  18652. if item.ChrgitmLv == "3" {
  18653. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18654. }
  18655. }
  18656. if item.MedChrgitmType == "03" { //检查费
  18657. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18658. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18659. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18660. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18661. if item.ChrgitmLv == "1" {
  18662. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18663. }
  18664. if item.ChrgitmLv == "2" {
  18665. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18666. }
  18667. if item.ChrgitmLv == "3" {
  18668. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18669. }
  18670. }
  18671. if item.MedChrgitmType == "04" { //化验费
  18672. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18673. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18674. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18675. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18676. if item.ChrgitmLv == "1" {
  18677. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18678. }
  18679. if item.ChrgitmLv == "2" {
  18680. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18681. }
  18682. if item.ChrgitmLv == "3" {
  18683. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18684. }
  18685. }
  18686. if item.MedChrgitmType == "05" { //治疗费
  18687. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18688. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18689. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18690. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18691. if item.ChrgitmLv == "1" {
  18692. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18693. }
  18694. if item.ChrgitmLv == "2" {
  18695. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18696. }
  18697. if item.ChrgitmLv == "3" {
  18698. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18699. }
  18700. }
  18701. if item.MedChrgitmType == "06" { //手术费
  18702. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18703. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18704. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18705. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18706. if item.ChrgitmLv == "1" {
  18707. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18708. }
  18709. if item.ChrgitmLv == "2" {
  18710. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18711. }
  18712. if item.ChrgitmLv == "3" {
  18713. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18714. }
  18715. }
  18716. if item.MedChrgitmType == "08" { //材料费
  18717. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18718. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18719. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18720. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18721. if item.ChrgitmLv == "1" {
  18722. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18723. }
  18724. if item.ChrgitmLv == "2" {
  18725. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18726. }
  18727. if item.ChrgitmLv == "3" {
  18728. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18729. }
  18730. }
  18731. if item.MedChrgitmType == "09" { //西药费
  18732. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18733. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18734. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18735. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18736. if item.ChrgitmLv == "1" {
  18737. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18738. }
  18739. if item.ChrgitmLv == "2" {
  18740. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18741. }
  18742. if item.ChrgitmLv == "3" {
  18743. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18744. }
  18745. }
  18746. if item.MedChrgitmType == "11" { //中成费
  18747. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18748. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18749. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18750. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18751. if item.ChrgitmLv == "1" {
  18752. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18753. }
  18754. if item.ChrgitmLv == "2" {
  18755. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18756. }
  18757. if item.ChrgitmLv == "3" {
  18758. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18759. }
  18760. }
  18761. if item.MedChrgitmType == "14" { //其他费
  18762. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18763. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18764. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18765. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18766. if item.ChrgitmLv == "1" {
  18767. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18768. }
  18769. if item.ChrgitmLv == "2" {
  18770. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18771. }
  18772. if item.ChrgitmLv == "3" {
  18773. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18774. }
  18775. }
  18776. }
  18777. var iteminfoStructs []service.IteminfoStruct
  18778. if bedCostTotal != 0 {
  18779. iteminfo.MedChrgitm = "01"
  18780. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18781. iteminfo.Amt = bedCostTotal
  18782. iteminfo.ClaaSumfee = bed_claa_sunmfee
  18783. iteminfo.ClabAmt = bed_clab_amt
  18784. iteminfo.OthAmt = bed_other_amt
  18785. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18786. }
  18787. if checkCostTotal != 0 {
  18788. iteminfo.MedChrgitm = "03"
  18789. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18790. iteminfo.Amt = checkCostTotal
  18791. iteminfo.ClaaSumfee = check_claa_sunmfee
  18792. iteminfo.ClabAmt = check_clab_amt
  18793. iteminfo.OthAmt = check_other_amt
  18794. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18795. }
  18796. if laboratoryCostTotal != 0 {
  18797. iteminfo.MedChrgitm = "04"
  18798. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18799. iteminfo.Amt = laboratoryCostTotal
  18800. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18801. iteminfo.ClabAmt = laboratory_clab_amt
  18802. iteminfo.OthAmt = laboratory_other_amt
  18803. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18804. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18805. }
  18806. if treatCostTotal != 0 {
  18807. iteminfo.MedChrgitm = "05"
  18808. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18809. iteminfo.Amt = treatCostTotal
  18810. iteminfo.ClaaSumfee = treat_claa_sunmfee
  18811. iteminfo.ClabAmt = treat_clab_amt
  18812. iteminfo.OthAmt = treat_other_amt
  18813. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18814. //(struct4101.IteminfoStruct, iteminfo)
  18815. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18816. }
  18817. if operationCostTotal != 0 {
  18818. iteminfo.MedChrgitm = "06"
  18819. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18820. iteminfo.Amt = operationCostTotal
  18821. iteminfo.ClaaSumfee = operation_claa_sunmfee
  18822. iteminfo.ClabAmt = operation_clab_amt
  18823. iteminfo.OthAmt = operation_other_amt
  18824. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18825. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18826. }
  18827. if materialCostTotal != 0 {
  18828. iteminfo.MedChrgitm = "08"
  18829. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18830. iteminfo.Amt = materialCostTotal
  18831. iteminfo.ClaaSumfee = material_claa_sunmfee
  18832. iteminfo.ClabAmt = material_clab_amt
  18833. iteminfo.OthAmt = material_other_amt
  18834. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18835. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18836. }
  18837. if westernMedicineCostTotal != 0 {
  18838. iteminfo.MedChrgitm = "09"
  18839. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18840. iteminfo.Amt = westernMedicineCostTotal
  18841. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18842. iteminfo.ClabAmt = westernMedicine_clab_amt
  18843. iteminfo.OthAmt = westernMedicine_other_amt
  18844. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18845. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18846. }
  18847. if chineseTraditionalMedicineCostTotal != 0 {
  18848. iteminfo.MedChrgitm = "11"
  18849. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18850. iteminfo.Amt = westernMedicineCostTotal
  18851. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18852. iteminfo.ClabAmt = westernMedicine_clab_amt
  18853. iteminfo.OthAmt = westernMedicine_other_amt
  18854. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18855. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18856. }
  18857. if otherCostTotal != 0 {
  18858. iteminfo.MedChrgitm = "14"
  18859. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18860. iteminfo.Amt = otherCostTotal
  18861. iteminfo.ClaaSumfee = other_claa_sunmfee
  18862. iteminfo.ClabAmt = other_clab_amt
  18863. iteminfo.OthAmt = other_other_amt
  18864. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18865. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18866. }
  18867. struct4101.IteminfoStruct = iteminfoStructs
  18868. struct4101.Ntly = "中国"
  18869. struct4101.AdmCaty = "A03.06"
  18870. struct4101.DoctorName = doctor.UserName
  18871. struct4101.DoctorCode = doctor.DoctorNumber
  18872. var res ResultSeventeen
  18873. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18874. struct4101.BillCode = order.Number
  18875. struct4101.BillNo = order.SetlId
  18876. var resOther ResultSeventeenOther
  18877. var pp models.PublicParams
  18878. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18879. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18880. pp.FixmedinsName = miConfig.OrgName
  18881. pp.FixmedinsCode = miConfig.Code
  18882. pp.RequestUrl = miConfig.Url
  18883. pp.Cainfo = miConfig.Cainfo
  18884. pp.SecretKey = miConfig.SecretKey
  18885. pp.AccessKey = miConfig.AccessKey
  18886. pp.OpterName = curRoles.UserName
  18887. client := &http.Client{}
  18888. var req *http.Request
  18889. data := make(map[string]interface{})
  18890. data["struct4101"] = struct4101
  18891. data["pp"] = pp
  18892. bytesData, _ := json.Marshal(data)
  18893. if miConfig.MdtrtareaAdmvs == "320921" {
  18894. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18895. } else {
  18896. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18897. }
  18898. resp, _ := client.Do(req)
  18899. defer resp.Body.Close()
  18900. body, ioErr := ioutil.ReadAll(resp.Body)
  18901. if ioErr != nil {
  18902. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18904. return
  18905. }
  18906. var respJSON map[string]interface{}
  18907. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18910. return
  18911. }
  18912. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18913. userJSONBytes, _ := json.Marshal(respJSON)
  18914. fmt.Println("log")
  18915. fmt.Println(string(userJSONBytes))
  18916. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18917. utils.ErrorLog("解析失败:%v", err)
  18918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18919. return
  18920. }
  18921. res.InfRefmsgid = resOther.InfRefmsgid
  18922. res.Output = resOther.Output
  18923. res.ErrMsg = resOther.ErrMsg
  18924. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18925. res.Infcode = infocode
  18926. } else if miConfig.MdtrtareaAdmvs == "360302" {
  18927. var pp models.PublicParams
  18928. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18929. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18930. pp.FixmedinsName = miConfig.OrgName
  18931. pp.FixmedinsCode = miConfig.Code
  18932. pp.RequestUrl = miConfig.Url
  18933. pp.Cainfo = miConfig.Cainfo
  18934. pp.SecretKey = miConfig.SecretKey
  18935. pp.AccessKey = miConfig.AccessKey
  18936. pp.OpterName = curRoles.UserName
  18937. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18938. result, _ := service.Jxyb4101(struct4101, pp)
  18939. var dat map[string]interface{}
  18940. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18941. fmt.Println(dat)
  18942. } else {
  18943. fmt.Println(err)
  18944. }
  18945. userJSONBytes, _ := json.Marshal(dat)
  18946. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18947. utils.ErrorLog("解析失败:%v", err)
  18948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18949. return
  18950. }
  18951. } else if miConfig.MdtrtareaAdmvs == "361025" {
  18952. var pp models.PublicParams
  18953. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18954. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18955. pp.FixmedinsName = miConfig.OrgName
  18956. pp.FixmedinsCode = miConfig.Code
  18957. pp.RequestUrl = miConfig.Url
  18958. pp.Cainfo = miConfig.Cainfo
  18959. pp.SecretKey = miConfig.SecretKey
  18960. pp.AccessKey = miConfig.AccessKey
  18961. pp.OpterName = curRoles.UserName
  18962. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18963. result, _ := service.Jxyb4101(struct4101, pp)
  18964. var dat map[string]interface{}
  18965. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18966. fmt.Println(dat)
  18967. } else {
  18968. fmt.Println(err)
  18969. }
  18970. userJSONBytes, _ := json.Marshal(dat)
  18971. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18972. utils.ErrorLog("解析失败:%v", err)
  18973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18974. return
  18975. }
  18976. } else if miConfig.MdtrtareaAdmvs == "430800" {
  18977. var pp models.PublicParams
  18978. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18979. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18980. pp.FixmedinsName = miConfig.OrgName
  18981. pp.FixmedinsCode = miConfig.Code
  18982. pp.RequestUrl = miConfig.Url
  18983. pp.Cainfo = miConfig.Cainfo
  18984. pp.SecretKey = miConfig.SecretKey
  18985. pp.AccessKey = miConfig.AccessKey
  18986. pp.OpterName = curRoles.UserName
  18987. result, _ := service.Hnyb4101(struct4101, pp)
  18988. var dat map[string]interface{}
  18989. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18990. fmt.Println(dat)
  18991. } else {
  18992. fmt.Println(err)
  18993. }
  18994. userJSONBytes, _ := json.Marshal(dat)
  18995. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18996. utils.ErrorLog("解析失败:%v", err)
  18997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18998. return
  18999. }
  19000. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19001. var resOther ResultSeventeenOther
  19002. var pp models.PublicParams
  19003. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19004. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19005. pp.FixmedinsName = miConfig.OrgName
  19006. pp.FixmedinsCode = miConfig.Code
  19007. pp.RequestUrl = miConfig.Url
  19008. pp.Cainfo = miConfig.Cainfo
  19009. pp.SecretKey = miConfig.SecretKey
  19010. pp.AccessKey = miConfig.AccessKey
  19011. pp.OpterName = curRoles.UserName
  19012. client := &http.Client{}
  19013. var req *http.Request
  19014. data := make(map[string]interface{})
  19015. data["struct4101"] = struct4101
  19016. data["pp"] = pp
  19017. bytesData, _ := json.Marshal(data)
  19018. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19019. resp, _ := client.Do(req)
  19020. defer resp.Body.Close()
  19021. body, ioErr := ioutil.ReadAll(resp.Body)
  19022. if ioErr != nil {
  19023. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19025. return
  19026. }
  19027. var respJSON map[string]interface{}
  19028. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19029. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19031. return
  19032. }
  19033. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19034. userJSONBytes, _ := json.Marshal(respJSON)
  19035. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19036. utils.ErrorLog("解析失败:%v", err)
  19037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19038. return
  19039. }
  19040. res.InfRefmsgid = resOther.InfRefmsgid
  19041. res.Output = resOther.Output
  19042. res.ErrMsg = resOther.ErrMsg
  19043. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19044. res.Infcode = infocode
  19045. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19046. var pp models.PublicParams
  19047. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19048. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19049. pp.FixmedinsName = miConfig.OrgName
  19050. pp.FixmedinsCode = miConfig.Code
  19051. pp.RequestUrl = miConfig.Url
  19052. pp.Cainfo = miConfig.Cainfo
  19053. pp.SecretKey = miConfig.SecretKey
  19054. pp.AccessKey = miConfig.AccessKey
  19055. pp.OpterName = curRoles.UserName
  19056. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19057. fmt.Println(requestLog)
  19058. fmt.Println(errMsgLog)
  19059. saveLog(result, requestLog, "4101a", "上传清单")
  19060. var dat map[string]interface{}
  19061. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19062. fmt.Println(dat)
  19063. } else {
  19064. fmt.Println(err)
  19065. }
  19066. userJSONBytes, _ := json.Marshal(dat)
  19067. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19068. utils.ErrorLog("解析失败:%v", err)
  19069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19070. return
  19071. }
  19072. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19073. var pp models.PublicParams
  19074. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19075. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19076. pp.FixmedinsName = miConfig.OrgName
  19077. pp.FixmedinsCode = miConfig.Code
  19078. pp.RequestUrl = miConfig.Url
  19079. pp.Cainfo = miConfig.Cainfo
  19080. pp.SecretKey = miConfig.SecretKey
  19081. pp.AccessKey = miConfig.AccessKey
  19082. pp.OpterName = curRoles.UserName
  19083. client := &http.Client{}
  19084. var req *http.Request
  19085. data := make(map[string]interface{})
  19086. data["struct4101"] = struct4101
  19087. data["pp"] = pp
  19088. bytesData, _ := json.Marshal(data)
  19089. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  19090. resp, _ := client.Do(req)
  19091. defer resp.Body.Close()
  19092. body, ioErr := ioutil.ReadAll(resp.Body)
  19093. if ioErr != nil {
  19094. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19096. return
  19097. }
  19098. var respJSON map[string]interface{}
  19099. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19100. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19102. return
  19103. }
  19104. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19105. userJSONBytes, _ := json.Marshal(respJSON)
  19106. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19107. utils.ErrorLog("解析失败:%v", err)
  19108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19109. return
  19110. }
  19111. } else {
  19112. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19113. var dat map[string]interface{}
  19114. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19115. fmt.Println(dat)
  19116. } else {
  19117. fmt.Println(err)
  19118. }
  19119. userJSONBytes, _ := json.Marshal(dat)
  19120. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19121. utils.ErrorLog("解析失败:%v", err)
  19122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19123. return
  19124. }
  19125. }
  19126. if res.Infcode != 0 {
  19127. errlog := &models.HisOrderError{
  19128. UserOrgId: order.UserOrgId,
  19129. Ctime: time.Now().Unix(),
  19130. Mtime: time.Now().Unix(),
  19131. ErrMsg: res.ErrMsg + "解析失败",
  19132. Status: 1,
  19133. PatientId: order.ID,
  19134. Stage: 10485,
  19135. }
  19136. service.CreateErrMsgLog(errlog)
  19137. continue
  19138. //c.ServeSuccessJSON(map[string]interface{}{
  19139. // "failed_code": -10,
  19140. // "msg": res.ErrMsg,
  19141. //})
  19142. } else {
  19143. //order.FaPiaoNumber = zero
  19144. //order.FaPiaoCode = last_order.FaPiaoCode
  19145. //service.UpdateOrder(order)
  19146. hisFundSettleListResult := &models.HisFundSettleListResult{
  19147. Number: res.Output.SetlListId,
  19148. Status: 1,
  19149. Ctime: time.Now().Unix(),
  19150. Mtime: time.Now().Unix(),
  19151. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19152. IsUpload: 1,
  19153. OrderId: order.ID,
  19154. }
  19155. service.CreateUploadRecord(hisFundSettleListResult)
  19156. continue
  19157. }
  19158. }
  19159. }
  19160. func (c *HisApiController) GetSettleList() {
  19161. order_id, _ := c.GetInt64("order_id")
  19162. admin_user_id, _ := c.GetInt64("admin_user_id")
  19163. order, _ := service.GetHisOrderByIDTwo(order_id)
  19164. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19165. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19166. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19167. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19168. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19169. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19170. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19171. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19172. if order.ID == 0 {
  19173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19174. return
  19175. }
  19176. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19177. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19178. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19179. //fmt.Println(count)
  19180. //var zero string
  19181. //number := count + 1
  19182. //if number >= 1000 {
  19183. // zero = "0000" + strconv.FormatInt(number, 10)
  19184. //} else if number >= 10000 {
  19185. // zero = "000" + strconv.FormatInt(number, 10)
  19186. //} else if number >= 100000 {
  19187. // zero = "00" + strconv.FormatInt(number, 10)
  19188. //} else if number >= 1000000 {
  19189. // zero = "0" + strconv.FormatInt(number, 10)
  19190. //} else {
  19191. // zero = strconv.FormatInt(number, 10)
  19192. //}
  19193. //fmt.Println(zero)
  19194. struct4101 := service.Struct4101{
  19195. PsnNo: order.PsnNo,
  19196. MdtrtId: order.MdtrtId,
  19197. SetlId: order.SetlId,
  19198. PsnName: order.PsnName,
  19199. Gend: order.Gend,
  19200. Brdy: his.Brdy,
  19201. Age: his.Age,
  19202. Naty: order.Naty,
  19203. PatnCertType: "01",
  19204. Certno: order.Certno,
  19205. Prfs: "90",
  19206. ConerName: roles[0].UserName,
  19207. PatnRlts: "99",
  19208. ConerAddr: miConfig.OrgName,
  19209. ConerTel: admin.Mobile,
  19210. HiType: order.Insutype,
  19211. Insuplc: miConfig.InsuplcAdmdvs,
  19212. MaindiagFlag: "1",
  19213. BillCode: order.SetlId,
  19214. BillNo: order.SetlId,
  19215. BizSn: order.Number,
  19216. PsnSelfPay: order.PsnPartAmt,
  19217. PsnOwnPay: order.PsnPartAmt,
  19218. AcctPay: order.AcctPay,
  19219. PsnCashpay: order.PsnCashPay,
  19220. HiPaymtd: "1",
  19221. Hsorg: miConfig.InsuplcAdmdvs,
  19222. HsorgOpter: miConfig.InsuplcAdmdvs,
  19223. MedinsFillPsn: curRoles.UserName,
  19224. MedinsFillDept: miConfig.OrgName,
  19225. IptMedType: "2",
  19226. }
  19227. struct4101.SetlBegnDate = order.SetlTime
  19228. struct4101.SetlEndDate = order.SetlTime
  19229. time_arr := strings.Split(order.SetlTime, " ")
  19230. struct4101.AdmTime = time_arr[0]
  19231. struct4101.AdmEndTime = time_arr[0]
  19232. //
  19233. //var rf []CustomFundPay
  19234. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19235. //
  19236. //var tempFunPays []service.CustomStruct
  19237. //for _, item := range rf {
  19238. // var tempFunPay service.CustomStruct
  19239. // tempFunPay.FundPayamt = item.FundPayamt
  19240. // tempFunPay.FundPayType = item.FundPayType
  19241. // tempFunPays = append(tempFunPays, tempFunPay)
  19242. //}
  19243. //struct4101.CustomStruct = tempFunPays
  19244. var tempDiaginfos []service.DiaginfoStructTwo
  19245. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19246. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19247. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  19248. var config []*models.HisXtDiagnoseConfig
  19249. for _, item := range diagnosis_ids {
  19250. id, _ := strconv.ParseInt(item, 10, 64)
  19251. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19252. config = append(config, &diagnosisConfig)
  19253. }
  19254. if miConfig.Code == "H15049901371" {
  19255. //for _, item := range config {
  19256. // if item.ID == 138 {
  19257. diagnosisConfig, _ := service.FindDiagnoseById(138)
  19258. var tempDiaginfo service.DiaginfoStructTwo
  19259. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  19260. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  19261. tempDiaginfo.DiagType = "1"
  19262. tempDiaginfo.MaindiagFlag = "1"
  19263. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19264. //}
  19265. //}
  19266. for _, item := range config {
  19267. if item.ID != 138 {
  19268. var tempDiaginfo service.DiaginfoStructTwo
  19269. tempDiaginfo.DiagCode = item.CountryCode
  19270. tempDiaginfo.DiagName = item.CountryContentName
  19271. tempDiaginfo.DiagType = "1"
  19272. tempDiaginfo.MaindiagFlag = "0"
  19273. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19274. }
  19275. }
  19276. } else {
  19277. for index, item := range config {
  19278. if index == 0 {
  19279. var tempDiaginfo service.DiaginfoStructTwo
  19280. tempDiaginfo.DiagCode = item.CountryCode
  19281. tempDiaginfo.DiagName = item.CountryContentName
  19282. tempDiaginfo.DiagType = "1"
  19283. tempDiaginfo.MaindiagFlag = "1"
  19284. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19285. } else {
  19286. var tempDiaginfo service.DiaginfoStructTwo
  19287. tempDiaginfo.DiagCode = item.CountryCode
  19288. tempDiaginfo.DiagName = item.CountryContentName
  19289. tempDiaginfo.DiagType = "1"
  19290. tempDiaginfo.MaindiagFlag = "0"
  19291. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19292. }
  19293. }
  19294. }
  19295. struct4101.Diseinfo = tempDiaginfos
  19296. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19297. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19298. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19299. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19300. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19301. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19302. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19303. var iteminfo service.IteminfoStruct
  19304. var bedCostTotal float64 = 0 //床位总费
  19305. var bedCostSelfTotal float64 = 0 //床位自费
  19306. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19307. var operationCostTotal float64 = 0 //手术费
  19308. var operationCostSelfTotal float64 = 0 //手术费
  19309. var operationCostPartSelfTotal float64 = 0 //手术费
  19310. var otherCostTotal float64 = 0 //其他费用
  19311. var otherCostSelfTotal float64 = 0 //其他费用
  19312. var otherCostPartSelfTotal float64 = 0 //其他费用
  19313. var materialCostTotal float64 = 0 //材料费
  19314. var materialCostSelfTotal float64 = 0 //材料费
  19315. var materialCostPartSelfTotal float64 = 0 //材料费
  19316. var westernMedicineCostTotal float64 = 0 //西药费
  19317. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19318. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19319. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19320. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19321. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19322. var checkCostTotal float64 = 0 //检查费
  19323. var checkCostSelfTotal float64 = 0 //检查费
  19324. var checkCostPartSelfTotal float64 = 0 //检查费
  19325. var laboratoryCostTotal float64 = 0 //化验费
  19326. var laboratoryCostSelfTotal float64 = 0 //化验费
  19327. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19328. var treatCostTotal float64 = 0 //治疗费用
  19329. var treatCostSelfTotal float64 = 0 //治疗费用
  19330. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19331. decimal.DivisionPrecision = 2
  19332. var bed_fulamt_ownpay_amt float64 = 0
  19333. var operation_fulamt_ownpay_amt float64 = 0
  19334. var other_fulamt_ownpay_amt float64 = 0
  19335. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19336. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19337. var check_fulamt_ownpay_amt float64 = 0
  19338. var material_fulamt_ownpay_amt float64 = 0
  19339. var laboratory_fulamt_ownpay_amt float64 = 0
  19340. var treat_fulamt_ownpay_amt float64 = 0
  19341. var bed_claa_sunmfee float64 = 0
  19342. var bed_clab_amt float64 = 0
  19343. var bed_other_amt float64 = 0
  19344. var operation_claa_sunmfee float64 = 0
  19345. var operation_clab_amt float64 = 0
  19346. var operation_other_amt float64 = 0
  19347. var other_claa_sunmfee float64 = 0
  19348. var other_clab_amt float64 = 0
  19349. var other_other_amt float64 = 0
  19350. var westernMedicine_claa_sunmfee float64 = 0
  19351. var westernMedicine_clab_amt float64 = 0
  19352. var westernMedicine_other_amt float64 = 0
  19353. var chineseTraditional_claa_sunmfee float64 = 0
  19354. var chineseTraditional_clab_amt float64 = 0
  19355. var chineseTraditional_other_amt float64 = 0
  19356. var check_claa_sunmfee float64 = 0
  19357. var check_clab_amt float64 = 0
  19358. var check_other_amt float64 = 0
  19359. var material_claa_sunmfee float64 = 0
  19360. var material_clab_amt float64 = 0
  19361. var material_other_amt float64 = 0
  19362. var laboratory_claa_sunmfee float64 = 0
  19363. var laboratory_clab_amt float64 = 0
  19364. var laboratory_other_amt float64 = 0
  19365. var treat_claa_sunmfee float64 = 0
  19366. var treat_clab_amt float64 = 0
  19367. var treat_other_amt float64 = 0
  19368. for _, item := range order.HisOrderInfo {
  19369. if item.MedChrgitmType == "01" { //床位费
  19370. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19371. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19372. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19373. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19374. if item.ChrgitmLv == "1" {
  19375. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19376. }
  19377. if item.ChrgitmLv == "2" {
  19378. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19379. }
  19380. if item.ChrgitmLv == "3" {
  19381. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19382. }
  19383. }
  19384. if item.MedChrgitmType == "03" { //检查费
  19385. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19386. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19387. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19388. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19389. if item.ChrgitmLv == "1" {
  19390. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19391. }
  19392. if item.ChrgitmLv == "2" {
  19393. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19394. }
  19395. if item.ChrgitmLv == "3" {
  19396. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19397. }
  19398. }
  19399. if item.MedChrgitmType == "04" { //化验费
  19400. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19401. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19402. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19403. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19404. if item.ChrgitmLv == "1" {
  19405. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19406. }
  19407. if item.ChrgitmLv == "2" {
  19408. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19409. }
  19410. if item.ChrgitmLv == "3" {
  19411. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19412. }
  19413. }
  19414. if item.MedChrgitmType == "05" { //治疗费
  19415. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19416. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19417. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19418. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19419. if item.ChrgitmLv == "1" {
  19420. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19421. }
  19422. if item.ChrgitmLv == "2" {
  19423. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19424. }
  19425. if item.ChrgitmLv == "3" {
  19426. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19427. }
  19428. }
  19429. if item.MedChrgitmType == "06" { //手术费
  19430. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19431. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19432. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19433. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19434. if item.ChrgitmLv == "1" {
  19435. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19436. }
  19437. if item.ChrgitmLv == "2" {
  19438. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19439. }
  19440. if item.ChrgitmLv == "3" {
  19441. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19442. }
  19443. }
  19444. if item.MedChrgitmType == "08" { //材料费
  19445. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19446. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19447. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19448. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19449. if item.ChrgitmLv == "1" {
  19450. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19451. }
  19452. if item.ChrgitmLv == "2" {
  19453. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19454. }
  19455. if item.ChrgitmLv == "3" {
  19456. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19457. }
  19458. }
  19459. if item.MedChrgitmType == "09" { //西药费
  19460. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19461. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19462. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19463. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19464. if item.ChrgitmLv == "1" {
  19465. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19466. }
  19467. if item.ChrgitmLv == "2" {
  19468. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19469. }
  19470. if item.ChrgitmLv == "3" {
  19471. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19472. }
  19473. }
  19474. if item.MedChrgitmType == "11" { //中成费
  19475. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19476. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19477. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19478. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19479. if item.ChrgitmLv == "1" {
  19480. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19481. }
  19482. if item.ChrgitmLv == "2" {
  19483. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19484. }
  19485. if item.ChrgitmLv == "3" {
  19486. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19487. }
  19488. }
  19489. if item.MedChrgitmType == "14" { //其他费
  19490. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19491. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19492. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19493. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19494. if item.ChrgitmLv == "1" {
  19495. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19496. }
  19497. if item.ChrgitmLv == "2" {
  19498. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19499. }
  19500. if item.ChrgitmLv == "3" {
  19501. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19502. }
  19503. }
  19504. }
  19505. var iteminfoStructs []service.IteminfoStruct
  19506. if bedCostTotal != 0 {
  19507. iteminfo.MedChrgitm = "01"
  19508. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19509. iteminfo.Amt = bedCostTotal
  19510. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19511. iteminfo.ClabAmt = bed_clab_amt
  19512. iteminfo.OthAmt = bed_other_amt
  19513. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19514. }
  19515. if checkCostTotal != 0 {
  19516. iteminfo.MedChrgitm = "03"
  19517. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19518. iteminfo.Amt = checkCostTotal
  19519. iteminfo.ClaaSumfee = check_claa_sunmfee
  19520. iteminfo.ClabAmt = check_clab_amt
  19521. iteminfo.OthAmt = check_other_amt
  19522. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19523. }
  19524. if laboratoryCostTotal != 0 {
  19525. iteminfo.MedChrgitm = "04"
  19526. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19527. iteminfo.Amt = laboratoryCostTotal
  19528. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19529. iteminfo.ClabAmt = laboratory_clab_amt
  19530. iteminfo.OthAmt = laboratory_other_amt
  19531. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19532. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19533. }
  19534. if treatCostTotal != 0 {
  19535. iteminfo.MedChrgitm = "05"
  19536. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19537. iteminfo.Amt = treatCostTotal
  19538. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19539. iteminfo.ClabAmt = treat_clab_amt
  19540. iteminfo.OthAmt = treat_other_amt
  19541. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19542. //(struct4101.IteminfoStruct, iteminfo)
  19543. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19544. }
  19545. if operationCostTotal != 0 {
  19546. iteminfo.MedChrgitm = "06"
  19547. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19548. iteminfo.Amt = operationCostTotal
  19549. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19550. iteminfo.ClabAmt = operation_clab_amt
  19551. iteminfo.OthAmt = operation_other_amt
  19552. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19553. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19554. }
  19555. if materialCostTotal != 0 {
  19556. iteminfo.MedChrgitm = "08"
  19557. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19558. iteminfo.Amt = materialCostTotal
  19559. iteminfo.ClaaSumfee = material_claa_sunmfee
  19560. iteminfo.ClabAmt = material_clab_amt
  19561. iteminfo.OthAmt = material_other_amt
  19562. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19563. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19564. }
  19565. if westernMedicineCostTotal != 0 {
  19566. iteminfo.MedChrgitm = "09"
  19567. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19568. iteminfo.Amt = westernMedicineCostTotal
  19569. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19570. iteminfo.ClabAmt = westernMedicine_clab_amt
  19571. iteminfo.OthAmt = westernMedicine_other_amt
  19572. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19573. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19574. }
  19575. if chineseTraditionalMedicineCostTotal != 0 {
  19576. iteminfo.MedChrgitm = "11"
  19577. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19578. iteminfo.Amt = westernMedicineCostTotal
  19579. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19580. iteminfo.ClabAmt = westernMedicine_clab_amt
  19581. iteminfo.OthAmt = westernMedicine_other_amt
  19582. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19583. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19584. }
  19585. if otherCostTotal != 0 {
  19586. iteminfo.MedChrgitm = "14"
  19587. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19588. iteminfo.Amt = otherCostTotal
  19589. iteminfo.ClaaSumfee = other_claa_sunmfee
  19590. iteminfo.ClabAmt = other_clab_amt
  19591. iteminfo.OthAmt = other_other_amt
  19592. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19593. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19594. }
  19595. struct4101.IteminfoStruct = iteminfoStructs
  19596. struct4101.Ntly = "中国"
  19597. struct4101.AdmCaty = "A03.06"
  19598. struct4101.DoctorName = doctor.UserName
  19599. struct4101.DoctorCode = doctor.DoctorNumber
  19600. var res ResultSeventeen
  19601. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19602. struct4101.BillCode = order.Number
  19603. struct4101.BillNo = order.SetlId
  19604. var resOther ResultSeventeenOther
  19605. var pp models.PublicParams
  19606. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19607. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19608. pp.FixmedinsName = miConfig.OrgName
  19609. pp.FixmedinsCode = miConfig.Code
  19610. pp.RequestUrl = miConfig.Url
  19611. pp.Cainfo = miConfig.Cainfo
  19612. pp.SecretKey = miConfig.SecretKey
  19613. pp.AccessKey = miConfig.AccessKey
  19614. pp.OpterName = curRoles.UserName
  19615. client := &http.Client{}
  19616. var req *http.Request
  19617. data := make(map[string]interface{})
  19618. data["struct4101"] = struct4101
  19619. data["pp"] = pp
  19620. bytesData, _ := json.Marshal(data)
  19621. if miConfig.MdtrtareaAdmvs == "320921" {
  19622. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19623. } else {
  19624. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19625. }
  19626. resp, _ := client.Do(req)
  19627. defer resp.Body.Close()
  19628. body, ioErr := ioutil.ReadAll(resp.Body)
  19629. if ioErr != nil {
  19630. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19632. return
  19633. }
  19634. var respJSON map[string]interface{}
  19635. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19636. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19638. return
  19639. }
  19640. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19641. userJSONBytes, _ := json.Marshal(respJSON)
  19642. fmt.Println("log")
  19643. fmt.Println(string(userJSONBytes))
  19644. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19645. utils.ErrorLog("解析失败:%v", err)
  19646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19647. return
  19648. }
  19649. res.InfRefmsgid = resOther.InfRefmsgid
  19650. res.Output = resOther.Output
  19651. res.ErrMsg = resOther.ErrMsg
  19652. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19653. res.Infcode = infocode
  19654. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19655. var pp models.PublicParams
  19656. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19657. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19658. pp.FixmedinsName = miConfig.OrgName
  19659. pp.FixmedinsCode = miConfig.Code
  19660. pp.RequestUrl = miConfig.Url
  19661. pp.Cainfo = miConfig.Cainfo
  19662. pp.SecretKey = miConfig.SecretKey
  19663. pp.AccessKey = miConfig.AccessKey
  19664. pp.OpterName = curRoles.UserName
  19665. result, _ := service.Jxyb4101(struct4101, pp)
  19666. var dat map[string]interface{}
  19667. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19668. fmt.Println(dat)
  19669. } else {
  19670. fmt.Println(err)
  19671. }
  19672. userJSONBytes, _ := json.Marshal(dat)
  19673. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19674. utils.ErrorLog("解析失败:%v", err)
  19675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19676. return
  19677. }
  19678. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19679. var pp models.PublicParams
  19680. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19681. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19682. pp.FixmedinsName = miConfig.OrgName
  19683. pp.FixmedinsCode = miConfig.Code
  19684. pp.RequestUrl = miConfig.Url
  19685. pp.Cainfo = miConfig.Cainfo
  19686. pp.SecretKey = miConfig.SecretKey
  19687. pp.AccessKey = miConfig.AccessKey
  19688. pp.OpterName = curRoles.UserName
  19689. result, _ := service.Jxyb4101(struct4101, pp)
  19690. var dat map[string]interface{}
  19691. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19692. fmt.Println(dat)
  19693. } else {
  19694. fmt.Println(err)
  19695. }
  19696. userJSONBytes, _ := json.Marshal(dat)
  19697. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19698. utils.ErrorLog("解析失败:%v", err)
  19699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19700. return
  19701. }
  19702. } else if miConfig.MdtrtareaAdmvs == "430800" {
  19703. var pp models.PublicParams
  19704. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19705. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19706. pp.FixmedinsName = miConfig.OrgName
  19707. pp.FixmedinsCode = miConfig.Code
  19708. pp.RequestUrl = miConfig.Url
  19709. pp.Cainfo = miConfig.Cainfo
  19710. pp.SecretKey = miConfig.SecretKey
  19711. pp.AccessKey = miConfig.AccessKey
  19712. pp.OpterName = curRoles.UserName
  19713. result, _ := service.Hnyb4101(struct4101, pp)
  19714. var dat map[string]interface{}
  19715. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19716. fmt.Println(dat)
  19717. } else {
  19718. fmt.Println(err)
  19719. }
  19720. userJSONBytes, _ := json.Marshal(dat)
  19721. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19722. utils.ErrorLog("解析失败:%v", err)
  19723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19724. return
  19725. }
  19726. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19727. var resOther ResultSeventeenOther
  19728. var pp models.PublicParams
  19729. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19730. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19731. pp.FixmedinsName = miConfig.OrgName
  19732. pp.FixmedinsCode = miConfig.Code
  19733. pp.RequestUrl = miConfig.Url
  19734. pp.Cainfo = miConfig.Cainfo
  19735. pp.SecretKey = miConfig.SecretKey
  19736. pp.AccessKey = miConfig.AccessKey
  19737. pp.OpterName = curRoles.UserName
  19738. client := &http.Client{}
  19739. var req *http.Request
  19740. data := make(map[string]interface{})
  19741. data["struct4101"] = struct4101
  19742. data["pp"] = pp
  19743. bytesData, _ := json.Marshal(data)
  19744. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19745. resp, _ := client.Do(req)
  19746. defer resp.Body.Close()
  19747. body, ioErr := ioutil.ReadAll(resp.Body)
  19748. if ioErr != nil {
  19749. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19751. return
  19752. }
  19753. var respJSON map[string]interface{}
  19754. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19755. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19757. return
  19758. }
  19759. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19760. userJSONBytes, _ := json.Marshal(respJSON)
  19761. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19762. utils.ErrorLog("解析失败:%v", err)
  19763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19764. return
  19765. }
  19766. res.InfRefmsgid = resOther.InfRefmsgid
  19767. res.Output = resOther.Output
  19768. res.ErrMsg = resOther.ErrMsg
  19769. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19770. res.Infcode = infocode
  19771. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19772. var pp models.PublicParams
  19773. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19774. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19775. pp.FixmedinsName = miConfig.OrgName
  19776. pp.FixmedinsCode = miConfig.Code
  19777. pp.RequestUrl = miConfig.Url
  19778. pp.Cainfo = miConfig.Cainfo
  19779. pp.SecretKey = miConfig.SecretKey
  19780. pp.AccessKey = miConfig.AccessKey
  19781. pp.OpterName = curRoles.UserName
  19782. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19783. fmt.Println(requestLog)
  19784. fmt.Println(errMsgLog)
  19785. saveLog(result, requestLog, "4101a", "上传清单")
  19786. var dat map[string]interface{}
  19787. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19788. fmt.Println(dat)
  19789. } else {
  19790. fmt.Println(err)
  19791. }
  19792. userJSONBytes, _ := json.Marshal(dat)
  19793. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19794. utils.ErrorLog("解析失败:%v", err)
  19795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19796. return
  19797. }
  19798. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19799. var pp models.PublicParams
  19800. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19801. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19802. pp.FixmedinsName = miConfig.OrgName
  19803. pp.FixmedinsCode = miConfig.Code
  19804. pp.RequestUrl = miConfig.Url
  19805. pp.Cainfo = miConfig.Cainfo
  19806. pp.SecretKey = miConfig.SecretKey
  19807. pp.AccessKey = miConfig.AccessKey
  19808. pp.OpterName = curRoles.UserName
  19809. client := &http.Client{}
  19810. var req *http.Request
  19811. data := make(map[string]interface{})
  19812. data["struct4101"] = struct4101
  19813. data["pp"] = pp
  19814. bytesData, _ := json.Marshal(data)
  19815. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  19816. resp, _ := client.Do(req)
  19817. defer resp.Body.Close()
  19818. body, ioErr := ioutil.ReadAll(resp.Body)
  19819. if ioErr != nil {
  19820. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19822. return
  19823. }
  19824. var respJSON map[string]interface{}
  19825. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19826. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19828. return
  19829. }
  19830. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19831. userJSONBytes, _ := json.Marshal(respJSON)
  19832. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19833. utils.ErrorLog("解析失败:%v", err)
  19834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19835. return
  19836. }
  19837. } else {
  19838. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19839. var dat map[string]interface{}
  19840. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19841. fmt.Println(dat)
  19842. } else {
  19843. fmt.Println(err)
  19844. }
  19845. userJSONBytes, _ := json.Marshal(dat)
  19846. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19847. utils.ErrorLog("解析失败:%v", err)
  19848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19849. return
  19850. }
  19851. }
  19852. if res.Infcode != 0 {
  19853. c.ServeSuccessJSON(map[string]interface{}{
  19854. "failed_code": -10,
  19855. "msg": res.ErrMsg,
  19856. })
  19857. return
  19858. } else {
  19859. //order.FaPiaoNumber = zero
  19860. //order.FaPiaoCode = last_order.FaPiaoCode
  19861. //service.UpdateOrder(order)
  19862. hisFundSettleListResult := &models.HisFundSettleListResult{
  19863. Number: res.Output.SetlListId,
  19864. Status: 1,
  19865. Ctime: time.Now().Unix(),
  19866. Mtime: time.Now().Unix(),
  19867. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19868. IsUpload: 1,
  19869. OrderId: order_id,
  19870. }
  19871. service.CreateUploadRecord(hisFundSettleListResult)
  19872. c.ServeSuccessJSON(map[string]interface{}{
  19873. "msg": "上传成功",
  19874. "result": hisFundSettleListResult,
  19875. })
  19876. return
  19877. }
  19878. }
  19879. func (c *HisApiController) GetSettleListHospital() {
  19880. order_id, _ := c.GetInt64("order_id")
  19881. admin_user_id, _ := c.GetInt64("admin_user_id")
  19882. order, _ := service.GetHisOrderByIDTwo(order_id)
  19883. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19884. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  19885. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19886. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19887. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19888. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19889. if order.ID == 0 {
  19890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19891. return
  19892. }
  19893. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19894. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19895. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19896. fmt.Println(count)
  19897. var zero string
  19898. number := count + 1
  19899. if number >= 1000 {
  19900. zero = "0000" + strconv.FormatInt(number, 10)
  19901. } else if number >= 10000 {
  19902. zero = "000" + strconv.FormatInt(number, 10)
  19903. } else if number >= 100000 {
  19904. zero = "00" + strconv.FormatInt(number, 10)
  19905. } else if number >= 1000000 {
  19906. zero = "0" + strconv.FormatInt(number, 10)
  19907. } else {
  19908. zero = strconv.FormatInt(number, 10)
  19909. }
  19910. fmt.Println(zero)
  19911. struct4101 := service.Struct4101{
  19912. PsnNo: order.PsnNo,
  19913. MdtrtId: order.MdtrtId,
  19914. SetlId: order.SetlId,
  19915. PsnName: order.PsnName,
  19916. Gend: order.Gend,
  19917. Brdy: his.Brdy,
  19918. Age: int64(order.Age),
  19919. Naty: order.Naty,
  19920. PatnCertType: "01",
  19921. Certno: order.Certno,
  19922. Prfs: "90",
  19923. ConerName: roles[0].UserName,
  19924. PatnRlts: "99",
  19925. ConerAddr: miConfig.OrgName,
  19926. ConerTel: admin.Mobile,
  19927. HiType: order.Insutype,
  19928. Insuplc: miConfig.InsuplcAdmdvs,
  19929. MaindiagFlag: "1",
  19930. BillCode: order.SetlId,
  19931. BillNo: order.SetlId,
  19932. BizSn: order.Number,
  19933. PsnSelfPay: order.PsnPartAmt,
  19934. PsnOwnPay: order.PsnPartAmt,
  19935. AcctPay: order.AcctPay,
  19936. PsnCashpay: order.PsnCashPay,
  19937. HiPaymtd: "1",
  19938. Hsorg: miConfig.InsuplcAdmdvs,
  19939. HsorgOpter: miConfig.InsuplcAdmdvs,
  19940. MedinsFillPsn: curRoles.UserName,
  19941. MedinsFillDept: depart.Name,
  19942. IptMedType: "2",
  19943. AdmTime: his.InHosptialTime,
  19944. AdmEndTime: his.OutHosptialTime,
  19945. }
  19946. struct4101.SetlBegnDate = order.SetlTime
  19947. struct4101.SetlEndDate = order.SetlTime
  19948. //var rf []CustomFundPay
  19949. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19950. //
  19951. //var tempFunPays []service.CustomStruct
  19952. //for _, item := range rf {
  19953. // var tempFunPay service.CustomStruct
  19954. // tempFunPay.FundPayamt = item.FundPayamt
  19955. // tempFunPay.FundPayType = item.FundPayType
  19956. // tempFunPays = append(tempFunPays, tempFunPay)
  19957. //}
  19958. //struct4101.CustomStruct = tempFunPays
  19959. var tempDiaginfos []service.DiaginfoStructTwo
  19960. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19961. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19962. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  19963. //for _, item := range infos {
  19964. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  19965. //}
  19966. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  19967. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  19968. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19969. fmt.Println(diagnosis_ids_arr)
  19970. if order.UserOrgId == 10210 {
  19971. var diagnosis_ids_arr_two []int64
  19972. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  19973. var config []*models.HisXtDiagnoseConfig
  19974. for _, id := range diagnosis_ids_arr_two {
  19975. //id, _ := strconv.ParseInt(item, 10, 64)
  19976. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19977. if diagnosisConfig.ID > 0 {
  19978. config = append(config, &diagnosisConfig)
  19979. }
  19980. }
  19981. for index, item := range config {
  19982. if item.ID > 0 {
  19983. if index == 0 {
  19984. var tempDiaginfo service.DiaginfoStructTwo
  19985. tempDiaginfo.DiagCode = item.CountryCode
  19986. tempDiaginfo.DiagName = item.CountryContentName
  19987. tempDiaginfo.DiagType = "1"
  19988. tempDiaginfo.MaindiagFlag = "1"
  19989. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19990. } else {
  19991. var tempDiaginfo service.DiaginfoStructTwo
  19992. tempDiaginfo.DiagCode = item.CountryCode
  19993. tempDiaginfo.DiagName = item.CountryContentName
  19994. tempDiaginfo.DiagType = "1"
  19995. tempDiaginfo.MaindiagFlag = "0"
  19996. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19997. }
  19998. }
  19999. }
  20000. struct4101.Diseinfo = tempDiaginfos
  20001. } else {
  20002. var config []*models.HisXtDiagnoseConfig
  20003. for _, item := range diagnosis_ids_arr {
  20004. id, _ := strconv.ParseInt(item, 10, 64)
  20005. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20006. if diagnosisConfig.ID > 0 {
  20007. config = append(config, &diagnosisConfig)
  20008. }
  20009. }
  20010. for index, item := range config {
  20011. if item.ID > 0 {
  20012. if index == 0 {
  20013. var tempDiaginfo service.DiaginfoStructTwo
  20014. tempDiaginfo.DiagCode = item.CountryCode
  20015. tempDiaginfo.DiagName = item.CountryContentName
  20016. tempDiaginfo.DiagType = "1"
  20017. tempDiaginfo.MaindiagFlag = "1"
  20018. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20019. } else {
  20020. var tempDiaginfo service.DiaginfoStructTwo
  20021. tempDiaginfo.DiagCode = item.CountryCode
  20022. tempDiaginfo.DiagName = item.CountryContentName
  20023. tempDiaginfo.DiagType = "1"
  20024. tempDiaginfo.MaindiagFlag = "0"
  20025. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20026. }
  20027. }
  20028. }
  20029. struct4101.Diseinfo = tempDiaginfos
  20030. }
  20031. sickConfigTwo, _ := service.FindSickById(his.SickType)
  20032. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20033. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20034. tempOpspdiseinfo2.OprnOprtCode = ""
  20035. tempOpspdiseinfo2.OprnOprtName = ""
  20036. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20037. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20038. var iteminfo service.IteminfoStruct
  20039. var bedCostTotal float64 = 0 //床位总费
  20040. var bedCostSelfTotal float64 = 0 //床位自费
  20041. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20042. var operationCostTotal float64 = 0 //手术费
  20043. var operationCostSelfTotal float64 = 0 //手术费
  20044. var operationCostPartSelfTotal float64 = 0 //手术费
  20045. var otherCostTotal float64 = 0 //其他费用
  20046. var otherCostSelfTotal float64 = 0 //其他费用
  20047. var otherCostPartSelfTotal float64 = 0 //其他费用
  20048. var materialCostTotal float64 = 0 //材料费
  20049. var materialCostSelfTotal float64 = 0 //材料费
  20050. var materialCostPartSelfTotal float64 = 0 //材料费
  20051. var westernMedicineCostTotal float64 = 0 //西药费
  20052. var westernMedicineCostSelfTotal float64 = 0 //西药费
  20053. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20054. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20055. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20056. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20057. var checkCostTotal float64 = 0 //检查费
  20058. var checkCostSelfTotal float64 = 0 //检查费
  20059. var checkCostPartSelfTotal float64 = 0 //检查费
  20060. var laboratoryCostTotal float64 = 0 //化验费
  20061. var laboratoryCostSelfTotal float64 = 0 //化验费
  20062. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20063. var treatCostTotal float64 = 0 //治疗费用
  20064. var treatCostSelfTotal float64 = 0 //治疗费用
  20065. var treatCostPartSelfTotal float64 = 0 //治疗费用
  20066. decimal.DivisionPrecision = 2
  20067. var bed_fulamt_ownpay_amt float64 = 0
  20068. var operation_fulamt_ownpay_amt float64 = 0
  20069. var other_fulamt_ownpay_amt float64 = 0
  20070. var westernMedicine_fulamt_ownpay_amt float64 = 0
  20071. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20072. var check_fulamt_ownpay_amt float64 = 0
  20073. var material_fulamt_ownpay_amt float64 = 0
  20074. var laboratory_fulamt_ownpay_amt float64 = 0
  20075. var treat_fulamt_ownpay_amt float64 = 0
  20076. var bed_claa_sunmfee float64 = 0
  20077. var bed_clab_amt float64 = 0
  20078. var bed_other_amt float64 = 0
  20079. var operation_claa_sunmfee float64 = 0
  20080. var operation_clab_amt float64 = 0
  20081. var operation_other_amt float64 = 0
  20082. var other_claa_sunmfee float64 = 0
  20083. var other_clab_amt float64 = 0
  20084. var other_other_amt float64 = 0
  20085. var westernMedicine_claa_sunmfee float64 = 0
  20086. var westernMedicine_clab_amt float64 = 0
  20087. var westernMedicine_other_amt float64 = 0
  20088. var chineseTraditional_claa_sunmfee float64 = 0
  20089. var chineseTraditional_clab_amt float64 = 0
  20090. var chineseTraditional_other_amt float64 = 0
  20091. var check_claa_sunmfee float64 = 0
  20092. var check_clab_amt float64 = 0
  20093. var check_other_amt float64 = 0
  20094. var material_claa_sunmfee float64 = 0
  20095. var material_clab_amt float64 = 0
  20096. var material_other_amt float64 = 0
  20097. var laboratory_claa_sunmfee float64 = 0
  20098. var laboratory_clab_amt float64 = 0
  20099. var laboratory_other_amt float64 = 0
  20100. var treat_claa_sunmfee float64 = 0
  20101. var treat_clab_amt float64 = 0
  20102. var treat_other_amt float64 = 0
  20103. for _, item := range order.HisOrderInfo {
  20104. if item.MedChrgitmType == "01" { //床位费
  20105. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20106. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20107. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20108. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20109. if item.ChrgitmLv == "1" {
  20110. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20111. }
  20112. if item.ChrgitmLv == "2" {
  20113. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20114. }
  20115. if item.ChrgitmLv == "3" {
  20116. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20117. }
  20118. }
  20119. if item.MedChrgitmType == "03" { //检查费
  20120. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20121. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20122. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20123. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20124. if item.ChrgitmLv == "1" {
  20125. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20126. }
  20127. if item.ChrgitmLv == "2" {
  20128. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20129. }
  20130. if item.ChrgitmLv == "3" {
  20131. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20132. }
  20133. }
  20134. if item.MedChrgitmType == "04" { //化验费
  20135. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20136. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20137. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20138. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20139. if item.ChrgitmLv == "1" {
  20140. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20141. }
  20142. if item.ChrgitmLv == "2" {
  20143. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20144. }
  20145. if item.ChrgitmLv == "3" {
  20146. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20147. }
  20148. }
  20149. if item.MedChrgitmType == "05" { //治疗费
  20150. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20151. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20152. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20153. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20154. if item.ChrgitmLv == "1" {
  20155. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20156. }
  20157. if item.ChrgitmLv == "2" {
  20158. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20159. }
  20160. if item.ChrgitmLv == "3" {
  20161. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20162. }
  20163. }
  20164. if item.MedChrgitmType == "06" { //手术费
  20165. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20166. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20167. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20168. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20169. if item.ChrgitmLv == "1" {
  20170. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20171. }
  20172. if item.ChrgitmLv == "2" {
  20173. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20174. }
  20175. if item.ChrgitmLv == "3" {
  20176. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20177. }
  20178. }
  20179. if item.MedChrgitmType == "08" { //材料费
  20180. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20181. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20182. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20183. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20184. if item.ChrgitmLv == "1" {
  20185. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20186. }
  20187. if item.ChrgitmLv == "2" {
  20188. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20189. }
  20190. if item.ChrgitmLv == "3" {
  20191. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20192. }
  20193. }
  20194. if item.MedChrgitmType == "09" { //西药费
  20195. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20196. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20197. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20198. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20199. if item.ChrgitmLv == "1" {
  20200. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20201. }
  20202. if item.ChrgitmLv == "2" {
  20203. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20204. }
  20205. if item.ChrgitmLv == "3" {
  20206. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20207. }
  20208. }
  20209. if item.MedChrgitmType == "11" { //中成费
  20210. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20211. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20212. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20213. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20214. if item.ChrgitmLv == "1" {
  20215. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20216. }
  20217. if item.ChrgitmLv == "2" {
  20218. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20219. }
  20220. if item.ChrgitmLv == "3" {
  20221. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20222. }
  20223. }
  20224. if item.MedChrgitmType == "14" { //其他费
  20225. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20226. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20227. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20228. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20229. if item.ChrgitmLv == "1" {
  20230. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20231. }
  20232. if item.ChrgitmLv == "2" {
  20233. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20234. }
  20235. if item.ChrgitmLv == "3" {
  20236. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20237. }
  20238. }
  20239. }
  20240. var iteminfoStructs []service.IteminfoStruct
  20241. if bedCostTotal != 0 {
  20242. iteminfo.MedChrgitm = "01"
  20243. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20244. iteminfo.Amt = bedCostTotal
  20245. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20246. iteminfo.ClabAmt = bed_clab_amt
  20247. iteminfo.OthAmt = bed_other_amt
  20248. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20249. }
  20250. if checkCostTotal != 0 {
  20251. iteminfo.MedChrgitm = "03"
  20252. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20253. iteminfo.Amt = checkCostTotal
  20254. iteminfo.ClaaSumfee = check_claa_sunmfee
  20255. iteminfo.ClabAmt = check_clab_amt
  20256. iteminfo.OthAmt = check_other_amt
  20257. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20258. }
  20259. if laboratoryCostTotal != 0 {
  20260. iteminfo.MedChrgitm = "04"
  20261. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20262. iteminfo.Amt = laboratoryCostTotal
  20263. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20264. iteminfo.ClabAmt = laboratory_clab_amt
  20265. iteminfo.OthAmt = laboratory_other_amt
  20266. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20267. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20268. }
  20269. if treatCostTotal != 0 {
  20270. iteminfo.MedChrgitm = "05"
  20271. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20272. iteminfo.Amt = treatCostTotal
  20273. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20274. iteminfo.ClabAmt = treat_clab_amt
  20275. iteminfo.OthAmt = treat_other_amt
  20276. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20277. //(struct4101.IteminfoStruct, iteminfo)
  20278. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20279. }
  20280. if operationCostTotal != 0 {
  20281. iteminfo.MedChrgitm = "06"
  20282. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20283. iteminfo.Amt = operationCostTotal
  20284. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20285. iteminfo.ClabAmt = operation_clab_amt
  20286. iteminfo.OthAmt = operation_other_amt
  20287. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20288. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20289. }
  20290. if materialCostTotal != 0 {
  20291. iteminfo.MedChrgitm = "08"
  20292. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20293. iteminfo.Amt = materialCostTotal
  20294. iteminfo.ClaaSumfee = material_claa_sunmfee
  20295. iteminfo.ClabAmt = material_clab_amt
  20296. iteminfo.OthAmt = material_other_amt
  20297. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20298. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20299. }
  20300. if westernMedicineCostTotal != 0 {
  20301. iteminfo.MedChrgitm = "09"
  20302. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20303. iteminfo.Amt = westernMedicineCostTotal
  20304. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20305. iteminfo.ClabAmt = westernMedicine_clab_amt
  20306. iteminfo.OthAmt = westernMedicine_other_amt
  20307. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20308. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20309. }
  20310. if chineseTraditionalMedicineCostTotal != 0 {
  20311. iteminfo.MedChrgitm = "11"
  20312. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20313. iteminfo.Amt = westernMedicineCostTotal
  20314. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20315. iteminfo.ClabAmt = westernMedicine_clab_amt
  20316. iteminfo.OthAmt = westernMedicine_other_amt
  20317. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20318. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20319. }
  20320. if otherCostTotal != 0 {
  20321. iteminfo.MedChrgitm = "14"
  20322. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20323. iteminfo.Amt = otherCostTotal
  20324. iteminfo.ClaaSumfee = other_claa_sunmfee
  20325. iteminfo.ClabAmt = other_clab_amt
  20326. iteminfo.OthAmt = other_other_amt
  20327. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20328. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20329. }
  20330. struct4101.IteminfoStruct = iteminfoStructs
  20331. struct4101.Ntly = "中国"
  20332. struct4101.AdmCaty = "A03.06"
  20333. var resOther ResultSeventeenOther
  20334. var res ResultSeventeen
  20335. if miConfig.MdtrtareaAdmvs == "150499" {
  20336. var pp models.PublicParams
  20337. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20338. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20339. pp.FixmedinsName = miConfig.OrgName
  20340. pp.FixmedinsCode = miConfig.Code
  20341. pp.RequestUrl = miConfig.Url
  20342. pp.Cainfo = miConfig.Cainfo
  20343. pp.SecretKey = miConfig.SecretKey
  20344. pp.AccessKey = miConfig.AccessKey
  20345. pp.OpterName = curRoles.UserName
  20346. client := &http.Client{}
  20347. var req *http.Request
  20348. data := make(map[string]interface{})
  20349. data["struct4101"] = struct4101
  20350. data["pp"] = pp
  20351. bytesData, _ := json.Marshal(data)
  20352. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20353. resp, _ := client.Do(req)
  20354. defer resp.Body.Close()
  20355. body, ioErr := ioutil.ReadAll(resp.Body)
  20356. if ioErr != nil {
  20357. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20359. return
  20360. }
  20361. var respJSON map[string]interface{}
  20362. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20363. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20365. return
  20366. }
  20367. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20368. userJSONBytes, _ := json.Marshal(respJSON)
  20369. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20370. utils.ErrorLog("解析失败:%v", err)
  20371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20372. return
  20373. }
  20374. res.InfRefmsgid = resOther.InfRefmsgid
  20375. res.Output = resOther.Output
  20376. res.ErrMsg = resOther.ErrMsg
  20377. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20378. res.Infcode = infocode
  20379. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20380. var pp models.PublicParams
  20381. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20382. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20383. pp.FixmedinsName = miConfig.OrgName
  20384. pp.FixmedinsCode = miConfig.Code
  20385. pp.RequestUrl = miConfig.Url
  20386. pp.Cainfo = miConfig.Cainfo
  20387. pp.SecretKey = miConfig.SecretKey
  20388. pp.AccessKey = miConfig.AccessKey
  20389. pp.OpterName = curRoles.UserName
  20390. result, _ := service.Jxyb4101(struct4101, pp)
  20391. var dat map[string]interface{}
  20392. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20393. fmt.Println(dat)
  20394. } else {
  20395. fmt.Println(err)
  20396. }
  20397. userJSONBytes, _ := json.Marshal(dat)
  20398. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20399. utils.ErrorLog("解析失败:%v", err)
  20400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20401. return
  20402. }
  20403. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20404. var pp models.PublicParams
  20405. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20406. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20407. pp.FixmedinsName = miConfig.OrgName
  20408. pp.FixmedinsCode = miConfig.Code
  20409. pp.RequestUrl = miConfig.Url
  20410. pp.Cainfo = miConfig.Cainfo
  20411. pp.SecretKey = miConfig.SecretKey
  20412. pp.AccessKey = miConfig.AccessKey
  20413. pp.OpterName = curRoles.UserName
  20414. result, _ := service.Jxyb4101(struct4101, pp)
  20415. var dat map[string]interface{}
  20416. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20417. fmt.Println(dat)
  20418. } else {
  20419. fmt.Println(err)
  20420. }
  20421. userJSONBytes, _ := json.Marshal(dat)
  20422. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20423. utils.ErrorLog("解析失败:%v", err)
  20424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20425. return
  20426. }
  20427. } else {
  20428. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20429. var dat map[string]interface{}
  20430. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20431. fmt.Println(dat)
  20432. } else {
  20433. fmt.Println(err)
  20434. }
  20435. userJSONBytes, _ := json.Marshal(dat)
  20436. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20437. utils.ErrorLog("解析失败:%v", err)
  20438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20439. return
  20440. }
  20441. }
  20442. if res.Infcode != 0 {
  20443. c.ServeSuccessJSON(map[string]interface{}{
  20444. "failed_code": -10,
  20445. "msg": res.ErrMsg,
  20446. })
  20447. return
  20448. } else {
  20449. if miConfig.MdtrtareaAdmvs != "150499" {
  20450. order.FaPiaoNumber = zero
  20451. order.FaPiaoCode = last_order.FaPiaoCode
  20452. service.UpdateOrder(order)
  20453. }
  20454. hisFundSettleListResult := &models.HisFundSettleListResult{
  20455. Number: res.Output.SetlListId,
  20456. Status: 1,
  20457. Ctime: time.Now().Unix(),
  20458. Mtime: time.Now().Unix(),
  20459. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20460. IsUpload: 1,
  20461. OrderId: order_id,
  20462. }
  20463. service.CreateUploadRecord(hisFundSettleListResult)
  20464. c.ServeSuccessJSON(map[string]interface{}{
  20465. "msg": "上传成功",
  20466. "result": hisFundSettleListResult,
  20467. })
  20468. return
  20469. }
  20470. }
  20471. //func (c *HisApiController) GetBatchSettleList() {
  20472. // orders, _ := service.GetAllHisOrder(10106)
  20473. // for _, item := range orders {
  20474. // order_id := item.ID
  20475. // order, _ := service.GetHisOrderByIDTwo(order_id)
  20476. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20477. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20478. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20479. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  20480. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20481. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20482. //
  20483. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20484. //
  20485. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20486. //
  20487. // if order.ID == 0 {
  20488. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20489. // return
  20490. // }
  20491. // if his.BalanceAccountsType == 2 {
  20492. // continue
  20493. // }
  20494. // struct4101 := service.Struct4101{
  20495. // PsnNo: order.PsnNo,
  20496. // MdtrtId: order.MdtrtId,
  20497. // SetlId: order.SetlId,
  20498. // PsnName: order.PsnName,
  20499. // Gend: order.Gend,
  20500. // Brdy: his.Brdy,
  20501. // Age: his.Age,
  20502. // Naty: order.Naty,
  20503. // PatnCertType: "01",
  20504. // Certno: order.Certno,
  20505. // Prfs: "90",
  20506. // ConerName: roles[0].UserName,
  20507. // PatnRlts: "99",
  20508. // ConerAddr: miConfig.OrgName,
  20509. // ConerTel: admin.Mobile,
  20510. // HiType: order.Insutype,
  20511. // Insuplc: his.InsuplcAdmdvs,
  20512. // MaindiagFlag: "1",
  20513. // BillCode: order.SetlId,
  20514. // BillNo: order.SetlId,
  20515. // BizSn: order.Number,
  20516. // PsnSelfPay: order.PsnPartAmt,
  20517. // PsnOwnPay: order.PsnPartAmt,
  20518. // AcctPay: order.AcctPay,
  20519. // PsnCashpay: order.PsnCashPay,
  20520. // HiPaymtd: "1",
  20521. // Hsorg: his.InsuplcAdmdvs,
  20522. // HsorgOpter: his.InsuplcAdmdvs,
  20523. // MedinsFillPsn: curRoles.UserName,
  20524. // MedinsFillDept: depart.Name,
  20525. // IptMedType: "2",
  20526. // }
  20527. // struct4101.SetlBegnDate = order.SetlTime
  20528. // struct4101.SetlEndDate = order.SetlTime
  20529. // //if order.SettleType == 1 {
  20530. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  20531. // // dateStr := t.Format("2006-01-02")
  20532. // // struct4101.SetlBegnDate = dateStr
  20533. // // struct4101.SetlEndDate = dateStr
  20534. // //} else {
  20535. // // t := time.Unix(int64(order.SettleStartTime), 0)
  20536. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  20537. // // dateStartStr := t.Format("2006-01-02")
  20538. // // dateEndStr := t2.Format("2006-01-02")
  20539. // // struct4101.SetlBegnDate = dateStartStr
  20540. // // struct4101.SetlEndDate = dateEndStr
  20541. // //}
  20542. //
  20543. // var rf []CustomFundPay
  20544. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  20545. //
  20546. // var tempFunPays []service.CustomStruct
  20547. // var tempFunPay610100 service.CustomStruct
  20548. //
  20549. // for _, item := range rf {
  20550. // if item.FundPayType == "610100" {
  20551. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  20552. // tempFunPay610100.FundPayType = item.FundPayType
  20553. // } else {
  20554. // var tempFunPay service.CustomStruct
  20555. // tempFunPay.FundPayamt = item.FundPayamt
  20556. // tempFunPay.FundPayType = item.FundPayType
  20557. // tempFunPays = append(tempFunPays, tempFunPay)
  20558. // }
  20559. // }
  20560. // tempFunPays = append(tempFunPays, tempFunPay610100)
  20561. // struct4101.CustomStruct = tempFunPays
  20562. //
  20563. // var tempDiaginfos []service.DiaginfoStructTwo
  20564. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20565. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20566. //
  20567. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  20568. // var config []*models.HisXtDiagnoseConfig
  20569. // for _, item := range diagnosis_ids {
  20570. // id, _ := strconv.ParseInt(item, 10, 64)
  20571. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  20572. // config = append(config, &diagnosisConfig)
  20573. // }
  20574. //
  20575. // for index, item := range config {
  20576. // if index == 0 {
  20577. // var tempDiaginfo service.DiaginfoStructTwo
  20578. // tempDiaginfo.DiagCode = item.CountryCode
  20579. // tempDiaginfo.DiagName = item.CountryContentName
  20580. // tempDiaginfo.DiagType = "1"
  20581. // tempDiaginfo.MaindiagFlag = "1"
  20582. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20583. // } else {
  20584. //
  20585. // var tempDiaginfo service.DiaginfoStructTwo
  20586. // tempDiaginfo.DiagCode = item.CountryCode
  20587. // tempDiaginfo.DiagName = item.CountryContentName
  20588. // tempDiaginfo.DiagType = "2"
  20589. // tempDiaginfo.MaindiagFlag = "0"
  20590. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20591. // }
  20592. // }
  20593. // struct4101.Diseinfo = tempDiaginfos
  20594. //
  20595. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  20596. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20597. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20598. // tempOpspdiseinfo2.OprnOprtCode = ""
  20599. // tempOpspdiseinfo2.OprnOprtName = ""
  20600. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20601. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20602. //
  20603. // var iteminfo service.IteminfoStruct
  20604. //
  20605. // var bedCostTotal float64 = 0 //床位总费
  20606. // var bedCostSelfTotal float64 = 0 //床位自费
  20607. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20608. //
  20609. // var examineCostTotal float64 = 0 //诊查总费
  20610. // var examineCostSelfTotal float64 = 0 //诊查自费
  20611. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  20612. //
  20613. // var nursingCostTotal float64 = 0 //护理总费
  20614. // var nursingCostSelfTotal float64 = 0 //护理自费
  20615. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  20616. //
  20617. // var chineseMedicineCostTotal float64 = 0 //中成药
  20618. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  20619. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  20620. //
  20621. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  20622. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  20623. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  20624. //
  20625. // var registerCostTotal float64 = 0 //一般诊疗费
  20626. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  20627. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  20628. //
  20629. // var operationCostTotal float64 = 0 //手术费
  20630. // var operationCostSelfTotal float64 = 0 //手术费
  20631. // var operationCostPartSelfTotal float64 = 0 //手术费
  20632. //
  20633. // var otherCostTotal float64 = 0 //其他费用
  20634. // var otherCostSelfTotal float64 = 0 //其他费用
  20635. // var otherCostPartSelfTotal float64 = 0 //其他费用
  20636. //
  20637. // var materialCostTotal float64 = 0 //材料费
  20638. // var materialCostSelfTotal float64 = 0 //材料费
  20639. // var materialCostPartSelfTotal float64 = 0 //材料费
  20640. //
  20641. // var westernMedicineCostTotal float64 = 0 //西药费
  20642. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  20643. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20644. //
  20645. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20646. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20647. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20648. //
  20649. // var checkCostTotal float64 = 0 //检查费
  20650. // var checkCostSelfTotal float64 = 0 //检查费
  20651. // var checkCostPartSelfTotal float64 = 0 //检查费
  20652. //
  20653. // var laboratoryCostTotal float64 = 0 //化验费
  20654. // var laboratoryCostSelfTotal float64 = 0 //化验费
  20655. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20656. //
  20657. // var treatCostTotal float64 = 0 //治疗费用
  20658. // var treatCostSelfTotal float64 = 0 //治疗费用
  20659. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  20660. //
  20661. // decimal.DivisionPrecision = 2
  20662. //
  20663. // var bed_fulamt_ownpay_amt float64 = 0
  20664. //
  20665. // var examine_fulamt_ownpay_amt float64 = 0
  20666. //
  20667. // var nursing_fulamt_ownpay_amt float64 = 0
  20668. //
  20669. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  20670. //
  20671. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  20672. //
  20673. // var register_fulamt_ownpay_amt float64 = 0
  20674. //
  20675. // var operation_fulamt_ownpay_amt float64 = 0
  20676. // var other_fulamt_ownpay_amt float64 = 0
  20677. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  20678. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20679. // var check_fulamt_ownpay_amt float64 = 0
  20680. // var material_fulamt_ownpay_amt float64 = 0
  20681. // var laboratory_fulamt_ownpay_amt float64 = 0
  20682. // var treat_fulamt_ownpay_amt float64 = 0
  20683. //
  20684. // var bed_claa_sunmfee float64 = 0
  20685. // var bed_clab_amt float64 = 0
  20686. // var bed_other_amt float64 = 0
  20687. //
  20688. // var examine_claa_sunmfee float64 = 0
  20689. // var examine_clab_amt float64 = 0
  20690. // var examine_other_amt float64 = 0
  20691. //
  20692. // var nursing_claa_sunmfee float64 = 0
  20693. // var nursing_clab_amt float64 = 0
  20694. // var nursing_other_amt float64 = 0
  20695. //
  20696. // var chinese_medicine_claa_sunmfee float64 = 0
  20697. // var chinese_medicine_clab_amt float64 = 0
  20698. // var chinese_medicine_other_amt float64 = 0
  20699. //
  20700. // var commonly_treatment_claa_sunmfee float64 = 0
  20701. // var commonly_treatment_clab_amt float64 = 0
  20702. // var commonly_treatment_other_amt float64 = 0
  20703. //
  20704. // var operation_claa_sunmfee float64 = 0
  20705. // var operation_clab_amt float64 = 0
  20706. // var operation_other_amt float64 = 0
  20707. //
  20708. // var other_claa_sunmfee float64 = 0
  20709. // var other_clab_amt float64 = 0
  20710. // var other_other_amt float64 = 0
  20711. //
  20712. // var westernMedicine_claa_sunmfee float64 = 0
  20713. // var westernMedicine_clab_amt float64 = 0
  20714. // var westernMedicine_other_amt float64 = 0
  20715. //
  20716. // var chineseTraditional_claa_sunmfee float64 = 0
  20717. // var chineseTraditional_clab_amt float64 = 0
  20718. // var chineseTraditional_other_amt float64 = 0
  20719. //
  20720. // var check_claa_sunmfee float64 = 0
  20721. // var check_clab_amt float64 = 0
  20722. // var check_other_amt float64 = 0
  20723. //
  20724. // var material_claa_sunmfee float64 = 0
  20725. // var material_clab_amt float64 = 0
  20726. // var material_other_amt float64 = 0
  20727. //
  20728. // var laboratory_claa_sunmfee float64 = 0
  20729. // var laboratory_clab_amt float64 = 0
  20730. // var laboratory_other_amt float64 = 0
  20731. //
  20732. // var treat_claa_sunmfee float64 = 0
  20733. // var treat_clab_amt float64 = 0
  20734. // var treat_other_amt float64 = 0
  20735. //
  20736. // var register_claa_sunmfee float64 = 0
  20737. // var register_clab_amt float64 = 0
  20738. // var register_other_amt float64 = 0
  20739. //
  20740. // for _, item := range order.HisOrderInfo {
  20741. // if item.MedChrgitmType == "01" { //床位费
  20742. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20743. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20744. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20745. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20746. // if item.ChrgitmLv == "1" {
  20747. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20748. // }
  20749. // if item.ChrgitmLv == "2" {
  20750. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20751. //
  20752. // }
  20753. // if item.ChrgitmLv == "3" {
  20754. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20755. // }
  20756. //
  20757. // }
  20758. //
  20759. // if item.MedChrgitmType == "02" { //诊查
  20760. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20761. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20762. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20763. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20764. // if item.ChrgitmLv == "1" {
  20765. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20766. // }
  20767. // if item.ChrgitmLv == "2" {
  20768. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20769. //
  20770. // }
  20771. // if item.ChrgitmLv == "3" {
  20772. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20773. // }
  20774. //
  20775. // }
  20776. //
  20777. // if item.MedChrgitmType == "03" { //检查费
  20778. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20779. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20780. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20781. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20782. // if item.ChrgitmLv == "1" {
  20783. //
  20784. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20785. //
  20786. // }
  20787. // if item.ChrgitmLv == "2" {
  20788. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20789. //
  20790. // }
  20791. // if item.ChrgitmLv == "3" {
  20792. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20793. // }
  20794. // }
  20795. //
  20796. // if item.MedChrgitmType == "04" { //化验费
  20797. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20798. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20799. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20800. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20801. // if item.ChrgitmLv == "1" {
  20802. //
  20803. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20804. //
  20805. // }
  20806. // if item.ChrgitmLv == "2" {
  20807. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20808. //
  20809. // }
  20810. // if item.ChrgitmLv == "3" {
  20811. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20812. // }
  20813. // }
  20814. //
  20815. // if item.MedChrgitmType == "05" { //治疗费
  20816. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20817. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20818. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20819. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20820. // if item.ChrgitmLv == "1" {
  20821. //
  20822. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20823. //
  20824. // }
  20825. // if item.ChrgitmLv == "2" {
  20826. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20827. //
  20828. // }
  20829. // if item.ChrgitmLv == "3" {
  20830. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20831. // }
  20832. // }
  20833. //
  20834. // if item.MedChrgitmType == "06" { //手术费
  20835. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20836. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20837. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20838. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20839. //
  20840. // if item.ChrgitmLv == "1" {
  20841. //
  20842. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20843. //
  20844. // }
  20845. // if item.ChrgitmLv == "2" {
  20846. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20847. //
  20848. // }
  20849. // if item.ChrgitmLv == "3" {
  20850. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20851. // }
  20852. // }
  20853. //
  20854. // if item.MedChrgitmType == "07" { //手术费
  20855. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20856. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20857. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20858. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20859. //
  20860. // if item.ChrgitmLv == "1" {
  20861. //
  20862. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20863. //
  20864. // }
  20865. // if item.ChrgitmLv == "2" {
  20866. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20867. //
  20868. // }
  20869. // if item.ChrgitmLv == "3" {
  20870. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20871. // }
  20872. // }
  20873. //
  20874. // if item.MedChrgitmType == "08" { //材料费
  20875. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20876. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20877. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20878. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20879. // if item.ChrgitmLv == "1" {
  20880. //
  20881. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20882. //
  20883. // }
  20884. // if item.ChrgitmLv == "2" {
  20885. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20886. //
  20887. // }
  20888. // if item.ChrgitmLv == "3" {
  20889. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20890. // }
  20891. // }
  20892. // if item.MedChrgitmType == "09" { //西药费
  20893. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20894. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20895. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20896. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20897. // if item.ChrgitmLv == "1" {
  20898. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20899. // }
  20900. // if item.ChrgitmLv == "2" {
  20901. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20902. // }
  20903. // if item.ChrgitmLv == "3" {
  20904. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20905. // }
  20906. // }
  20907. // if item.MedChrgitmType == "10" { //中药饮片
  20908. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20909. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20910. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20911. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20912. // if item.ChrgitmLv == "1" {
  20913. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20914. // }
  20915. // if item.ChrgitmLv == "2" {
  20916. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20917. // }
  20918. // if item.ChrgitmLv == "3" {
  20919. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20920. // }
  20921. // }
  20922. //
  20923. // if item.MedChrgitmType == "11" { //中成费
  20924. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20925. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20926. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20927. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20928. // if item.ChrgitmLv == "1" {
  20929. //
  20930. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20931. //
  20932. // }
  20933. // if item.ChrgitmLv == "2" {
  20934. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20935. //
  20936. // }
  20937. // if item.ChrgitmLv == "3" {
  20938. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20939. // }
  20940. // }
  20941. //
  20942. // if item.MedChrgitmType == "12" { //中成费
  20943. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20944. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20945. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20946. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20947. // if item.ChrgitmLv == "1" {
  20948. //
  20949. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20950. //
  20951. // }
  20952. // if item.ChrgitmLv == "2" {
  20953. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20954. //
  20955. // }
  20956. // if item.ChrgitmLv == "3" {
  20957. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20958. // }
  20959. // }
  20960. //
  20961. // if item.MedChrgitmType == "13" { //中成费
  20962. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20963. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20964. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20965. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20966. // if item.ChrgitmLv == "1" {
  20967. //
  20968. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20969. //
  20970. // }
  20971. // if item.ChrgitmLv == "2" {
  20972. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20973. //
  20974. // }
  20975. // if item.ChrgitmLv == "3" {
  20976. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20977. // }
  20978. // }
  20979. //
  20980. // if item.MedChrgitmType == "14" { //其他费
  20981. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20982. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20983. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20984. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20985. // if item.ChrgitmLv == "1" {
  20986. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20987. //
  20988. // }
  20989. // if item.ChrgitmLv == "2" {
  20990. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20991. //
  20992. // }
  20993. // if item.ChrgitmLv == "3" {
  20994. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20995. // }
  20996. // }
  20997. //
  20998. // }
  20999. //
  21000. // var iteminfoStructs []service.IteminfoStruct
  21001. //
  21002. // if bedCostTotal != 0 {
  21003. // iteminfo.MedChrgitm = "01"
  21004. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21005. // iteminfo.Amt = bedCostTotal
  21006. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  21007. // iteminfo.ClabAmt = bed_clab_amt
  21008. // iteminfo.OthAmt = bed_other_amt
  21009. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21010. // }
  21011. //
  21012. // if examineCostTotal != 0 {
  21013. // iteminfo.MedChrgitm = "02"
  21014. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  21015. // iteminfo.Amt = examineCostTotal
  21016. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  21017. // iteminfo.ClabAmt = examine_clab_amt
  21018. // iteminfo.OthAmt = examine_other_amt
  21019. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21020. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21021. // }
  21022. //
  21023. // if checkCostTotal != 0 {
  21024. // iteminfo.MedChrgitm = "03"
  21025. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  21026. // iteminfo.Amt = checkCostTotal
  21027. // iteminfo.ClaaSumfee = check_claa_sunmfee
  21028. // iteminfo.ClabAmt = check_clab_amt
  21029. // iteminfo.OthAmt = check_other_amt
  21030. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21031. //
  21032. // }
  21033. //
  21034. // if laboratoryCostTotal != 0 {
  21035. // iteminfo.MedChrgitm = "04"
  21036. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  21037. // iteminfo.Amt = laboratoryCostTotal
  21038. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  21039. // iteminfo.ClabAmt = laboratory_clab_amt
  21040. // iteminfo.OthAmt = laboratory_other_amt
  21041. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21042. //
  21043. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21044. //
  21045. // }
  21046. //
  21047. // if treatCostTotal != 0 {
  21048. // iteminfo.MedChrgitm = "05"
  21049. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  21050. // iteminfo.Amt = treatCostTotal
  21051. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  21052. // iteminfo.ClabAmt = treat_clab_amt
  21053. // iteminfo.OthAmt = treat_other_amt
  21054. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21055. // //(struct4101.IteminfoStruct, iteminfo)
  21056. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21057. // }
  21058. //
  21059. // if operationCostTotal != 0 {
  21060. // iteminfo.MedChrgitm = "06"
  21061. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21062. // iteminfo.Amt = operationCostTotal
  21063. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  21064. // iteminfo.ClabAmt = operation_clab_amt
  21065. // iteminfo.OthAmt = operation_other_amt
  21066. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21067. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21068. // }
  21069. //
  21070. // if nursingCostTotal != 0 {
  21071. // iteminfo.MedChrgitm = "07"
  21072. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  21073. // iteminfo.Amt = nursingCostTotal
  21074. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  21075. // iteminfo.ClabAmt = nursing_clab_amt
  21076. // iteminfo.OthAmt = nursing_other_amt
  21077. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21078. // }
  21079. //
  21080. // if materialCostTotal != 0 {
  21081. // iteminfo.MedChrgitm = "08"
  21082. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  21083. // iteminfo.Amt = materialCostTotal
  21084. // iteminfo.ClaaSumfee = material_claa_sunmfee
  21085. // iteminfo.ClabAmt = material_clab_amt
  21086. // iteminfo.OthAmt = material_other_amt
  21087. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21088. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21089. // }
  21090. //
  21091. // if westernMedicineCostTotal != 0 {
  21092. // iteminfo.MedChrgitm = "09"
  21093. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21094. // iteminfo.Amt = westernMedicineCostTotal
  21095. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21096. // iteminfo.ClabAmt = westernMedicine_clab_amt
  21097. // iteminfo.OthAmt = westernMedicine_other_amt
  21098. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21099. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21100. //
  21101. // }
  21102. //
  21103. // if chineseMedicineCostTotal != 0 {
  21104. // iteminfo.MedChrgitm = "10"
  21105. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  21106. // iteminfo.Amt = chineseMedicineCostTotal
  21107. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  21108. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  21109. // iteminfo.OthAmt = chinese_medicine_other_amt
  21110. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21111. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21112. //
  21113. // }
  21114. //
  21115. // if chineseTraditionalMedicineCostTotal != 0 {
  21116. // iteminfo.MedChrgitm = "11"
  21117. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21118. // iteminfo.Amt = westernMedicineCostTotal
  21119. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21120. // iteminfo.ClabAmt = westernMedicine_clab_amt
  21121. // iteminfo.OthAmt = westernMedicine_other_amt
  21122. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21123. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21124. //
  21125. // }
  21126. //
  21127. // if commonlyTreatmentCostTotal != 0 {
  21128. // iteminfo.MedChrgitm = "12"
  21129. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  21130. // iteminfo.Amt = commonlyTreatmentCostTotal
  21131. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  21132. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  21133. // iteminfo.OthAmt = commonly_treatment_other_amt
  21134. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21135. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21136. //
  21137. // }
  21138. //
  21139. // if registerCostTotal != 0 {
  21140. // iteminfo.MedChrgitm = "13"
  21141. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  21142. // iteminfo.Amt = registerCostTotal
  21143. // iteminfo.ClaaSumfee = register_claa_sunmfee
  21144. // iteminfo.ClabAmt = register_clab_amt
  21145. // iteminfo.OthAmt = register_other_amt
  21146. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21147. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21148. //
  21149. // }
  21150. //
  21151. // if otherCostTotal != 0 {
  21152. // iteminfo.MedChrgitm = "14"
  21153. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  21154. // iteminfo.Amt = otherCostTotal
  21155. // iteminfo.ClaaSumfee = other_claa_sunmfee
  21156. // iteminfo.ClabAmt = other_clab_amt
  21157. // iteminfo.OthAmt = other_other_amt
  21158. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21159. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21160. //
  21161. // }
  21162. // struct4101.IteminfoStruct = iteminfoStructs
  21163. // time_arr := strings.Split(order.SetlTime, " ")
  21164. // struct4101.AdmTime = time_arr[0]
  21165. // struct4101.AdmEndTime = time_arr[0]
  21166. //
  21167. // struct4101.DoctorName = doctor.UserName
  21168. // struct4101.DoctorCode = doctor.DoctorNumber
  21169. //
  21170. // struct4101.Ntly = "中国"
  21171. // struct4101.AdmCaty = "A03.06"
  21172. // var res ResultSeventeen
  21173. // if miConfig.MdtrtareaAdmvs == "421300" {
  21174. // data := make(map[string]interface{})
  21175. // data["struct4101"] = struct4101
  21176. // data["secret_key"] = miConfig.SecretKey
  21177. // data["org_name"] = miConfig.OrgName
  21178. // data["opera"] = curRoles.UserName
  21179. // data["code"] = miConfig.Code
  21180. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21181. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21182. //
  21183. // client := &http.Client{}
  21184. // bytesData, _ := json.Marshal(data)
  21185. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21186. // resp, _ := client.Do(req)
  21187. // defer resp.Body.Close()
  21188. // body, ioErr := ioutil.ReadAll(resp.Body)
  21189. // if ioErr != nil {
  21190. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21191. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21192. // return
  21193. // }
  21194. // var respJSON map[string]interface{}
  21195. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21196. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21197. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21198. // return
  21199. // }
  21200. //
  21201. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21202. // userJSONBytes, _ := json.Marshal(respJSON)
  21203. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21204. // utils.ErrorLog("解析失败:%v", err)
  21205. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21206. // adminUser := c.GetAdminUserInfo()
  21207. // errlog := &models.HisOrderError{
  21208. // UserOrgId: adminUser.CurrentOrgId,
  21209. // Ctime: time.Now().Unix(),
  21210. // Mtime: time.Now().Unix(),
  21211. // ErrMsg: res.ErrMsg + "解析失败",
  21212. // Status: 1,
  21213. // PatientId: order_id,
  21214. // Stage: 10088,
  21215. // }
  21216. // service.CreateErrMsgLog(errlog)
  21217. // continue
  21218. // }
  21219. //
  21220. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  21221. // data := make(map[string]interface{})
  21222. // data["struct4101"] = struct4101
  21223. // data["secret_key"] = miConfig.SecretKey
  21224. // data["org_name"] = miConfig.OrgName
  21225. // data["opera"] = curRoles.UserName
  21226. // data["code"] = miConfig.Code
  21227. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21228. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21229. //
  21230. // client := &http.Client{}
  21231. // bytesData, _ := json.Marshal(data)
  21232. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21233. // resp, _ := client.Do(req)
  21234. // defer resp.Body.Close()
  21235. // body, ioErr := ioutil.ReadAll(resp.Body)
  21236. // if ioErr != nil {
  21237. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21238. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21239. // return
  21240. // }
  21241. // var respJSON map[string]interface{}
  21242. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21243. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21244. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21245. // return
  21246. // }
  21247. //
  21248. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21249. // userJSONBytes, _ := json.Marshal(respJSON)
  21250. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21251. // utils.ErrorLog("解析失败:%v", err)
  21252. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21253. // adminUser := c.GetAdminUserInfo()
  21254. // errlog := &models.HisOrderError{
  21255. // UserOrgId: adminUser.CurrentOrgId,
  21256. // Ctime: time.Now().Unix(),
  21257. // Mtime: time.Now().Unix(),
  21258. // ErrMsg: res.ErrMsg + "解析失败",
  21259. // Status: 1,
  21260. // PatientId: order_id,
  21261. // Stage: 10088,
  21262. // }
  21263. // service.CreateErrMsgLog(errlog)
  21264. // continue
  21265. // }
  21266. //
  21267. // } else {
  21268. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  21269. // fmt.Println(result)
  21270. //
  21271. // var dat map[string]interface{}
  21272. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21273. // fmt.Println(dat)
  21274. // } else {
  21275. // fmt.Println(err)
  21276. // }
  21277. // userJSONBytes, _ := json.Marshal(dat)
  21278. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21279. // utils.ErrorLog("解析失败:%v", err)
  21280. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21281. // adminUser := c.GetAdminUserInfo()
  21282. // errlog := &models.HisOrderError{
  21283. // UserOrgId: adminUser.CurrentOrgId,
  21284. // Ctime: time.Now().Unix(),
  21285. // Mtime: time.Now().Unix(),
  21286. // ErrMsg: res.ErrMsg + "解析失败",
  21287. // Status: 1,
  21288. // PatientId: order_id,
  21289. // Stage: 10106,
  21290. // }
  21291. // service.CreateErrMsgLog(errlog)
  21292. // continue
  21293. // }
  21294. // }
  21295. //
  21296. // if res.Infcode != 0 {
  21297. // adminUser := c.GetAdminUserInfo()
  21298. // errlog := &models.HisOrderError{
  21299. // UserOrgId: adminUser.CurrentOrgId,
  21300. // Ctime: time.Now().Unix(),
  21301. // Mtime: time.Now().Unix(),
  21302. // ErrMsg: res.ErrMsg,
  21303. // Status: 1,
  21304. // PatientId: order_id,
  21305. // Stage: 10106,
  21306. // }
  21307. // service.CreateErrMsgLog(errlog)
  21308. // continue
  21309. // } else {
  21310. // hisFundSettleListResult := &models.HisFundSettleListResult{
  21311. // Number: res.Output.SetlListId,
  21312. // Status: 1,
  21313. // Ctime: time.Now().Unix(),
  21314. // Mtime: time.Now().Unix(),
  21315. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21316. // IsUpload: 1,
  21317. // OrderId: order_id,
  21318. // }
  21319. // service.CreateUploadRecord(hisFundSettleListResult)
  21320. // continue
  21321. // }
  21322. // }
  21323. //}
  21324. func (c *HisApiController) GetOrgInfo() {
  21325. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  21326. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  21327. }
  21328. func (c *HisApiController) GetHisPatientInfo() {
  21329. medical_insurance_card := c.GetString("medical_insurance_card")
  21330. id_card_type, _ := c.GetInt64("id_card_type")
  21331. id_card := c.GetString("id_card")
  21332. adminInfo := c.GetAdminUserInfo()
  21333. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  21334. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  21335. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  21336. IdCardNo := ""
  21337. if id_card_type == 1 {
  21338. IdCardNo = medical_insurance_card
  21339. } else if id_card_type == 2 {
  21340. IdCardNo = id_card
  21341. }
  21342. if config.IsOpen == 1 {
  21343. 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
  21344. resp, requestErr := http.Get(api)
  21345. if requestErr != nil {
  21346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21347. return
  21348. }
  21349. defer resp.Body.Close()
  21350. body, ioErr := ioutil.ReadAll(resp.Body)
  21351. if ioErr != nil {
  21352. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21354. return
  21355. }
  21356. var respJSON map[string]interface{}
  21357. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21358. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21360. return
  21361. }
  21362. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21363. userJSONBytes, _ := json.Marshal(userJSON)
  21364. var res ResultTwo
  21365. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21366. utils.ErrorLog("解析失败:%v", err)
  21367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21368. return
  21369. }
  21370. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21371. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21372. infoStr := string(Iinfos)
  21373. idetinfoStr := string(Idetinfos)
  21374. if res.Infcode == 0 {
  21375. his := models.VMHisPatient{
  21376. Status: 1,
  21377. Ctime: time.Now().Unix(),
  21378. Mtime: time.Now().Unix(),
  21379. PsnNo: res.Output.Baseinfo.PsnNo,
  21380. PsnCertType: res.Output.Baseinfo.PsnCertType,
  21381. Certno: res.Output.Baseinfo.Certno,
  21382. PsnName: res.Output.Baseinfo.PsnName,
  21383. Gend: res.Output.Baseinfo.Gend,
  21384. Naty: res.Output.Baseinfo.Naty,
  21385. Iinfo: infoStr,
  21386. Idetinfo: idetinfoStr,
  21387. UserOrgId: adminInfo.CurrentOrgId,
  21388. IsReturn: 1,
  21389. IdCardType: id_card_type,
  21390. }
  21391. c.ServeSuccessJSON(map[string]interface{}{
  21392. "info": his,
  21393. })
  21394. } else {
  21395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  21396. return
  21397. }
  21398. }
  21399. }
  21400. //func GetBasBaseInfo() (jsonStr string, err error) {
  21401. //
  21402. // handle := syscall.NewLazyDLL("SSCard.dll")
  21403. // add := handle.NewProc("ReadCardBas")
  21404. // str := make([]byte, 1024)
  21405. // str1 := make([]byte, 1024)
  21406. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21407. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  21408. //
  21409. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  21410. //
  21411. // fmt.Println("> Add(4,5)的结果为:", ret)
  21412. // handle.Release()
  21413. //
  21414. // return "", nil
  21415. //
  21416. //}
  21417. //func GetQRBaseInfo() (jsonStr string, err error) {
  21418. // handle := syscall.LoadDLL("SSCard.dll")
  21419. // ReadCardBas := handle.FindProc("GetQRBase")
  21420. //
  21421. // str := make([]byte, 256)
  21422. // str1 := make([]byte, 256)
  21423. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21424. //
  21425. // fmt.Println(string(str))
  21426. // fmt.Println(r)
  21427. // return string(str), nil
  21428. //}
  21429. //func CardInit() int {
  21430. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  21431. // add := DllTestDef.MustFindProc("Init")
  21432. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21433. // if err != nil {
  21434. // fmt.Println("SSCard的运算结果为:", ret)
  21435. // }
  21436. // result := int(ret)
  21437. // return result
  21438. //}
  21439. //func CardInit() int {
  21440. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21441. // if err != nil {
  21442. // fmt.Println("SSCard的运算结果为:", ret)
  21443. // }
  21444. // fmt.Println(err)
  21445. // result := int(ret)
  21446. // return result
  21447. //}
  21448. func IntPtr(n int) uintptr {
  21449. return uintptr(n)
  21450. }
  21451. func StrPtr(s string) uintptr {
  21452. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  21453. }
  21454. type Result2001 struct {
  21455. Cainfo interface{} `json:"cainfo"`
  21456. ErrMsg string `json:"err_msg"`
  21457. InfRefmsgid string `json:"inf_refmsgid"`
  21458. Infcode int64 `json:"infcode"`
  21459. Output struct {
  21460. Trtinfo struct {
  21461. PsnNo string `json:"psn_no"`
  21462. TrtChkType string `json:"trt_chk_type"`
  21463. FundPayType string `json:"fund_pay_type"`
  21464. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21465. Begndate string `json:"begndate"`
  21466. Enddate string `json:"enddate"`
  21467. TrtChkRslt string `json:"trt_chk_rslt"`
  21468. } `json:"trtinfo"`
  21469. } `json:"output"`
  21470. RefmsgTime string `json:"refmsg_time"`
  21471. RespondTime string `json:"respond_time"`
  21472. Signtype interface{} `json:"signtype"`
  21473. WarnMsg interface{} `json:"warn_msg"`
  21474. }
  21475. type Result2001Org10265 struct {
  21476. Cainfo interface{} `json:"cainfo"`
  21477. ErrMsg string `json:"err_msg"`
  21478. InfRefmsgid string `json:"inf_refmsgid"`
  21479. Infcode string `json:"infcode"`
  21480. Output struct {
  21481. Trtinfo struct {
  21482. PsnNo string `json:"psn_no"`
  21483. TrtChkType string `json:"trt_chk_type"`
  21484. FundPayType string `json:"fund_pay_type"`
  21485. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21486. Begndate string `json:"begndate"`
  21487. Enddate string `json:"enddate"`
  21488. TrtChkRslt string `json:"trt_chk_rslt"`
  21489. } `json:"trtinfo"`
  21490. } `json:"output"`
  21491. RefmsgTime string `json:"refmsg_time"`
  21492. RespondTime string `json:"respond_time"`
  21493. Signtype interface{} `json:"signtype"`
  21494. WarnMsg interface{} `json:"warn_msg"`
  21495. }
  21496. type ResultTwo struct {
  21497. ErrMsg string `json:"err_msg"`
  21498. InfRefmsgid string `json:"inf_refmsgid"`
  21499. Infcode int64 `json:"infcode"`
  21500. Output struct {
  21501. Baseinfo struct {
  21502. //Brdy string `json:"brdy"`
  21503. Certno string `json:"certno"`
  21504. Gend string `json:"gend"`
  21505. Naty string `json:"naty"`
  21506. PsnCertType string `json:"psn_cert_type"`
  21507. PsnName string `json:"psn_name"`
  21508. PsnNo string `json:"psn_no"`
  21509. } `json:"baseinfo"`
  21510. Idetinfo []interface{} `json:"idetinfo"`
  21511. Iinfo []struct {
  21512. Balc float64 `json:"balc"`
  21513. CvlservFlag string `json:"cvlserv_flag"`
  21514. EmpName string `json:"emp_name"`
  21515. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21516. Insutype string `json:"insutype"`
  21517. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21518. //PausInsuDate string `json:"paus_insu_date"`
  21519. //PsnInsuDate string `json:"psn_insu_date"`
  21520. PsnInsuStas string `json:"psn_insu_stas"`
  21521. PsnType string `json:"psn_type"`
  21522. } `json:"insuinfo"`
  21523. } `json:"output"`
  21524. RefmsgTime string `json:"refmsg_time"`
  21525. RespondTime string `json:"respond_time"`
  21526. Signtype interface{} `json:"signtype"`
  21527. WarnInfo interface{} `json:"warn_info"`
  21528. }
  21529. type ResultTwo10265 struct {
  21530. ErrMsg string `json:"err_msg"`
  21531. InfRefmsgid string `json:"inf_refmsgid"`
  21532. Infcode string `json:"infcode"`
  21533. Output struct {
  21534. Baseinfo struct {
  21535. //Brdy string `json:"brdy"`
  21536. Certno string `json:"certno"`
  21537. Gend string `json:"gend"`
  21538. Naty string `json:"naty"`
  21539. PsnCertType string `json:"psn_cert_type"`
  21540. PsnName string `json:"psn_name"`
  21541. PsnNo string `json:"psn_no"`
  21542. } `json:"baseinfo"`
  21543. Idetinfo []interface{} `json:"idetinfo"`
  21544. Iinfo []struct {
  21545. Balc float64 `json:"balc"`
  21546. CvlservFlag string `json:"cvlserv_flag"`
  21547. EmpName string `json:"emp_name"`
  21548. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21549. Insutype string `json:"insutype"`
  21550. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21551. PsnInsuStas string `json:"psn_insu_stas"`
  21552. PsnType string `json:"psn_type"`
  21553. } `json:"insuinfo"`
  21554. } `json:"output"`
  21555. RefmsgTime string `json:"refmsg_time"`
  21556. RespondTime string `json:"respond_time"`
  21557. Signtype interface{} `json:"signtype"`
  21558. WarnInfo interface{} `json:"warn_info"`
  21559. }
  21560. type ResultThree struct {
  21561. Cainfo interface{} `json:"cainfo"`
  21562. ErrMsg string `json:"err_msg"`
  21563. InfRefmsgid string `json:"inf_refmsgid"`
  21564. Infcode int64 `json:"infcode"`
  21565. Output struct {
  21566. Data struct {
  21567. IptOtpNo string `json:"ipt_otp_no"`
  21568. MdtrtID string `json:"mdtrt_id"`
  21569. PsnNo string `json:"psn_no"`
  21570. } `json:"data"`
  21571. } `json:"output"`
  21572. RefmsgTime string `json:"refmsg_time"`
  21573. RespondTime string `json:"respond_time"`
  21574. Signtype interface{} `json:"signtype"`
  21575. WarnMsg interface{} `json:"warn_msg"`
  21576. }
  21577. type ResultThree10265 struct {
  21578. Cainfo interface{} `json:"cainfo"`
  21579. ErrMsg string `json:"err_msg"`
  21580. InfRefmsgid string `json:"inf_refmsgid"`
  21581. Infcode string `json:"infcode"`
  21582. Output struct {
  21583. Data struct {
  21584. IptOtpNo string `json:"ipt_otp_no"`
  21585. MdtrtID string `json:"mdtrt_id"`
  21586. PsnNo string `json:"psn_no"`
  21587. } `json:"data"`
  21588. } `json:"output"`
  21589. RefmsgTime string `json:"refmsg_time"`
  21590. RespondTime string `json:"respond_time"`
  21591. Signtype interface{} `json:"signtype"`
  21592. WarnMsg interface{} `json:"warn_msg"`
  21593. }
  21594. type ResultFour struct {
  21595. Cainfo string `json:"cainfo"`
  21596. ErrMsg string `json:"err_msg"`
  21597. InfRefmsgid string `json:"inf_refmsgid"`
  21598. Infcode int64 `json:"infcode"`
  21599. Output struct {
  21600. Result []struct {
  21601. BasMednFlag string `json:"bas_medn_flag"`
  21602. ChldMedcFlag string `json:"chld_medc_flag"`
  21603. ChrgitmLv string `json:"chrgitm_lv"`
  21604. Cnt float64 `json:"cnt"`
  21605. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21606. DrtReimFlag string `json:"drt_reim_flag"`
  21607. FeedetlSn string `json:"feedetl_sn"`
  21608. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21609. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21610. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21611. ListSpItemFlag string `json:"list_sp_item_flag"`
  21612. LmtUsedFlag string `json:"lmt_used_flag"`
  21613. MedChrgitmType string `json:"med_chrgitm_type"`
  21614. Memo string `json:"memo"`
  21615. OverlmtAmt float64 `json:"overlmt_amt"`
  21616. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21617. Pric float64 `json:"pric"`
  21618. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21619. SelfpayProp float64 `json:"selfpay_prop"`
  21620. } `json:"result"`
  21621. } `json:"output"`
  21622. RefmsgTime string `json:"refmsg_time"`
  21623. RespondTime string `json:"respond_time"`
  21624. Signtype string `json:"signtype"`
  21625. WarnMsg string `json:"warn_msg"`
  21626. }
  21627. type ResultFour10265 struct {
  21628. Cainfo string `json:"cainfo"`
  21629. ErrMsg string `json:"err_msg"`
  21630. InfRefmsgid string `json:"inf_refmsgid"`
  21631. Infcode string `json:"infcode"`
  21632. Output struct {
  21633. Result []struct {
  21634. BasMednFlag string `json:"bas_medn_flag"`
  21635. ChldMedcFlag string `json:"chld_medc_flag"`
  21636. ChrgitmLv string `json:"chrgitm_lv"`
  21637. Cnt float64 `json:"cnt"`
  21638. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21639. DrtReimFlag string `json:"drt_reim_flag"`
  21640. FeedetlSn string `json:"feedetl_sn"`
  21641. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21642. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21643. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21644. ListSpItemFlag string `json:"list_sp_item_flag"`
  21645. LmtUsedFlag string `json:"lmt_used_flag"`
  21646. MedChrgitmType string `json:"med_chrgitm_type"`
  21647. Memo string `json:"memo"`
  21648. OverlmtAmt float64 `json:"overlmt_amt"`
  21649. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21650. Pric float64 `json:"pric"`
  21651. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21652. SelfpayProp float64 `json:"selfpay_prop"`
  21653. } `json:"result"`
  21654. } `json:"output"`
  21655. RefmsgTime string `json:"refmsg_time"`
  21656. RespondTime string `json:"respond_time"`
  21657. Signtype string `json:"signtype"`
  21658. WarnMsg string `json:"warn_msg"`
  21659. }
  21660. type ResultMemo struct {
  21661. InsuAdmdvs string `json:"insuAdmdvs"`
  21662. }
  21663. // [{"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}]
  21664. type ResultIDInfo struct {
  21665. Begntime string `json:"begntime"`
  21666. Endtime string `json:"endtime"`
  21667. Memo string `json:"memo"`
  21668. }
  21669. type ResultFive struct {
  21670. Balc float64 `json:"balc"`
  21671. CvlservFlag string `json:"cvlserv_flag"`
  21672. EmpName string `json:"emp_name"`
  21673. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21674. Insutype string `json:"insutype"`
  21675. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21676. PausInsuDate string `json:"paus_insu_date"`
  21677. PsnInsuDate string `json:"psn_insu_date"`
  21678. PsnInsuStas string `json:"psn_insu_stas"`
  21679. PsnType string `json:"psn_type"`
  21680. }
  21681. type ResultSix struct {
  21682. Cainfo interface{} `json:"cainfo"`
  21683. ErrMsg string `json:"err_msg"`
  21684. InfRefmsgid string `json:"inf_refmsgid"`
  21685. Infcode int64 `json:"infcode"`
  21686. Output struct {
  21687. } `json:"output"`
  21688. RefmsgTime string `json:"refmsg_time"`
  21689. RespondTime string `json:"respond_time"`
  21690. Signtype interface{} `json:"signtype"`
  21691. WarnMsg interface{} `json:"warn_msg"`
  21692. }
  21693. type ResultSix3103 struct {
  21694. Cainfo interface{} `json:"cainfo"`
  21695. ErrMsg string `json:"err_msg"`
  21696. InfRefmsgid string `json:"inf_refmsgid"`
  21697. Infcode int64 `json:"infcode"`
  21698. RefmsgTime string `json:"refmsg_time"`
  21699. RespondTime string `json:"respond_time"`
  21700. Signtype interface{} `json:"signtype"`
  21701. WarnMsg interface{} `json:"warn_msg"`
  21702. }
  21703. type FJ3507Result struct {
  21704. Cainfo interface{} `json:"cainfo"`
  21705. ErrMsg string `json:"err_msg"`
  21706. InfRefmsgid string `json:"inf_refmsgid"`
  21707. Infcode int64 `json:"infcode"`
  21708. Output struct {
  21709. retRslt string `json:"retRslt"`
  21710. msgRslt string `json:"msgRslt"`
  21711. } `json:"output"`
  21712. RefmsgTime string `json:"refmsg_time"`
  21713. RespondTime string `json:"respond_time"`
  21714. Signtype interface{} `json:"signtype"`
  21715. WarnMsg interface{} `json:"warn_msg"`
  21716. }
  21717. type FJ3507ResultFor10188 struct {
  21718. Cainfo interface{} `json:"cainfo"`
  21719. ErrMsg string `json:"err_msg"`
  21720. InfRefmsgid string `json:"inf_refmsgid"`
  21721. Infcode string `json:"infcode"`
  21722. RefmsgTime string `json:"refmsg_time"`
  21723. RespondTime string `json:"respond_time"`
  21724. Signtype interface{} `json:"signtype"`
  21725. WarnMsg interface{} `json:"warn_msg"`
  21726. }
  21727. type Result2406 struct {
  21728. Cainfo interface{} `json:"cainfo"`
  21729. ErrMsg string `json:"err_msg"`
  21730. InfRefmsgid string `json:"inf_refmsgid"`
  21731. Infcode int64 `json:"infcode"`
  21732. Output struct {
  21733. Result struct {
  21734. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  21735. } `json:"result"`
  21736. } `json:"output"`
  21737. RefmsgTime string `json:"refmsg_time"`
  21738. RespondTime string `json:"respond_time"`
  21739. Signtype interface{} `json:"signtype"`
  21740. WarnMsg interface{} `json:"warn_msg"`
  21741. }
  21742. type GZResultSix struct {
  21743. Cainfo interface{} `json:"cainfo"`
  21744. ErrMsg string `json:"err_msg"`
  21745. InfRefmsgid string `json:"inf_refmsgid"`
  21746. Infcode int64 `json:"infcode"`
  21747. Output string `json:"output"`
  21748. RefmsgTime string `json:"refmsg_time"`
  21749. RespondTime string `json:"respond_time"`
  21750. Signtype interface{} `json:"signtype"`
  21751. WarnMsg interface{} `json:"warn_msg"`
  21752. }
  21753. type ResultSix10265 struct {
  21754. Cainfo interface{} `json:"cainfo"`
  21755. ErrMsg string `json:"err_msg"`
  21756. InfRefmsgid string `json:"inf_refmsgid"`
  21757. Infcode string `json:"infcode"`
  21758. Output struct {
  21759. } `json:"output"`
  21760. RefmsgTime string `json:"refmsg_time"`
  21761. RespondTime string `json:"respond_time"`
  21762. Signtype interface{} `json:"signtype"`
  21763. WarnMsg interface{} `json:"warn_msg"`
  21764. }
  21765. type ResultSeven struct {
  21766. Cainfo string `json:"cainfo"`
  21767. ErrMsg string `json:"err_msg"`
  21768. InfRefmsgid string `json:"inf_refmsgid"`
  21769. Infcode int64 `json:"infcode"`
  21770. Output struct {
  21771. Setlinfo struct {
  21772. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21773. AcctPay float64 `json:"acct_pay"`
  21774. ActPayDedc float64 `json:"act_pay_dedc"`
  21775. Age float64 `json:"age"`
  21776. Balc float64 `json:"balc"`
  21777. Certno string `json:"certno"`
  21778. ClrOptins string `json:"clr_optins"`
  21779. ClrType string `json:"clr_type"`
  21780. ClrWay string `json:"clr_way"`
  21781. CvlservFlag string `json:"cvlserv_flag"`
  21782. CvlservPay float64 `json:"cvlserv_pay"`
  21783. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21784. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21785. Gend string `json:"gend"`
  21786. HifesPay float64 `json:"hifes_pay"`
  21787. HifmiPay float64 `json:"hifmi_pay"`
  21788. HifpPay float64 `json:"hifp_pay"`
  21789. HospPartAmt float64 `json:"hosp_part_amt"`
  21790. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21791. Insutype string `json:"insutype"`
  21792. MafPay float64 `json:"maf_pay"`
  21793. MdtrtCertType string `json:"mdtrt_cert_type"`
  21794. HifobPay float64 `json:"hifob_pay"`
  21795. MdtrtID string `json:"mdtrt_id"`
  21796. MedType string `json:"med_type"`
  21797. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21798. MedinsSetlID string `json:"medins_setl_id"`
  21799. Naty string `json:"naty"`
  21800. OthPay float64 `json:"oth_pay"`
  21801. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21802. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21803. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21804. PsnCashPay float64 `json:"psn_cash_pay"`
  21805. PsnCertType string `json:"psn_cert_type"`
  21806. PsnName string `json:"psn_name"`
  21807. PsnNo string `json:"psn_no"`
  21808. PsnPartAmt float64 `json:"psn_part_amt"`
  21809. PsnType string `json:"psn_type"`
  21810. SetlID string `json:"setl_id"`
  21811. SetlTime string `json:"setl_time"`
  21812. } `json:"setlinfo"`
  21813. Setldetail interface{} `json:"setldetail"`
  21814. } `json:"output"`
  21815. RefmsgTime string `json:"refmsg_time"`
  21816. RespondTime string `json:"respond_time"`
  21817. Signtype interface{} `json:"signtype"`
  21818. WarnMsg interface{} `json:"warn_msg"`
  21819. }
  21820. type ResultSevenAH struct {
  21821. Cainfo string `json:"cainfo"`
  21822. ErrMsg string `json:"err_msg"`
  21823. InfRefmsgid string `json:"inf_refmsgid"`
  21824. Infcode int64 `json:"infcode"`
  21825. Output struct {
  21826. Setlinfo struct {
  21827. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21828. AcctPay float64 `json:"acct_pay"`
  21829. ActPayDedc float64 `json:"act_pay_dedc"`
  21830. Age float64 `json:"age"`
  21831. Balc float64 `json:"balc"`
  21832. Certno string `json:"certno"`
  21833. ClrOptins string `json:"clr_optins"`
  21834. ClrType string `json:"clr_type"`
  21835. ClrWay string `json:"clr_way"`
  21836. CvlservFlag string `json:"cvlserv_flag"`
  21837. CvlservPay float64 `json:"cvlserv_pay"`
  21838. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21839. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21840. Gend string `json:"gend"`
  21841. HifesPay float64 `json:"hifes_pay"`
  21842. HifmiPay float64 `json:"hifmi_pay"`
  21843. HifpPay float64 `json:"hifp_pay"`
  21844. HospPartAmt float64 `json:"hosp_part_amt"`
  21845. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21846. Insutype string `json:"insutype"`
  21847. MafPay float64 `json:"maf_pay"`
  21848. MdtrtCertType string `json:"mdtrt_cert_type"`
  21849. HifobPay float64 `json:"hifob_pay"`
  21850. MdtrtID string `json:"mdtrt_id"`
  21851. MedType string `json:"med_type"`
  21852. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21853. MedinsSetlID string `json:"medins_setl_id"`
  21854. Naty string `json:"naty"`
  21855. OthPay float64 `json:"oth_pay"`
  21856. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21857. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21858. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21859. PsnCashPay float64 `json:"psn_cash_pay"`
  21860. PsnCertType string `json:"psn_cert_type"`
  21861. PsnName string `json:"psn_name"`
  21862. PsnNo string `json:"psn_no"`
  21863. PsnPartAmt float64 `json:"psn_part_amt"`
  21864. PsnType string `json:"psn_type"`
  21865. SetlID string `json:"setl_id"`
  21866. SetlTime int64 `json:"setl_time"`
  21867. } `json:"setlinfo"`
  21868. Setldetail interface{} `json:"setldetail"`
  21869. } `json:"output"`
  21870. RefmsgTime string `json:"refmsg_time"`
  21871. RespondTime string `json:"respond_time"`
  21872. Signtype interface{} `json:"signtype"`
  21873. WarnMsg interface{} `json:"warn_msg"`
  21874. }
  21875. type ResultSeven10265 struct {
  21876. Cainfo string `json:"cainfo"`
  21877. ErrMsg string `json:"err_msg"`
  21878. InfRefmsgid string `json:"inf_refmsgid"`
  21879. Infcode string `json:"infcode"`
  21880. Output struct {
  21881. Setlinfo struct {
  21882. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21883. AcctPay float64 `json:"acct_pay"`
  21884. ActPayDedc float64 `json:"act_pay_dedc"`
  21885. Age float64 `json:"age"`
  21886. Balc float64 `json:"balc"`
  21887. Certno string `json:"certno"`
  21888. ClrOptins string `json:"clr_optins"`
  21889. ClrType string `json:"clr_type"`
  21890. ClrWay string `json:"clr_way"`
  21891. CvlservFlag string `json:"cvlserv_flag"`
  21892. CvlservPay float64 `json:"cvlserv_pay"`
  21893. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21894. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21895. Gend string `json:"gend"`
  21896. HifesPay float64 `json:"hifes_pay"`
  21897. HifmiPay float64 `json:"hifmi_pay"`
  21898. HifpPay float64 `json:"hifp_pay"`
  21899. HospPartAmt float64 `json:"hosp_part_amt"`
  21900. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21901. Insutype string `json:"insutype"`
  21902. MafPay float64 `json:"maf_pay"`
  21903. MdtrtCertType string `json:"mdtrt_cert_type"`
  21904. HifobPay float64 `json:"hifob_pay"`
  21905. MdtrtID string `json:"mdtrt_id"`
  21906. MedType string `json:"med_type"`
  21907. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21908. MedinsSetlID string `json:"medins_setl_id"`
  21909. Naty string `json:"naty"`
  21910. OthPay float64 `json:"oth_pay"`
  21911. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21912. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21913. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21914. PsnCashPay float64 `json:"psn_cash_pay"`
  21915. PsnCertType string `json:"psn_cert_type"`
  21916. PsnName string `json:"psn_name"`
  21917. PsnNo string `json:"psn_no"`
  21918. PsnPartAmt float64 `json:"psn_part_amt"`
  21919. PsnType string `json:"psn_type"`
  21920. SetlID string `json:"setl_id"`
  21921. SetlTime string `json:"setl_time"`
  21922. } `json:"setlinfo"`
  21923. Setldetail interface{} `json:"setldetail"`
  21924. } `json:"output"`
  21925. RefmsgTime string `json:"refmsg_time"`
  21926. RespondTime string `json:"respond_time"`
  21927. Signtype interface{} `json:"signtype"`
  21928. WarnMsg interface{} `json:"warn_msg"`
  21929. }
  21930. type ResultSeven10265Two struct {
  21931. Cainfo string `json:"cainfo"`
  21932. ErrMsg string `json:"err_msg"`
  21933. InfRefmsgid string `json:"inf_refmsgid"`
  21934. Infcode string `json:"infcode"`
  21935. Output struct {
  21936. Setlinfo struct {
  21937. AcctMulaidPay string `json:"acct_mulaid_pay"`
  21938. AcctPay float64 `json:"acct_pay"`
  21939. ActPayDedc float64 `json:"act_pay_dedc"`
  21940. Age float64 `json:"age"`
  21941. Balc float64 `json:"balc"`
  21942. Certno string `json:"certno"`
  21943. ClrOptins string `json:"clr_optins"`
  21944. ClrType string `json:"clr_type"`
  21945. ClrWay string `json:"clr_way"`
  21946. CvlservFlag string `json:"cvlserv_flag"`
  21947. CvlservPay float64 `json:"cvlserv_pay"`
  21948. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21949. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21950. Gend string `json:"gend"`
  21951. HifesPay float64 `json:"hifes_pay"`
  21952. HifmiPay float64 `json:"hifmi_pay"`
  21953. HifpPay float64 `json:"hifp_pay"`
  21954. HospPartAmt string `json:"hosp_part_amt"`
  21955. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21956. Insutype string `json:"insutype"`
  21957. MafPay float64 `json:"maf_pay"`
  21958. MdtrtCertType string `json:"mdtrt_cert_type"`
  21959. HifobPay float64 `json:"hifob_pay"`
  21960. MdtrtID string `json:"mdtrt_id"`
  21961. MedType string `json:"med_type"`
  21962. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21963. MedinsSetlID string `json:"medins_setl_id"`
  21964. Naty string `json:"naty"`
  21965. OthPay float64 `json:"oth_pay"`
  21966. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21967. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21968. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21969. PsnCashPay float64 `json:"psn_cash_pay"`
  21970. PsnCertType string `json:"psn_cert_type"`
  21971. PsnName string `json:"psn_name"`
  21972. PsnNo string `json:"psn_no"`
  21973. PsnPartAmt float64 `json:"psn_part_amt"`
  21974. PsnType string `json:"psn_type"`
  21975. SetlID string `json:"setl_id"`
  21976. SetlTime string `json:"setl_time"`
  21977. } `json:"setlinfo"`
  21978. Setldetail interface{} `json:"setldetail"`
  21979. } `json:"output"`
  21980. RefmsgTime string `json:"refmsg_time"`
  21981. RespondTime string `json:"respond_time"`
  21982. Signtype interface{} `json:"signtype"`
  21983. WarnMsg interface{} `json:"warn_msg"`
  21984. }
  21985. type GZResultSeven10265Two struct {
  21986. Cainfo string `json:"cainfo"`
  21987. ErrMsg string `json:"err_msg"`
  21988. InfRefmsgid string `json:"inf_refmsgid"`
  21989. Infcode int64 `json:"infcode"`
  21990. Output struct {
  21991. Setlinfo struct {
  21992. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21993. AcctPay float64 `json:"acct_pay"`
  21994. ActPayDedc float64 `json:"act_pay_dedc"`
  21995. Age float64 `json:"age"`
  21996. Balc float64 `json:"balc"`
  21997. Certno string `json:"certno"`
  21998. ClrOptins string `json:"clr_optins"`
  21999. ClrType string `json:"clr_type"`
  22000. ClrWay string `json:"clr_way"`
  22001. CvlservFlag string `json:"cvlserv_flag"`
  22002. CvlservPay float64 `json:"cvlserv_pay"`
  22003. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22004. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22005. Gend string `json:"gend"`
  22006. HifesPay float64 `json:"hifes_pay"`
  22007. HifmiPay float64 `json:"hifmi_pay"`
  22008. HifpPay float64 `json:"hifp_pay"`
  22009. HospPartAmt float64 `json:"hosp_part_amt"`
  22010. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22011. Insutype string `json:"insutype"`
  22012. MafPay float64 `json:"maf_pay"`
  22013. MdtrtCertType string `json:"mdtrt_cert_type"`
  22014. HifobPay float64 `json:"hifob_pay"`
  22015. MdtrtID string `json:"mdtrt_id"`
  22016. MedType string `json:"med_type"`
  22017. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22018. MedinsSetlID string `json:"medins_setl_id"`
  22019. Naty string `json:"naty"`
  22020. OthPay float64 `json:"oth_pay"`
  22021. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22022. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  22023. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22024. PsnCashPay float64 `json:"psn_cash_pay"`
  22025. PsnCertType string `json:"psn_cert_type"`
  22026. PsnName string `json:"psn_name"`
  22027. PsnNo string `json:"psn_no"`
  22028. PsnPartAmt float64 `json:"psn_part_amt"`
  22029. PsnType string `json:"psn_type"`
  22030. SetlID string `json:"setl_id"`
  22031. SetlTime string `json:"setl_time"`
  22032. } `json:"setlinfo"`
  22033. Setldetail interface{} `json:"setldetail"`
  22034. } `json:"output"`
  22035. RefmsgTime string `json:"refmsg_time"`
  22036. RespondTime string `json:"respond_time"`
  22037. Signtype interface{} `json:"signtype"`
  22038. WarnMsg interface{} `json:"warn_msg"`
  22039. }
  22040. type ResultEight struct {
  22041. Cainfo string `json:"cainfo"`
  22042. ErrMsg string `json:"err_msg"`
  22043. InfRefmsgid string `json:"inf_refmsgid"`
  22044. Infcode int64 `json:"infcode"`
  22045. Output struct {
  22046. Stmtinfo struct {
  22047. SetlOptins string `json:"setl_optins"`
  22048. StmtRslt string `json:"stmt_rslt"`
  22049. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  22050. } `json:"stmtinfo"`
  22051. } `json:"output"`
  22052. RefmsgTime string `json:"refmsg_time"`
  22053. RespondTime string `json:"respond_time"`
  22054. Signtype interface{} `json:"signtype"`
  22055. WarnMsg interface{} `json:"warn_msg"`
  22056. }
  22057. type ResultEightFor10188 struct {
  22058. Cainfo string `json:"cainfo"`
  22059. ErrMsg string `json:"err_msg"`
  22060. InfRefmsgid string `json:"inf_refmsgid"`
  22061. Infcode string `json:"infcode"`
  22062. Output struct {
  22063. Stmtinfo struct {
  22064. SetlOptins string `json:"setl_optins"`
  22065. StmtRslt string `json:"stmt_rslt"`
  22066. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  22067. } `json:"stmtinfo"`
  22068. } `json:"output"`
  22069. RefmsgTime string `json:"refmsg_time"`
  22070. RespondTime string `json:"respond_time"`
  22071. Signtype interface{} `json:"signtype"`
  22072. WarnMsg interface{} `json:"warn_msg"`
  22073. }
  22074. type ResultNine struct {
  22075. Cainfo string `json:"cainfo"`
  22076. ErrMsg string `json:"err_msg"`
  22077. InfRefmsgid string `json:"inf_refmsgid"`
  22078. Infcode int64 `json:"infcode"`
  22079. Output struct {
  22080. FileQuryNo string `json:"file_qury_no"`
  22081. } `json:"output"`
  22082. RefmsgTime string `json:"refmsg_time"`
  22083. RespondTime string `json:"respond_time"`
  22084. Signtype interface{} `json:"signtype"`
  22085. WarnMsg interface{} `json:"warn_msg"`
  22086. }
  22087. type ResultTen struct {
  22088. Cainfo string `json:"cainfo"`
  22089. ErrMsg string `json:"err_msg"`
  22090. InfRefmsgid string `json:"inf_refmsgid"`
  22091. Infcode int64 `json:"infcode"`
  22092. Output struct {
  22093. Fileinfo struct {
  22094. DldEndtime string `json:"dld_endtime"`
  22095. FileQuryNo string `json:"file_qury_no"`
  22096. Filename string `json:"filename"`
  22097. } `json:"fileinfo"`
  22098. } `json:"output"`
  22099. RefmsgTime string `json:"refmsg_time"`
  22100. RespondTime string `json:"respond_time"`
  22101. Signtype interface{} `json:"signtype"`
  22102. WarnMsg interface{} `json:"warn_msg"`
  22103. }
  22104. type Result5262 struct {
  22105. ErrMsg string `json:"err_msg"`
  22106. InfRefmsgid string `json:"inf_refmsgid"`
  22107. Infcode int64 `json:"infcode"`
  22108. Output struct {
  22109. PageInfo struct {
  22110. Size int `json:"size"`
  22111. RecordCounts int `json:"record_counts"`
  22112. } `json:"page_info"`
  22113. Idetinfo []interface{} `json:"idetinfo"`
  22114. Result []struct {
  22115. SetlID string `json:"setl_id"`
  22116. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22117. MdtrtID string `json:"mdtrt_id"`
  22118. InitSetlID string `json:"init_setl_id,omitempty"`
  22119. PsnNo string `json:"psn_no"`
  22120. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22121. PsnName string `json:"psn_name"`
  22122. PsnCertType string `json:"psn_cert_type"`
  22123. Certno string `json:"certno"`
  22124. Gend string `json:"gend,omitempty"`
  22125. Naty string `json:"naty,omitempty"`
  22126. Brdy string `json:"brdy,omitempty"`
  22127. Age float64 `json:"age,omitempty"`
  22128. Insutype string `json:"insutype,omitempty"`
  22129. PsnType string `json:"psn_type"`
  22130. CvlservFlag string `json:"cvlserv_flag"`
  22131. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22132. SpPsnType string `json:"sp_psn_type,omitempty"`
  22133. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22134. ClctGrde string `json:"clct_grde,omitempty"`
  22135. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22136. NwbFlag string `json:"nwb_flag,omitempty"`
  22137. InsuAdmdvs string `json:"insu_admdvs"`
  22138. EmpNo string `json:"emp_no,omitempty"`
  22139. EmpName string `json:"emp_name,omitempty"`
  22140. EmpType string `json:"emp_type,omitempty"`
  22141. EconType string `json:"econ_type,omitempty"`
  22142. AfilIndu string `json:"afil_indu,omitempty"`
  22143. AfilRlts string `json:"afil_rlts,omitempty"`
  22144. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22145. PayLoc string `json:"pay_loc,omitempty"`
  22146. FixmedinsCode string `json:"fixmedins_code"`
  22147. FixmedinsName string `json:"fixmedins_name"`
  22148. HospLv string `json:"hosp_lv,omitempty"`
  22149. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22150. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22151. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22152. Begndate string `json:"begndate"`
  22153. Enddate string `json:"enddate"`
  22154. SetlTime string `json:"setl_time"`
  22155. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22156. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22157. MedType string `json:"med_type"`
  22158. SetlType string `json:"setl_type,omitempty"`
  22159. ClrType string `json:"clr_type,omitempty"`
  22160. ClrWay string `json:"clr_way,omitempty"`
  22161. PsnSetlway string `json:"psn_setlway,omitempty"`
  22162. ClrOptins string `json:"clr_optins,omitempty"`
  22163. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22164. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22165. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22166. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22167. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22168. DedcStd float64 `json:"dedc_std,omitempty"`
  22169. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22170. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22171. HifpPay float64 `json:"hifp_pay,omitempty"`
  22172. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22173. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22174. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22175. HifesPay float64 `json:"hifes_pay,omitempty"`
  22176. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22177. HifobPay float64 `json:"hifob_pay,omitempty"`
  22178. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22179. MafPay float64 `json:"maf_pay,omitempty"`
  22180. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22181. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22182. PsnPay float64 `json:"psn_pay,omitempty"`
  22183. AcctPay float64 `json:"acct_pay,omitempty"`
  22184. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22185. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22186. Balc float64 `json:"balc,omitempty"`
  22187. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22188. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22189. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22190. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22191. Year string `json:"year,omitempty"`
  22192. DiseNo string `json:"dise_no,omitempty"`
  22193. DiseName string `json:"dise_name,omitempty"`
  22194. Invono string `json:"invono,omitempty"`
  22195. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22196. ValiFlag string `json:"vali_flag,omitempty"`
  22197. Memo string `json:"memo,omitempty"`
  22198. Rid string `json:"rid"`
  22199. UpdtTime string `json:"updt_time,omitempty"`
  22200. CrterID string `json:"crter_id,omitempty"`
  22201. CrterName string `json:"crter_name,omitempty"`
  22202. CrteTime string `json:"crte_time,omitempty"`
  22203. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  22204. OpterID string `json:"opter_id,omitempty"`
  22205. OpterName string `json:"opter_name,omitempty"`
  22206. OptTime string `json:"opt_time,omitempty"`
  22207. OptinsNo string `json:"optins_no,omitempty"`
  22208. PoolareaNo string `json:"poolarea_no,omitempty"`
  22209. } `json:"result"`
  22210. } `json:"output"`
  22211. RefmsgTime string `json:"refmsg_time"`
  22212. RespondTime string `json:"respond_time"`
  22213. Signtype interface{} `json:"signtype"`
  22214. WarnInfo interface{} `json:"warn_info"`
  22215. }
  22216. type Result5267 struct {
  22217. ErrMsg string `json:"err_msg"`
  22218. InfRefmsgid string `json:"inf_refmsgid"`
  22219. Infcode int64 `json:"infcode"`
  22220. Output struct {
  22221. PageInfo struct {
  22222. Size int `json:"size"`
  22223. RecordCounts int `json:"record_counts"`
  22224. } `json:"pageinfo"`
  22225. Result []struct {
  22226. SetlID string `json:"setl_id"`
  22227. ClrOptins string `json:"clr_optins"`
  22228. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22229. MdtrtID string `json:"mdtrt_id"`
  22230. InitSetlID string `json:"init_setl_id,omitempty"`
  22231. PsnNo string `json:"psn_no"`
  22232. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22233. PsnName string `json:"psn_name"`
  22234. PsnCertType string `json:"psn_cert_type"`
  22235. Certno string `json:"certno"`
  22236. Gend string `json:"gend,omitempty"`
  22237. Naty string `json:"naty,omitempty"`
  22238. Brdy string `json:"brdy,omitempty"`
  22239. Age float64 `json:"age,omitempty"`
  22240. Insutype string `json:"insutype,omitempty"`
  22241. PsnType string `json:"psn_type"`
  22242. CvlservFlag string `json:"cvlserv_flag"`
  22243. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22244. SpPsnType string `json:"sp_psn_type,omitempty"`
  22245. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22246. ClctGrde string `json:"clct_grde,omitempty"`
  22247. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22248. NwbFlag string `json:"nwb_flag,omitempty"`
  22249. InsuAdmdvs string `json:"insu_admdvs"`
  22250. EmpNo string `json:"emp_no,omitempty"`
  22251. EmpName string `json:"emp_name,omitempty"`
  22252. EmpType string `json:"emp_type,omitempty"`
  22253. EconType string `json:"econ_type,omitempty"`
  22254. AfilIndu string `json:"afil_indu,omitempty"`
  22255. AfilRlts string `json:"afil_rlts,omitempty"`
  22256. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22257. PayLoc string `json:"pay_loc,omitempty"`
  22258. FixmedinsCode string `json:"fixmedins_code"`
  22259. FixmedinsName string `json:"fixmedins_name"`
  22260. HospLv string `json:"hosp_lv,omitempty"`
  22261. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22262. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22263. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22264. Begndate string `json:"begndate,omitempty"`
  22265. Enddate string `json:"enddate,omitempty"`
  22266. SetlTime string `json:"setl_time,omitempty"`
  22267. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22268. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22269. MedType string `json:"med_type"`
  22270. SetlType string `json:"setl_type,omitempty"`
  22271. ClrType string `json:"clr_type,omitempty"`
  22272. ClrWay string `json:"clr_way,omitempty"`
  22273. PsnSetlway string `json:"psn_setlway,omitempty"`
  22274. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22275. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22276. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22277. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22278. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22279. DedcStd float64 `json:"dedc_std,omitempty"`
  22280. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22281. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22282. HifpPay float64 `json:"hifp_pay,omitempty"`
  22283. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22284. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22285. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22286. HifesPay float64 `json:"hifes_pay,omitempty"`
  22287. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22288. HifobPay float64 `json:"hifob_pay,omitempty"`
  22289. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22290. MafPay float64 `json:"maf_pay,omitempty"`
  22291. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22292. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22293. PsnPay float64 `json:"psn_pay,omitempty"`
  22294. AcctPay float64 `json:"acct_pay,omitempty"`
  22295. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22296. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22297. Balc float64 `json:"balc,omitempty"`
  22298. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22299. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22300. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22301. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22302. Year string `json:"year,omitempty"`
  22303. DiseNo string `json:"dise_no,omitempty"`
  22304. DiseName string `json:"dise_name,omitempty"`
  22305. Invono string `json:"invono,omitempty"`
  22306. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22307. Memo string `json:"memo,omitempty"`
  22308. UpdtTime string `json:"updt_time,omitempty"`
  22309. OpterID string `json:"opter_id,omitempty"`
  22310. OpterName string `json:"opter_name,omitempty"`
  22311. OptTime string `json:"opt_time,omitempty"`
  22312. OptinsNo string `json:"optins_no,omitempty"`
  22313. PoolareaNo string `json:"poolarea_no,omitempty"`
  22314. } `json:"result"`
  22315. } `json:"output"`
  22316. RefmsgTime string `json:"refmsg_time"`
  22317. RespondTime string `json:"respond_time"`
  22318. Signtype interface{} `json:"signtype"`
  22319. WarnInfo interface{} `json:"warn_info"`
  22320. }
  22321. // type Autogenerated struct {
  22322. // Output struct {
  22323. // Setlinfo struct {
  22324. // SetlTime string `json:"setl_time"`
  22325. // CvlservPay float64 `json:"cvlserv_pay"`
  22326. // Year string `json:"year"`
  22327. // MedType string `json:"med_type"`
  22328. // PsnPay float64 `json:"psn_pay"`
  22329. // OpterID string `json:"opter_id"`
  22330. // Begndate string `json:"begndate"`
  22331. // FlxempeFlag string `json:"flxempe_flag"`
  22332. // HifmiPay float64 `json:"hifmi_pay"`
  22333. // PsnNo string `json:"psn_no"`
  22334. // ActPayDedc float64 `json:"act_pay_dedc"`
  22335. // MedinsSetlID interface{} `json:"medins_setl_id"`
  22336. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22337. // ClrWay string `json:"clr_way"`
  22338. // OthPay float64 `json:"oth_pay"`
  22339. // Gend string `json:"gend"`
  22340. // MdtrtID string `json:"mdtrt_id"`
  22341. // AcctPay float64 `json:"acct_pay"`
  22342. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  22343. // Insutype string `json:"insutype"`
  22344. // Invono interface{} `json:"invono"`
  22345. // Enddate string `json:"enddate"`
  22346. // CashPayamt float64 `json:"cash_payamt"`
  22347. // PsnType string `json:"psn_type"`
  22348. // FixmedinsName string `json:"fixmedins_name"`
  22349. // HifpPay float64 `json:"hifp_pay"`
  22350. // NewFlag interface{} `json:"new_flag"`
  22351. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22352. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  22353. // PayLoc string `json:"pay_loc"`
  22354. // ClrType string `json:"clr_type"`
  22355. // RefdSetlFlag string `json:"refd_setl_flag"`
  22356. // CvlservFlag string `json:"cvlserv_flag"`
  22357. // EmpName string `json:"emp_name"`
  22358. // Brdy string `json:"brdy"`
  22359. // Naty string `json:"naty"`
  22360. // Certno string `json:"certno"`
  22361. // DiseCode string `json:"dise_code"`
  22362. // FixmedinsCode string `json:"fixmedins_code"`
  22363. // DedcHospLv string `json:"dedc_hosp_lv"`
  22364. // OpterName string `json:"opter_name"`
  22365. // Balc float64 `json:"balc"`
  22366. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22367. // PsnCertType string `json:"psn_cert_type"`
  22368. // HifobPay float64 `json:"hifob_pay"`
  22369. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  22370. // HifesPay float64 `json:"hifes_pay"`
  22371. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22372. // OptTime string `json:"opt_time"`
  22373. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22374. // SetlID string `json:"setl_id"`
  22375. // MafPay float64 `json:"maf_pay"`
  22376. // PsnName string `json:"psn_name"`
  22377. // InsuOptins interface{} `json:"insu_optins"`
  22378. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22379. // ClrOptins string `json:"clr_optins"`
  22380. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22381. // DiseName string `json:"dise_name"`
  22382. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22383. // Age float64 `json:"age"`
  22384. // DtrtCertType string `json:"dtrt_cert_type"`
  22385. // HospLv string `json:"hosp_lv"`
  22386. // } `json:"setlinfo"`
  22387. // Setldetail []struct {
  22388. // FundPayType string `json:"fund_pay_type"`
  22389. // FundPayamt float64 `json:"fund_payamt"`
  22390. // SetlProcInfo interface{} `json:"setl_proc_info"`
  22391. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  22392. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  22393. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  22394. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22395. // } `json:"setldetail"`
  22396. // } `json:"output"`
  22397. // Infcode int `json:"infcode"`
  22398. // WarnMsg interface{} `json:"warn_msg"`
  22399. // Cainfo interface{} `json:"cainfo"`
  22400. // ErrMsg interface{} `json:"err_msg"`
  22401. // RefmsgTime string `json:"refmsg_time"`
  22402. // Signtype interface{} `json:"signtype"`
  22403. // RespondTime string `json:"respond_time"`
  22404. // InfRefmsgid string `json:"inf_refmsgid"`
  22405. // }
  22406. type Result002 struct {
  22407. Cainfo interface{} `json:"cainfo"`
  22408. ErrMsg string `json:"err_msg"`
  22409. InfRefmsgid string `json:"inf_refmsgid"`
  22410. Infcode int64 `json:"infcode"`
  22411. Output struct {
  22412. RxFile string `json:"rx_file"`
  22413. SignDigest string `json:"sign_digest"`
  22414. SignCertSn string `json:"sign_cert_sn"`
  22415. SignCertDn string `json:"sign_cert_dn"`
  22416. } `json:"output"`
  22417. RefmsgTime string `json:"refmsg_time"`
  22418. RespondTime string `json:"respond_time"`
  22419. Signtype interface{} `json:"signtype"`
  22420. WarnMsg interface{} `json:"warn_msg"`
  22421. }
  22422. type Result003 struct {
  22423. Cainfo interface{} `json:"cainfo"`
  22424. ErrMsg string `json:"err_msg"`
  22425. InfRefmsgid string `json:"inf_refmsgid"`
  22426. Infcode int64 `json:"infcode"`
  22427. Output struct {
  22428. HiRxno string `json:"hi_rxno"`
  22429. RxStasCodg string `json:"rx_stas_codg"`
  22430. RxStasName string `json:"rx_stas_name"`
  22431. } `json:"output"`
  22432. RefmsgTime string `json:"refmsg_time"`
  22433. RespondTime string `json:"respond_time"`
  22434. Signtype interface{} `json:"signtype"`
  22435. WarnMsg interface{} `json:"warn_msg"`
  22436. }
  22437. type ResultEleven struct {
  22438. Cainfo string `json:"cainfo"`
  22439. ErrMsg string `json:"err_msg"`
  22440. InfRefmsgid string `json:"inf_refmsgid"`
  22441. Infcode int64 `json:"infcode"`
  22442. Output struct {
  22443. Setlinfo struct {
  22444. SetlTime string `json:"setl_time"`
  22445. CvlservPay float64 `json:"cvlserv_pay"`
  22446. Year string `json:"year"`
  22447. MedType string `json:"med_type"`
  22448. PsnPay float64 `json:"psn_pay"`
  22449. OpterID string `json:"opter_id"`
  22450. Begndate string `json:"begndate"`
  22451. FlxempeFlag string `json:"flxempe_flag"`
  22452. HifmiPay float64 `json:"hifmi_pay"`
  22453. PsnNo string `json:"psn_no"`
  22454. ActPayDedc float64 `json:"act_pay_dedc"`
  22455. MedinsSetlID interface{} `json:"medins_setl_id"`
  22456. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22457. ClrWay string `json:"clr_way"`
  22458. OthPay float64 `json:"oth_pay"`
  22459. Gend string `json:"gend"`
  22460. MdtrtID string `json:"mdtrt_id"`
  22461. AcctPay float64 `json:"acct_pay"`
  22462. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22463. Insutype string `json:"insutype"`
  22464. Invono interface{} `json:"invono"`
  22465. Enddate string `json:"enddate"`
  22466. CashPayamt float64 `json:"cash_payamt"`
  22467. PsnType string `json:"psn_type"`
  22468. FixmedinsName string `json:"fixmedins_name"`
  22469. HifpPay float64 `json:"hifp_pay"`
  22470. NewFlag interface{} `json:"new_flag"`
  22471. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22472. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22473. PayLoc string `json:"pay_loc"`
  22474. ClrType string `json:"clr_type"`
  22475. RefdSetlFlag string `json:"refd_setl_flag"`
  22476. CvlservFlag string `json:"cvlserv_flag"`
  22477. EmpName string `json:"emp_name"`
  22478. Brdy string `json:"brdy"`
  22479. Naty string `json:"naty"`
  22480. Certno string `json:"certno"`
  22481. DiseCode string `json:"dise_code"`
  22482. FixmedinsCode string `json:"fixmedins_code"`
  22483. DedcHospLv string `json:"dedc_hosp_lv"`
  22484. OpterName string `json:"opter_name"`
  22485. Balc float64 `json:"balc"`
  22486. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22487. PsnCertType string `json:"psn_cert_type"`
  22488. HifobPay float64 `json:"hifob_pay"`
  22489. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22490. HifesPay float64 `json:"hifes_pay"`
  22491. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22492. OptTime string `json:"opt_time"`
  22493. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22494. SetlID string `json:"setl_id"`
  22495. MafPay float64 `json:"maf_pay"`
  22496. PsnName string `json:"psn_name"`
  22497. InsuOptins interface{} `json:"insu_optins"`
  22498. PrefFundPay interface{} `json:"pref_fund_pay"`
  22499. ClrOptins string `json:"clr_optins"`
  22500. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22501. DiseName string `json:"dise_name"`
  22502. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22503. Age float64 `json:"age"`
  22504. DtrtCertType string `json:"dtrt_cert_type"`
  22505. HospLv string `json:"hosp_lv"`
  22506. PsnCashPay float64 `json:"psn_cash_pay"`
  22507. } `json:"setlinfo"`
  22508. } `json:"output"`
  22509. RefmsgTime string `json:"refmsg_time"`
  22510. RespondTime string `json:"respond_time"`
  22511. Signtype interface{} `json:"signtype"`
  22512. WarnMsg interface{} `json:"warn_msg"`
  22513. }
  22514. type ResultElevenah struct {
  22515. Cainfo string `json:"cainfo"`
  22516. ErrMsg string `json:"err_msg"`
  22517. InfRefmsgid string `json:"inf_refmsgid"`
  22518. Infcode int64 `json:"infcode"`
  22519. Output struct {
  22520. Setlinfo struct {
  22521. SetlTime int64 `json:"setl_time"`
  22522. CvlservPay float64 `json:"cvlserv_pay"`
  22523. Year string `json:"year"`
  22524. MedType string `json:"med_type"`
  22525. PsnPay float64 `json:"psn_pay"`
  22526. OpterID string `json:"opter_id"`
  22527. Begndate int64 `json:"begndate"`
  22528. FlxempeFlag string `json:"flxempe_flag"`
  22529. HifmiPay float64 `json:"hifmi_pay"`
  22530. PsnNo string `json:"psn_no"`
  22531. ActPayDedc float64 `json:"act_pay_dedc"`
  22532. MedinsSetlID interface{} `json:"medins_setl_id"`
  22533. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22534. ClrWay string `json:"clr_way"`
  22535. OthPay float64 `json:"oth_pay"`
  22536. Gend string `json:"gend"`
  22537. MdtrtID string `json:"mdtrt_id"`
  22538. AcctPay float64 `json:"acct_pay"`
  22539. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22540. Insutype string `json:"insutype"`
  22541. Invono interface{} `json:"invono"`
  22542. Enddate int64 `json:"enddate"`
  22543. CashPayamt float64 `json:"cash_payamt"`
  22544. PsnType string `json:"psn_type"`
  22545. FixmedinsName string `json:"fixmedins_name"`
  22546. HifpPay float64 `json:"hifp_pay"`
  22547. NewFlag interface{} `json:"new_flag"`
  22548. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22549. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22550. PayLoc string `json:"pay_loc"`
  22551. ClrType string `json:"clr_type"`
  22552. RefdSetlFlag string `json:"refd_setl_flag"`
  22553. CvlservFlag string `json:"cvlserv_flag"`
  22554. EmpName string `json:"emp_name"`
  22555. Brdy int64 `json:"brdy"`
  22556. Naty string `json:"naty"`
  22557. Certno string `json:"certno"`
  22558. DiseCode string `json:"dise_code"`
  22559. FixmedinsCode string `json:"fixmedins_code"`
  22560. DedcHospLv string `json:"dedc_hosp_lv"`
  22561. OpterName string `json:"opter_name"`
  22562. Balc float64 `json:"balc"`
  22563. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22564. PsnCertType string `json:"psn_cert_type"`
  22565. HifobPay float64 `json:"hifob_pay"`
  22566. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22567. HifesPay float64 `json:"hifes_pay"`
  22568. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22569. OptTime int64 `json:"opt_time"`
  22570. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22571. SetlID string `json:"setl_id"`
  22572. MafPay float64 `json:"maf_pay"`
  22573. PsnName string `json:"psn_name"`
  22574. InsuOptins interface{} `json:"insu_optins"`
  22575. PrefFundPay interface{} `json:"pref_fund_pay"`
  22576. ClrOptins string `json:"clr_optins"`
  22577. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22578. DiseName string `json:"dise_name"`
  22579. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22580. Age float64 `json:"age"`
  22581. DtrtCertType string `json:"dtrt_cert_type"`
  22582. HospLv string `json:"hosp_lv"`
  22583. PsnCashPay float64 `json:"psn_cash_pay"`
  22584. } `json:"setlinfo"`
  22585. } `json:"output"`
  22586. RefmsgTime string `json:"refmsg_time"`
  22587. RespondTime string `json:"respond_time"`
  22588. Signtype interface{} `json:"signtype"`
  22589. WarnMsg interface{} `json:"warn_msg"`
  22590. }
  22591. type ResultEleven10265 struct {
  22592. Cainfo string `json:"cainfo"`
  22593. ErrMsg string `json:"err_msg"`
  22594. InfRefmsgid string `json:"inf_refmsgid"`
  22595. Infcode string `json:"infcode"`
  22596. Output struct {
  22597. Setlinfo struct {
  22598. SetlTime string `json:"setl_time"`
  22599. CvlservPay float64 `json:"cvlserv_pay"`
  22600. Year string `json:"year"`
  22601. MedType string `json:"med_type"`
  22602. PsnPay float64 `json:"psn_pay"`
  22603. OpterID string `json:"opter_id"`
  22604. Begndate string `json:"begndate"`
  22605. FlxempeFlag string `json:"flxempe_flag"`
  22606. HifmiPay float64 `json:"hifmi_pay"`
  22607. PsnNo string `json:"psn_no"`
  22608. ActPayDedc float64 `json:"act_pay_dedc"`
  22609. MedinsSetlID interface{} `json:"medins_setl_id"`
  22610. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22611. ClrWay string `json:"clr_way"`
  22612. OthPay float64 `json:"oth_pay"`
  22613. Gend string `json:"gend"`
  22614. MdtrtID string `json:"mdtrt_id"`
  22615. AcctPay float64 `json:"acct_pay"`
  22616. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22617. Insutype string `json:"insutype"`
  22618. Invono interface{} `json:"invono"`
  22619. Enddate string `json:"enddate"`
  22620. CashPayamt float64 `json:"cash_payamt"`
  22621. PsnType string `json:"psn_type"`
  22622. FixmedinsName string `json:"fixmedins_name"`
  22623. HifpPay float64 `json:"hifp_pay"`
  22624. NewFlag interface{} `json:"new_flag"`
  22625. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22626. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22627. PayLoc string `json:"pay_loc"`
  22628. ClrType string `json:"clr_type"`
  22629. RefdSetlFlag string `json:"refd_setl_flag"`
  22630. CvlservFlag string `json:"cvlserv_flag"`
  22631. EmpName string `json:"emp_name"`
  22632. Brdy string `json:"brdy"`
  22633. Naty string `json:"naty"`
  22634. Certno string `json:"certno"`
  22635. DiseCode string `json:"dise_code"`
  22636. FixmedinsCode string `json:"fixmedins_code"`
  22637. DedcHospLv string `json:"dedc_hosp_lv"`
  22638. OpterName string `json:"opter_name"`
  22639. Balc float64 `json:"balc"`
  22640. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22641. PsnCertType string `json:"psn_cert_type"`
  22642. HifobPay float64 `json:"hifob_pay"`
  22643. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22644. HifesPay float64 `json:"hifes_pay"`
  22645. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22646. OptTime string `json:"opt_time"`
  22647. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22648. SetlID string `json:"setl_id"`
  22649. MafPay float64 `json:"maf_pay"`
  22650. PsnName string `json:"psn_name"`
  22651. InsuOptins interface{} `json:"insu_optins"`
  22652. PrefFundPay interface{} `json:"pref_fund_pay"`
  22653. ClrOptins string `json:"clr_optins"`
  22654. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22655. DiseName string `json:"dise_name"`
  22656. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22657. Age float64 `json:"age"`
  22658. DtrtCertType string `json:"dtrt_cert_type"`
  22659. HospLv string `json:"hosp_lv"`
  22660. PsnCashPay float64 `json:"psn_cash_pay"`
  22661. } `json:"setlinfo"`
  22662. } `json:"output"`
  22663. RefmsgTime string `json:"refmsg_time"`
  22664. RespondTime string `json:"respond_time"`
  22665. Signtype interface{} `json:"signtype"`
  22666. WarnMsg interface{} `json:"warn_msg"`
  22667. }
  22668. type ResultTwelve struct {
  22669. Cainfo string `json:"cainfo"`
  22670. ErrMsg string `json:"err_msg"`
  22671. InfRefmsgid string `json:"inf_refmsgid"`
  22672. Infcode int64 `json:"infcode"`
  22673. Output struct {
  22674. MdtrtId string `json:"mdtrt_id"`
  22675. ChrgBchno string `json:"chrg_bchno"`
  22676. PsnNo string `json:"psn_no"`
  22677. } `json:"output"`
  22678. RefmsgTime string `json:"refmsg_time"`
  22679. RespondTime string `json:"respond_time"`
  22680. Signtype interface{} `json:"signtype"`
  22681. WarnMsg interface{} `json:"warn_msg"`
  22682. }
  22683. type ResultThirteen struct {
  22684. ErrMsg string `json:"err_msg"`
  22685. InfRefmsgid string `json:"inf_refmsgid"`
  22686. Infcode int64 `json:"infcode"`
  22687. Output struct {
  22688. Result struct {
  22689. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22690. } `json:"result"`
  22691. } `json:"output"`
  22692. RefmsgTime string `json:"refmsg_time"`
  22693. RespondTime string `json:"respond_time"`
  22694. Signtype interface{} `json:"signtype"`
  22695. WarnInfo interface{} `json:"warn_info"`
  22696. }
  22697. type ResultThirteen10265 struct {
  22698. ErrMsg string `json:"err_msg"`
  22699. InfRefmsgid string `json:"inf_refmsgid"`
  22700. Infcode string `json:"infcode"`
  22701. Output struct {
  22702. Result struct {
  22703. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22704. } `json:"result"`
  22705. } `json:"output"`
  22706. RefmsgTime string `json:"refmsg_time"`
  22707. RespondTime string `json:"respond_time"`
  22708. Signtype interface{} `json:"signtype"`
  22709. WarnInfo interface{} `json:"warn_info"`
  22710. }
  22711. type ResultFourteen struct {
  22712. ErrMsg string `json:"err_msg"`
  22713. InfRefmsgid string `json:"inf_refmsgid"`
  22714. Infcode int64 `json:"infcode"`
  22715. Output struct {
  22716. } `json:"output"`
  22717. RefmsgTime string `json:"refmsg_time"`
  22718. RespondTime string `json:"respond_time"`
  22719. Signtype interface{} `json:"signtype"`
  22720. WarnInfo interface{} `json:"warn_info"`
  22721. }
  22722. type ResultCFYLJG001 struct {
  22723. ErrMsg string `json:"err_msg"`
  22724. InfRefmsgid string `json:"inf_refmsgid"`
  22725. Infcode int64 `json:"infcode"`
  22726. Output struct {
  22727. RxTraceCode string `json:"rx_trace_code"`
  22728. HiRxno string `json:"hi_rxno"`
  22729. } `json:"output"`
  22730. RefmsgTime string `json:"refmsg_time"`
  22731. RespondTime string `json:"respond_time"`
  22732. Signtype interface{} `json:"signtype"`
  22733. WarnInfo interface{} `json:"warn_info"`
  22734. }
  22735. type ResultCFYLJG007 struct {
  22736. ErrMsg string `json:"err_msg"`
  22737. InfRefmsgid string `json:"inf_refmsgid"`
  22738. Infcode int64 `json:"infcode"`
  22739. Output struct {
  22740. HiRxno string `json:"hi_rxno"`
  22741. RxStasName string `json:"rx_stas_name"`
  22742. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  22743. Seltdelts []interface{} `json:"seltdelts"`
  22744. RxUsedStasName string `json:"rx_used_stas_name"`
  22745. RxStasCodg string `json:"rx_stas_codg"`
  22746. } `json:"output"`
  22747. RefmsgTime string `json:"refmsg_time"`
  22748. RespondTime string `json:"respond_time"`
  22749. Signtype interface{} `json:"signtype"`
  22750. WarnInfo interface{} `json:"warn_info"`
  22751. }
  22752. type ResultCFYLJG002 struct {
  22753. ErrMsg string `json:"err_msg"`
  22754. InfRefmsgid string `json:"inf_refmsgid"`
  22755. Infcode int64 `json:"infcode"`
  22756. Output struct {
  22757. RxFile string `json:"rx_file"`
  22758. SignDigest string `json:"sign_digest"`
  22759. SignCertSn string `json:"sign_cert_sn"`
  22760. SignCertDn string `json:"sign_cert_dn"`
  22761. } `json:"output"`
  22762. RefmsgTime string `json:"refmsg_time"`
  22763. RespondTime string `json:"respond_time"`
  22764. Signtype interface{} `json:"signtype"`
  22765. WarnInfo interface{} `json:"warn_info"`
  22766. }
  22767. type ResultCFYLJG003 struct {
  22768. ErrMsg string `json:"err_msg"`
  22769. InfRefmsgid string `json:"inf_refmsgid"`
  22770. Infcode int64 `json:"infcode"`
  22771. Output struct {
  22772. HiRxno string `json:"hi_rxno"`
  22773. RxStasCodg string `json:"rx_stas_codg"`
  22774. RxStasName string `json:"rx_stas_name"`
  22775. } `json:"output"`
  22776. RefmsgTime string `json:"refmsg_time"`
  22777. RespondTime string `json:"respond_time"`
  22778. Signtype interface{} `json:"signtype"`
  22779. WarnInfo interface{} `json:"warn_info"`
  22780. }
  22781. type ResultCFYLJG004 struct {
  22782. ErrMsg string `json:"err_msg"`
  22783. InfRefmsgid string `json:"inf_refmsgid"`
  22784. Infcode int64 `json:"infcode"`
  22785. Output struct {
  22786. HiRxno string `json:"hi_rxno"`
  22787. RxStasCodg string `json:"rx_stas_codg"`
  22788. RxStasName string `json:"rx_stas_name"`
  22789. } `json:"output"`
  22790. RefmsgTime string `json:"refmsg_time"`
  22791. RespondTime string `json:"respond_time"`
  22792. Signtype interface{} `json:"signtype"`
  22793. WarnInfo interface{} `json:"warn_info"`
  22794. }
  22795. type ResultCFYLJG008 struct {
  22796. ErrMsg string `json:"err_msg"`
  22797. InfRefmsgid string `json:"inf_refmsgid"`
  22798. Infcode int64 `json:"infcode"`
  22799. Output struct {
  22800. PoolareaNo string `json:"poolareaNo"`
  22801. AdmdvsName string `json:"admdvsName"`
  22802. Count string `json:"count"`
  22803. } `json:"output"`
  22804. RefmsgTime string `json:"refmsg_time"`
  22805. RespondTime string `json:"respond_time"`
  22806. Signtype interface{} `json:"signtype"`
  22807. WarnInfo interface{} `json:"warn_info"`
  22808. }
  22809. type ResultCFYLJG005 struct {
  22810. ErrMsg string `json:"err_msg"`
  22811. InfRefmsgid string `json:"inf_refmsgid"`
  22812. Infcode int64 `json:"infcode"`
  22813. Output struct {
  22814. HiRxNo string `json:"hi_rxno"`
  22815. FixMedinsCode string `json:"fixmedins_code"`
  22816. FixMedinsName string `json:"fixmedins_name"`
  22817. RxStasCodg string `json:"rx_stas_codg"`
  22818. RxStasName string `json:"rx_stas_name"`
  22819. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  22820. RxUserdStasName string `json:"rx_userd_stas_name"`
  22821. PrscTime string `json:"prsc_time"`
  22822. RxDrugCnt float64 `json:"rx_drug_cnt"`
  22823. RxUsedWayCodg string `json:"rx_used_way_codg"`
  22824. RxUsedWayName string `json:"rx_used_way_name"`
  22825. RxFrquCodg string `json:"rx_frqu_codg"`
  22826. RxFrquName string `json:"rx_frqu_name"`
  22827. RxDosunt string `json:"rx_dosunt"`
  22828. RxDoscnt float64 `json:"rx_doscnt"`
  22829. RxDrordDscr string `json:"rx_drord_dscr"`
  22830. ValiDays int64 `json:"vali_days"`
  22831. ValiEndTime string `json:"vali_end_time"`
  22832. ReptFlag string `json:"rept_flag"`
  22833. MaxReptCnt int64 `json:"max_rept_cnt"`
  22834. ReptdCnt int64 `json:"reptd_cnt"`
  22835. MinInrvDays int64 `json:"min_inrv_days"`
  22836. RxTypeCode string `json:"rx_type_code"`
  22837. RxTypeName string `json:"rx_type_name"`
  22838. LongRxFlag string `json:"long_rx_flag"`
  22839. RxDetlList []struct {
  22840. MedListCodg string `json:"med_list_codg"`
  22841. MedinsListCodg string `json:"medins_list_codg"`
  22842. HospPrepFlag string `json:"hosp_prep_flag"`
  22843. RxItemTypeCode string `json:"rx_item_type_code"`
  22844. RxItemTypeName string `json:"rx_item_type_name"`
  22845. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  22846. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  22847. TcmHerbFoote string `json:"tcmherb_foote"`
  22848. MednTypeCode string `json:"medn_type_code"`
  22849. MednTypeName string `json:"medn_type_name"`
  22850. MainMedcFlag string `json:"main_medc_flag"`
  22851. UrgtFlag string `json:"urgt_flag"`
  22852. BasMednFlag string `json:"bas_medn_flag"`
  22853. ImpDrugFlag string `json:"imp_drug_flag"`
  22854. ProdBarc string `json:"prod_barc"`
  22855. DrugProdname string `json:"drug_prodname"`
  22856. GennameCodg string `json:"genname_codg"`
  22857. DrugGenname string `json:"drug_genname"`
  22858. DrugDosform string `json:"drug_dosform"`
  22859. DrugSpec string `json:"drug_spec"`
  22860. PrdrName string `json:"prdr_name"`
  22861. MedcWayCodg string `json:"medc_way_codg"`
  22862. MedcWayDscr string `json:"medc_way_dscr"`
  22863. MedcBegntime string `json:"medc_begntime"`
  22864. MedcEndtime string `json:"medc_endtime"`
  22865. MedcDays float64 `json:"medc_days"`
  22866. DrugPric float64 `json:"drug_pric"`
  22867. DrugSumamt float64 `json:"drug_sumamt"`
  22868. DrugCnt float64 `json:"drug_cnt"`
  22869. DrugDosunt string `json:"drug_dosunt"`
  22870. SinDoscnt float64 `json:"sin_doscnt"`
  22871. SinDosunt string `json:"sin_dosunt"`
  22872. UsedFrquCodg string `json:"used_frqu_codg"`
  22873. UsedFrquName string `json:"used_frqu_name"`
  22874. DrugTotlcnt string `json:"drug_totlcnt"`
  22875. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  22876. DiseCodg string `json:"dise_codg"`
  22877. HospApprFlag string `json:"hosp_appr_flag"`
  22878. } `json:"rx_detl_list"`
  22879. RxOtpinfo struct {
  22880. MedType string `json:"med_type"`
  22881. IptOtpNo string `json:"ipt_otp_no"`
  22882. OtpIptFlag string `json:"otp_ipt_flag"`
  22883. PatnName string `json:"patn_name"`
  22884. PatnAge float64 `json:"patn_age"`
  22885. PatnHgt float64 `json:"patn_hgt"`
  22886. PatnWt float64 `json:"patn_wt"`
  22887. Gend string `json:"gend"`
  22888. GesoVal float64 `json:"geso_val"`
  22889. NwbFlag string `json:"nwb_flag"`
  22890. NwbAge string `json:"nwb_age"`
  22891. SuckPrdFlag string `json:"suck_prd_flag"`
  22892. AlgsHis string `json:"algs_his"`
  22893. Insutype string `json:"insutype"`
  22894. PrscDeptName string `json:"prsc_dept_name"`
  22895. PrscDrName string `json:"prsc_dr_name"`
  22896. PharName string `json:"phar_name"`
  22897. PharChkTime string `json:"phar_chk_time"`
  22898. MdtrtTime string `json:"mdtrt_time"`
  22899. DiseCodg string `json:"dise_codg"`
  22900. DiseName string `json:"dise_name"`
  22901. SpDiseFlag string `json:"sp_dise_flag"`
  22902. MaindiagCode string `json:"maindiag_code"`
  22903. MaindiagName string `json:"maindiag_name"`
  22904. DiseCondDscr string `json:"dise_cond_dscr"`
  22905. FstdiagFlag string `json:"fstdiag_flag"`
  22906. } `json:"rx_otpinfo"`
  22907. RxDiseList []struct {
  22908. DiagType string `json:"diag_type"`
  22909. MaindiagFlag string `json:"maindiag_flag"`
  22910. DiagSrtNo string `json:"diag_srt_no"`
  22911. DiagCode string `json:"diag_code"`
  22912. DiagName string `json:"diag_name"`
  22913. DiagDept string `json:"diag_dept"`
  22914. DiagDrNo string `json:"diag_dr_no"`
  22915. DiagDrName string `json:"diag_dr_name"`
  22916. DiagTime string `json:"diag_time"`
  22917. TcmDiseCode string `json:"tcm_dise_code"`
  22918. TcmDiseName string `json:"tcm_dise_name"`
  22919. TcmSympCode string `json:"tcmsymp_code"`
  22920. TcmSymp string `json:"tcmsymp"`
  22921. } `json:"rx_dise_list"`
  22922. } `json:"output"`
  22923. RefmsgTime string `json:"refmsg_time"`
  22924. RespondTime string `json:"respond_time"`
  22925. Signtype interface{} `json:"signtype"`
  22926. WarnInfo interface{} `json:"warn_info"`
  22927. }
  22928. type ResultCFYLJG006 struct {
  22929. ErrMsg string `json:"err_msg"`
  22930. InfRefmsgid string `json:"inf_refmsgid"`
  22931. Infcode int64 `json:"infcode"`
  22932. Output struct {
  22933. HiRxNo string `json:"hi_rxno"`
  22934. PharCode string `json:"phar_code"`
  22935. PharName string `json:"phar_name"`
  22936. RxChkOpnn string `json:"rx_chk_opnn"`
  22937. RxChkTime string `json:"rx_chk_time"`
  22938. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  22939. RxChkStasName string `json:"rx_chk_stas_name"`
  22940. RxStasCodg string `json:"rx_stas_codg"`
  22941. RxStasName string `json:"rx_stas_name"`
  22942. } `json:"output"`
  22943. RefmsgTime string `json:"refmsg_time"`
  22944. RespondTime string `json:"respond_time"`
  22945. Signtype interface{} `json:"signtype"`
  22946. WarnInfo interface{} `json:"warn_info"`
  22947. }
  22948. type ResultFourteen10265 struct {
  22949. ErrMsg string `json:"err_msg"`
  22950. InfRefmsgid string `json:"inf_refmsgid"`
  22951. Infcode string `json:"infcode"`
  22952. Output struct {
  22953. } `json:"output"`
  22954. RefmsgTime string `json:"refmsg_time"`
  22955. RespondTime string `json:"respond_time"`
  22956. Signtype interface{} `json:"signtype"`
  22957. WarnInfo interface{} `json:"warn_info"`
  22958. }
  22959. type ResultSixteen struct {
  22960. Cainfo string `json:"cainfo"`
  22961. ErrMsg string `json:"err_msg"`
  22962. InfRefmsgid string `json:"inf_refmsgid"`
  22963. Infcode int64 `json:"infcode"`
  22964. Output struct {
  22965. Setlinfo struct {
  22966. MdtrtID string `json:"mdtrt_id"`
  22967. SetlID string `json:"setl_id"`
  22968. ClrOptins string `json:"clr_optins"`
  22969. SetlTime string `json:"setl_time"`
  22970. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22971. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22972. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22973. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22974. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22975. ActPayDedc float64 `json:"act_pay_dedc"`
  22976. HifpPay float64 `json:"hifp_pay"`
  22977. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22978. Lfpay float64 `json:"selfpay"`
  22979. CvlservPay float64 `json:"cvlserv_pay"`
  22980. HifesPay float64 `json:"hifes_pay"`
  22981. HifmiPay float64 `json:"hifmi_pay"`
  22982. HifobPay float64 `json:"hifob_pay"`
  22983. MafPay float64 `json:"maf_pay"`
  22984. OthPay float64 `json:"oth_pay"`
  22985. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22986. PsnPartAmt float64 `json:"psn_part_amt"`
  22987. AcctPay float64 `json:"acct_pay"`
  22988. Balc float64 `json:"balc"`
  22989. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22990. HospPartAmt float64 `json:"hosp_part_amt"`
  22991. MedinsSetlID string `json:"medins_setl_id"`
  22992. PdnCashPay string `json:"pdn_cash_pay"`
  22993. } `json:"setlinfo"`
  22994. } `json:"output"`
  22995. RefmsgTime string `json:"refmsg_time"`
  22996. RespondTime string `json:"respond_time"`
  22997. Signtype interface{} `json:"signtype"`
  22998. WarnMsg interface{} `json:"warn_msg"`
  22999. }
  23000. type ResultSixteen10265 struct {
  23001. Cainfo string `json:"cainfo"`
  23002. ErrMsg string `json:"err_msg"`
  23003. InfRefmsgid string `json:"inf_refmsgid"`
  23004. Infcode string `json:"infcode"`
  23005. Output struct {
  23006. Setlinfo struct {
  23007. MdtrtID string `json:"mdtrt_id"`
  23008. SetlID string `json:"setl_id"`
  23009. ClrOptins string `json:"clr_optins"`
  23010. SetlTime string `json:"setl_time"`
  23011. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23012. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23013. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23014. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23015. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23016. ActPayDedc float64 `json:"act_pay_dedc"`
  23017. HifpPay float64 `json:"hifp_pay"`
  23018. PoolPropSe float64 `json:"pool_prop_selfpay"`
  23019. Lfpay float64 `json:"selfpay"`
  23020. CvlservPay float64 `json:"cvlserv_pay"`
  23021. HifesPay float64 `json:"hifes_pay"`
  23022. HifmiPay float64 `json:"hifmi_pay"`
  23023. HifobPay float64 `json:"hifob_pay"`
  23024. MafPay float64 `json:"maf_pay"`
  23025. OthPay float64 `json:"oth_pay"`
  23026. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23027. PsnPartAmt float64 `json:"psn_part_amt"`
  23028. AcctPay float64 `json:"acct_pay"`
  23029. Balc float64 `json:"balc"`
  23030. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23031. HospPartAmt float64 `json:"hosp_part_amt"`
  23032. MedinsSetlID string `json:"medins_setl_id"`
  23033. PdnCashPay string `json:"pdn_cash_pay"`
  23034. } `json:"setlinfo"`
  23035. } `json:"output"`
  23036. RefmsgTime string `json:"refmsg_time"`
  23037. RespondTime string `json:"respond_time"`
  23038. Signtype interface{} `json:"signtype"`
  23039. WarnMsg interface{} `json:"warn_msg"`
  23040. }
  23041. type ResultSixteen10265Two struct {
  23042. Cainfo string `json:"cainfo"`
  23043. ErrMsg string `json:"err_msg"`
  23044. InfRefmsgid string `json:"inf_refmsgid"`
  23045. Infcode string `json:"infcode"`
  23046. Output struct {
  23047. Setlinfo interface{} `json:"setlinfo"`
  23048. } `json:"output"`
  23049. RefmsgTime string `json:"refmsg_time"`
  23050. RespondTime string `json:"respond_time"`
  23051. Signtype interface{} `json:"signtype"`
  23052. WarnMsg interface{} `json:"warn_msg"`
  23053. }
  23054. type ResultgzSixteen10265Two struct {
  23055. Cainfo string `json:"cainfo"`
  23056. ErrMsg string `json:"err_msg"`
  23057. InfRefmsgid string `json:"inf_refmsgid"`
  23058. Infcode int64 `json:"infcode"`
  23059. Output struct {
  23060. Setlinfo interface{} `json:"setlinfo"`
  23061. } `json:"output"`
  23062. RefmsgTime string `json:"refmsg_time"`
  23063. RespondTime string `json:"respond_time"`
  23064. Signtype interface{} `json:"signtype"`
  23065. WarnMsg interface{} `json:"warn_msg"`
  23066. }
  23067. type ResultSeventeen struct {
  23068. ErrMsg string `json:"err_msg"`
  23069. InfRefmsgid string `json:"inf_refmsgid"`
  23070. Infcode int64 `json:"infcode"`
  23071. Output struct {
  23072. SetlListId string `json:"setl_list_id"`
  23073. } `json:"output"`
  23074. RefmsgTime string `json:"refmsg_time"`
  23075. RespondTime string `json:"respond_time"`
  23076. Signtype string `json:"signtype"`
  23077. WarnInfo string `json:"warn_info"`
  23078. }
  23079. type ResultSeventeenOther struct {
  23080. ErrMsg string `json:"err_msg"`
  23081. InfRefmsgid string `json:"inf_refmsgid"`
  23082. Infcode string `json:"infcode"`
  23083. Output struct {
  23084. SetlListId string `json:"setl_list_id"`
  23085. } `json:"output"`
  23086. RefmsgTime string `json:"refmsg_time"`
  23087. RespondTime string `json:"respond_time"`
  23088. Signtype string `json:"signtype"`
  23089. WarnInfo string `json:"warn_info"`
  23090. }
  23091. type Result90991 struct {
  23092. ErrMsg string `json:"err_msg"`
  23093. InfRefmsgid string `json:"inf_refmsgid"`
  23094. Infcode int64 `json:"infcode"`
  23095. Output struct {
  23096. Result struct {
  23097. PsnNo string `json:"psn_no"`
  23098. CardStat string `json:"card_stat"`
  23099. Certno string `json:"certno"`
  23100. PsnName string `json:"psn_name"`
  23101. CheckStat string `json:"check_stat"`
  23102. SscnoCheckStat string `json:"sscno_check_stat"`
  23103. } `json:"result"`
  23104. } `json:"output"`
  23105. RefmsgTime string `json:"refmsg_time"`
  23106. RespondTime string `json:"respond_time"`
  23107. Signtype interface{} `json:"signtype"`
  23108. WarnInfo interface{} `json:"warn_info"`
  23109. }
  23110. type Result90100 struct {
  23111. ErrMsg string `json:"err_msg"`
  23112. InfRefmsgid string `json:"inf_refmsgid"`
  23113. Infcode int64 `json:"infcode"`
  23114. Output struct {
  23115. PoolareaNo string `json:"poolarea_no"`
  23116. PoolareaNoName string `json:"poolarea_no_name"`
  23117. Insutype string `json:"insutype"`
  23118. InsutypeName string `json:"insutype_name"`
  23119. ClctType string `json:"clct_type"`
  23120. ClctTypeName string `json:"clct_type_name"`
  23121. ClctFlag string `json:"clct_flag"`
  23122. ClctFlagName string `json:"clct_flag_name"`
  23123. AccrymBegn string `json:"accrym_begn"`
  23124. AccrymEnd string `json:"accrym_end"`
  23125. ClctTime string `json:"clct_time"`
  23126. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  23127. } `json:"output"`
  23128. RefmsgTime string `json:"refmsg_time"`
  23129. RespondTime string `json:"respond_time"`
  23130. Signtype interface{} `json:"signtype"`
  23131. WarnInfo interface{} `json:"warn_info"`
  23132. }
  23133. type Custom struct {
  23134. DetItemFeeSumamt string
  23135. Cut string
  23136. FeedetlSn string
  23137. Price string
  23138. MedListCodg string
  23139. Type int64
  23140. AdviceId int64
  23141. ProjectId int64
  23142. ItemId int64
  23143. }
  23144. type Result5301 struct {
  23145. ErrMsg string `json:"err_msg"`
  23146. InfRefmsgid string `json:"inf_refmsgid"`
  23147. Infcode int64 `json:"infcode"`
  23148. Output struct {
  23149. Result []struct {
  23150. OpspDiseCode string `json:"opsp_dise_code"`
  23151. OpspDiseName string `json:"opsp_dise_name"`
  23152. Begndate string `json:"begndate"`
  23153. Enddate string `json:"enddate"`
  23154. } `json:"feedetail"`
  23155. } `json:"output"`
  23156. RefmsgTime string `json:"refmsg_time"`
  23157. RespondTime string `json:"respond_time"`
  23158. Signtype interface{} `json:"signtype"`
  23159. WarnInfo interface{} `json:"warn_info"`
  23160. }
  23161. type Result5301For10265 struct {
  23162. ErrMsg string `json:"err_msg"`
  23163. InfRefmsgid string `json:"inf_refmsgid"`
  23164. Infcode string `json:"infcode"`
  23165. Output struct {
  23166. Result []struct {
  23167. OpspDiseCode string `json:"opsp_dise_code"`
  23168. OpspDiseName string `json:"opsp_dise_name"`
  23169. Begndate string `json:"begndate"`
  23170. Enddate string `json:"enddate"`
  23171. } `json:"feedetail"`
  23172. } `json:"output"`
  23173. RefmsgTime string `json:"refmsg_time"`
  23174. RespondTime string `json:"respond_time"`
  23175. Signtype interface{} `json:"signtype"`
  23176. WarnInfo interface{} `json:"warn_info"`
  23177. }
  23178. //获取个人信息----挂号-----上传就诊信息
  23179. func (c *HisApiController) GetRegisterInfo() {
  23180. id, _ := c.GetInt64("id")
  23181. record_time := c.GetString("record_time")
  23182. settlementValue, _ := c.GetInt64("settlement_value")
  23183. medical_insurance_card := c.GetString("medical_insurance_card")
  23184. name := c.GetString("name")
  23185. id_card_type, _ := c.GetInt64("id_card_type")
  23186. certificates, _ := c.GetInt64("certificates")
  23187. medical_care, _ := c.GetInt64("medical_care")
  23188. birthday := c.GetString("birthday")
  23189. id_card := c.GetString("id_card")
  23190. register_type, _ := c.GetInt64("register")
  23191. doctor, _ := c.GetInt64("doctor")
  23192. department, _ := c.GetInt64("department")
  23193. gender, _ := c.GetInt64("sex")
  23194. registration_fee, _ := c.GetFloat("registration_fee")
  23195. medical_expenses, _ := c.GetFloat("medical_expenses")
  23196. social_type, _ := c.GetInt64("social_type")
  23197. admin_user_id, _ := c.GetInt64("admin_user_id")
  23198. insuplc_admdvs := c.GetString("insuplc_admdvs")
  23199. mdtrt_type := c.GetString("mdtrt_type")
  23200. if id_card_type == 5 {
  23201. id_card_type = 4
  23202. }
  23203. timeLayout := "2006-01-02"
  23204. loc, _ := time.LoadLocation("Local")
  23205. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  23206. birthUnix := birthdays.Unix()
  23207. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23208. if err != nil {
  23209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23210. return
  23211. }
  23212. recordDateTime := theTime.Unix()
  23213. adminInfo := c.GetAdminUserInfo()
  23214. var patient service.Patients
  23215. if id == 0 {
  23216. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  23217. } else {
  23218. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  23219. }
  23220. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23221. if patientPrescription.ID == 0 {
  23222. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23223. }
  23224. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  23225. if patient.ID == 0 {
  23226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  23227. return
  23228. }
  23229. if len(patient.IdCardNo) == 0 {
  23230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  23231. return
  23232. }
  23233. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  23234. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  23235. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  23236. //就诊结算未完成,不能进行二次挂号
  23237. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  23238. if len(his) >= 1 {
  23239. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  23240. if len(his) >= 1 && order.ID == 0 {
  23241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  23242. return
  23243. }
  23244. }
  23245. //var register_log string
  23246. if config.IsOpen == 1 {
  23247. var res ResultTwo
  23248. var res10265 ResultTwo10265
  23249. var PsnNo string
  23250. var PsnCertType string
  23251. var Certno string
  23252. var PsnName string
  23253. var Gend string
  23254. var Naty string
  23255. var Brdy string
  23256. var Age float64
  23257. var infoStr string
  23258. var idetinfoStr string
  23259. var infocode int64
  23260. var verify_number string
  23261. fmt.Println(verify_number)
  23262. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  23263. psn_info, _ := service.GetPsnByPatientId(id)
  23264. PsnNo = psn_info.PsnNo
  23265. PsnCertType = psn_info.PsnCertType
  23266. Certno = psn_info.Certno
  23267. PsnName = psn_info.PsnName
  23268. Gend = psn_info.Gend
  23269. Naty = psn_info.Naty
  23270. Brdy = psn_info.Brdy
  23271. Age = psn_info.Age
  23272. infoStr = psn_info.Insuinfo
  23273. idetinfoStr = psn_info.Idetinfo
  23274. infocode = 0
  23275. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23276. psn_info, _ := service.GetPsnByPatientId(id)
  23277. PsnNo = psn_info.PsnNo
  23278. PsnCertType = psn_info.PsnCertType
  23279. Certno = psn_info.Certno
  23280. PsnName = psn_info.PsnName
  23281. Gend = psn_info.Gend
  23282. Naty = psn_info.Naty
  23283. Brdy = psn_info.Brdy
  23284. Age = psn_info.Age
  23285. infoStr = psn_info.Insuinfo
  23286. idetinfoStr = psn_info.Idetinfo
  23287. infocode = 0
  23288. verify_number = psn_info.VerifyNumber
  23289. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23290. if id_card_type == 2 {
  23291. //请求内网数据
  23292. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  23293. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23294. "&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
  23295. resp, requestErr := http.Get(api)
  23296. if requestErr != nil {
  23297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23298. return
  23299. }
  23300. body, ioErr := ioutil.ReadAll(resp.Body)
  23301. if ioErr != nil {
  23302. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23304. return
  23305. }
  23306. var respJSON map[string]interface{}
  23307. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23308. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23310. return
  23311. }
  23312. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23313. result_byte, _ := json.Marshal(respJSON)
  23314. result := string(result_byte)
  23315. var dat map[string]interface{}
  23316. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23317. fmt.Println(dat)
  23318. } else {
  23319. fmt.Println(err)
  23320. }
  23321. userJSONBytes, _ := json.Marshal(dat)
  23322. var res ResultTwo
  23323. var resTwo10265 ResultTwo10265
  23324. if miConfig.Code == "H15049901371" {
  23325. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  23326. utils.ErrorLog("解析失败:%v", err)
  23327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23328. return
  23329. }
  23330. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  23331. res.Infcode = Infcode
  23332. res.ErrMsg = resTwo10265.ErrMsg
  23333. res.Output = resTwo10265.Output
  23334. res.InfRefmsgid = resTwo10265.InfRefmsgid
  23335. res.RespondTime = resTwo10265.RespondTime
  23336. res.WarnInfo = resTwo10265.WarnInfo
  23337. } else {
  23338. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23339. utils.ErrorLog("解析失败:%v", err)
  23340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23341. return
  23342. }
  23343. }
  23344. //var insutypes []string
  23345. //var insutype string
  23346. //var is390 int = 0
  23347. //var is310 int = 0
  23348. //for _, item := range res.Output.Iinfo {
  23349. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23350. // insutypes = append(insutypes, item.Insutype)
  23351. // }
  23352. //}
  23353. //if len(insutypes) == 1 {
  23354. // insutype = insutypes[0]
  23355. //} else {
  23356. // for _, i := range insutypes {
  23357. // if i == "390" {
  23358. // is390 = 1
  23359. // }
  23360. //
  23361. // if i == "310" {
  23362. // is310 = 1
  23363. // }
  23364. // }
  23365. //}
  23366. //if is390 == 1 {
  23367. // insutype = "390"
  23368. //}
  23369. //if is310 == 1 {
  23370. // insutype = "310"
  23371. //}
  23372. //if len(insutypes) == 0 {
  23373. // insutype = "310"
  23374. //}
  23375. PsnNo = res.Output.Baseinfo.PsnNo
  23376. PsnCertType = res.Output.Baseinfo.PsnCertType
  23377. Certno = res.Output.Baseinfo.Certno
  23378. PsnName = res.Output.Baseinfo.PsnName
  23379. Gend = res.Output.Baseinfo.Gend
  23380. Naty = res.Output.Baseinfo.Naty
  23381. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23382. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23383. infoStr = string(Iinfos)
  23384. idetinfoStr = string(Idetinfos)
  23385. infocode = res.Infcode
  23386. //infocode = 0
  23387. //verify_number = psn_info.VerifyNumber
  23388. } else {
  23389. psn_info, _ := service.GetPsnByPatientId(id)
  23390. PsnNo = psn_info.PsnNo
  23391. PsnCertType = psn_info.PsnCertType
  23392. Certno = psn_info.Certno
  23393. PsnName = psn_info.PsnName
  23394. Gend = psn_info.Gend
  23395. Naty = psn_info.Naty
  23396. Brdy = psn_info.Brdy
  23397. Age = psn_info.Age
  23398. infoStr = psn_info.Insuinfo
  23399. idetinfoStr = psn_info.Idetinfo
  23400. infocode = 0
  23401. verify_number = psn_info.VerifyNumber
  23402. }
  23403. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23404. if id_card_type == 1 {
  23405. psn_info, _ := service.GetPsnByPatientId(id)
  23406. PsnNo = psn_info.PsnNo
  23407. PsnCertType = psn_info.PsnCertType
  23408. Certno = psn_info.Certno
  23409. PsnName = psn_info.PsnName
  23410. Gend = psn_info.Gend
  23411. Naty = psn_info.Naty
  23412. Brdy = psn_info.Brdy
  23413. Age = psn_info.Age
  23414. infoStr = psn_info.Insuinfo
  23415. idetinfoStr = psn_info.Idetinfo
  23416. infocode = 0
  23417. verify_number = psn_info.VerifyNumber
  23418. } else if id_card_type == 2 {
  23419. 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)
  23420. fmt.Println(errMsgLog)
  23421. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23422. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23423. utils.ErrorLog("解析失败:%v", err)
  23424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23425. return
  23426. }
  23427. PsnNo = res.Output.Baseinfo.PsnNo
  23428. PsnCertType = res.Output.Baseinfo.PsnCertType
  23429. Certno = res.Output.Baseinfo.Certno
  23430. PsnName = res.Output.Baseinfo.PsnName
  23431. Gend = res.Output.Baseinfo.Gend
  23432. Naty = res.Output.Baseinfo.Naty
  23433. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23434. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23435. infoStr = string(Iinfos)
  23436. idetinfoStr = string(Idetinfos)
  23437. infocode = res.Infcode
  23438. }
  23439. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23440. if id_card_type == 1 {
  23441. psn_info, _ := service.GetPsnByPatientId(id)
  23442. PsnNo = psn_info.PsnNo
  23443. PsnCertType = psn_info.PsnCertType
  23444. Certno = psn_info.Certno
  23445. PsnName = psn_info.PsnName
  23446. Gend = psn_info.Gend
  23447. Naty = psn_info.Naty
  23448. Brdy = psn_info.Brdy
  23449. Age = psn_info.Age
  23450. infoStr = psn_info.Insuinfo
  23451. idetinfoStr = psn_info.Idetinfo
  23452. infocode = 0
  23453. verify_number = psn_info.VerifyNumber
  23454. } else if id_card_type == 2 {
  23455. 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, "")
  23456. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23457. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23458. utils.ErrorLog("解析失败:%v", err)
  23459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23460. return
  23461. }
  23462. PsnNo = res.Output.Baseinfo.PsnNo
  23463. PsnCertType = res.Output.Baseinfo.PsnCertType
  23464. Certno = res.Output.Baseinfo.Certno
  23465. PsnName = res.Output.Baseinfo.PsnName
  23466. Gend = res.Output.Baseinfo.Gend
  23467. Naty = res.Output.Baseinfo.Naty
  23468. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23469. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23470. infoStr = string(Iinfos)
  23471. idetinfoStr = string(Idetinfos)
  23472. infocode = res.Infcode
  23473. } else {
  23474. psn_info, _ := service.GetPsnByPatientId(id)
  23475. PsnNo = psn_info.PsnNo
  23476. PsnCertType = psn_info.PsnCertType
  23477. Certno = psn_info.Certno
  23478. PsnName = psn_info.PsnName
  23479. Gend = psn_info.Gend
  23480. Naty = psn_info.Naty
  23481. Brdy = psn_info.Brdy
  23482. Age = psn_info.Age
  23483. infoStr = psn_info.Insuinfo
  23484. idetinfoStr = psn_info.Idetinfo
  23485. infocode = 0
  23486. verify_number = psn_info.VerifyNumber
  23487. }
  23488. } else if miConfig.MdtrtareaAdmvs == "361025" {
  23489. if id_card_type == 1 {
  23490. psn_info, _ := service.GetPsnByPatientId(id)
  23491. PsnNo = psn_info.PsnNo
  23492. PsnCertType = psn_info.PsnCertType
  23493. Certno = psn_info.Certno
  23494. PsnName = psn_info.PsnName
  23495. Gend = psn_info.Gend
  23496. Naty = psn_info.Naty
  23497. Brdy = psn_info.Brdy
  23498. Age = psn_info.Age
  23499. infoStr = psn_info.Insuinfo
  23500. idetinfoStr = psn_info.Idetinfo
  23501. infocode = 0
  23502. verify_number = psn_info.VerifyNumber
  23503. } else if id_card_type == 2 {
  23504. psn_info, _ := service.GetPsnByPatientId(id)
  23505. PsnNo = psn_info.PsnNo
  23506. PsnCertType = psn_info.PsnCertType
  23507. Certno = psn_info.Certno
  23508. PsnName = psn_info.PsnName
  23509. Gend = psn_info.Gend
  23510. Naty = psn_info.Naty
  23511. Brdy = psn_info.Brdy
  23512. Age = psn_info.Age
  23513. infoStr = psn_info.Insuinfo
  23514. idetinfoStr = psn_info.Idetinfo
  23515. infocode = 0
  23516. verify_number = psn_info.VerifyNumber
  23517. } else {
  23518. psn_info, _ := service.GetPsnByPatientId(id)
  23519. PsnNo = psn_info.PsnNo
  23520. PsnCertType = psn_info.PsnCertType
  23521. Certno = psn_info.Certno
  23522. PsnName = psn_info.PsnName
  23523. Gend = psn_info.Gend
  23524. Naty = psn_info.Naty
  23525. Brdy = psn_info.Brdy
  23526. Age = psn_info.Age
  23527. infoStr = psn_info.Insuinfo
  23528. idetinfoStr = psn_info.Idetinfo
  23529. infocode = 0
  23530. verify_number = psn_info.VerifyNumber
  23531. }
  23532. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  23533. psn_info, _ := service.GetPsnByPatientId(id)
  23534. PsnNo = psn_info.PsnNo
  23535. PsnCertType = psn_info.PsnCertType
  23536. Certno = psn_info.Certno
  23537. PsnName = psn_info.PsnName
  23538. Gend = psn_info.Gend
  23539. Naty = psn_info.Naty
  23540. Brdy = psn_info.Brdy
  23541. Age = psn_info.Age
  23542. infoStr = psn_info.Insuinfo
  23543. idetinfoStr = psn_info.Idetinfo
  23544. infocode = 0
  23545. verify_number = psn_info.VerifyNumber
  23546. idetinfoStr = psn_info.Idetinfo
  23547. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23548. if id_card_type == 1 {
  23549. psn_info, _ := service.GetPsnByPatientId(id)
  23550. PsnNo = psn_info.PsnNo
  23551. PsnCertType = psn_info.PsnCertType
  23552. Certno = psn_info.Certno
  23553. PsnName = psn_info.PsnName
  23554. Gend = psn_info.Gend
  23555. Naty = psn_info.Naty
  23556. Brdy = psn_info.Brdy
  23557. Age = psn_info.Age
  23558. infoStr = psn_info.Insuinfo
  23559. idetinfoStr = psn_info.Idetinfo
  23560. infocode = 0
  23561. verify_number = psn_info.VerifyNumber
  23562. } else if id_card_type == 2 {
  23563. 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)
  23564. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23565. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23566. utils.ErrorLog("解析失败:%v", err)
  23567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23568. return
  23569. }
  23570. PsnNo = res.Output.Baseinfo.PsnNo
  23571. PsnCertType = res.Output.Baseinfo.PsnCertType
  23572. Certno = res.Output.Baseinfo.Certno
  23573. PsnName = res.Output.Baseinfo.PsnName
  23574. Gend = res.Output.Baseinfo.Gend
  23575. Naty = res.Output.Baseinfo.Naty
  23576. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23577. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23578. infoStr = string(Iinfos)
  23579. idetinfoStr = string(Idetinfos)
  23580. infocode = res.Infcode
  23581. } else if id_card_type == 4 {
  23582. psn_info, _ := service.GetPsnByPatientId(id)
  23583. PsnNo = psn_info.PsnNo
  23584. PsnCertType = psn_info.PsnCertType
  23585. Certno = psn_info.Certno
  23586. PsnName = psn_info.PsnName
  23587. Gend = psn_info.Gend
  23588. Naty = psn_info.Naty
  23589. Brdy = psn_info.Brdy
  23590. Age = psn_info.Age
  23591. infoStr = psn_info.Insuinfo
  23592. idetinfoStr = psn_info.Idetinfo
  23593. infocode = 0
  23594. verify_number = psn_info.VerifyNumber
  23595. }
  23596. } else if miConfig.MdtrtareaAdmvs == "131023" {
  23597. var result string
  23598. var requestLog string
  23599. 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), "")
  23600. if id_card_type == 4 {
  23601. psn_info, _ := service.GetPsnByPatientId(id)
  23602. PsnNo = psn_info.PsnNo
  23603. PsnCertType = psn_info.PsnCertType
  23604. Certno = psn_info.Certno
  23605. PsnName = psn_info.PsnName
  23606. Gend = psn_info.Gend
  23607. Naty = psn_info.Naty
  23608. Brdy = psn_info.Brdy
  23609. Age = psn_info.Age
  23610. infoStr = psn_info.Insuinfo
  23611. idetinfoStr = psn_info.Idetinfo
  23612. infocode = 0
  23613. verify_number = psn_info.VerifyNumber
  23614. } else {
  23615. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23616. if miConfig.Code == "H15049901371" {
  23617. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23618. utils.ErrorLog("解析失败:%v", err)
  23619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23620. return
  23621. }
  23622. res.ErrMsg = res10265.ErrMsg
  23623. res.Output = res10265.Output
  23624. res.InfRefmsgid = res10265.InfRefmsgid
  23625. } else {
  23626. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23627. utils.ErrorLog("解析失败:%v", err)
  23628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23629. return
  23630. }
  23631. }
  23632. PsnNo = res.Output.Baseinfo.PsnNo
  23633. PsnCertType = res.Output.Baseinfo.PsnCertType
  23634. Certno = res.Output.Baseinfo.Certno
  23635. PsnName = res.Output.Baseinfo.PsnName
  23636. Gend = res.Output.Baseinfo.Gend
  23637. Naty = res.Output.Baseinfo.Naty
  23638. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23639. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23640. infoStr = string(Iinfos)
  23641. idetinfoStr = string(Idetinfos)
  23642. if miConfig.Code == "H15049901371" {
  23643. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23644. } else {
  23645. infocode = res.Infcode
  23646. }
  23647. }
  23648. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23649. psn_info, _ := service.GetPsnByPatientId(id)
  23650. PsnNo = psn_info.PsnNo
  23651. PsnCertType = psn_info.PsnCertType
  23652. Certno = psn_info.Certno
  23653. PsnName = psn_info.PsnName
  23654. Gend = psn_info.Gend
  23655. Naty = psn_info.Naty
  23656. Brdy = psn_info.Brdy
  23657. Age = psn_info.Age
  23658. infoStr = psn_info.Insuinfo
  23659. idetinfoStr = psn_info.Idetinfo
  23660. infocode = 0
  23661. verify_number = psn_info.VerifyNumber
  23662. } else if miConfig.MdtrtareaAdmvs == "450721" {
  23663. psn_info, _ := service.GetPsnByPatientId(id)
  23664. PsnNo = psn_info.PsnNo
  23665. PsnCertType = psn_info.PsnCertType
  23666. Certno = psn_info.Certno
  23667. PsnName = psn_info.PsnName
  23668. Gend = psn_info.Gend
  23669. Naty = psn_info.Naty
  23670. Brdy = psn_info.Brdy
  23671. Age = psn_info.Age
  23672. infoStr = psn_info.Insuinfo
  23673. idetinfoStr = psn_info.Idetinfo
  23674. infocode = 0
  23675. verify_number = psn_info.VerifyNumber
  23676. } else {
  23677. var result string
  23678. var requestLog string
  23679. //if miConfig.UserOrgId == 10138 {
  23680. if id_card_type != 4 || id_card_type != 1 {
  23681. var insa string
  23682. if len(patient.InsuplcAdmdvs) > 0 {
  23683. insa = patient.InsuplcAdmdvs
  23684. } else {
  23685. insa = miConfig.InsuplcAdmdvs
  23686. }
  23687. //psn_info, _ := service.GetPsnByPatientId(id)
  23688. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  23689. 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)
  23690. }
  23691. //}
  23692. //else {
  23693. // var insa string
  23694. // if len(patient.InsuplcAdmdvs) > 0 {
  23695. // insa = patient.InsuplcAdmdvs
  23696. // } else {
  23697. // insa = miConfig.InsuplcAdmdvs
  23698. // }
  23699. // 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)
  23700. //}
  23701. if id_card_type == 4 || id_card_type == 1 {
  23702. psn_info, _ := service.GetPsnByPatientId(id)
  23703. PsnNo = psn_info.PsnNo
  23704. PsnCertType = psn_info.PsnCertType
  23705. Certno = psn_info.Certno
  23706. PsnName = psn_info.PsnName
  23707. Gend = psn_info.Gend
  23708. Naty = psn_info.Naty
  23709. Brdy = psn_info.Brdy
  23710. Age = psn_info.Age
  23711. infoStr = psn_info.Insuinfo
  23712. idetinfoStr = psn_info.Idetinfo
  23713. infocode = 0
  23714. verify_number = psn_info.VerifyNumber
  23715. } else {
  23716. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23717. if miConfig.Code == "H15049901371" {
  23718. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23719. utils.ErrorLog("解析失败:%v", err)
  23720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23721. return
  23722. }
  23723. res.ErrMsg = res10265.ErrMsg
  23724. res.Output = res10265.Output
  23725. res.InfRefmsgid = res10265.InfRefmsgid
  23726. } else {
  23727. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23728. utils.ErrorLog("解析失败:%v", err)
  23729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23730. return
  23731. }
  23732. }
  23733. PsnNo = res.Output.Baseinfo.PsnNo
  23734. PsnCertType = res.Output.Baseinfo.PsnCertType
  23735. Certno = res.Output.Baseinfo.Certno
  23736. PsnName = res.Output.Baseinfo.PsnName
  23737. Gend = res.Output.Baseinfo.Gend
  23738. Naty = res.Output.Baseinfo.Naty
  23739. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23740. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23741. infoStr = string(Iinfos)
  23742. idetinfoStr = string(Idetinfos)
  23743. if miConfig.Code == "H15049901371" {
  23744. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23745. } else {
  23746. infocode = res.Infcode
  23747. }
  23748. }
  23749. }
  23750. if infocode == 0 {
  23751. his := models.VMHisPatient{
  23752. Name: name,
  23753. Gender: gender,
  23754. Birthday: birthUnix,
  23755. MedicalTreatmentType: medical_care,
  23756. IdType: certificates,
  23757. IdCardNo: id_card,
  23758. BalanceAccountsType: settlementValue,
  23759. SocialType: social_type,
  23760. MedicalInsuranceNumber: medical_insurance_card,
  23761. RegisterType: register_type,
  23762. RegisterCost: registration_fee,
  23763. TreatmentCost: medical_expenses,
  23764. Status: 1,
  23765. Ctime: time.Now().Unix(),
  23766. Mtime: time.Now().Unix(),
  23767. PsnNo: PsnNo,
  23768. PsnCertType: PsnCertType,
  23769. Certno: Certno,
  23770. PsnName: PsnName,
  23771. Gend: Gend,
  23772. Naty: Naty,
  23773. Brdy: Brdy,
  23774. Age: Age,
  23775. Iinfo: infoStr,
  23776. Idetinfo: idetinfoStr,
  23777. PatientId: patient.ID,
  23778. RecordDate: theTime.Unix(),
  23779. UserOrgId: adminInfo.CurrentOrgId,
  23780. AdminUserId: admin_user_id,
  23781. IsReturn: 1,
  23782. IdCardType: id_card_type,
  23783. Doctor: doctor,
  23784. Departments: department,
  23785. MdtrtGrpType: mdtrt_type,
  23786. }
  23787. timestamp := time.Now().Unix()
  23788. tempTime := time.Unix(timestamp, 0)
  23789. timeFormat := tempTime.Format("20060102150405")
  23790. chrgBchno := rand.Intn(100000) + 10000
  23791. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  23792. his.Number = ipt_otp_no
  23793. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  23794. department, _ := service.GetDepartMentDetail(department)
  23795. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  23796. IdCardNo := ""
  23797. if id_card_type == 1 {
  23798. // IdCardNo = medical_insurance_card
  23799. IdCardNo = patient.IdCardNo
  23800. } else {
  23801. IdCardNo = patient.IdCardNo
  23802. }
  23803. var rf []*ResultFive
  23804. json.Unmarshal([]byte(his.Iinfo), &rf)
  23805. var insutypes []*ResultFive
  23806. var insutype string
  23807. var insuplc_admdvs_temp string
  23808. var is390 int = 0
  23809. var is310 int = 0
  23810. for _, item := range rf {
  23811. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23812. insutypes = append(insutypes, item)
  23813. }
  23814. }
  23815. if len(insutypes) == 1 {
  23816. insutype = insutypes[0].Insutype
  23817. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  23818. if insutype == "390" {
  23819. is390 = 1
  23820. }
  23821. if insutype == "310" {
  23822. is310 = 1
  23823. }
  23824. } else {
  23825. for _, i := range insutypes {
  23826. if i.Insutype == "390" {
  23827. is390 = 1
  23828. }
  23829. if i.Insutype == "310" {
  23830. is310 = 1
  23831. }
  23832. }
  23833. }
  23834. if is390 == 1 {
  23835. insutype = "390"
  23836. }
  23837. if is310 == 1 {
  23838. insutype = "310"
  23839. }
  23840. fmt.Println(social_type)
  23841. if social_type > 0 {
  23842. insutype = strconv.FormatInt(social_type, 10)
  23843. }
  23844. var infocode int64
  23845. var resThree ResultThree
  23846. var resThree10265 ResultThree10265
  23847. if len(insuplc_admdvs) == 0 {
  23848. psn_info, _ := service.GetPsnByPatientId(id)
  23849. //if len(psn_info.InsuplcAdmdvs) > 0 {
  23850. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23851. //}
  23852. } else {
  23853. insuplc_admdvs_temp = insuplc_admdvs
  23854. }
  23855. if miConfig.MdtrtareaAdmvs == "421300" {
  23856. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23857. psn_info, _ := service.GetPsnByPatientId(id)
  23858. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23859. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23860. "&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
  23861. resp, requestErr := http.Get(api)
  23862. if requestErr != nil {
  23863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23864. return
  23865. }
  23866. body, ioErr := ioutil.ReadAll(resp.Body)
  23867. if ioErr != nil {
  23868. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23870. return
  23871. }
  23872. var respJSON map[string]interface{}
  23873. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23874. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23876. return
  23877. }
  23878. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23879. result, _ := json.Marshal(respJSON)
  23880. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23881. utils.ErrorLog("解析失败:%v", err)
  23882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23883. return
  23884. }
  23885. infocode = resThree.Infcode
  23886. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23887. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23888. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23889. // insuplc_admdvs_temp =
  23890. //}
  23891. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23892. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23893. //}
  23894. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23895. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23896. "&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
  23897. resp, requestErr := http.Get(api)
  23898. if requestErr != nil {
  23899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23900. return
  23901. }
  23902. body, ioErr := ioutil.ReadAll(resp.Body)
  23903. if ioErr != nil {
  23904. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23906. return
  23907. }
  23908. var respJSON map[string]interface{}
  23909. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23910. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23912. return
  23913. }
  23914. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23915. result, _ := json.Marshal(respJSON)
  23916. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23917. utils.ErrorLog("解析失败:%v", err)
  23918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23919. return
  23920. }
  23921. infocode = resThree.Infcode
  23922. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23923. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23924. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23925. // insuplc_admdvs_temp =
  23926. //}
  23927. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23928. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23929. //}
  23930. utils.ErrorLog("解析失败:%v", insutype)
  23931. utils.ErrorLog("解析失败:%v", PsnNo)
  23932. utils.ErrorLog("解析失败:%v", Certno)
  23933. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  23934. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  23935. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  23936. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  23937. utils.ErrorLog("解析失败:%v", PsnNo)
  23938. utils.ErrorLog("解析失败:%v", department.Number)
  23939. utils.ErrorLog("解析失败:%v", department.Name)
  23940. utils.ErrorLog("解析失败:%v", roles.UserName)
  23941. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23942. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23943. "&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
  23944. resp, requestErr := http.Get(api)
  23945. if requestErr != nil {
  23946. utils.ErrorLog("解析失败:%v", requestErr)
  23947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23948. return
  23949. }
  23950. body, ioErr := ioutil.ReadAll(resp.Body)
  23951. if ioErr != nil {
  23952. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23954. return
  23955. }
  23956. var respJSON map[string]interface{}
  23957. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23958. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23960. return
  23961. }
  23962. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23963. result, _ := json.Marshal(respJSON)
  23964. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23965. utils.ErrorLog("解析失败:%v", err)
  23966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23967. return
  23968. }
  23969. infocode = resThree.Infcode
  23970. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23971. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23972. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23973. // insuplc_admdvs_temp =
  23974. //}
  23975. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23976. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23977. //}
  23978. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23979. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23980. "&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
  23981. resp, requestErr := http.Get(api)
  23982. if requestErr != nil {
  23983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23984. return
  23985. }
  23986. body, ioErr := ioutil.ReadAll(resp.Body)
  23987. if ioErr != nil {
  23988. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23990. return
  23991. }
  23992. var respJSON map[string]interface{}
  23993. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23994. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23996. return
  23997. }
  23998. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23999. result, _ := json.Marshal(respJSON)
  24000. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24001. utils.ErrorLog("解析失败:%v", err)
  24002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24003. return
  24004. }
  24005. infocode = resThree.Infcode
  24006. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24007. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24008. psn_info, _ := service.GetPsnByPatientId(id)
  24009. var verify_number string
  24010. if id_card_type == 4 {
  24011. verify_number = psn_info.VerifyNumber
  24012. } else if id_card_type == 1 {
  24013. bas := strings.Split(psn_info.CardInfo, "|")
  24014. cardNumber := bas[2]
  24015. verify_number = cardNumber
  24016. }
  24017. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24018. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24019. "&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
  24020. resp, requestErr := http.Get(api)
  24021. if requestErr != nil {
  24022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24023. return
  24024. }
  24025. body, ioErr := ioutil.ReadAll(resp.Body)
  24026. if ioErr != nil {
  24027. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24029. return
  24030. }
  24031. var respJSON map[string]interface{}
  24032. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24033. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24035. return
  24036. }
  24037. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24038. result, _ := json.Marshal(respJSON)
  24039. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24040. // utils.ErrorLog("解析失败:%v", err)
  24041. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24042. // return
  24043. //}
  24044. //infocode = resThree.Infcode
  24045. //result, _ := json.Marshal(respJSON)
  24046. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24047. utils.ErrorLog("解析失败:%v", err)
  24048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24049. return
  24050. }
  24051. resThree.ErrMsg = resThree10265.ErrMsg
  24052. resThree.Output = resThree10265.Output
  24053. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24054. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24055. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24056. psn_info, _ := service.GetPsnByPatientId(id)
  24057. his.PsnNo = psn_info.PsnNo
  24058. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24059. var cert_no string
  24060. if id_card_type == 3 {
  24061. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  24062. cert_no = IdCardNo
  24063. } else if id_card_type == 4 {
  24064. cert_no = IdCardNo
  24065. psn_info.VerifyNumber = psn_info.VerifyNumber
  24066. } else {
  24067. bas := strings.Split(psn_info.CardInfo, "|")
  24068. cert_no = bas[2]
  24069. }
  24070. var hisPrescription []*models.HisPrescription
  24071. for _, item := range rf {
  24072. if item.Insutype == insutype {
  24073. //insuplc_admdvs = item.InsuplcAdmdvs
  24074. his.InsuplcAdmdvs = insuplc_admdvs
  24075. }
  24076. }
  24077. his.Insutype = insutype
  24078. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24079. fmt.Println(res3101)
  24080. fmt.Println(res3101.Infcode)
  24081. if res3101.Infcode == "0" {
  24082. fmt.Println("33333333")
  24083. if len(res3101.Output.Result) > 0 {
  24084. fmt.Println("222222")
  24085. for _, item := range res3101.Output.Result {
  24086. if len(res3101.ErrMsg) == 0 {
  24087. res3101.ErrMsg = item.VolaCont
  24088. } else {
  24089. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24090. }
  24091. }
  24092. c.ServeSuccessJSON(map[string]interface{}{
  24093. "failed_code": -10,
  24094. "msg": res3101.ErrMsg,
  24095. })
  24096. return
  24097. } else {
  24098. fmt.Println("11111")
  24099. var api string
  24100. if miConfig.MdtrtareaAdmvs == "320921" {
  24101. ipt_otp_no = timeFormat
  24102. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24103. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24104. "&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
  24105. } else {
  24106. ipt_otp_no = timeFormat
  24107. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24108. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24109. "&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
  24110. }
  24111. resp, requestErr := http.Get(api)
  24112. if requestErr != nil {
  24113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24114. return
  24115. }
  24116. body, ioErr := ioutil.ReadAll(resp.Body)
  24117. if ioErr != nil {
  24118. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24120. return
  24121. }
  24122. var respJSON map[string]interface{}
  24123. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24124. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24126. return
  24127. }
  24128. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24129. result, _ := json.Marshal(respJSON)
  24130. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24131. utils.ErrorLog("解析失败:%v", err)
  24132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24133. return
  24134. }
  24135. resThree.ErrMsg = resThree10265.ErrMsg
  24136. resThree.Output = resThree10265.Output
  24137. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24138. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24139. }
  24140. } else if res3101.Infcode != "0" {
  24141. c.ServeSuccessJSON(map[string]interface{}{
  24142. "failed_code": -10,
  24143. "msg": res3101.ErrMsg,
  24144. })
  24145. return
  24146. }
  24147. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24148. psn_info, _ := service.GetPsnByPatientId(id)
  24149. var cert_no string
  24150. if id_card_type == 1 {
  24151. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  24152. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24153. } else if id_card_type == 4 {
  24154. cert_no = psn_info.VerifyNumber
  24155. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24156. } else {
  24157. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24158. cert_no = psn_info.VerifyNumber
  24159. }
  24160. 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)
  24161. saveLog(result, requestLog, "2201", "挂号")
  24162. if miConfig.Code == "H15049901371" {
  24163. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24164. utils.ErrorLog("解析失败:%v", err)
  24165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24166. return
  24167. }
  24168. resThree.ErrMsg = resThree10265.ErrMsg
  24169. resThree.Output = resThree10265.Output
  24170. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24171. } else {
  24172. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24173. utils.ErrorLog("解析失败:%v", err)
  24174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24175. return
  24176. }
  24177. }
  24178. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24179. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  24180. psn_info, _ := service.GetPsnByPatientId(id)
  24181. var result string
  24182. var requestLog string
  24183. if id_card_type == 1 {
  24184. bas := strings.Split(psn_info.CardInfo, "|")
  24185. basNumber := bas[2]
  24186. card_sn := bas[3]
  24187. 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)
  24188. saveLog(result, requestLog, "2201A", "挂号")
  24189. } else if id_card_type == 2 {
  24190. 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, "", "", "", "", "", "")
  24191. saveLog(result, requestLog, "2201A", "挂号")
  24192. } else {
  24193. 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)
  24194. saveLog(result, requestLog, "2201A", "挂号")
  24195. }
  24196. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24197. utils.ErrorLog("解析失败:%v", err)
  24198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24199. return
  24200. }
  24201. infocode = resThree.Infcode
  24202. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  24203. psn_info, _ := service.GetPsnByPatientId(id)
  24204. var result string
  24205. var requestLog string
  24206. if id_card_type == 1 {
  24207. bas := strings.Split(psn_info.CardInfo, "|")
  24208. basNumber := bas[2]
  24209. card_sn := ""
  24210. 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)
  24211. saveLog(result, requestLog, "2201A", "挂号")
  24212. } else if id_card_type == 2 {
  24213. 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, "", "", "", "", "", "")
  24214. saveLog(result, requestLog, "2201A", "挂号")
  24215. } else {
  24216. 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)
  24217. saveLog(result, requestLog, "2201A", "挂号")
  24218. }
  24219. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24220. utils.ErrorLog("解析失败:%v", err)
  24221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24222. return
  24223. }
  24224. infocode = resThree.Infcode
  24225. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24226. psn_info, _ := service.GetPsnByPatientId(id)
  24227. his.PsnNo = psn_info.PsnNo
  24228. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24229. var cert_no string
  24230. if id_card_type == 1 {
  24231. bas := strings.Split(psn_info.CardInfo, "|")
  24232. cert_no = bas[2]
  24233. } else if id_card_type == 4 {
  24234. cert_no = psn_info.VerifyNumber
  24235. psn_info.VerifyNumber = psn_info.VerifyNumber
  24236. IdCardNo = psn_info.VerifyNumber
  24237. } else {
  24238. cert_no = IdCardNo
  24239. psn_info.VerifyNumber = cert_no
  24240. }
  24241. for _, item := range rf {
  24242. if item.Insutype == insutype {
  24243. his.InsuplcAdmdvs = insuplc_admdvs
  24244. }
  24245. }
  24246. his.Insutype = insutype
  24247. var api string
  24248. ipt_otp_no = timeFormat
  24249. api = miConfig.SecretKey + "ahyb/2201?verify_number=" + cert_no + "&cert_no=" + IdCardNo + "&psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24250. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24251. "&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
  24252. resp, requestErr := http.Get(api)
  24253. if requestErr != nil {
  24254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24255. return
  24256. }
  24257. body, ioErr := ioutil.ReadAll(resp.Body)
  24258. if ioErr != nil {
  24259. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24261. return
  24262. }
  24263. var respJSON map[string]interface{}
  24264. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24265. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24267. return
  24268. }
  24269. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24270. if status == "0" {
  24271. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24272. c.ServeSuccessJSON(map[string]interface{}{
  24273. "failed_code": -10,
  24274. "msg": err_msg,
  24275. })
  24276. return
  24277. }
  24278. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24279. result, _ := json.Marshal(respJSON)
  24280. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24281. utils.ErrorLog("解析失败:%v", err)
  24282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24283. return
  24284. }
  24285. infocode = resThree.Infcode
  24286. } else if miConfig.MdtrtareaAdmvs == "340699" {
  24287. psn_info, _ := service.GetPsnByPatientId(id)
  24288. his.PsnNo = psn_info.PsnNo
  24289. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24290. var cert_no string
  24291. if id_card_type == 1 {
  24292. bas := strings.Split(psn_info.CardInfo, "|")
  24293. cert_no = bas[2]
  24294. } else if id_card_type == 4 {
  24295. cert_no = psn_info.VerifyNumber
  24296. psn_info.VerifyNumber = psn_info.VerifyNumber
  24297. IdCardNo = psn_info.VerifyNumber
  24298. } else {
  24299. cert_no = IdCardNo
  24300. psn_info.VerifyNumber = cert_no
  24301. }
  24302. for _, item := range rf {
  24303. if item.Insutype == insutype {
  24304. his.InsuplcAdmdvs = insuplc_admdvs
  24305. patient.InsuplcAdmdvs = insuplc_admdvs
  24306. }
  24307. }
  24308. his.Insutype = insutype
  24309. var api string
  24310. ipt_otp_no = timeFormat
  24311. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&verify_number=" + cert_no + "&cert_no=" + IdCardNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24312. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24313. "&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
  24314. resp, requestErr := http.Get(api)
  24315. if requestErr != nil {
  24316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24317. return
  24318. }
  24319. body, ioErr := ioutil.ReadAll(resp.Body)
  24320. if ioErr != nil {
  24321. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24323. return
  24324. }
  24325. var respJSON map[string]interface{}
  24326. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24327. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24329. return
  24330. }
  24331. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24332. if status == "0" {
  24333. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24334. c.ServeSuccessJSON(map[string]interface{}{
  24335. "failed_code": -10,
  24336. "msg": err_msg,
  24337. })
  24338. return
  24339. }
  24340. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24341. result, _ := json.Marshal(respJSON)
  24342. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24343. utils.ErrorLog("解析失败:%v", err)
  24344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24345. return
  24346. }
  24347. infocode = resThree.Infcode
  24348. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24349. psn_info, _ := service.GetPsnByPatientId(id)
  24350. var result string
  24351. var requestLog string
  24352. if id_card_type == 1 {
  24353. bas := strings.Split(psn_info.CardInfo, "|")
  24354. basNumber := bas[2]
  24355. card_sn := bas[3]
  24356. 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)
  24357. saveLog(result, requestLog, "2201A", "挂号")
  24358. } else if id_card_type == 2 {
  24359. 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, "", "")
  24360. saveLog(result, requestLog, "2201A", "挂号")
  24361. } else {
  24362. 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, "", "")
  24363. saveLog(result, requestLog, "2201A", "挂号")
  24364. }
  24365. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24366. utils.ErrorLog("解析失败:%v", err)
  24367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24368. return
  24369. }
  24370. infocode = resThree.Infcode
  24371. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24372. psn_info, _ := service.GetPsnByPatientId(id)
  24373. 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)
  24374. saveLog(result, requestLog, "2201A", "挂号")
  24375. if miConfig.Code == "H15049901371" {
  24376. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24377. utils.ErrorLog("解析失败:%v", err)
  24378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24379. return
  24380. }
  24381. resThree.ErrMsg = resThree10265.ErrMsg
  24382. resThree.Output = resThree10265.Output
  24383. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24384. } else {
  24385. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24386. utils.ErrorLog("解析失败:%v", err)
  24387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24388. return
  24389. }
  24390. }
  24391. if miConfig.Code == "H15049901371" {
  24392. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24393. } else {
  24394. infocode = resThree.Infcode
  24395. }
  24396. } else {
  24397. psn_info, _ := service.GetPsnByPatientId(id)
  24398. if id_card_type == 4 || id_card_type == 1 {
  24399. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24400. }
  24401. var rf []*ResultFive
  24402. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24403. var insutypes []*ResultFive
  24404. var insutype string
  24405. var is390 int = 0
  24406. var is310 int = 0
  24407. for _, item := range rf {
  24408. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24409. insutypes = append(insutypes, item)
  24410. }
  24411. }
  24412. if len(insutypes) == 1 {
  24413. insutype = insutypes[0].Insutype
  24414. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24415. } else {
  24416. for _, i := range insutypes {
  24417. if i.Insutype == "390" {
  24418. is390 = 1
  24419. }
  24420. if i.Insutype == "310" {
  24421. is310 = 1
  24422. }
  24423. }
  24424. }
  24425. if is390 == 1 {
  24426. insutype = "390"
  24427. }
  24428. if is310 == 1 {
  24429. insutype = "310"
  24430. }
  24431. fmt.Println(len(insutypes))
  24432. if len(insutypes) == 0 {
  24433. for index, item := range rf {
  24434. if index == 0 {
  24435. insutype = item.Insutype
  24436. insuplc_admdvs = item.InsuplcAdmdvs
  24437. }
  24438. }
  24439. fmt.Println(insutype)
  24440. fmt.Println(insuplc_admdvs)
  24441. }
  24442. if social_type > 0 {
  24443. insutype = strconv.FormatInt(social_type, 10)
  24444. }
  24445. fmt.Println("--------")
  24446. fmt.Println(psn_info)
  24447. fmt.Println(psn_info.PsnNo)
  24448. if miConfig.MdtrtareaAdmvs == "441202" {
  24449. var hisPrescription []*models.HisPrescription
  24450. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24451. if res3101.Infcode == 0 {
  24452. fmt.Println("33333333")
  24453. if len(res3101.Output.Result) > 0 {
  24454. fmt.Println("222222")
  24455. for _, item := range res3101.Output.Result {
  24456. if len(res3101.ErrMsg) == 0 {
  24457. res3101.ErrMsg = item.VolaCont
  24458. } else {
  24459. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24460. }
  24461. }
  24462. c.ServeSuccessJSON(map[string]interface{}{
  24463. "failed_code": -10,
  24464. "msg": res3101.ErrMsg,
  24465. })
  24466. return
  24467. } else {
  24468. hour := time.Now().Format("15")
  24469. min := time.Now().Format("04")
  24470. sec := time.Now().Format("05")
  24471. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24472. fmt.Println(record_time_two)
  24473. 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)
  24474. saveLog(result, requestLog, "2201A", "挂号")
  24475. if miConfig.Code == "H15049901371" {
  24476. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24477. utils.ErrorLog("解析失败:%v", err)
  24478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24479. return
  24480. }
  24481. resThree.ErrMsg = resThree10265.ErrMsg
  24482. resThree.Output = resThree10265.Output
  24483. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24484. } else {
  24485. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24486. utils.ErrorLog("解析失败:%v", err)
  24487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24488. return
  24489. }
  24490. }
  24491. if miConfig.Code == "H15049901371" {
  24492. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24493. } else {
  24494. infocode = resThree.Infcode
  24495. }
  24496. }
  24497. } else if res3101.Infcode != 0 {
  24498. c.ServeSuccessJSON(map[string]interface{}{
  24499. "failed_code": -10,
  24500. "msg": res3101.ErrMsg,
  24501. })
  24502. return
  24503. }
  24504. } else if miConfig.MdtrtareaAdmvs == "440205" {
  24505. var hisPrescription []*models.HisPrescription
  24506. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24507. if res3101.Infcode == 0 {
  24508. fmt.Println("33333333")
  24509. if len(res3101.Output.Result) > 0 {
  24510. fmt.Println("222222")
  24511. for _, item := range res3101.Output.Result {
  24512. if len(res3101.ErrMsg) == 0 {
  24513. res3101.ErrMsg = item.VolaCont
  24514. } else {
  24515. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24516. }
  24517. }
  24518. c.ServeSuccessJSON(map[string]interface{}{
  24519. "failed_code": -10,
  24520. "msg": res3101.ErrMsg,
  24521. })
  24522. return
  24523. } else {
  24524. hour := time.Now().Format("15")
  24525. min := time.Now().Format("04")
  24526. sec := time.Now().Format("05")
  24527. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24528. fmt.Println(record_time_two)
  24529. 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)
  24530. saveLog(result, requestLog, "2201A", "挂号")
  24531. if miConfig.Code == "H15049901371" {
  24532. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24533. utils.ErrorLog("解析失败:%v", err)
  24534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24535. return
  24536. }
  24537. resThree.ErrMsg = resThree10265.ErrMsg
  24538. resThree.Output = resThree10265.Output
  24539. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24540. } else {
  24541. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24542. utils.ErrorLog("解析失败:%v", err)
  24543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24544. return
  24545. }
  24546. }
  24547. if miConfig.Code == "H15049901371" {
  24548. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24549. } else {
  24550. infocode = resThree.Infcode
  24551. }
  24552. }
  24553. } else if res3101.Infcode != 0 {
  24554. c.ServeSuccessJSON(map[string]interface{}{
  24555. "failed_code": -10,
  24556. "msg": res3101.ErrMsg,
  24557. })
  24558. return
  24559. }
  24560. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24561. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24562. psn_info, _ := service.GetPsnByPatientId(id)
  24563. var verify_number string
  24564. if id_card_type == 4 {
  24565. verify_number = psn_info.VerifyNumber
  24566. } else if id_card_type == 1 {
  24567. bas := strings.Split(psn_info.CardInfo, "|")
  24568. cardNumber := bas[2]
  24569. verify_number = cardNumber
  24570. } else {
  24571. verify_number = psn_info.Certno
  24572. }
  24573. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24574. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24575. "&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
  24576. resp, requestErr := http.Get(api)
  24577. if requestErr != nil {
  24578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24579. return
  24580. }
  24581. body, ioErr := ioutil.ReadAll(resp.Body)
  24582. if ioErr != nil {
  24583. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24585. return
  24586. }
  24587. var respJSON map[string]interface{}
  24588. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24589. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24591. return
  24592. }
  24593. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24594. result, _ := json.Marshal(respJSON)
  24595. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24596. utils.ErrorLog("解析失败:%v", err)
  24597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24598. return
  24599. }
  24600. infocode = resThree.Infcode
  24601. } else {
  24602. hour := time.Now().Format("15")
  24603. min := time.Now().Format("04")
  24604. sec := time.Now().Format("05")
  24605. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24606. if id_card_type == 1 {
  24607. for _, item := range rf {
  24608. if item.Insutype == strconv.FormatInt(social_type, 10) {
  24609. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  24610. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24611. } else if strconv.FormatInt(social_type, 10) == "390" {
  24612. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24613. } else {
  24614. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24615. }
  24616. }
  24617. }
  24618. }
  24619. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  24620. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24621. }
  24622. if id_card_type == 1 {
  24623. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  24624. bas := strings.Split(psn_info.CardInfo, "|")
  24625. basNumber := bas[1]
  24626. IdCardNo = basNumber
  24627. }
  24628. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  24629. IdCardNo = psn_info.VerifyNumber
  24630. }
  24631. if len(insuplc_admdvs_temp) == 0 {
  24632. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24633. }
  24634. var result string
  24635. var requestLog string
  24636. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" {
  24637. var hisPrescription []*models.HisPrescription
  24638. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24639. if res3101.Infcode == 0 {
  24640. if len(res3101.Output.Result) > 0 {
  24641. if len(res3101.Output.Result) > 0 {
  24642. c.ServeSuccessJSON(map[string]interface{}{
  24643. "failed_code": -10,
  24644. "failed_type": 100,
  24645. "warm_type": 1,
  24646. "msg": res3101,
  24647. })
  24648. return
  24649. } else {
  24650. c.ServeSuccessJSON(map[string]interface{}{
  24651. "failed_code": -10,
  24652. "msg": res3101.ErrMsg,
  24653. })
  24654. return
  24655. }
  24656. } else {
  24657. hour := time.Now().Format("15")
  24658. min := time.Now().Format("04")
  24659. sec := time.Now().Format("05")
  24660. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24661. fmt.Println(record_time_two)
  24662. if his.IdCardType == 2 {
  24663. IdCardNo = psn_info.Certno
  24664. psn_info.VerifyNumber = psn_info.Certno
  24665. } else if his.IdCardType == 4 {
  24666. IdCardNo = psn_info.Certno
  24667. } else {
  24668. bas := strings.Split(psn_info.CardInfo, "|")
  24669. IdCardNo = bas[2]
  24670. }
  24671. 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)
  24672. saveLog(result, requestLog, "2201A", "挂号")
  24673. if miConfig.Code == "H15049901371" {
  24674. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24675. utils.ErrorLog("解析失败:%v", err)
  24676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24677. return
  24678. }
  24679. resThree.ErrMsg = resThree10265.ErrMsg
  24680. resThree.Output = resThree10265.Output
  24681. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24682. } else {
  24683. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24684. utils.ErrorLog("解析失败:%v", err)
  24685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24686. return
  24687. }
  24688. }
  24689. if miConfig.Code == "H15049901371" {
  24690. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24691. } else {
  24692. infocode = resThree.Infcode
  24693. }
  24694. }
  24695. } else if res3101.Infcode != 0 {
  24696. c.ServeSuccessJSON(map[string]interface{}{
  24697. "failed_code": -10,
  24698. "msg": res3101.ErrMsg,
  24699. })
  24700. return
  24701. }
  24702. } else {
  24703. psn_info, _ := service.GetPsnByPatientId(id)
  24704. var rf []*ResultFive
  24705. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24706. //var insutypes []*ResultFive
  24707. var insutype string
  24708. var insutypes []*ResultFive
  24709. var is390 int = 0
  24710. var is310 int = 0
  24711. for _, item := range rf {
  24712. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24713. insutypes = append(insutypes, item)
  24714. }
  24715. }
  24716. if len(insutypes) == 1 {
  24717. insutype = insutypes[0].Insutype
  24718. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24719. } else {
  24720. for _, i := range insutypes {
  24721. if i.Insutype == "390" {
  24722. is390 = 1
  24723. }
  24724. if i.Insutype == "310" {
  24725. is310 = 1
  24726. }
  24727. }
  24728. }
  24729. if is390 == 1 {
  24730. insutype = "390"
  24731. }
  24732. if is310 == 1 {
  24733. insutype = "310"
  24734. }
  24735. if len(insutypes) == 0 {
  24736. insutype = "310"
  24737. }
  24738. if social_type > 0 {
  24739. insutype = strconv.FormatInt(social_type, 10)
  24740. }
  24741. for _, item := range rf {
  24742. utils.ErrorLog("解析失败:%v", item.Insutype)
  24743. utils.ErrorLog("解析失败:%v", insutype)
  24744. if item.Insutype == insutype {
  24745. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24746. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  24747. }
  24748. }
  24749. 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)
  24750. saveLog(result, requestLog, "2201A", "挂号")
  24751. }
  24752. if miConfig.Code == "H15049901371" {
  24753. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24754. utils.ErrorLog("解析失败:%v", err)
  24755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24756. return
  24757. }
  24758. resThree.ErrMsg = resThree10265.ErrMsg
  24759. resThree.Output = resThree10265.Output
  24760. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24761. } else {
  24762. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24763. utils.ErrorLog("解析失败:%v", err)
  24764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24765. return
  24766. }
  24767. }
  24768. if miConfig.Code == "H15049901371" {
  24769. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24770. } else {
  24771. infocode = resThree.Infcode
  24772. }
  24773. }
  24774. }
  24775. if infocode == -1 {
  24776. adminUser := c.GetAdminUserInfo()
  24777. errlog := &models.HisOrderError{
  24778. UserOrgId: adminUser.CurrentOrgId,
  24779. Ctime: time.Now().Unix(),
  24780. Mtime: time.Now().Unix(),
  24781. ErrMsg: resThree.ErrMsg,
  24782. Status: 1,
  24783. PatientId: id,
  24784. RecordTime: recordDateTime,
  24785. Stage: 2,
  24786. }
  24787. service.CreateErrMsgLog(errlog)
  24788. c.ServeSuccessJSON(map[string]interface{}{
  24789. "failed_code": -10,
  24790. "msg": resThree.ErrMsg,
  24791. })
  24792. return
  24793. }
  24794. his.Number = resThree.Output.Data.MdtrtID
  24795. his.PsnNo = resThree.Output.Data.PsnNo
  24796. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  24797. his.IdCardNo = patient.IdCardNo
  24798. his.PhoneNumber = patient.Phone
  24799. his.UserOrgId = adminInfo.CurrentOrgId
  24800. his.Insutype = insutype
  24801. his.Ctime = time.Now().Unix()
  24802. his.Mtime = time.Now().Unix()
  24803. his.InsuplcAdmdvs = insuplc_admdvs_temp
  24804. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  24805. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24806. }
  24807. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  24808. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24809. }
  24810. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  24811. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24812. }
  24813. his.Status = 1
  24814. his.MdtrtGrpType = mdtrt_type
  24815. service.UpdateHisPatientStatus(&his)
  24816. service.UpdateHisPatient123(&patient)
  24817. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  24818. c.ServeSuccessJSON(map[string]interface{}{
  24819. "his_info": his,
  24820. })
  24821. } else {
  24822. adminUser := c.GetAdminUserInfo()
  24823. errlog := &models.HisOrderError{
  24824. UserOrgId: adminUser.CurrentOrgId,
  24825. Ctime: time.Now().Unix(),
  24826. Mtime: time.Now().Unix(),
  24827. ErrMsg: res.ErrMsg,
  24828. Status: 1,
  24829. PatientId: id,
  24830. RecordTime: recordDateTime,
  24831. Stage: 1,
  24832. }
  24833. service.CreateErrMsgLog(errlog)
  24834. c.ServeSuccessJSON(map[string]interface{}{
  24835. "failed_code": -10,
  24836. "msg": res.ErrMsg,
  24837. })
  24838. return
  24839. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  24840. }
  24841. }
  24842. }
  24843. func (c *HisApiController) GetUploadInfo() {
  24844. id, _ := c.GetInt64("id")
  24845. record_time := c.GetString("record_time")
  24846. his_patient_id, _ := c.GetInt64("his_patient_id")
  24847. order_id, _ := c.GetInt64("order_id")
  24848. pay_way, _ := c.GetInt64("pay_way")
  24849. pay_ways := c.GetString("pay_ways")
  24850. oth_desc := c.GetString("oth_desc")
  24851. pay_price, _ := c.GetFloat("pay_price")
  24852. pay_card_no := c.GetString("pay_card_no")
  24853. discount_price, _ := c.GetFloat("discount_price")
  24854. preferential_price, _ := c.GetFloat("preferential_price")
  24855. reality_price, _ := c.GetFloat("reality_price")
  24856. found_price, _ := c.GetFloat("found_price")
  24857. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  24858. private_price, _ := c.GetFloat("private_price")
  24859. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  24860. admin_user_id, _ := c.GetInt64("admin_user_id")
  24861. fapiao_code := c.GetString("fapiao_code")
  24862. fapiao_number := c.GetString("fapiao_number")
  24863. diagnosis_id := c.GetString("diagnosis")
  24864. sick_type, _ := c.GetInt64("sick_type")
  24865. reg_type, _ := c.GetInt64("p_type")
  24866. begin_time := c.GetString("begin_time")
  24867. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  24868. cash_pay := c.GetString("cash_pay")
  24869. band_card_pay := c.GetString("band_card_pay")
  24870. wechat_pay := c.GetString("wechat_pay")
  24871. ali_pay := c.GetString("ali_pay")
  24872. jifen_pay := c.GetString("jifen_pay")
  24873. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  24874. fmt.Println(acct_used_flag)
  24875. id_str := c.GetString("ids")
  24876. ids_arr := strings.Split(id_str, ",")
  24877. timeLayout := "2006-01-02"
  24878. loc, _ := time.LoadLocation("Local")
  24879. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24880. if err != nil {
  24881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24882. return
  24883. }
  24884. recordDateTime := theTime.Unix()
  24885. adminUser := c.GetAdminUserInfo()
  24886. var tempOrder models.HisOrder
  24887. tempOrder, _ = service.GetHisOrderByID(order_id)
  24888. var prescriptions []*models.HisPrescription
  24889. var start_time int64
  24890. var end_time int64
  24891. //押金模块
  24892. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  24893. tmp_decimal := c.GetString("tmp_decimal")
  24894. var decimal float64 //本次使用的押金
  24895. var errmsg error
  24896. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  24897. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  24898. return
  24899. }
  24900. if len(tmp_decimal) > 0 {
  24901. if tmp_decimal[0] == 45 {
  24902. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  24903. return
  24904. }
  24905. }
  24906. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  24907. fmt.Println(errs)
  24908. decimal = tt
  24909. //if adminUser.CurrentOrgId == 10106{
  24910. // if len(fapiao_code) == 0{
  24911. // fapiao_code = "144072080589"
  24912. // }
  24913. // if len(fapiao_number) == 0{
  24914. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  24915. // if order.ID == 0{
  24916. // fapiao_number = "00001520"
  24917. // }else{
  24918. // //fapiao_code = "00001520"
  24919. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  24920. // var zero string
  24921. // if fpNumber >= 1000{
  24922. // zero = "0000" + strconv.Itoa(fpNumber)
  24923. // }else if fpNumber >= 10000{
  24924. // zero = "000" + strconv.Itoa(fpNumber)
  24925. // } else if fpNumber >= 100000{
  24926. // zero = "00" + strconv.Itoa(fpNumber)
  24927. // } else if fpNumber >= 1000000{
  24928. // zero = "0" + strconv.Itoa(fpNumber)
  24929. // }else {
  24930. // zero = strconv.Itoa(fpNumber)
  24931. // }
  24932. // fapiao_number = zero
  24933. // }
  24934. // }
  24935. //}
  24936. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24937. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24938. var patientPrescription models.HisPrescriptionInfo
  24939. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24940. if patientPrescription.ID == 0 {
  24941. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  24942. }
  24943. //if patientPrescription.Do
  24944. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24945. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  24946. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  24947. diagnosis_ids := strings.Split(diagnosis_id, ",")
  24948. var config []*models.HisXtDiagnoseConfig
  24949. for _, item := range diagnosis_ids {
  24950. id, _ := strconv.ParseInt(item, 10, 64)
  24951. diagnosisConfig, _ := service.FindDiagnoseById(id)
  24952. config = append(config, &diagnosisConfig)
  24953. }
  24954. sickConfig, _ := service.FindSickById(sick_type)
  24955. //if tempOrder.ID == 0 {
  24956. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  24957. //}
  24958. if tempOrder.ID == 0 {
  24959. var result string
  24960. var requestLog string
  24961. var res2 ResultSix
  24962. var res3 GZResultSix
  24963. var ressix10265 ResultSix10265
  24964. if miConfig.MdtrtareaAdmvs == "421300" {
  24965. data := make(map[string]interface{})
  24966. client := &http.Client{}
  24967. data["psn_no"] = his.PsnNo
  24968. data["mdtrt_id"] = his.Number
  24969. data["opter"] = roles.UserName
  24970. data["org_name"] = miConfig.OrgName
  24971. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24972. data["doctor_id"] = doctor_info.DoctorNumber
  24973. data["doctor_name"] = doctor_info.UserName
  24974. data["department"] = department.Name
  24975. data["fixmedins_code"] = miConfig.Code
  24976. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24977. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24978. data["secret_key"] = miConfig.SecretKey
  24979. data["sick_code"] = sickConfig.CountryCode
  24980. data["sick_name"] = sickConfig.ClassName
  24981. data["dept"] = strconv.FormatInt(department.ID, 10)
  24982. data["config"] = config
  24983. data["begin_time"] = begin_time
  24984. bytesData, _ := json.Marshal(data)
  24985. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24986. resp, _ := client.Do(req)
  24987. defer resp.Body.Close()
  24988. body, ioErr := ioutil.ReadAll(resp.Body)
  24989. if ioErr != nil {
  24990. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24992. return
  24993. }
  24994. var respJSON map[string]interface{}
  24995. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24996. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24998. return
  24999. }
  25000. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25001. userJSONBytes, _ := json.Marshal(respJSON)
  25002. fmt.Println("log")
  25003. fmt.Println(string(userJSONBytes))
  25004. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25005. utils.ErrorLog("解析失败:%v", err)
  25006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25007. return
  25008. }
  25009. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25010. data := make(map[string]interface{})
  25011. client := &http.Client{}
  25012. data["psn_no"] = his.PsnNo
  25013. data["mdtrt_id"] = his.Number
  25014. data["opter"] = roles.UserName
  25015. data["org_name"] = miConfig.OrgName
  25016. if reg_type == 11 && his.Insutype == "390" {
  25017. data["med_type"] = "110104"
  25018. } else {
  25019. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25020. }
  25021. data["doctor_id"] = doctor_info.DoctorNumber
  25022. data["doctor_name"] = doctor_info.UserName
  25023. data["department"] = department.Name
  25024. data["fixmedins_code"] = miConfig.Code
  25025. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25026. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25027. data["secret_key"] = miConfig.SecretKey
  25028. data["sick_code"] = sickConfig.CountryCode
  25029. data["sick_name"] = sickConfig.ClassName
  25030. data["dept"] = strconv.FormatInt(department.ID, 10)
  25031. data["config"] = config
  25032. data["begin_time"] = begin_time
  25033. bytesData, _ := json.Marshal(data)
  25034. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  25035. resp, _ := client.Do(req)
  25036. defer resp.Body.Close()
  25037. body, ioErr := ioutil.ReadAll(resp.Body)
  25038. if ioErr != nil {
  25039. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25041. return
  25042. }
  25043. var respJSON map[string]interface{}
  25044. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25045. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25047. return
  25048. }
  25049. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25050. userJSONBytes, _ := json.Marshal(respJSON)
  25051. fmt.Println("log")
  25052. fmt.Println(string(userJSONBytes))
  25053. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25054. utils.ErrorLog("解析失败:%v", err)
  25055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25056. return
  25057. }
  25058. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25059. data := make(map[string]interface{})
  25060. client := &http.Client{}
  25061. data["psn_no"] = his.PsnNo
  25062. data["mdtrt_id"] = his.Number
  25063. data["opter"] = roles.UserName
  25064. data["org_name"] = miConfig.OrgName
  25065. if reg_type == 11 && his.Insutype == "390" {
  25066. data["med_type"] = "110104"
  25067. } else {
  25068. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25069. }
  25070. data["doctor_id"] = doctor_info.DoctorNumber
  25071. data["doctor_name"] = doctor_info.UserName
  25072. data["department"] = department.Name
  25073. data["fixmedins_code"] = miConfig.Code
  25074. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25075. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25076. data["secret_key"] = miConfig.SecretKey
  25077. data["sick_code"] = sickConfig.CountryCode
  25078. data["sick_name"] = sickConfig.ClassName
  25079. data["dept"] = strconv.FormatInt(department.ID, 10)
  25080. data["config"] = config
  25081. data["begin_time"] = begin_time
  25082. bytesData, _ := json.Marshal(data)
  25083. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25084. resp, _ := client.Do(req)
  25085. defer resp.Body.Close()
  25086. body, ioErr := ioutil.ReadAll(resp.Body)
  25087. if ioErr != nil {
  25088. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25090. return
  25091. }
  25092. var respJSON map[string]interface{}
  25093. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25094. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25096. return
  25097. }
  25098. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25099. userJSONBytes, _ := json.Marshal(respJSON)
  25100. fmt.Println("log")
  25101. fmt.Println(string(userJSONBytes))
  25102. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25103. utils.ErrorLog("解析失败:%v", err)
  25104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25105. return
  25106. }
  25107. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25108. data := make(map[string]interface{})
  25109. client := &http.Client{}
  25110. data["psn_no"] = his.PsnNo
  25111. data["mdtrt_id"] = his.Number
  25112. data["opter"] = roles.UserName
  25113. data["org_name"] = miConfig.OrgName
  25114. if reg_type == 11 && his.Insutype == "390" {
  25115. data["med_type"] = "110104"
  25116. } else {
  25117. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25118. }
  25119. data["doctor_id"] = doctor_info.DoctorNumber
  25120. data["doctor_name"] = doctor_info.UserName
  25121. data["department"] = department.Name
  25122. data["fixmedins_code"] = miConfig.Code
  25123. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25124. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25125. data["secret_key"] = miConfig.SecretKey
  25126. data["sick_code"] = sickConfig.CountryCode
  25127. data["sick_name"] = sickConfig.ClassName
  25128. data["dept"] = strconv.FormatInt(department.ID, 10)
  25129. data["config"] = config
  25130. data["begin_time"] = begin_time
  25131. bytesData, _ := json.Marshal(data)
  25132. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25133. resp, _ := client.Do(req)
  25134. defer resp.Body.Close()
  25135. body, ioErr := ioutil.ReadAll(resp.Body)
  25136. if ioErr != nil {
  25137. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25139. return
  25140. }
  25141. var respJSON map[string]interface{}
  25142. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25143. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25145. return
  25146. }
  25147. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25148. userJSONBytes, _ := json.Marshal(respJSON)
  25149. fmt.Println("log")
  25150. fmt.Println(string(userJSONBytes))
  25151. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25152. utils.ErrorLog("解析失败:%v", err)
  25153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25154. return
  25155. }
  25156. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25157. data := make(map[string]interface{})
  25158. client := &http.Client{}
  25159. data["psn_no"] = his.PsnNo
  25160. data["mdtrt_id"] = his.Number
  25161. data["doctor"] = roles.UserName
  25162. data["department"] = department.Name
  25163. data["org_name"] = miConfig.OrgName
  25164. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25165. data["doctor_id"] = doctor_info.DoctorNumber
  25166. data["new_doctor_name"] = doctor_info.UserName
  25167. data["fixmedins_code"] = miConfig.Code
  25168. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25169. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25170. data["secret_key"] = miConfig.SecretKey
  25171. data["sick_code"] = sickConfig.CountryCode
  25172. data["sick_name"] = sickConfig.ClassName
  25173. data["url"] = miConfig.Url
  25174. data["ak"] = miConfig.AccessKey
  25175. data["begin_time"] = begin_time
  25176. data["cainfo"] = miConfig.Cainfo
  25177. data["dept"] = strconv.FormatInt(department.ID, 10)
  25178. data["config"] = config
  25179. bytesData, _ := json.Marshal(data)
  25180. var req *http.Request
  25181. if miConfig.MdtrtareaAdmvs == "320921" {
  25182. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25183. //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 +
  25184. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  25185. } else {
  25186. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25187. }
  25188. resp, _ := client.Do(req)
  25189. defer resp.Body.Close()
  25190. body, ioErr := ioutil.ReadAll(resp.Body)
  25191. if ioErr != nil {
  25192. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25194. return
  25195. }
  25196. var respJSON map[string]interface{}
  25197. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25198. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25200. return
  25201. }
  25202. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25203. userJSONBytes, _ := json.Marshal(respJSON)
  25204. fmt.Println("log")
  25205. fmt.Println(string(userJSONBytes))
  25206. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25207. utils.ErrorLog("解析失败:%v", err)
  25208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25209. return
  25210. }
  25211. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25212. res2.Output = ressix10265.Output
  25213. res2.ErrMsg = ressix10265.ErrMsg
  25214. res2.Cainfo = ressix10265.Cainfo
  25215. res2.WarnMsg = ressix10265.WarnMsg
  25216. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25217. res2.Infcode = infocode
  25218. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25219. data := make(map[string]interface{})
  25220. client := &http.Client{}
  25221. data["psn_no"] = his.PsnNo
  25222. data["mdtrt_id"] = his.Number
  25223. data["doctor"] = roles.UserName
  25224. data["department"] = department.Name
  25225. data["org_name"] = miConfig.OrgName
  25226. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25227. data["doctor_id"] = doctor_info.DoctorNumber
  25228. data["new_doctor_name"] = doctor_info.UserName
  25229. data["fixmedins_code"] = miConfig.Code
  25230. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25231. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25232. data["secret_key"] = miConfig.SecretKey
  25233. data["sick_code"] = sickConfig.CountryCode
  25234. data["sick_name"] = sickConfig.ClassName
  25235. data["url"] = miConfig.Url
  25236. data["ak"] = miConfig.AccessKey
  25237. data["begin_time"] = begin_time
  25238. data["cainfo"] = miConfig.Cainfo
  25239. data["dept"] = strconv.FormatInt(department.ID, 10)
  25240. data["config"] = config
  25241. bytesData, _ := json.Marshal(data)
  25242. var req *http.Request
  25243. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  25244. resp, _ := client.Do(req)
  25245. defer resp.Body.Close()
  25246. body, ioErr := ioutil.ReadAll(resp.Body)
  25247. if ioErr != nil {
  25248. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25250. return
  25251. }
  25252. var respJSON map[string]interface{}
  25253. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25256. return
  25257. }
  25258. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25259. userJSONBytes, _ := json.Marshal(respJSON)
  25260. fmt.Println("log")
  25261. fmt.Println(string(userJSONBytes))
  25262. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25263. utils.ErrorLog("解析失败:%v", err)
  25264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25265. return
  25266. }
  25267. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25268. res2.Output = ressix10265.Output
  25269. res2.ErrMsg = ressix10265.ErrMsg
  25270. res2.Cainfo = ressix10265.Cainfo
  25271. res2.WarnMsg = ressix10265.WarnMsg
  25272. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25273. res2.Infcode = infocode
  25274. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25275. 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)
  25276. saveLog(result, requestLog, "2203", "上传就诊信息")
  25277. var respJSON2 map[string]interface{}
  25278. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25281. return
  25282. }
  25283. userJSONBytes2, _ := json.Marshal(respJSON2)
  25284. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25285. utils.ErrorLog("解析失败:%v", err)
  25286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25287. return
  25288. }
  25289. 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)
  25290. fmt.Println(result2)
  25291. fmt.Println(src_request)
  25292. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25293. data := make(map[string]interface{})
  25294. client := &http.Client{}
  25295. data["psn_no"] = his.PsnNo
  25296. data["mdtrt_id"] = his.Number
  25297. data["doctor"] = roles.UserName
  25298. data["department"] = department.Name
  25299. data["org_name"] = miConfig.OrgName
  25300. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25301. data["doctor_id"] = doctor_info.DoctorNumber
  25302. data["new_doctor_name"] = doctor_info.UserName
  25303. data["fixmedins_code"] = miConfig.Code
  25304. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25305. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25306. data["secret_key"] = miConfig.SecretKey
  25307. data["sick_code"] = sickConfig.CountryCode
  25308. data["sick_name"] = sickConfig.ClassName
  25309. data["url"] = miConfig.Url
  25310. data["ak"] = miConfig.AccessKey
  25311. data["begin_time"] = begin_time
  25312. data["cainfo"] = miConfig.Cainfo
  25313. data["dept"] = strconv.FormatInt(department.ID, 10)
  25314. data["config"] = config
  25315. bytesData, _ := json.Marshal(data)
  25316. var req *http.Request
  25317. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  25318. resp, _ := client.Do(req)
  25319. defer resp.Body.Close()
  25320. body, ioErr := ioutil.ReadAll(resp.Body)
  25321. if ioErr != nil {
  25322. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25324. return
  25325. }
  25326. var respJSON map[string]interface{}
  25327. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25328. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25330. return
  25331. }
  25332. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25333. userJSONBytes, _ := json.Marshal(respJSON)
  25334. fmt.Println("log")
  25335. fmt.Println(string(userJSONBytes))
  25336. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25337. utils.ErrorLog("解析失败:%v", err)
  25338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25339. return
  25340. }
  25341. } else {
  25342. if miConfig.MdtrtareaAdmvs == "440781" { //
  25343. 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)
  25344. } else {
  25345. if miConfig.Code == "H15049901371" {
  25346. //赤峰地区国家医保医疗类别
  25347. //职工透析:医疗类别选特殊情况门诊990502
  25348. //居民定额血透门慢: 医疗类别选门诊慢病140104
  25349. var med_type string
  25350. if his.Insutype == "390" {
  25351. if reg_type == 14 {
  25352. med_type = "9933"
  25353. } else if reg_type == 11 {
  25354. med_type = "11"
  25355. }
  25356. } else if his.Insutype == "310" {
  25357. if reg_type == 14 {
  25358. med_type = "990502"
  25359. } else if reg_type == 11 {
  25360. med_type = "11"
  25361. }
  25362. }
  25363. 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)
  25364. } else {
  25365. 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)
  25366. }
  25367. }
  25368. saveLog(result, requestLog, "2203", "上传就诊信息")
  25369. var respJSON2 map[string]interface{}
  25370. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25371. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25373. return
  25374. }
  25375. userJSONBytes2, _ := json.Marshal(respJSON2)
  25376. if miConfig.Code == "H15049901371" {
  25377. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  25378. utils.ErrorLog("解析失败:%v", err)
  25379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25380. return
  25381. }
  25382. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25383. res2.Output = ressix10265.Output
  25384. res2.ErrMsg = ressix10265.ErrMsg
  25385. res2.Cainfo = ressix10265.Cainfo
  25386. res2.WarnMsg = ressix10265.WarnMsg
  25387. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25388. res2.Infcode = infocode
  25389. } else {
  25390. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25391. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  25392. utils.ErrorLog("解析失败:%v", err)
  25393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25394. return
  25395. }
  25396. res2.Infcode = res3.Infcode
  25397. } else {
  25398. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25399. utils.ErrorLog("解析失败:%v", err)
  25400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25401. return
  25402. }
  25403. }
  25404. }
  25405. }
  25406. if res2.Infcode == -1 {
  25407. adminUser := c.GetAdminUserInfo()
  25408. errlog := &models.HisOrderError{
  25409. UserOrgId: adminUser.CurrentOrgId,
  25410. Ctime: time.Now().Unix(),
  25411. Mtime: time.Now().Unix(),
  25412. ErrMsg: res2.ErrMsg,
  25413. Status: 1,
  25414. PatientId: id,
  25415. RecordTime: recordDateTime,
  25416. Stage: 3,
  25417. }
  25418. service.CreateErrMsgLog(errlog)
  25419. c.ServeSuccessJSON(map[string]interface{}{
  25420. "failed_code": -10,
  25421. "msg": res2.ErrMsg,
  25422. })
  25423. return
  25424. } else {
  25425. his.Diagnosis = diagnosis_id
  25426. his.SickType = sickConfig.ID
  25427. //var p_type int64
  25428. //if reg_type == 1111 || reg_type == 1112 {
  25429. // p_type = 11
  25430. //
  25431. //}
  25432. his.PType = fmt.Sprintf("%d", reg_type)
  25433. service.UpdateHisPatientThree(&his)
  25434. data := make(map[string]interface{})
  25435. if settle_accounts_type == 1 { //日结
  25436. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  25437. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  25438. } else {
  25439. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  25440. }
  25441. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  25442. data["pre"] = prescriptions
  25443. } else { //月结
  25444. start_time_str := c.GetString("start_time")
  25445. end_time_str := c.GetString("end_time")
  25446. timeLayout := "2006-01-02"
  25447. loc, _ := time.LoadLocation("Local")
  25448. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  25449. if err != nil {
  25450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25451. return
  25452. }
  25453. recordStartTime := theStartTime.Unix()
  25454. start_time = recordStartTime
  25455. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  25456. if err != nil {
  25457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25458. return
  25459. }
  25460. recordEndTime := theEndTime.Unix()
  25461. end_time = recordEndTime
  25462. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  25463. data["pre"] = prescriptions
  25464. }
  25465. timestamp := time.Now().Unix()
  25466. tempTime := time.Unix(timestamp, 0)
  25467. timeFormat := tempTime.Format("20060102150405")
  25468. chrgBchno := rand.Intn(100000) + 10000
  25469. new_chrg_bchno := ""
  25470. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  25471. new_chrg_bchno = chrg_bchno
  25472. strconv.FormatInt(his.PatientId, 10)
  25473. client := &http.Client{}
  25474. if adminUser.CurrentOrgId == 10265 {
  25475. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  25476. new_chrg_bchno = "0000"
  25477. }
  25478. }
  25479. data["psn_no"] = his.PsnNo
  25480. data["mdtrt_id"] = his.Number
  25481. data["chrg_bchno"] = new_chrg_bchno
  25482. data["org_name"] = miConfig.OrgName
  25483. data["doctor"] = doctor_info.UserName
  25484. data["doctor_id"] = doctor_info.DoctorNumber
  25485. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  25486. data["fixmedins_code"] = miConfig.Code
  25487. data["dept_code"] = department.Number
  25488. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25489. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25490. data["secret_key"] = miConfig.SecretKey
  25491. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  25492. data["url"] = miConfig.Url
  25493. data["ak"] = miConfig.AccessKey
  25494. data["new_doctor_name"] = patientPrescription.Doctor
  25495. data["diag_code"] = sickConfig.CountryCode
  25496. data["cainfo"] = miConfig.Cainfo
  25497. data["opter"] = roles.UserName
  25498. var ids []int64
  25499. for _, item := range prescriptions {
  25500. ids = append(ids, item.ID)
  25501. }
  25502. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25503. if config.IsOpen == 1 { //对接了医保,走医保流程
  25504. var res ResultFour
  25505. var resFour10265 ResultFour10265
  25506. if miConfig.MdtrtareaAdmvs == "421300" {
  25507. bytesData, _ := json.Marshal(data)
  25508. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25509. resp, _ := client.Do(req)
  25510. defer resp.Body.Close()
  25511. body, ioErr := ioutil.ReadAll(resp.Body)
  25512. if ioErr != nil {
  25513. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25515. return
  25516. }
  25517. var respJSON map[string]interface{}
  25518. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25519. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25521. return
  25522. }
  25523. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25524. userJSONBytes, _ := json.Marshal(respJSON)
  25525. fmt.Println("log")
  25526. fmt.Println(string(userJSONBytes))
  25527. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25528. utils.ErrorLog("解析失败:%v", err)
  25529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25530. return
  25531. }
  25532. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25533. bytesData, _ := json.Marshal(data)
  25534. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25535. resp, _ := client.Do(req)
  25536. defer resp.Body.Close()
  25537. body, ioErr := ioutil.ReadAll(resp.Body)
  25538. if ioErr != nil {
  25539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25541. return
  25542. }
  25543. var respJSON map[string]interface{}
  25544. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25547. return
  25548. }
  25549. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25550. userJSONBytes, _ := json.Marshal(respJSON)
  25551. fmt.Println("log")
  25552. fmt.Println(string(userJSONBytes))
  25553. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25554. utils.ErrorLog("解析失败:%v", err)
  25555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25556. return
  25557. }
  25558. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25559. bytesData, _ := json.Marshal(data)
  25560. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25561. resp, _ := client.Do(req)
  25562. defer resp.Body.Close()
  25563. body, ioErr := ioutil.ReadAll(resp.Body)
  25564. if ioErr != nil {
  25565. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25567. return
  25568. }
  25569. var respJSON map[string]interface{}
  25570. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25573. return
  25574. }
  25575. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25576. userJSONBytes, _ := json.Marshal(respJSON)
  25577. fmt.Println("log")
  25578. fmt.Println(string(userJSONBytes))
  25579. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25580. utils.ErrorLog("解析失败:%v", err)
  25581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25582. return
  25583. }
  25584. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25585. bytesData, _ := json.Marshal(data)
  25586. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25587. resp, _ := client.Do(req)
  25588. defer resp.Body.Close()
  25589. body, ioErr := ioutil.ReadAll(resp.Body)
  25590. if ioErr != nil {
  25591. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25593. return
  25594. }
  25595. var respJSON map[string]interface{}
  25596. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25597. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25599. return
  25600. }
  25601. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25602. userJSONBytes, _ := json.Marshal(respJSON)
  25603. fmt.Println("log")
  25604. fmt.Println(string(userJSONBytes))
  25605. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25606. utils.ErrorLog("解析失败:%v", err)
  25607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25608. return
  25609. }
  25610. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25611. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  25612. if result3101.Infcode == "0" {
  25613. if len(result3101.Output.Result) > 0 {
  25614. var errMsgs []string
  25615. for _, item := range result3101.Output.Result {
  25616. errMsgs = append(errMsgs, item.VolaCont)
  25617. }
  25618. c.ServeSuccessJSON(map[string]interface{}{
  25619. "failed_code": -10,
  25620. "msg": errMsgs,
  25621. })
  25622. return
  25623. }
  25624. }
  25625. bytesData, _ := json.Marshal(data)
  25626. var req *http.Request
  25627. if miConfig.MdtrtareaAdmvs == "320921" {
  25628. data["diag_code"] = sickConfig.CountryCode
  25629. fmt.Println(data)
  25630. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25631. } else {
  25632. data["diag_code"] = sickConfig.CountryCode
  25633. fmt.Println(data)
  25634. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25635. }
  25636. resp, _ := client.Do(req)
  25637. defer resp.Body.Close()
  25638. body, ioErr := ioutil.ReadAll(resp.Body)
  25639. if ioErr != nil {
  25640. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25642. return
  25643. }
  25644. var respJSON map[string]interface{}
  25645. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25646. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25648. return
  25649. }
  25650. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25651. userJSONBytes, _ := json.Marshal(respJSON)
  25652. fmt.Println("log")
  25653. fmt.Println(string(userJSONBytes))
  25654. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25655. utils.ErrorLog("解析失败:%v", err)
  25656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25657. return
  25658. }
  25659. res.InfRefmsgid = resFour10265.InfRefmsgid
  25660. res.Output = resFour10265.Output
  25661. res.ErrMsg = resFour10265.ErrMsg
  25662. res.Cainfo = resFour10265.Cainfo
  25663. res.WarnMsg = resFour10265.WarnMsg
  25664. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25665. res.Infcode = infocode
  25666. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25667. var pagesize int = 2
  25668. var start int = 1
  25669. var stop int
  25670. var pagecount int
  25671. var curpage int
  25672. var isSuccess bool = true
  25673. data["doctor_id"] = doctor_info.DoctorNumber
  25674. //总页数,向上取整,注意除之前要先转换类型为float64
  25675. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  25676. for curpage = 1; curpage <= pagecount; curpage++ {
  25677. if curpage == 1 {
  25678. start = 1
  25679. } else {
  25680. start = (curpage-1)*pagesize + 1
  25681. }
  25682. stop = curpage * pagesize
  25683. if stop > len(prescriptions) {
  25684. stop = len(prescriptions)
  25685. }
  25686. //var requestLog string
  25687. data["pre"] = prescriptions[start-1 : stop]
  25688. fmt.Println(data["pre"])
  25689. bytesData, _ := json.Marshal(data)
  25690. var req *http.Request
  25691. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  25692. resp, _ := client.Do(req)
  25693. defer resp.Body.Close()
  25694. body, ioErr := ioutil.ReadAll(resp.Body)
  25695. if ioErr != nil {
  25696. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25698. return
  25699. }
  25700. var respJSON map[string]interface{}
  25701. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25704. return
  25705. }
  25706. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25707. userJSONBytes, _ := json.Marshal(respJSON)
  25708. fmt.Println("log")
  25709. fmt.Println(string(userJSONBytes))
  25710. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25711. utils.ErrorLog("解析失败:%v", err)
  25712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25713. return
  25714. }
  25715. res.InfRefmsgid = resFour10265.InfRefmsgid
  25716. res.Output = resFour10265.Output
  25717. res.ErrMsg = resFour10265.ErrMsg
  25718. res.Cainfo = resFour10265.Cainfo
  25719. res.WarnMsg = resFour10265.WarnMsg
  25720. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25721. res.Infcode = infocode
  25722. if infocode == 0 {
  25723. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  25724. } else {
  25725. isSuccess = false
  25726. errlog := &models.HisOrderError{
  25727. UserOrgId: adminUser.CurrentOrgId,
  25728. Ctime: time.Now().Unix(),
  25729. Mtime: time.Now().Unix(),
  25730. Number: chrg_bchno,
  25731. ErrMsg: "",
  25732. Status: 1,
  25733. PatientId: id,
  25734. RecordTime: recordDateTime,
  25735. Stage: 4,
  25736. }
  25737. service.CreateErrMsgLog(errlog)
  25738. c.ServeSuccessJSON(map[string]interface{}{
  25739. "failed_code": -10,
  25740. "msg": res.ErrMsg,
  25741. })
  25742. return
  25743. }
  25744. }
  25745. if isSuccess {
  25746. res.Infcode = 0
  25747. }
  25748. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25749. 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)
  25750. var dat map[string]interface{}
  25751. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25752. fmt.Println(dat)
  25753. } else {
  25754. fmt.Println(err)
  25755. }
  25756. saveLog(result, request_log, "2204", "上传费用明细")
  25757. userJSONBytes, _ := json.Marshal(dat)
  25758. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25759. utils.ErrorLog("解析失败:%v", err)
  25760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25761. return
  25762. }
  25763. res.InfRefmsgid = resFour10265.InfRefmsgid
  25764. res.Output = resFour10265.Output
  25765. res.ErrMsg = resFour10265.ErrMsg
  25766. res.Cainfo = resFour10265.Cainfo
  25767. res.WarnMsg = resFour10265.WarnMsg
  25768. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25769. res.Infcode = infocode
  25770. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25771. bytesData, _ := json.Marshal(data)
  25772. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  25773. resp, _ := client.Do(req)
  25774. defer resp.Body.Close()
  25775. body, ioErr := ioutil.ReadAll(resp.Body)
  25776. if ioErr != nil {
  25777. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25779. return
  25780. }
  25781. var respJSON map[string]interface{}
  25782. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25785. return
  25786. }
  25787. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25788. userJSONBytes, _ := json.Marshal(respJSON)
  25789. fmt.Println("log")
  25790. fmt.Println(string(userJSONBytes))
  25791. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25792. utils.ErrorLog("解析失败:%v", err)
  25793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25794. return
  25795. }
  25796. } else {
  25797. if miConfig.Code == "H15049901371" {
  25798. 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)
  25799. var dat map[string]interface{}
  25800. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25801. fmt.Println(dat)
  25802. } else {
  25803. fmt.Println(err)
  25804. }
  25805. saveLog(result, request_log, "2204", "上传费用明细")
  25806. userJSONBytes, _ := json.Marshal(dat)
  25807. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25808. utils.ErrorLog("解析失败:%v", err)
  25809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25810. return
  25811. }
  25812. res.InfRefmsgid = resFour10265.InfRefmsgid
  25813. res.Output = resFour10265.Output
  25814. res.ErrMsg = resFour10265.ErrMsg
  25815. res.Cainfo = resFour10265.Cainfo
  25816. res.WarnMsg = resFour10265.WarnMsg
  25817. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25818. res.Infcode = infocode
  25819. } else {
  25820. 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)
  25821. var dat map[string]interface{}
  25822. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25823. fmt.Println(dat)
  25824. } else {
  25825. fmt.Println(err)
  25826. }
  25827. saveLog(result, request_log, "2204", "上传费用明细")
  25828. userJSONBytes, _ := json.Marshal(dat)
  25829. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25830. utils.ErrorLog("解析失败:%v", err)
  25831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25832. return
  25833. }
  25834. }
  25835. }
  25836. if res.Infcode == 0 {
  25837. order := &models.HisOrder{
  25838. UserOrgId: adminUser.CurrentOrgId,
  25839. HisPatientId: his.ID,
  25840. PatientId: his.PatientId,
  25841. SettleAccountsDate: recordDateTime,
  25842. MdtrtId: his.Number,
  25843. PsnNo: his.PsnNo,
  25844. MedType: strconv.FormatInt(reg_type, 10),
  25845. Ctime: time.Now().Unix(),
  25846. Mtime: time.Now().Unix(),
  25847. Status: 1,
  25848. Number: chrg_bchno,
  25849. Infcode: res.Infcode,
  25850. WarnMsg: res.WarnMsg,
  25851. Cainfo: res.Cainfo,
  25852. ErrMsg: res.ErrMsg,
  25853. RespondTime: res.RefmsgTime,
  25854. InfRefmsgid: res.InfRefmsgid,
  25855. OrderStatus: 1,
  25856. PayWay: pay_way,
  25857. PayWays: pay_ways,
  25858. OthDesc: oth_desc,
  25859. PayPrice: pay_price,
  25860. PayCardNo: pay_card_no,
  25861. DiscountPrice: discount_price,
  25862. PreferentialPrice: preferential_price,
  25863. RealityPrice: reality_price,
  25864. FoundPrice: found_price,
  25865. MedicalInsurancePrice: medical_insurance_price,
  25866. PrivatePrice: private_price,
  25867. IsMedicineInsurance: 1,
  25868. SettleType: settle_accounts_type,
  25869. SettleStartTime: start_time,
  25870. SettleEndTime: end_time,
  25871. Creator: roles.AdminUserId,
  25872. Modify: roles.AdminUserId,
  25873. FaPiaoNumber: fapiao_number,
  25874. FaPiaoCode: fapiao_code,
  25875. PType: 2,
  25876. Diagnosis: diagnosis_id,
  25877. CashPay: cash_pay,
  25878. WechatPay: wechat_pay,
  25879. AliPay: ali_pay,
  25880. JifenPay: jifen_pay,
  25881. BandCardPay: band_card_pay,
  25882. }
  25883. err = service.CreateOrder(order)
  25884. if err != nil {
  25885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  25886. return
  25887. }
  25888. for _, item := range res.Output.Result {
  25889. temp := strings.Split(item.FeedetlSn, "-")
  25890. var advice_id int64 = 0
  25891. var project_id int64 = 0
  25892. var types int64 = 0
  25893. id, _ := strconv.ParseInt(temp[2], 10, 64)
  25894. types, _ = strconv.ParseInt(temp[1], 10, 64)
  25895. if temp[1] == "1" {
  25896. advice_id = id
  25897. project_id = 0
  25898. } else if temp[1] == "2" {
  25899. advice_id = 0
  25900. project_id = id
  25901. }
  25902. if item.MedChrgitmType == "9" {
  25903. item.MedChrgitmType = "09"
  25904. }
  25905. info := &models.HisOrderInfo{
  25906. OrderNumber: order.Number,
  25907. FeedetlSn: item.FeedetlSn,
  25908. UploadDate: time.Now().Unix(),
  25909. AdviceId: advice_id,
  25910. DetItemFeeSumamt: item.DetItemFeeSumamt,
  25911. Cnt: item.Cnt,
  25912. Pric: float64(item.Pric),
  25913. PatientId: his.PatientId,
  25914. PricUplmtAmt: item.PricUplmtAmt,
  25915. SelfpayProp: item.SelfpayProp,
  25916. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  25917. OverlmtAmt: item.OverlmtAmt,
  25918. PreselfpayAmt: item.PreselfpayAmt,
  25919. BasMednFlag: item.BasMednFlag,
  25920. MedChrgitmType: item.MedChrgitmType,
  25921. HiNegoDrugFlag: item.HiNegoDrugFlag,
  25922. Status: 1,
  25923. Memo: item.Memo,
  25924. Mtime: time.Now().Unix(),
  25925. InscpScpAmt: item.InscpScpAmt,
  25926. DrtReimFlag: item.DrtReimFlag,
  25927. Ctime: time.Now().Unix(),
  25928. ListSpItemFlag: item.ListSpItemFlag,
  25929. ChldMedcFlag: item.ChldMedcFlag,
  25930. LmtUsedFlag: item.LmtUsedFlag,
  25931. ChrgitmLv: item.ChrgitmLv,
  25932. UserOrgId: adminUser.CurrentOrgId,
  25933. HisPatientId: his.ID,
  25934. OrderId: order.ID,
  25935. ProjectId: project_id,
  25936. Type: types,
  25937. }
  25938. service.CreateOrderInfo(info)
  25939. }
  25940. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  25941. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  25942. var total float64
  25943. for _, item := range prescriptions {
  25944. if item.Type == 1 { //药品
  25945. for _, subItem := range item.HisDoctorAdviceInfo {
  25946. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25947. total_one := price * subItem.PrescribingNumber
  25948. total = total + total_one
  25949. }
  25950. }
  25951. if item.Type == 2 { //项目
  25952. for _, subItem := range item.HisPrescriptionProject {
  25953. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  25954. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25955. total_one := price * cnt
  25956. total = total + total_one
  25957. }
  25958. }
  25959. }
  25960. allTotal := fmt.Sprintf("%.2f", total)
  25961. //if adminUser.CurrentOrgId == 9919 {
  25962. //
  25963. // allTotal = fmt.Sprintf("%.2f", total)
  25964. //
  25965. //} else {
  25966. //
  25967. // allTotal = fmt.Sprintf("%.2f", total)
  25968. //
  25969. //}
  25970. if res.Infcode == 0 {
  25971. var rf []*ResultFive
  25972. json.Unmarshal([]byte(his.Iinfo), &rf)
  25973. chrg_bchno := chrg_bchno
  25974. cert_no := his.Certno
  25975. var insutypes []string
  25976. var insutype string
  25977. var is390 int = 0
  25978. var is310 int = 0
  25979. for _, item := range rf {
  25980. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25981. insutypes = append(insutypes, item.Insutype)
  25982. }
  25983. }
  25984. if len(insutypes) == 1 {
  25985. insutype = insutypes[0]
  25986. } else {
  25987. for _, i := range insutypes {
  25988. if i == "390" {
  25989. is390 = 1
  25990. }
  25991. if i == "310" {
  25992. is310 = 1
  25993. }
  25994. }
  25995. }
  25996. if is390 == 1 {
  25997. insutype = "390"
  25998. }
  25999. if is310 == 1 {
  26000. insutype = "310"
  26001. }
  26002. if len(insutypes) == 0 {
  26003. insutype = "310"
  26004. }
  26005. if len(insutypes) == 2 {
  26006. insutype = strconv.FormatInt(his.SocialType, 10)
  26007. }
  26008. insutype = strconv.FormatInt(his.SocialType, 10)
  26009. //insutype = "390"
  26010. if his.IdCardType == 1 {
  26011. // cert_no = his.MedicalInsuranceNumber
  26012. cert_no = his.Certno
  26013. } else {
  26014. cert_no = his.Certno
  26015. }
  26016. var res ResultSeven
  26017. var resSeven10265 ResultSeven10265
  26018. var gzresSeven10265Two GZResultSeven10265Two
  26019. var src_resquest string
  26020. var result2 string
  26021. if miConfig.MdtrtareaAdmvs == "421300" {
  26022. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26023. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26024. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26025. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26026. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26027. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26028. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26029. resp, requestErr := http.Get(api)
  26030. if requestErr != nil {
  26031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26032. return
  26033. }
  26034. body, ioErr := ioutil.ReadAll(resp.Body)
  26035. if ioErr != nil {
  26036. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26038. return
  26039. }
  26040. var respJSON map[string]interface{}
  26041. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26042. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26044. return
  26045. }
  26046. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26047. result, _ := json.Marshal(respJSON)
  26048. if miConfig.Code == "H15049901371" {
  26049. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26050. utils.ErrorLog("解析失败:%v", err)
  26051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26052. return
  26053. }
  26054. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26055. res.Output = resSeven10265.Output
  26056. res.ErrMsg = resSeven10265.ErrMsg
  26057. res.Cainfo = resSeven10265.Cainfo
  26058. res.WarnMsg = resSeven10265.WarnMsg
  26059. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26060. res.Infcode = infocode
  26061. } else {
  26062. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26063. utils.ErrorLog("解析失败:%v", err)
  26064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26065. return
  26066. }
  26067. }
  26068. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26069. if reg_type == 11 && his.Insutype == "390" {
  26070. reg_type = 110104
  26071. }
  26072. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26073. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26074. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26075. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26076. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26077. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26078. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26079. resp, requestErr := http.Get(api)
  26080. if requestErr != nil {
  26081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26082. return
  26083. }
  26084. body, ioErr := ioutil.ReadAll(resp.Body)
  26085. if ioErr != nil {
  26086. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26088. return
  26089. }
  26090. var respJSON map[string]interface{}
  26091. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26092. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26094. return
  26095. }
  26096. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26097. result, _ := json.Marshal(respJSON)
  26098. if miConfig.Code == "H15049901371" {
  26099. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26100. utils.ErrorLog("解析失败:%v", err)
  26101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26102. return
  26103. }
  26104. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26105. res.Output = resSeven10265.Output
  26106. res.ErrMsg = resSeven10265.ErrMsg
  26107. res.Cainfo = resSeven10265.Cainfo
  26108. res.WarnMsg = resSeven10265.WarnMsg
  26109. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26110. res.Infcode = infocode
  26111. } else {
  26112. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26113. utils.ErrorLog("解析失败:%v", err)
  26114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26115. return
  26116. }
  26117. }
  26118. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26119. if reg_type == 11 && his.Insutype == "390" {
  26120. reg_type = 110104
  26121. }
  26122. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26123. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26124. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26125. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26126. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26127. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26128. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26129. resp, requestErr := http.Get(api)
  26130. if requestErr != nil {
  26131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26132. return
  26133. }
  26134. body, ioErr := ioutil.ReadAll(resp.Body)
  26135. if ioErr != nil {
  26136. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26138. return
  26139. }
  26140. var respJSON map[string]interface{}
  26141. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26142. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26144. return
  26145. }
  26146. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26147. result, _ := json.Marshal(respJSON)
  26148. if miConfig.Code == "H15049901371" {
  26149. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26150. utils.ErrorLog("解析失败:%v", err)
  26151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26152. return
  26153. }
  26154. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26155. res.Output = resSeven10265.Output
  26156. res.ErrMsg = resSeven10265.ErrMsg
  26157. res.Cainfo = resSeven10265.Cainfo
  26158. res.WarnMsg = resSeven10265.WarnMsg
  26159. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26160. res.Infcode = infocode
  26161. } else {
  26162. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26163. utils.ErrorLog("解析失败:%v", err)
  26164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26165. return
  26166. }
  26167. }
  26168. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26169. if reg_type == 11 && his.Insutype == "390" {
  26170. reg_type = 110104
  26171. }
  26172. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26173. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26174. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26175. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26176. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26177. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26178. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26179. resp, requestErr := http.Get(api)
  26180. if requestErr != nil {
  26181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26182. return
  26183. }
  26184. body, ioErr := ioutil.ReadAll(resp.Body)
  26185. if ioErr != nil {
  26186. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26188. return
  26189. }
  26190. var respJSON map[string]interface{}
  26191. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26194. return
  26195. }
  26196. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26197. result, _ := json.Marshal(respJSON)
  26198. if miConfig.Code == "H15049901371" {
  26199. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26200. utils.ErrorLog("解析失败:%v", err)
  26201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26202. return
  26203. }
  26204. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26205. res.Output = resSeven10265.Output
  26206. res.ErrMsg = resSeven10265.ErrMsg
  26207. res.Cainfo = resSeven10265.Cainfo
  26208. res.WarnMsg = resSeven10265.WarnMsg
  26209. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26210. res.Infcode = infocode
  26211. } else {
  26212. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26213. utils.ErrorLog("解析失败:%v", err)
  26214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26215. return
  26216. }
  26217. }
  26218. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26219. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  26220. if result3101.Infcode == "0" {
  26221. if len(result3101.Output.Result) > 0 {
  26222. var errMsgs []string
  26223. for _, item := range result3101.Output.Result {
  26224. errMsgs = append(errMsgs, item.VolaCont)
  26225. }
  26226. c.ServeSuccessJSON(map[string]interface{}{
  26227. "failed_code": -10,
  26228. "msg": errMsgs,
  26229. })
  26230. return
  26231. } else {
  26232. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26233. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26234. bas := strings.Split(psn_info.CardInfo, "|")
  26235. if his.IdCardType == 1 {
  26236. cert_no = bas[2]
  26237. } else if his.IdCardType == 3 {
  26238. cert_no = his.Certno
  26239. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26240. } else if his.IdCardType == 4 {
  26241. cert_no = his.Certno
  26242. psn_info.VerifyNumber = psn_info.VerifyNumber
  26243. }
  26244. var api string
  26245. if miConfig.MdtrtareaAdmvs == "320921" {
  26246. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26247. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26248. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26249. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26250. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26251. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26252. "&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
  26253. } else {
  26254. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26255. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26256. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26257. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26258. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26259. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26260. "&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
  26261. }
  26262. resp, requestErr := http.Get(api)
  26263. if requestErr != nil {
  26264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26265. return
  26266. }
  26267. body, ioErr := ioutil.ReadAll(resp.Body)
  26268. if ioErr != nil {
  26269. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26271. return
  26272. }
  26273. var respJSON map[string]interface{}
  26274. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26275. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26277. return
  26278. }
  26279. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26280. result, _ := json.Marshal(respJSON)
  26281. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26282. utils.ErrorLog("解析失败:%v", err)
  26283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26284. return
  26285. }
  26286. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26287. res.Output = resSeven10265.Output
  26288. res.ErrMsg = resSeven10265.ErrMsg
  26289. res.Cainfo = resSeven10265.Cainfo
  26290. res.WarnMsg = resSeven10265.WarnMsg
  26291. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26292. res.Infcode = infocode
  26293. }
  26294. }
  26295. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26296. psn_info, _ := service.GetPsnByPatientId(id)
  26297. var verify_number string
  26298. if psn_info.IdCardType == 4 {
  26299. verify_number = psn_info.VerifyNumber
  26300. } else if psn_info.IdCardType == 1 {
  26301. bas := strings.Split(psn_info.CardInfo, "|")
  26302. cardNumber := bas[2]
  26303. verify_number = cardNumber
  26304. } else {
  26305. psn_info.IdCardType = 2
  26306. verify_number = psn_info.Certno
  26307. }
  26308. var api string
  26309. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26310. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26311. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26312. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26313. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26314. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26315. "&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
  26316. resp, requestErr := http.Get(api)
  26317. if requestErr != nil {
  26318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26319. return
  26320. }
  26321. body, ioErr := ioutil.ReadAll(resp.Body)
  26322. if ioErr != nil {
  26323. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26325. return
  26326. }
  26327. var respJSON map[string]interface{}
  26328. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26329. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26331. return
  26332. }
  26333. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26334. result, _ := json.Marshal(respJSON)
  26335. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26336. utils.ErrorLog("解析失败:%v", err)
  26337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26338. return
  26339. }
  26340. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26341. res.Output = resSeven10265.Output
  26342. res.ErrMsg = resSeven10265.ErrMsg
  26343. res.Cainfo = resSeven10265.Cainfo
  26344. res.WarnMsg = resSeven10265.WarnMsg
  26345. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26346. res.Infcode = infocode
  26347. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26348. var cert_no string
  26349. if his.IdCardType == 4 {
  26350. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26351. cert_no = psn_info.VerifyNumber
  26352. 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)
  26353. } else if his.IdCardType == 1 {
  26354. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26355. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26356. 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)
  26357. }
  26358. //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)
  26359. var dat map[string]interface{}
  26360. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26361. fmt.Println(dat)
  26362. } else {
  26363. fmt.Println(err)
  26364. }
  26365. saveLog(result2, src_resquest, "2207", "结算")
  26366. userJSONBytes, _ := json.Marshal(dat)
  26367. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26368. utils.ErrorLog("解析失败:%v", err)
  26369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26370. return
  26371. }
  26372. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26373. res.Output = resSeven10265.Output
  26374. res.ErrMsg = resSeven10265.ErrMsg
  26375. res.Cainfo = resSeven10265.Cainfo
  26376. res.WarnMsg = resSeven10265.WarnMsg
  26377. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26378. res.Infcode = infocode
  26379. } else if miConfig.MdtrtareaAdmvs == "450721" {
  26380. res2 := c.GetoleInfo()
  26381. if res2.Infcode == 0 {
  26382. var result string
  26383. var request_log string
  26384. var result_log string
  26385. if res2.Output.MdtrtCertType == "02" {
  26386. 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)
  26387. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26388. } else if res2.Output.MdtrtCertType == "01" {
  26389. 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)
  26390. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26391. } else {
  26392. 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)
  26393. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26394. }
  26395. var dat map[string]interface{}
  26396. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26397. fmt.Println(dat)
  26398. } else {
  26399. fmt.Println(err)
  26400. }
  26401. userJSONBytes, _ := json.Marshal(dat)
  26402. var res5 ResultTwo
  26403. //var resTwo10265 ResultTwo10265
  26404. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26405. utils.ErrorLog("解析失败:%v", err)
  26406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26407. return
  26408. }
  26409. if res5.Infcode == -1 {
  26410. c.ServeSuccessJSON(map[string]interface{}{
  26411. "failed_code": -10,
  26412. "msg": res5.ErrMsg,
  26413. })
  26414. return
  26415. }
  26416. var insutypes []string
  26417. var insutype string
  26418. var is390 int = 0
  26419. var is310 int = 0
  26420. for _, item := range res5.Output.Iinfo {
  26421. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26422. insutypes = append(insutypes, item.Insutype)
  26423. }
  26424. }
  26425. if len(insutypes) == 1 {
  26426. insutype = insutypes[0]
  26427. } else {
  26428. for _, i := range insutypes {
  26429. if i == "390" {
  26430. is390 = 1
  26431. }
  26432. if i == "310" {
  26433. is310 = 1
  26434. }
  26435. }
  26436. }
  26437. if is390 == 1 {
  26438. insutype = "390"
  26439. }
  26440. if is310 == 1 {
  26441. insutype = "310"
  26442. }
  26443. if len(insutypes) == 0 {
  26444. insutype = "310"
  26445. }
  26446. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26447. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26448. infoStr := string(Iinfos)
  26449. idetinfoStr := string(Idetinfos)
  26450. psn := &models.HisPsn{
  26451. PsnNo: res5.Output.Baseinfo.PsnNo,
  26452. PatientId: id,
  26453. Certno: res5.Output.Baseinfo.Certno,
  26454. Gend: res5.Output.Baseinfo.Gend,
  26455. Naty: res5.Output.Baseinfo.Naty,
  26456. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26457. PsnName: res5.Output.Baseinfo.PsnName,
  26458. Idetinfo: idetinfoStr,
  26459. Insuinfo: infoStr,
  26460. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26461. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26462. VerifyNumber: res2.Output.EcToken,
  26463. }
  26464. if res2.Output.MdtrtCertType == "01" {
  26465. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26466. psn.VerifyNumber = res2.Output.EcToken
  26467. } else if res2.Output.MdtrtCertType == "02" {
  26468. psn.VerifyNumber = res2.Output.CardNo
  26469. } else {
  26470. psn.VerifyNumber = res2.Output.MdtrtCertNo
  26471. }
  26472. service.CreateHisPsn(psn)
  26473. if res2.Output.MdtrtCertType == "01" {
  26474. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26475. token := res2.Output.EcToken
  26476. 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)
  26477. } else if res2.Output.MdtrtCertType == "02" {
  26478. 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)
  26479. } else {
  26480. 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)
  26481. }
  26482. var dat2 map[string]interface{}
  26483. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26484. fmt.Println(dat2)
  26485. } else {
  26486. fmt.Println(err)
  26487. }
  26488. userJSONBytes3, _ := json.Marshal(dat2)
  26489. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26490. utils.ErrorLog("解析失败:%v", err)
  26491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26492. return
  26493. }
  26494. saveLog(result2, src_resquest, "2207", "结算")
  26495. } else {
  26496. c.ServeSuccessJSON(map[string]interface{}{
  26497. "failed_code": -10,
  26498. "msg": res2.ErrMsg,
  26499. })
  26500. return
  26501. }
  26502. } else {
  26503. if miConfig.Code == "H15049901371" {
  26504. //赤峰地区国家医保医疗类别
  26505. //职工透析:医疗类别选特殊情况门诊990502
  26506. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26507. var med_type string
  26508. if his.Insutype == "390" {
  26509. if reg_type == 14 {
  26510. med_type = "9933"
  26511. } else if reg_type == 11 {
  26512. med_type = "11"
  26513. }
  26514. } else if his.Insutype == "310" {
  26515. if reg_type == 14 {
  26516. med_type = "990502"
  26517. } else if reg_type == 11 {
  26518. med_type = "11"
  26519. }
  26520. }
  26521. 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)
  26522. } else {
  26523. if his.IdCardType == 4 {
  26524. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26525. var token string
  26526. token = psn_info.VerifyNumber
  26527. 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)
  26528. } else {
  26529. if his.IdCardType == 1 {
  26530. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26531. bas := strings.Split(psn_info.CardInfo, "|")
  26532. basNumber := bas[2]
  26533. cert_no = basNumber
  26534. }
  26535. 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)
  26536. }
  26537. }
  26538. //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)
  26539. var dat map[string]interface{}
  26540. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26541. fmt.Println(dat)
  26542. } else {
  26543. fmt.Println(err)
  26544. }
  26545. saveLog(result2, src_resquest, "2207", "结算")
  26546. userJSONBytes, _ := json.Marshal(dat)
  26547. if miConfig.Code == "H15049901371" {
  26548. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26549. utils.ErrorLog("解析失败:%v", err)
  26550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26551. return
  26552. }
  26553. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26554. res.Output = resSeven10265.Output
  26555. res.ErrMsg = resSeven10265.ErrMsg
  26556. res.Cainfo = resSeven10265.Cainfo
  26557. res.WarnMsg = resSeven10265.WarnMsg
  26558. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26559. res.Infcode = infocode
  26560. } else {
  26561. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26562. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  26563. utils.ErrorLog("解析失败:%v", err)
  26564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26565. return
  26566. }
  26567. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  26568. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  26569. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  26570. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26571. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  26572. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  26573. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  26574. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26575. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  26576. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26577. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26578. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26579. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26580. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26581. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  26582. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  26583. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  26584. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  26585. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  26586. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  26587. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26588. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  26589. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  26590. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  26591. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  26592. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  26593. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  26594. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  26595. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  26596. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  26597. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  26598. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  26599. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  26600. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  26601. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  26602. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  26603. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  26604. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  26605. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26606. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  26607. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  26608. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  26609. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  26610. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  26611. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  26612. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  26613. res.ErrMsg = gzresSeven10265Two.ErrMsg
  26614. res.Cainfo = gzresSeven10265Two.Cainfo
  26615. res.WarnMsg = gzresSeven10265Two.WarnMsg
  26616. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  26617. //res.Infcode = infocode
  26618. } else {
  26619. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26620. utils.ErrorLog("解析失败:%v", err)
  26621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26622. return
  26623. }
  26624. }
  26625. }
  26626. }
  26627. if res.Infcode == -1 {
  26628. errlog := &models.HisOrderError{
  26629. UserOrgId: adminUser.CurrentOrgId,
  26630. Ctime: time.Now().Unix(),
  26631. Mtime: time.Now().Unix(),
  26632. Number: chrg_bchno,
  26633. ErrMsg: res.ErrMsg,
  26634. Status: 1,
  26635. PatientId: id,
  26636. RecordTime: recordDateTime,
  26637. Stage: 6,
  26638. }
  26639. service.CreateErrMsgLog(errlog)
  26640. c.ServeSuccessJSON(map[string]interface{}{
  26641. "failed_code": -10,
  26642. "msg": res.ErrMsg,
  26643. })
  26644. return
  26645. } else {
  26646. sickConfig, _ := service.FindSickById(his.SickType)
  26647. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  26648. order.OrderStatus = 2
  26649. order.Status = 1
  26650. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  26651. order.SetlId = res.Output.Setlinfo.SetlID
  26652. order.PsnNo = res.Output.Setlinfo.PsnNo
  26653. order.PsnName = res.Output.Setlinfo.PsnName
  26654. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  26655. order.Certno = res.Output.Setlinfo.Certno
  26656. order.Gend = res.Output.Setlinfo.Gend
  26657. order.Naty = res.Output.Setlinfo.Naty
  26658. order.Age = res.Output.Setlinfo.Age
  26659. order.Insutype = res.Output.Setlinfo.Insutype
  26660. order.PsnType = res.Output.Setlinfo.PsnType
  26661. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  26662. order.SetlTime = res.Output.Setlinfo.SetlTime
  26663. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  26664. if res.Output.Setlinfo.MedType == "140101" {
  26665. order.MedType = "14"
  26666. } else {
  26667. if res.Output.Setlinfo.MedType == "110104" {
  26668. order.MedType = "11"
  26669. } else {
  26670. order.MedType = res.Output.Setlinfo.MedType
  26671. }
  26672. }
  26673. if reg_type == 1112 {
  26674. order.MedType = "1112"
  26675. }
  26676. if reg_type == 1111 {
  26677. order.MedType = "1111"
  26678. }
  26679. order.ClrType = res.Output.Setlinfo.ClrType
  26680. if adminUser.CurrentOrgId == 10480 {
  26681. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  26682. order.ClrType = "11"
  26683. } else {
  26684. order.ClrType = "9903"
  26685. }
  26686. }
  26687. if adminUser.CurrentOrgId == 10721 {
  26688. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  26689. order.ClrType = "11"
  26690. } else {
  26691. order.ClrType = "9903"
  26692. }
  26693. }
  26694. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  26695. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  26696. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  26697. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  26698. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  26699. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  26700. order.HifpPay = res.Output.Setlinfo.HifpPay
  26701. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  26702. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  26703. order.HifesPay = res.Output.Setlinfo.HifesPay
  26704. order.HifobPay = res.Output.Setlinfo.HifobPay
  26705. order.MafPay = res.Output.Setlinfo.MafPay
  26706. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  26707. order.OthPay = res.Output.Setlinfo.OthPay
  26708. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  26709. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  26710. order.AcctPay = res.Output.Setlinfo.AcctPay
  26711. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  26712. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  26713. order.Balc = res.Output.Setlinfo.Balc
  26714. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  26715. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  26716. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  26717. //order.ClrType = res.Output.Setlinfo.ClrType
  26718. order.ClrWay = res.Output.Setlinfo.ClrWay
  26719. order.Creator = order.Creator
  26720. order.Modify = roles.AdminUserId
  26721. order.RequestLog = src_resquest
  26722. order.FaPiaoNumber = fapiao_number
  26723. order.FaPiaoCode = fapiao_code
  26724. order.SickName = sickConfig.ClassName
  26725. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  26726. //detailStr := string(setlDetail)
  26727. //order.SetlDetail = detailStr
  26728. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  26729. err = service.UpDateOrder(order)
  26730. if err == nil {
  26731. //判断是否使用了押金
  26732. if dec_way == "true" {
  26733. tmpstring := strconv.FormatInt(order.ID, 10)
  26734. order.Decimal = decimal
  26735. service.UpDateOrder(order)
  26736. //扣押金
  26737. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  26738. if errmsg != nil {
  26739. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  26740. return
  26741. }
  26742. }
  26743. c.ServeSuccessJSON(map[string]interface{}{
  26744. "msg": "结算成功",
  26745. })
  26746. } else {
  26747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  26748. return
  26749. }
  26750. }
  26751. } else {
  26752. adminUser := c.GetAdminUserInfo()
  26753. errlog := &models.HisOrderError{
  26754. UserOrgId: adminUser.CurrentOrgId,
  26755. Ctime: time.Now().Unix(),
  26756. Mtime: time.Now().Unix(),
  26757. ErrMsg: res.ErrMsg,
  26758. Status: 1,
  26759. PatientId: id,
  26760. RecordTime: recordDateTime,
  26761. Stage: 4,
  26762. }
  26763. service.CreateErrMsgLog(errlog)
  26764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  26765. return
  26766. }
  26767. } else {
  26768. adminUser := c.GetAdminUserInfo()
  26769. errlog := &models.HisOrderError{
  26770. UserOrgId: adminUser.CurrentOrgId,
  26771. Ctime: time.Now().Unix(),
  26772. Mtime: time.Now().Unix(),
  26773. ErrMsg: res.ErrMsg,
  26774. Status: 1,
  26775. PatientId: id,
  26776. RecordTime: recordDateTime,
  26777. Stage: 4,
  26778. }
  26779. service.CreateErrMsgLog(errlog)
  26780. c.ServeSuccessJSON(map[string]interface{}{
  26781. "failed_code": -10,
  26782. "msg": res.ErrMsg,
  26783. })
  26784. return
  26785. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  26786. //return
  26787. }
  26788. }
  26789. }
  26790. } else if tempOrder.ID > 0 {
  26791. if tempOrder.IsPre == 1 {
  26792. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  26793. var rf []*ResultFive
  26794. json.Unmarshal([]byte(his.Iinfo), &rf)
  26795. chrg_bchno := tempOrder.Number
  26796. cert_no := his.Certno
  26797. var insutypes []string
  26798. var insutype string
  26799. var is390 int = 0
  26800. var is310 int = 0
  26801. for _, item := range rf {
  26802. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26803. insutypes = append(insutypes, item.Insutype)
  26804. }
  26805. }
  26806. if len(insutypes) == 1 {
  26807. insutype = insutypes[0]
  26808. } else {
  26809. for _, i := range insutypes {
  26810. if i == "390" {
  26811. is390 = 1
  26812. }
  26813. if i == "310" {
  26814. is310 = 1
  26815. }
  26816. }
  26817. }
  26818. if is390 == 1 {
  26819. insutype = "390"
  26820. }
  26821. if is310 == 1 {
  26822. insutype = "310"
  26823. }
  26824. if len(insutypes) == 0 {
  26825. insutype = "310"
  26826. }
  26827. if len(insutypes) == 2 {
  26828. insutype = strconv.FormatInt(his.SocialType, 10)
  26829. }
  26830. //insutype = "390"
  26831. if his.IdCardType == 1 {
  26832. // cert_no = his.MedicalInsuranceNumber
  26833. cert_no = his.Certno
  26834. } else {
  26835. cert_no = his.Certno
  26836. }
  26837. var res ResultSeven
  26838. var ahres ResultSevenAH
  26839. var resSeven10265 ResultSeven10265
  26840. var gzresSeven10265Two GZResultSeven10265Two
  26841. var src_resquest string
  26842. var result2 string
  26843. if miConfig.MdtrtareaAdmvs == "450721" {
  26844. res2 := c.GetoleInfo()
  26845. if res2.Infcode == 0 {
  26846. var result string
  26847. var request_log string
  26848. var result_log string
  26849. if res2.Output.MdtrtCertType == "02" {
  26850. 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)
  26851. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26852. } else if res2.Output.MdtrtCertType == "01" {
  26853. 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)
  26854. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26855. } else {
  26856. 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)
  26857. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26858. }
  26859. var dat map[string]interface{}
  26860. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26861. fmt.Println(dat)
  26862. } else {
  26863. fmt.Println(err)
  26864. }
  26865. userJSONBytes, _ := json.Marshal(dat)
  26866. var res5 ResultTwo
  26867. //var resTwo10265 ResultTwo10265
  26868. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26869. utils.ErrorLog("解析失败:%v", err)
  26870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26871. return
  26872. }
  26873. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  26874. if res5.Infcode == -1 {
  26875. c.ServeSuccessJSON(map[string]interface{}{
  26876. "failed_code": -10,
  26877. "msg": res5.ErrMsg,
  26878. })
  26879. return
  26880. }
  26881. var insutypes []string
  26882. var insutype string
  26883. var is390 int = 0
  26884. var is310 int = 0
  26885. for _, item := range res5.Output.Iinfo {
  26886. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26887. insutypes = append(insutypes, item.Insutype)
  26888. }
  26889. }
  26890. if len(insutypes) == 1 {
  26891. insutype = insutypes[0]
  26892. } else {
  26893. for _, i := range insutypes {
  26894. if i == "390" {
  26895. is390 = 1
  26896. }
  26897. if i == "310" {
  26898. is310 = 1
  26899. }
  26900. }
  26901. }
  26902. if is390 == 1 {
  26903. insutype = "390"
  26904. }
  26905. if is310 == 1 {
  26906. insutype = "310"
  26907. }
  26908. if len(insutypes) == 0 {
  26909. insutype = "310"
  26910. }
  26911. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26912. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26913. infoStr := string(Iinfos)
  26914. idetinfoStr := string(Idetinfos)
  26915. psn := &models.HisPsn{
  26916. PsnNo: res5.Output.Baseinfo.PsnNo,
  26917. PatientId: id,
  26918. Certno: res5.Output.Baseinfo.Certno,
  26919. Gend: res5.Output.Baseinfo.Gend,
  26920. Naty: res5.Output.Baseinfo.Naty,
  26921. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26922. PsnName: res5.Output.Baseinfo.PsnName,
  26923. Idetinfo: idetinfoStr,
  26924. Insuinfo: infoStr,
  26925. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26926. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26927. VerifyNumber: res2.Output.EcToken,
  26928. }
  26929. service.CreateHisPsn(psn)
  26930. if res2.Output.MdtrtCertType == "01" {
  26931. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26932. token := res2.Output.EcToken
  26933. 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)
  26934. } else if res2.Output.MdtrtCertType == "02" {
  26935. 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)
  26936. } else {
  26937. 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)
  26938. }
  26939. var dat2 map[string]interface{}
  26940. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26941. fmt.Println(dat2)
  26942. } else {
  26943. fmt.Println(err)
  26944. }
  26945. userJSONBytes3, _ := json.Marshal(dat2)
  26946. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26947. utils.ErrorLog("解析失败:%v", err)
  26948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26949. return
  26950. }
  26951. saveLog(result2, src_resquest, "2207", "结算")
  26952. } else {
  26953. c.ServeSuccessJSON(map[string]interface{}{
  26954. "failed_code": -10,
  26955. "msg": res2.ErrMsg,
  26956. })
  26957. return
  26958. }
  26959. } else if miConfig.MdtrtareaAdmvs == "421300" {
  26960. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26961. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26962. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26963. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26964. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26965. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26966. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26967. resp, requestErr := http.Get(api)
  26968. if requestErr != nil {
  26969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26970. return
  26971. }
  26972. body, ioErr := ioutil.ReadAll(resp.Body)
  26973. if ioErr != nil {
  26974. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26976. return
  26977. }
  26978. var respJSON map[string]interface{}
  26979. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26982. return
  26983. }
  26984. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26985. result, _ := json.Marshal(respJSON)
  26986. fmt.Println("log")
  26987. fmt.Println(string(result))
  26988. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26989. utils.ErrorLog("解析失败:%v", err)
  26990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26991. return
  26992. }
  26993. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26994. if reg_type == 11 && his.Insutype == "390" {
  26995. reg_type = 110104
  26996. }
  26997. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26998. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26999. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27000. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27001. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27002. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27003. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27004. resp, requestErr := http.Get(api)
  27005. if requestErr != nil {
  27006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27007. return
  27008. }
  27009. body, ioErr := ioutil.ReadAll(resp.Body)
  27010. if ioErr != nil {
  27011. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27013. return
  27014. }
  27015. var respJSON map[string]interface{}
  27016. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27017. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27019. return
  27020. }
  27021. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27022. result, _ := json.Marshal(respJSON)
  27023. fmt.Println("log")
  27024. fmt.Println(string(result))
  27025. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27026. utils.ErrorLog("解析失败:%v", err)
  27027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27028. return
  27029. }
  27030. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27031. if reg_type == 11 && his.Insutype == "390" {
  27032. reg_type = 110104
  27033. }
  27034. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27035. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27036. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27037. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27038. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27039. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27040. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27041. resp, requestErr := http.Get(api)
  27042. if requestErr != nil {
  27043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27044. return
  27045. }
  27046. body, ioErr := ioutil.ReadAll(resp.Body)
  27047. if ioErr != nil {
  27048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27050. return
  27051. }
  27052. var respJSON map[string]interface{}
  27053. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27056. return
  27057. }
  27058. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27059. result, _ := json.Marshal(respJSON)
  27060. fmt.Println("log")
  27061. fmt.Println(string(result))
  27062. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27063. utils.ErrorLog("解析失败:%v", err)
  27064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27065. return
  27066. }
  27067. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27068. if reg_type == 11 && his.Insutype == "390" {
  27069. reg_type = 110104
  27070. }
  27071. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27072. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27073. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27074. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27075. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27076. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27077. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27078. resp, requestErr := http.Get(api)
  27079. if requestErr != nil {
  27080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27081. return
  27082. }
  27083. body, ioErr := ioutil.ReadAll(resp.Body)
  27084. if ioErr != nil {
  27085. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27087. return
  27088. }
  27089. var respJSON map[string]interface{}
  27090. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27091. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27093. return
  27094. }
  27095. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27096. result, _ := json.Marshal(respJSON)
  27097. fmt.Println("log")
  27098. fmt.Println(string(result))
  27099. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27100. utils.ErrorLog("解析失败:%v", err)
  27101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27102. return
  27103. }
  27104. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27105. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  27106. if result3101.Infcode == "0" {
  27107. if len(result3101.Output.Result) > 0 {
  27108. var errMsgs []string
  27109. for _, item := range result3101.Output.Result {
  27110. errMsgs = append(errMsgs, item.VolaCont)
  27111. }
  27112. c.ServeSuccessJSON(map[string]interface{}{
  27113. "failed_code": -10,
  27114. "msg": errMsgs,
  27115. })
  27116. return
  27117. } else {
  27118. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27119. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27120. bas := strings.Split(psn_info.CardInfo, "|")
  27121. if his.IdCardType == 1 {
  27122. cert_no = bas[2]
  27123. } else if his.IdCardType == 3 {
  27124. cert_no = his.Certno
  27125. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27126. } else if his.IdCardType == 4 {
  27127. cert_no = his.Certno
  27128. psn_info.VerifyNumber = psn_info.VerifyNumber
  27129. }
  27130. //江苏地区国家医保医疗类别
  27131. //职工透析:医疗类别选特殊情况门诊9933
  27132. //居民血透门慢: 医疗类别选门诊慢病1402
  27133. //var med_type string
  27134. //if his.Insutype == "310" {
  27135. // if reg_type == 14 {
  27136. // med_type = "9933"
  27137. // } else if reg_type == 11 {
  27138. // med_type = "11"
  27139. //
  27140. // }
  27141. //} else if his.Insutype == "390" {
  27142. // if reg_type == 14 {
  27143. // med_type = "1402"
  27144. // } else if reg_type == 11 {
  27145. // med_type = "11"
  27146. // }
  27147. //}
  27148. var api string
  27149. if miConfig.MdtrtareaAdmvs == "320921" {
  27150. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27151. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27152. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27153. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27154. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27155. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27156. "&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
  27157. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27158. } else {
  27159. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27160. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27161. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27162. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27163. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27164. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27165. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27166. "&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
  27167. }
  27168. resp, requestErr := http.Get(api)
  27169. if requestErr != nil {
  27170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27171. return
  27172. }
  27173. body, ioErr := ioutil.ReadAll(resp.Body)
  27174. if ioErr != nil {
  27175. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27177. return
  27178. }
  27179. var respJSON map[string]interface{}
  27180. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27181. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27183. return
  27184. }
  27185. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27186. result, _ := json.Marshal(respJSON)
  27187. fmt.Println("log")
  27188. fmt.Println(string(result))
  27189. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27190. utils.ErrorLog("解析失败:%v", err)
  27191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27192. return
  27193. }
  27194. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27195. res.Output = resSeven10265.Output
  27196. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27197. res.ErrMsg = resSeven10265.ErrMsg
  27198. res.Cainfo = resSeven10265.Cainfo
  27199. res.WarnMsg = resSeven10265.WarnMsg
  27200. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27201. res.Infcode = infocode
  27202. }
  27203. }
  27204. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27205. psn_info, _ := service.GetPsnByPatientId(id)
  27206. var verify_number string
  27207. if psn_info.IdCardType == 4 {
  27208. verify_number = psn_info.VerifyNumber
  27209. } else if psn_info.IdCardType == 1 {
  27210. bas := strings.Split(psn_info.CardInfo, "|")
  27211. cardNumber := bas[2]
  27212. verify_number = cardNumber
  27213. } else {
  27214. verify_number = psn_info.Certno
  27215. psn_info.IdCardType = 2
  27216. }
  27217. var api string
  27218. new_chrg_bchno := chrg_bchno
  27219. if adminUser.CurrentOrgId == 10265 {
  27220. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27221. new_chrg_bchno = "0000"
  27222. }
  27223. }
  27224. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27225. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  27226. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27227. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27228. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27229. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27230. "&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
  27231. resp, requestErr := http.Get(api)
  27232. if requestErr != nil {
  27233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27234. return
  27235. }
  27236. body, ioErr := ioutil.ReadAll(resp.Body)
  27237. if ioErr != nil {
  27238. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27240. return
  27241. }
  27242. var respJSON map[string]interface{}
  27243. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27244. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27246. return
  27247. }
  27248. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27249. result, _ := json.Marshal(respJSON)
  27250. fmt.Println("log")
  27251. fmt.Println(string(result))
  27252. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27253. utils.ErrorLog("解析失败:%v", err)
  27254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27255. return
  27256. }
  27257. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27258. res.Output = resSeven10265.Output
  27259. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27260. res.ErrMsg = resSeven10265.ErrMsg
  27261. res.Cainfo = resSeven10265.Cainfo
  27262. res.WarnMsg = resSeven10265.WarnMsg
  27263. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27264. res.Infcode = infocode
  27265. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27266. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27267. var cert_no string
  27268. if his.IdCardType == 1 {
  27269. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27270. } else {
  27271. cert_no = psn_info.VerifyNumber
  27272. }
  27273. 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)
  27274. var dat map[string]interface{}
  27275. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27276. fmt.Println(dat)
  27277. } else {
  27278. fmt.Println(err)
  27279. }
  27280. saveLog(result2, src_resquest, "2207", "结算")
  27281. userJSONBytes, _ := json.Marshal(dat)
  27282. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27283. utils.ErrorLog("解析失败:%v", err)
  27284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27285. return
  27286. }
  27287. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27288. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27289. var cert_no string
  27290. var card_sn string
  27291. if his.IdCardType == 1 {
  27292. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27293. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27294. bas := strings.Split(psn_info.CardInfo, "|")
  27295. card_sn = bas[3]
  27296. } else if his.IdCardType == 2 {
  27297. cert_no = his.IdCardNo
  27298. } else {
  27299. cert_no = psn_info.VerifyNumber
  27300. }
  27301. var rf []*ResultFive
  27302. json.Unmarshal([]byte(his.Iinfo), &rf)
  27303. var psn_type string
  27304. for _, item := range rf {
  27305. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27306. psn_type = item.PsnType
  27307. }
  27308. }
  27309. 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)
  27310. var dat map[string]interface{}
  27311. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27312. fmt.Println(dat)
  27313. } else {
  27314. fmt.Println(err)
  27315. }
  27316. saveLog(result2, src_resquest, "2207", "结算")
  27317. userJSONBytes, _ := json.Marshal(dat)
  27318. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27319. utils.ErrorLog("解析失败:%v", err)
  27320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27321. return
  27322. }
  27323. } else if miConfig.MdtrtareaAdmvs == "361025" {
  27324. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27325. var cert_no string
  27326. var card_sn string
  27327. if his.IdCardType == 1 {
  27328. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27329. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27330. //bas := strings.Split(psn_info.CardInfo, "|")
  27331. card_sn = ""
  27332. } else if his.IdCardType == 2 {
  27333. cert_no = his.IdCardNo
  27334. } else {
  27335. cert_no = psn_info.VerifyNumber
  27336. }
  27337. var rf []*ResultFive
  27338. json.Unmarshal([]byte(his.Iinfo), &rf)
  27339. var psn_type string
  27340. for _, item := range rf {
  27341. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27342. psn_type = item.PsnType
  27343. }
  27344. }
  27345. 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)
  27346. var dat map[string]interface{}
  27347. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27348. fmt.Println(dat)
  27349. } else {
  27350. fmt.Println(err)
  27351. }
  27352. saveLog(result2, src_resquest, "2207", "结算")
  27353. userJSONBytes, _ := json.Marshal(dat)
  27354. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27355. utils.ErrorLog("解析失败:%v", err)
  27356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27357. return
  27358. }
  27359. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27360. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27361. if his.IdCardType == 1 {
  27362. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27363. bas := strings.Split(psn_info.CardInfo, "|")
  27364. cert_no = bas[2]
  27365. } else if his.IdCardType == 3 {
  27366. cert_no = his.Certno
  27367. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27368. } else if his.IdCardType == 4 {
  27369. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27370. cert_no = psn_info.VerifyNumber
  27371. psn_info.VerifyNumber = psn_info.VerifyNumber
  27372. } else {
  27373. cert_no = his.Certno
  27374. psn_info.VerifyNumber = his.Certno
  27375. }
  27376. var api string
  27377. var med_type string
  27378. if his.Insutype == "390" {
  27379. if reg_type == 992102 {
  27380. med_type = "992102"
  27381. }
  27382. if reg_type == 140104 {
  27383. med_type = "140104"
  27384. }
  27385. if reg_type == 140201 {
  27386. med_type = "140201"
  27387. }
  27388. if reg_type == 14 {
  27389. med_type = "14"
  27390. }
  27391. } else if his.Insutype == "310" {
  27392. if reg_type == 992102 {
  27393. med_type = "992102"
  27394. }
  27395. if reg_type == 140104 {
  27396. med_type = "140104"
  27397. }
  27398. if reg_type == 140201 {
  27399. med_type = "140201"
  27400. }
  27401. if reg_type == 14 {
  27402. med_type = "14"
  27403. }
  27404. }
  27405. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27406. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27407. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27408. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27409. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27410. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27411. "&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
  27412. resp, requestErr := http.Get(api)
  27413. if requestErr != nil {
  27414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27415. return
  27416. }
  27417. body, ioErr := ioutil.ReadAll(resp.Body)
  27418. if ioErr != nil {
  27419. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27421. return
  27422. }
  27423. var respJSON map[string]interface{}
  27424. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27425. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27427. return
  27428. }
  27429. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27430. if status == "0" {
  27431. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27432. c.ServeSuccessJSON(map[string]interface{}{
  27433. "failed_code": -10,
  27434. "msg": err_msg,
  27435. })
  27436. return
  27437. }
  27438. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27439. result, _ := json.Marshal(respJSON)
  27440. fmt.Println("log")
  27441. fmt.Println(string(result))
  27442. if err := json.Unmarshal(result, &ahres); err != nil {
  27443. utils.ErrorLog("解析失败:%v", err)
  27444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27445. return
  27446. }
  27447. res.InfRefmsgid = ahres.InfRefmsgid
  27448. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27449. // 创建对应的Time类型
  27450. t := time.UnixMilli(timestamp)
  27451. // 格式化成指定的日期字符串
  27452. str := t.Format("2006-01-02 15:04:05")
  27453. res.Output.Setlinfo.SetlTime = str
  27454. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27455. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27456. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27457. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27458. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27459. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27460. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27461. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27462. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27463. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27464. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27465. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27466. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27467. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27468. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27469. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27470. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27471. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27472. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27473. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27474. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27475. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27476. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27477. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27478. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27479. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27480. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27481. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27482. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27483. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27484. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27485. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27486. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27487. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27488. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27489. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27490. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27491. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27492. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27493. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27494. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27495. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27496. res.Output.Setldetail = ahres.Output.Setldetail
  27497. res.ErrMsg = ahres.ErrMsg
  27498. res.Cainfo = ahres.Cainfo
  27499. res.WarnMsg = ahres.WarnMsg
  27500. res.Infcode = ahres.Infcode
  27501. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27502. res.Output.Setlinfo.ClrType = "11"
  27503. } else {
  27504. res.Output.Setlinfo.ClrType = "9903"
  27505. }
  27506. } else if miConfig.MdtrtareaAdmvs == "340699" {
  27507. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27508. if his.IdCardType == 1 {
  27509. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27510. bas := strings.Split(psn_info.CardInfo, "|")
  27511. cert_no = bas[2]
  27512. } else if his.IdCardType == 3 {
  27513. cert_no = his.Certno
  27514. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27515. } else if his.IdCardType == 4 {
  27516. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27517. cert_no = his.Certno
  27518. psn_info.VerifyNumber = psn_info.VerifyNumber
  27519. } else {
  27520. cert_no = his.Certno
  27521. psn_info.VerifyNumber = his.Certno
  27522. }
  27523. var api string
  27524. var med_type string
  27525. if his.Insutype == "390" {
  27526. if reg_type == 992102 {
  27527. med_type = "992102"
  27528. }
  27529. if reg_type == 140104 {
  27530. med_type = "140104"
  27531. }
  27532. if reg_type == 14 {
  27533. med_type = "14"
  27534. }
  27535. if reg_type == 140201 {
  27536. med_type = "140201"
  27537. }
  27538. } else if his.Insutype == "310" {
  27539. if reg_type == 992102 {
  27540. med_type = "992102"
  27541. }
  27542. if reg_type == 14 {
  27543. med_type = "14"
  27544. }
  27545. if reg_type == 140104 {
  27546. med_type = "140104"
  27547. }
  27548. if reg_type == 140201 {
  27549. med_type = "140201"
  27550. }
  27551. }
  27552. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27553. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27554. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27555. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27556. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27557. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27558. "&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
  27559. resp, requestErr := http.Get(api)
  27560. if requestErr != nil {
  27561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27562. return
  27563. }
  27564. body, ioErr := ioutil.ReadAll(resp.Body)
  27565. if ioErr != nil {
  27566. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27568. return
  27569. }
  27570. var respJSON map[string]interface{}
  27571. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27572. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27574. return
  27575. }
  27576. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27577. if status == "0" {
  27578. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27579. c.ServeSuccessJSON(map[string]interface{}{
  27580. "failed_code": -10,
  27581. "msg": err_msg,
  27582. })
  27583. return
  27584. }
  27585. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27586. result, _ := json.Marshal(respJSON)
  27587. fmt.Println("log")
  27588. fmt.Println(string(result))
  27589. if err := json.Unmarshal(result, &ahres); err != nil {
  27590. utils.ErrorLog("解析失败:%v", err)
  27591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27592. return
  27593. }
  27594. res.InfRefmsgid = ahres.InfRefmsgid
  27595. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27596. // 创建对应的Time类型
  27597. t := time.UnixMilli(timestamp)
  27598. // 格式化成指定的日期字符串
  27599. str := t.Format("2006-01-02 15:04:05")
  27600. res.Output.Setlinfo.SetlTime = str
  27601. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27602. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27603. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27604. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27605. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27606. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27607. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27608. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27609. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27610. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27611. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27612. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27613. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27614. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27615. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27616. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27617. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27618. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27619. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27620. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27621. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27622. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27623. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27624. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27625. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27626. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27627. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27628. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27629. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27630. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27631. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27632. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27633. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27634. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27635. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27636. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27637. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27638. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27639. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27640. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27641. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27642. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27643. res.Output.Setldetail = ahres.Output.Setldetail
  27644. res.ErrMsg = ahres.ErrMsg
  27645. res.Cainfo = ahres.Cainfo
  27646. res.WarnMsg = ahres.WarnMsg
  27647. res.Infcode = ahres.Infcode
  27648. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  27649. res.Output.Setlinfo.ClrType = "11"
  27650. } else {
  27651. res.Output.Setlinfo.ClrType = "9903"
  27652. }
  27653. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27654. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27655. var cert_no string
  27656. if his.IdCardType == 1 {
  27657. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27658. } else if his.IdCardType == 2 {
  27659. cert_no = his.IdCardNo
  27660. } else {
  27661. cert_no = psn_info.VerifyNumber
  27662. }
  27663. 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, "")
  27664. var dat map[string]interface{}
  27665. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27666. fmt.Println(dat)
  27667. } else {
  27668. fmt.Println(err)
  27669. }
  27670. saveLog(result2, src_resquest, "2207", "结算")
  27671. userJSONBytes, _ := json.Marshal(dat)
  27672. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27673. utils.ErrorLog("解析失败:%v", err)
  27674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27675. return
  27676. }
  27677. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27678. psn_info, _ := service.GetPsnByPatientId(id)
  27679. var verify_number string
  27680. if psn_info.IdCardType == 4 {
  27681. verify_number = psn_info.VerifyNumber
  27682. } else if psn_info.IdCardType == 1 {
  27683. bas := strings.Split(psn_info.CardInfo, "|")
  27684. cardNumber := bas[2]
  27685. verify_number = cardNumber
  27686. } else {
  27687. verify_number = psn_info.Certno
  27688. psn_info.IdCardType = 2
  27689. }
  27690. var api string
  27691. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27692. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27693. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27694. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27695. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27696. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27697. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  27698. resp, requestErr := http.Get(api)
  27699. if requestErr != nil {
  27700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27701. return
  27702. }
  27703. body, ioErr := ioutil.ReadAll(resp.Body)
  27704. if ioErr != nil {
  27705. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27707. return
  27708. }
  27709. var respJSON map[string]interface{}
  27710. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27711. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27713. return
  27714. }
  27715. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27716. result, _ := json.Marshal(respJSON)
  27717. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27718. utils.ErrorLog("解析失败:%v", err)
  27719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27720. return
  27721. }
  27722. } else {
  27723. var src_resquest string
  27724. if miConfig.Code == "H15049901371" {
  27725. //赤峰地区国家医保医疗类别
  27726. //职工透析:医疗类别选特殊情况门诊990502
  27727. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27728. var med_type string
  27729. if his.Insutype == "390" {
  27730. if reg_type == 14 {
  27731. med_type = "9933"
  27732. } else if reg_type == 11 {
  27733. med_type = "11"
  27734. }
  27735. } else if his.Insutype == "310" {
  27736. if reg_type == 14 {
  27737. med_type = "990502"
  27738. } else if reg_type == 11 {
  27739. med_type = "11"
  27740. }
  27741. }
  27742. 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)
  27743. } else {
  27744. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" {
  27745. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  27746. if result3101.Infcode == 0 {
  27747. if len(result3101.Output.Result) > 0 {
  27748. c.ServeSuccessJSON(map[string]interface{}{
  27749. "failed_code": -10,
  27750. "failed_type": 100,
  27751. "warm_type": 2,
  27752. "msg": result3101,
  27753. })
  27754. return
  27755. }
  27756. } else {
  27757. c.ServeSuccessJSON(map[string]interface{}{
  27758. "failed_code": -10,
  27759. "msg": result3101.ErrMsg,
  27760. })
  27761. return
  27762. }
  27763. }
  27764. if his.IdCardType == 4 {
  27765. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27766. token := psn_info.VerifyNumber
  27767. 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)
  27768. } else {
  27769. 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)
  27770. }
  27771. }
  27772. var dat map[string]interface{}
  27773. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27774. fmt.Println(dat)
  27775. } else {
  27776. fmt.Println(err)
  27777. }
  27778. saveLog(result2, src_resquest, "2207", "结算")
  27779. userJSONBytes, _ := json.Marshal(dat)
  27780. if miConfig.Code == "H15049901371" {
  27781. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27782. utils.ErrorLog("解析失败:%v", err)
  27783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27784. return
  27785. }
  27786. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27787. res.Output = resSeven10265.Output
  27788. res.ErrMsg = resSeven10265.ErrMsg
  27789. res.Cainfo = resSeven10265.Cainfo
  27790. res.WarnMsg = resSeven10265.WarnMsg
  27791. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27792. res.Infcode = infocode
  27793. } else {
  27794. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27795. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27796. utils.ErrorLog("解析失败:%v", err)
  27797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27798. return
  27799. }
  27800. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27801. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27802. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27803. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27804. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27805. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27806. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27807. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27808. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27809. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27810. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27811. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27812. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27813. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27814. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27815. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27816. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27817. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27818. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27819. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27820. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27821. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27822. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27823. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27824. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27825. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27826. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27827. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27828. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27829. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27830. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27831. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27832. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27833. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27834. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27835. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27836. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27837. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27838. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27839. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27840. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27841. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27842. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27843. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27844. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27845. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27846. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27847. res.Cainfo = gzresSeven10265Two.Cainfo
  27848. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27849. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27850. //res.Infcode = infocode
  27851. } else {
  27852. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27853. utils.ErrorLog("解析失败:%v", err)
  27854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27855. return
  27856. }
  27857. }
  27858. }
  27859. }
  27860. if res.Infcode == -1 {
  27861. errlog := &models.HisOrderError{
  27862. UserOrgId: adminUser.CurrentOrgId,
  27863. Ctime: time.Now().Unix(),
  27864. Mtime: time.Now().Unix(),
  27865. Number: chrg_bchno,
  27866. ErrMsg: res.ErrMsg,
  27867. Status: 1,
  27868. PatientId: id,
  27869. RecordTime: recordDateTime,
  27870. Stage: 6,
  27871. }
  27872. service.CreateErrMsgLog(errlog)
  27873. c.ServeSuccessJSON(map[string]interface{}{
  27874. "failed_code": -10,
  27875. "msg": res.ErrMsg,
  27876. })
  27877. return
  27878. } else {
  27879. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27880. order.OrderStatus = 2
  27881. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27882. order.SetlId = res.Output.Setlinfo.SetlID
  27883. order.PsnNo = res.Output.Setlinfo.PsnNo
  27884. order.PsnName = res.Output.Setlinfo.PsnName
  27885. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27886. order.Certno = res.Output.Setlinfo.Certno
  27887. order.Gend = res.Output.Setlinfo.Gend
  27888. order.Naty = res.Output.Setlinfo.Naty
  27889. order.Age = res.Output.Setlinfo.Age
  27890. order.Insutype = res.Output.Setlinfo.Insutype
  27891. order.PsnType = res.Output.Setlinfo.PsnType
  27892. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  27893. order.SetlTime = res.Output.Setlinfo.SetlTime
  27894. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  27895. order.PayWays = pay_ways
  27896. order.AcctUsedFlag = acct_used_flag
  27897. order.WechatPay = wechat_pay
  27898. order.AliPay = ali_pay
  27899. order.JifenPay = jifen_pay
  27900. order.BandCardPay = band_card_pay
  27901. order.CashPay = cash_pay
  27902. order.OthDesc = oth_desc
  27903. //order.MedType = res.Output.Setlinfo.MedType
  27904. if reg_type == 1112 {
  27905. order.MedType = "1112"
  27906. }
  27907. if reg_type == 1111 {
  27908. order.MedType = "1111"
  27909. }
  27910. order.ClrType = res.Output.Setlinfo.ClrType
  27911. if adminUser.CurrentOrgId == 10480 {
  27912. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27913. order.ClrType = "11"
  27914. } else {
  27915. order.ClrType = "9903"
  27916. }
  27917. }
  27918. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  27919. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  27920. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  27921. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  27922. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  27923. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  27924. order.HifpPay = res.Output.Setlinfo.HifpPay
  27925. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  27926. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  27927. order.HifesPay = res.Output.Setlinfo.HifesPay
  27928. order.HifobPay = res.Output.Setlinfo.HifobPay
  27929. order.MafPay = res.Output.Setlinfo.MafPay
  27930. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  27931. order.OthPay = res.Output.Setlinfo.OthPay
  27932. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  27933. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  27934. order.AcctPay = res.Output.Setlinfo.AcctPay
  27935. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  27936. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  27937. order.Balc = res.Output.Setlinfo.Balc
  27938. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  27939. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  27940. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  27941. order.ClrWay = res.Output.Setlinfo.ClrWay
  27942. order.Creator = order.Creator
  27943. order.Modify = roles.AdminUserId
  27944. order.RequestLog = src_resquest
  27945. order.Diagnosis = diagnosis_id
  27946. order.FaPiaoNumber = fapiao_number
  27947. order.FaPiaoCode = fapiao_code
  27948. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  27949. detailStr := string(setlDetail)
  27950. order.SetlDetail = detailStr
  27951. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  27952. err = service.UpDateOrder(order)
  27953. if err == nil {
  27954. //判断是否使用了押金
  27955. if dec_way == "true" {
  27956. tmpstring := strconv.FormatInt(order.ID, 10)
  27957. //扣押金
  27958. order.Decimal = decimal
  27959. service.UpDateOrder(order)
  27960. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  27961. if errmsg != nil {
  27962. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  27963. return
  27964. }
  27965. }
  27966. c.ServeSuccessJSON(map[string]interface{}{
  27967. "msg": "结算成功",
  27968. })
  27969. } else {
  27970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  27971. return
  27972. }
  27973. }
  27974. }
  27975. }
  27976. }
  27977. // 上传明细-预结算-
  27978. func (c *HisApiController) GetPreUploadInfo() {
  27979. id, _ := c.GetInt64("id")
  27980. record_time := c.GetString("record_time")
  27981. his_patient_id, _ := c.GetInt64("his_patient_id")
  27982. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  27983. admin_user_id, _ := c.GetInt64("admin_user_id")
  27984. diagnosis_id := c.GetString("diagnosis")
  27985. sick_type, _ := c.GetInt64("sick_type")
  27986. reg_type, _ := c.GetInt64("p_type")
  27987. begin_time := c.GetString("begin_time")
  27988. acct_used_flag := c.GetString("acct_used_flag")
  27989. id_str := c.GetString("ids")
  27990. ids_arr := strings.Split(id_str, ",")
  27991. timeLayout := "2006-01-02"
  27992. loc, _ := time.LoadLocation("Local")
  27993. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27994. if err != nil {
  27995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27996. return
  27997. }
  27998. recordDateTime := theTime.Unix()
  27999. adminUser := c.GetAdminUserInfo()
  28000. diagnosis_ids := strings.Split(diagnosis_id, ",")
  28001. var config []*models.HisXtDiagnoseConfig
  28002. for _, item := range diagnosis_ids {
  28003. id, _ := strconv.ParseInt(item, 10, 64)
  28004. if id > 0 {
  28005. diagnosisConfig, _ := service.FindDiagnoseById(id)
  28006. config = append(config, &diagnosisConfig)
  28007. }
  28008. }
  28009. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  28010. sickConfig, _ := service.FindSickById(sick_type)
  28011. var prescriptions []*models.HisPrescription
  28012. var start_time int64
  28013. var end_time int64
  28014. var isSuccess bool = true
  28015. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28016. fmt.Println(his_patient_id)
  28017. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  28018. timestamp := time.Now().Unix()
  28019. tempTime := time.Unix(timestamp, 0)
  28020. timeFormat := tempTime.Format("20060102150405")
  28021. chrgBchno := rand.Intn(100000) + 10000
  28022. new_chrg_bchno := ""
  28023. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  28024. new_chrg_bchno = chrg_bchno
  28025. if adminUser.CurrentOrgId == 10265 {
  28026. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  28027. new_chrg_bchno = "0000"
  28028. }
  28029. }
  28030. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28031. var patientPrescription models.HisPrescriptionInfo
  28032. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  28033. if patientPrescription.ID == 0 {
  28034. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  28035. }
  28036. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28037. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  28038. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  28039. strconv.FormatInt(his.PatientId, 10)
  28040. var res2406 Result2406
  28041. //安徽单病种处理
  28042. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  28043. data := make(map[string]interface{})
  28044. client := &http.Client{}
  28045. data["psn_no"] = his.PsnNo
  28046. data["mdtrt_id"] = his.Number
  28047. data["operator"] = roles.UserName
  28048. data["cert_no"] = his.IdCardNo
  28049. data["org_name"] = miConfig.OrgName
  28050. data["psn_name"] = his.Name
  28051. data["ipt_otp_no"] = his.IptOtpNo
  28052. data["ipt_psn_sp_flag_type"] = "0901"
  28053. data["ipt_psn_sp_flag"] = "1"
  28054. data["fixmedins_code"] = miConfig.Code
  28055. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28056. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28057. data["url"] = miConfig.Url
  28058. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  28059. bytesData, _ := json.Marshal(data)
  28060. var req *http.Request
  28061. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  28062. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  28063. resp, _ := client.Do(req)
  28064. defer resp.Body.Close()
  28065. body, ioErr := ioutil.ReadAll(resp.Body)
  28066. if ioErr != nil {
  28067. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28069. return
  28070. }
  28071. var respJSON map[string]interface{}
  28072. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28073. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28075. return
  28076. }
  28077. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28078. if status == "0" {
  28079. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28080. c.ServeSuccessJSON(map[string]interface{}{
  28081. "failed_code": -10,
  28082. "msg": err_msg,
  28083. })
  28084. return
  28085. }
  28086. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28087. userJSONBytes, _ := json.Marshal(respJSON)
  28088. fmt.Println("log")
  28089. fmt.Println(string(userJSONBytes))
  28090. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  28091. utils.ErrorLog("解析失败:%v", err)
  28092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28093. return
  28094. }
  28095. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  28096. data := make(map[string]interface{})
  28097. client := &http.Client{}
  28098. data["psn_no"] = his.PsnNo
  28099. data["mdtrt_id"] = his.Number
  28100. data["operator"] = roles.UserName
  28101. data["cert_no"] = his.IdCardNo
  28102. data["org_name"] = miConfig.OrgName
  28103. data["psn_name"] = his.Name
  28104. data["ipt_otp_no"] = his.IptOtpNo
  28105. data["ipt_psn_sp_flag_type"] = "0901"
  28106. data["ipt_psn_sp_flag"] = "1"
  28107. data["fixmedins_code"] = miConfig.Code
  28108. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28109. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28110. data["url"] = miConfig.Url
  28111. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  28112. bytesData, _ := json.Marshal(data)
  28113. var req *http.Request
  28114. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  28115. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  28116. resp, _ := client.Do(req)
  28117. defer resp.Body.Close()
  28118. body, ioErr := ioutil.ReadAll(resp.Body)
  28119. if ioErr != nil {
  28120. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28122. return
  28123. }
  28124. var respJSON map[string]interface{}
  28125. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28128. return
  28129. }
  28130. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28131. if status == "0" {
  28132. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28133. c.ServeSuccessJSON(map[string]interface{}{
  28134. "failed_code": -10,
  28135. "msg": err_msg,
  28136. })
  28137. return
  28138. }
  28139. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28140. userJSONBytes, _ := json.Marshal(respJSON)
  28141. fmt.Println("log")
  28142. fmt.Println(string(userJSONBytes))
  28143. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  28144. utils.ErrorLog("解析失败:%v", err)
  28145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28146. return
  28147. }
  28148. }
  28149. if res2406.Infcode != 0 {
  28150. adminUser := c.GetAdminUserInfo()
  28151. errlog := &models.HisOrderError{
  28152. UserOrgId: adminUser.CurrentOrgId,
  28153. Ctime: time.Now().Unix(),
  28154. Mtime: time.Now().Unix(),
  28155. ErrMsg: res2406.ErrMsg,
  28156. Status: 1,
  28157. PatientId: id,
  28158. RecordTime: recordDateTime,
  28159. Stage: 3,
  28160. }
  28161. service.CreateErrMsgLog(errlog)
  28162. c.ServeSuccessJSON(map[string]interface{}{
  28163. "failed_code": -10,
  28164. "msg": res2406.ErrMsg,
  28165. })
  28166. return
  28167. }
  28168. var res2 ResultSix
  28169. var res3 GZResultSix
  28170. var resSix10265 ResultSix10265
  28171. //var time_stamp string
  28172. if miConfig.MdtrtareaAdmvs == "421300" {
  28173. data := make(map[string]interface{})
  28174. client := &http.Client{}
  28175. data["psn_no"] = his.PsnNo
  28176. data["mdtrt_id"] = his.Number
  28177. data["department"] = department.Name
  28178. data["org_name"] = miConfig.OrgName
  28179. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28180. data["doctor_id"] = doctor_info.DoctorNumber
  28181. data["doctor_name"] = roles.UserName
  28182. data["fixmedins_code"] = miConfig.Code
  28183. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28184. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28185. data["secret_key"] = miConfig.SecretKey
  28186. data["sick_code"] = sickConfig.CountryCode
  28187. data["sick_name"] = sickConfig.ClassName
  28188. data["begin_time"] = begin_time
  28189. data["dept"] = strconv.FormatInt(department.ID, 10)
  28190. data["config"] = config
  28191. data["opter"] = roles.UserName
  28192. fmt.Println(data)
  28193. bytesData, _ := json.Marshal(data)
  28194. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28195. resp, _ := client.Do(req)
  28196. defer resp.Body.Close()
  28197. body, ioErr := ioutil.ReadAll(resp.Body)
  28198. if ioErr != nil {
  28199. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28201. return
  28202. }
  28203. var respJSON map[string]interface{}
  28204. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28205. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28207. return
  28208. }
  28209. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28210. userJSONBytes, _ := json.Marshal(respJSON)
  28211. fmt.Println("log")
  28212. fmt.Println(string(userJSONBytes))
  28213. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28214. utils.ErrorLog("解析失败:%v", err)
  28215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28216. return
  28217. }
  28218. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28219. data := make(map[string]interface{})
  28220. client := &http.Client{}
  28221. data["psn_no"] = his.PsnNo
  28222. data["mdtrt_id"] = his.Number
  28223. data["department"] = department.Name
  28224. data["org_name"] = miConfig.OrgName
  28225. if reg_type == 11 && his.Insutype == "390" {
  28226. data["med_type"] = "110104"
  28227. } else {
  28228. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28229. }
  28230. data["doctor_id"] = doctor_info.DoctorNumber
  28231. data["doctor_name"] = roles.UserName
  28232. data["fixmedins_code"] = miConfig.Code
  28233. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28234. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28235. data["secret_key"] = miConfig.SecretKey
  28236. data["sick_code"] = sickConfig.CountryCode
  28237. data["sick_name"] = sickConfig.ClassName
  28238. data["begin_time"] = begin_time
  28239. data["dept"] = strconv.FormatInt(department.ID, 10)
  28240. data["config"] = config
  28241. data["opter"] = roles.UserName
  28242. fmt.Println(data)
  28243. bytesData, _ := json.Marshal(data)
  28244. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28245. resp, _ := client.Do(req)
  28246. defer resp.Body.Close()
  28247. body, ioErr := ioutil.ReadAll(resp.Body)
  28248. if ioErr != nil {
  28249. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28251. return
  28252. }
  28253. var respJSON map[string]interface{}
  28254. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28255. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28257. return
  28258. }
  28259. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28260. userJSONBytes, _ := json.Marshal(respJSON)
  28261. fmt.Println("log")
  28262. fmt.Println(string(userJSONBytes))
  28263. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28264. utils.ErrorLog("解析失败:%v", err)
  28265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28266. return
  28267. }
  28268. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28269. data := make(map[string]interface{})
  28270. client := &http.Client{}
  28271. data["psn_no"] = his.PsnNo
  28272. data["mdtrt_id"] = his.Number
  28273. data["department"] = department.Name
  28274. data["org_name"] = miConfig.OrgName
  28275. if reg_type == 11 && his.Insutype == "390" {
  28276. data["med_type"] = "110104"
  28277. } else {
  28278. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28279. }
  28280. data["doctor_id"] = doctor_info.DoctorNumber
  28281. data["doctor_name"] = roles.UserName
  28282. data["fixmedins_code"] = miConfig.Code
  28283. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28284. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28285. data["secret_key"] = miConfig.SecretKey
  28286. data["sick_code"] = sickConfig.CountryCode
  28287. data["sick_name"] = sickConfig.ClassName
  28288. data["begin_time"] = begin_time
  28289. data["dept"] = strconv.FormatInt(department.ID, 10)
  28290. data["config"] = config
  28291. data["opter"] = roles.UserName
  28292. fmt.Println(data)
  28293. bytesData, _ := json.Marshal(data)
  28294. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28295. resp, _ := client.Do(req)
  28296. defer resp.Body.Close()
  28297. body, ioErr := ioutil.ReadAll(resp.Body)
  28298. if ioErr != nil {
  28299. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28301. return
  28302. }
  28303. var respJSON map[string]interface{}
  28304. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28307. return
  28308. }
  28309. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28310. userJSONBytes, _ := json.Marshal(respJSON)
  28311. fmt.Println("log")
  28312. fmt.Println(string(userJSONBytes))
  28313. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28314. utils.ErrorLog("解析失败:%v", err)
  28315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28316. return
  28317. }
  28318. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28319. data := make(map[string]interface{})
  28320. client := &http.Client{}
  28321. data["psn_no"] = his.PsnNo
  28322. data["mdtrt_id"] = his.Number
  28323. data["department"] = department.Name
  28324. data["org_name"] = miConfig.OrgName
  28325. if reg_type == 11 && his.Insutype == "390" {
  28326. data["med_type"] = "110104"
  28327. } else {
  28328. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28329. }
  28330. data["doctor_id"] = doctor_info.DoctorNumber
  28331. data["doctor_name"] = roles.UserName
  28332. data["fixmedins_code"] = miConfig.Code
  28333. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28334. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28335. data["secret_key"] = miConfig.SecretKey
  28336. data["sick_code"] = sickConfig.CountryCode
  28337. data["sick_name"] = sickConfig.ClassName
  28338. data["begin_time"] = begin_time
  28339. data["dept"] = strconv.FormatInt(department.ID, 10)
  28340. data["config"] = config
  28341. data["opter"] = roles.UserName
  28342. fmt.Println(data)
  28343. bytesData, _ := json.Marshal(data)
  28344. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28345. resp, _ := client.Do(req)
  28346. defer resp.Body.Close()
  28347. body, ioErr := ioutil.ReadAll(resp.Body)
  28348. if ioErr != nil {
  28349. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28351. return
  28352. }
  28353. var respJSON map[string]interface{}
  28354. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28355. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28357. return
  28358. }
  28359. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28360. userJSONBytes, _ := json.Marshal(respJSON)
  28361. fmt.Println("log")
  28362. fmt.Println(string(userJSONBytes))
  28363. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28364. utils.ErrorLog("解析失败:%v", err)
  28365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28366. return
  28367. }
  28368. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28369. data := make(map[string]interface{})
  28370. client := &http.Client{}
  28371. data["psn_no"] = his.PsnNo
  28372. data["mdtrt_id"] = his.Number
  28373. data["doctor"] = roles.UserName
  28374. data["department"] = department.Name
  28375. data["org_name"] = miConfig.OrgName
  28376. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28377. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28378. data["fixmedins_code"] = miConfig.Code
  28379. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28380. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28381. data["secret_key"] = miConfig.SecretKey
  28382. data["sick_code"] = sickConfig.CountryCode
  28383. data["sick_name"] = sickConfig.ClassName
  28384. data["begin_time"] = begin_time
  28385. data["dept"] = strconv.FormatInt(department.ID, 10)
  28386. data["config"] = config
  28387. data["url"] = miConfig.Url
  28388. data["ak"] = miConfig.AccessKey
  28389. data["cainfo"] = miConfig.Cainfo
  28390. bytesData, _ := json.Marshal(data)
  28391. var req *http.Request
  28392. if miConfig.MdtrtareaAdmvs == "320921" {
  28393. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28394. } else {
  28395. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28396. }
  28397. resp, _ := client.Do(req)
  28398. defer resp.Body.Close()
  28399. body, ioErr := ioutil.ReadAll(resp.Body)
  28400. if ioErr != nil {
  28401. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28403. return
  28404. }
  28405. var respJSON map[string]interface{}
  28406. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28409. return
  28410. }
  28411. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28412. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28413. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28414. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28415. userJSONBytes, _ := json.Marshal(respJSON)
  28416. fmt.Println("log")
  28417. fmt.Println(string(userJSONBytes))
  28418. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28419. utils.ErrorLog("解析失败:%v", err)
  28420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28421. return
  28422. }
  28423. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28424. res2.Output = resSix10265.Output
  28425. res2.ErrMsg = resSix10265.ErrMsg
  28426. res2.Cainfo = resSix10265.Cainfo
  28427. res2.WarnMsg = resSix10265.WarnMsg
  28428. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28429. res2.Infcode = infocode
  28430. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28431. data := make(map[string]interface{})
  28432. client := &http.Client{}
  28433. data["psn_no"] = his.PsnNo
  28434. data["mdtrt_id"] = his.Number
  28435. data["doctor"] = roles.UserName
  28436. data["department"] = department.Name
  28437. data["org_name"] = miConfig.OrgName
  28438. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28439. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28440. data["fixmedins_code"] = miConfig.Code
  28441. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28442. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28443. data["secret_key"] = miConfig.SecretKey
  28444. data["sick_code"] = sickConfig.CountryCode
  28445. data["sick_name"] = sickConfig.ClassName
  28446. data["begin_time"] = begin_time
  28447. data["dept"] = strconv.FormatInt(department.ID, 10)
  28448. data["config"] = config
  28449. //data["url"] = miConfig.Url
  28450. //data["ak"] = miConfig.AccessKey
  28451. data["cainfo"] = miConfig.Cainfo
  28452. fmt.Println(data)
  28453. bytesData, _ := json.Marshal(data)
  28454. var req *http.Request
  28455. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  28456. resp, _ := client.Do(req)
  28457. defer resp.Body.Close()
  28458. body, ioErr := ioutil.ReadAll(resp.Body)
  28459. if ioErr != nil {
  28460. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28462. return
  28463. }
  28464. var respJSON map[string]interface{}
  28465. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28466. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28468. return
  28469. }
  28470. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28471. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28472. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28473. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28474. userJSONBytes, _ := json.Marshal(respJSON)
  28475. fmt.Println("log")
  28476. fmt.Println(string(userJSONBytes))
  28477. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28478. utils.ErrorLog("解析失败:%v", err)
  28479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28480. return
  28481. }
  28482. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28483. res2.Output = resSix10265.Output
  28484. res2.ErrMsg = resSix10265.ErrMsg
  28485. res2.Cainfo = resSix10265.Cainfo
  28486. res2.WarnMsg = resSix10265.WarnMsg
  28487. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28488. res2.Infcode = infocode
  28489. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28490. 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)
  28491. saveLog(result, requestLog, "2203", "上传就诊信息")
  28492. var respJSON2 map[string]interface{}
  28493. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28494. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28496. return
  28497. }
  28498. userJSONBytes2, _ := json.Marshal(respJSON2)
  28499. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28500. utils.ErrorLog("解析失败:%v", err)
  28501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28502. return
  28503. }
  28504. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28505. var result string
  28506. var requestLog string
  28507. 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, "")
  28508. saveLog(result, requestLog, "2203", "上传就诊信息")
  28509. var respJSON2 map[string]interface{}
  28510. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28511. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28513. return
  28514. }
  28515. userJSONBytes2, _ := json.Marshal(respJSON2)
  28516. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28517. utils.ErrorLog("解析失败:%v", err)
  28518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28519. return
  28520. }
  28521. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28522. var result string
  28523. var requestLog string
  28524. 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, "")
  28525. saveLog(result, requestLog, "2203", "上传就诊信息")
  28526. var respJSON2 map[string]interface{}
  28527. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28528. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28530. return
  28531. }
  28532. userJSONBytes2, _ := json.Marshal(respJSON2)
  28533. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28534. utils.ErrorLog("解析失败:%v", err)
  28535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28536. return
  28537. }
  28538. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28539. data := make(map[string]interface{})
  28540. client := &http.Client{}
  28541. data["psn_no"] = his.PsnNo
  28542. data["mdtrt_id"] = his.Number
  28543. data["operator"] = roles.UserName
  28544. data["department"] = department.Name
  28545. data["org_name"] = miConfig.OrgName
  28546. var med_type string
  28547. if his.Insutype == "390" {
  28548. if reg_type == 992102 {
  28549. med_type = "992102"
  28550. data["sick_code"] = "ZDZ940"
  28551. data["sick_name"] = "慢性肾衰竭"
  28552. }
  28553. if reg_type == 140104 {
  28554. med_type = "140104"
  28555. data["sick_code"] = sickConfig.CountryCode
  28556. data["sick_name"] = sickConfig.ClassName
  28557. }
  28558. if reg_type == 14 {
  28559. med_type = "140104"
  28560. data["sick_code"] = sickConfig.CountryCode
  28561. data["sick_name"] = sickConfig.ClassName
  28562. }
  28563. } else if his.Insutype == "310" {
  28564. if reg_type == 992102 {
  28565. med_type = "992102"
  28566. data["sick_code"] = "ZDZ940"
  28567. data["sick_name"] = "慢性肾衰竭"
  28568. }
  28569. if reg_type == 140104 {
  28570. med_type = "140104"
  28571. data["sick_code"] = sickConfig.CountryCode
  28572. data["sick_name"] = sickConfig.ClassName
  28573. }
  28574. if reg_type == 14 {
  28575. med_type = "14"
  28576. data["sick_code"] = sickConfig.CountryCode
  28577. data["sick_name"] = sickConfig.ClassName
  28578. }
  28579. }
  28580. data["med_type"] = med_type
  28581. data["doctor_number"] = doctor_info.DoctorNumber
  28582. data["doctor_name"] = doctor_info.UserName
  28583. data["fixmedins_code"] = miConfig.Code
  28584. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28585. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28586. data["secret_key"] = miConfig.SecretKey
  28587. data["begin_time"] = begin_time
  28588. data["dept"] = strconv.FormatInt(department.ID, 10)
  28589. data["config"] = config
  28590. data["url"] = miConfig.Url
  28591. data["ak"] = miConfig.AccessKey
  28592. data["cainfo"] = miConfig.Cainfo
  28593. bytesData, _ := json.Marshal(data)
  28594. var req *http.Request
  28595. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28596. resp, _ := client.Do(req)
  28597. defer resp.Body.Close()
  28598. body, ioErr := ioutil.ReadAll(resp.Body)
  28599. if ioErr != nil {
  28600. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28602. return
  28603. }
  28604. var respJSON map[string]interface{}
  28605. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28606. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28608. return
  28609. }
  28610. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28611. if status == "0" {
  28612. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28613. c.ServeSuccessJSON(map[string]interface{}{
  28614. "failed_code": -10,
  28615. "msg": err_msg,
  28616. })
  28617. return
  28618. }
  28619. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28620. userJSONBytes, _ := json.Marshal(respJSON)
  28621. fmt.Println("log")
  28622. fmt.Println(string(userJSONBytes))
  28623. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28624. utils.ErrorLog("解析失败:%v", err)
  28625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28626. return
  28627. }
  28628. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28629. data := make(map[string]interface{})
  28630. client := &http.Client{}
  28631. data["psn_no"] = his.PsnNo
  28632. data["mdtrt_id"] = his.Number
  28633. data["operator"] = roles.UserName
  28634. data["department"] = department.Name
  28635. data["org_name"] = miConfig.OrgName
  28636. var med_type string
  28637. if his.Insutype == "390" {
  28638. if reg_type == 992102 {
  28639. med_type = "992102"
  28640. data["sick_code"] = sickConfig.CountryCode
  28641. data["sick_name"] = sickConfig.ClassName
  28642. }
  28643. if reg_type == 140104 {
  28644. med_type = "140104"
  28645. data["sick_code"] = sickConfig.CountryCode
  28646. data["sick_name"] = sickConfig.ClassName
  28647. }
  28648. if reg_type == 140201 {
  28649. med_type = "140201"
  28650. data["sick_code"] = sickConfig.CountryCode
  28651. data["sick_name"] = sickConfig.ClassName
  28652. }
  28653. if reg_type == 14 {
  28654. med_type = "14"
  28655. data["sick_code"] = sickConfig.CountryCode
  28656. data["sick_name"] = sickConfig.ClassName
  28657. }
  28658. } else if his.Insutype == "310" {
  28659. if reg_type == 992102 {
  28660. med_type = "992102"
  28661. data["sick_code"] = sickConfig.CountryCode
  28662. data["sick_name"] = sickConfig.ClassName
  28663. }
  28664. if reg_type == 140104 {
  28665. med_type = "140104"
  28666. data["sick_code"] = sickConfig.CountryCode
  28667. data["sick_name"] = sickConfig.ClassName
  28668. }
  28669. if reg_type == 140201 {
  28670. med_type = "140201"
  28671. data["sick_code"] = sickConfig.CountryCode
  28672. data["sick_name"] = sickConfig.ClassName
  28673. }
  28674. if reg_type == 14 {
  28675. med_type = "14"
  28676. data["sick_code"] = sickConfig.CountryCode
  28677. data["sick_name"] = sickConfig.ClassName
  28678. }
  28679. }
  28680. data["med_type"] = med_type
  28681. data["doctor_number"] = doctor_info.DoctorNumber
  28682. data["doctor_name"] = doctor_info.UserName
  28683. data["fixmedins_code"] = miConfig.Code
  28684. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28685. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28686. data["secret_key"] = miConfig.SecretKey
  28687. data["begin_time"] = begin_time
  28688. data["dept"] = strconv.FormatInt(department.ID, 10)
  28689. data["config"] = config
  28690. data["url"] = miConfig.Url
  28691. data["ak"] = miConfig.AccessKey
  28692. data["cainfo"] = miConfig.Cainfo
  28693. bytesData, _ := json.Marshal(data)
  28694. var req *http.Request
  28695. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28696. resp, _ := client.Do(req)
  28697. defer resp.Body.Close()
  28698. body, ioErr := ioutil.ReadAll(resp.Body)
  28699. if ioErr != nil {
  28700. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28702. return
  28703. }
  28704. var respJSON map[string]interface{}
  28705. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28706. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28708. return
  28709. }
  28710. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28711. if status == "0" {
  28712. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28713. c.ServeSuccessJSON(map[string]interface{}{
  28714. "failed_code": -10,
  28715. "msg": err_msg,
  28716. })
  28717. return
  28718. }
  28719. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28720. userJSONBytes, _ := json.Marshal(respJSON)
  28721. fmt.Println("log")
  28722. fmt.Println(string(userJSONBytes))
  28723. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28724. utils.ErrorLog("解析失败:%v", err)
  28725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28726. return
  28727. }
  28728. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28729. var result string
  28730. var requestLog string
  28731. 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, "")
  28732. saveLog(result, requestLog, "2203", "上传就诊信息")
  28733. var respJSON2 map[string]interface{}
  28734. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28735. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28737. return
  28738. }
  28739. userJSONBytes2, _ := json.Marshal(respJSON2)
  28740. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28741. utils.ErrorLog("解析失败:%v", err)
  28742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28743. return
  28744. }
  28745. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28746. data := make(map[string]interface{})
  28747. client := &http.Client{}
  28748. data["psn_no"] = his.PsnNo
  28749. data["mdtrt_id"] = his.Number
  28750. data["doctor"] = roles.UserName
  28751. data["department"] = department.Name
  28752. data["org_name"] = miConfig.OrgName
  28753. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28754. data["doctor_id"] = doctor_info.DoctorNumber
  28755. data["fixmedins_code"] = miConfig.Code
  28756. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28757. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28758. data["secret_key"] = miConfig.SecretKey
  28759. data["sick_code"] = sickConfig.CountryCode
  28760. data["sick_name"] = sickConfig.ClassName
  28761. data["begin_time"] = begin_time
  28762. data["new_doctor_name"] = doctor_info.UserName
  28763. data["dept"] = strconv.FormatInt(department.ID, 10)
  28764. data["config"] = config
  28765. bytesData, _ := json.Marshal(data)
  28766. var req *http.Request
  28767. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  28768. resp, _ := client.Do(req)
  28769. defer resp.Body.Close()
  28770. body, ioErr := ioutil.ReadAll(resp.Body)
  28771. if ioErr != nil {
  28772. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28774. return
  28775. }
  28776. var respJSON map[string]interface{}
  28777. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28778. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28780. return
  28781. }
  28782. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28783. userJSONBytes, _ := json.Marshal(respJSON)
  28784. fmt.Println("log")
  28785. fmt.Println(string(userJSONBytes))
  28786. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28787. utils.ErrorLog("解析失败:%v", err)
  28788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28789. return
  28790. }
  28791. } else {
  28792. var result string
  28793. var requestLog string
  28794. if miConfig.MdtrtareaAdmvs == "440781" { //
  28795. 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)
  28796. } else {
  28797. if miConfig.Code == "H15049901371" {
  28798. //赤峰地区国家医保医疗类别
  28799. //职工透析:医疗类别选特殊情况门诊990502
  28800. //居民定额血透门慢: 医疗类别选门诊慢病140104
  28801. var med_type string
  28802. if his.Insutype == "390" {
  28803. if reg_type == 14 {
  28804. med_type = "9933"
  28805. } else if reg_type == 11 {
  28806. med_type = "11"
  28807. }
  28808. } else if his.Insutype == "310" {
  28809. if reg_type == 14 {
  28810. med_type = "990502"
  28811. } else if reg_type == 11 {
  28812. med_type = "11"
  28813. }
  28814. }
  28815. 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)
  28816. } else {
  28817. 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)
  28818. }
  28819. saveLog(result, requestLog, "2203", "上传就诊信息")
  28820. var respJSON2 map[string]interface{}
  28821. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28822. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28824. return
  28825. }
  28826. userJSONBytes2, _ := json.Marshal(respJSON2)
  28827. if miConfig.Code == "H15049901371" {
  28828. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  28829. utils.ErrorLog("解析失败:%v", err)
  28830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28831. return
  28832. }
  28833. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28834. res2.Output = resSix10265.Output
  28835. res2.ErrMsg = resSix10265.ErrMsg
  28836. res2.Cainfo = resSix10265.Cainfo
  28837. res2.WarnMsg = resSix10265.WarnMsg
  28838. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28839. res2.Infcode = infocode
  28840. } else {
  28841. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28842. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  28843. utils.ErrorLog("解析失败:%v", err)
  28844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28845. return
  28846. }
  28847. res2.Infcode = res3.Infcode
  28848. } else {
  28849. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28850. utils.ErrorLog("解析失败:%v", err)
  28851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28852. return
  28853. }
  28854. }
  28855. }
  28856. }
  28857. }
  28858. if res2.Infcode == -1 {
  28859. adminUser := c.GetAdminUserInfo()
  28860. errlog := &models.HisOrderError{
  28861. UserOrgId: adminUser.CurrentOrgId,
  28862. Ctime: time.Now().Unix(),
  28863. Mtime: time.Now().Unix(),
  28864. ErrMsg: res2.ErrMsg,
  28865. Status: 1,
  28866. PatientId: id,
  28867. RecordTime: recordDateTime,
  28868. Stage: 3,
  28869. }
  28870. service.CreateErrMsgLog(errlog)
  28871. c.ServeSuccessJSON(map[string]interface{}{
  28872. "failed_code": -10,
  28873. "msg": res2.ErrMsg,
  28874. })
  28875. return
  28876. }
  28877. if res2.Infcode != 0 {
  28878. adminUser := c.GetAdminUserInfo()
  28879. errlog := &models.HisOrderError{
  28880. UserOrgId: adminUser.CurrentOrgId,
  28881. Ctime: time.Now().Unix(),
  28882. Mtime: time.Now().Unix(),
  28883. ErrMsg: res2.ErrMsg,
  28884. Status: 1,
  28885. PatientId: id,
  28886. RecordTime: recordDateTime,
  28887. Stage: 3,
  28888. }
  28889. service.CreateErrMsgLog(errlog)
  28890. c.ServeSuccessJSON(map[string]interface{}{
  28891. "failed_code": -10,
  28892. "msg": res2.ErrMsg,
  28893. })
  28894. return
  28895. } else {
  28896. his.Diagnosis = diagnosis_id
  28897. his.SickType = sickConfig.ID
  28898. his.PType = fmt.Sprintf("%d", reg_type)
  28899. service.UpdateHisPatientThree(&his)
  28900. data := make(map[string]interface{})
  28901. if settle_accounts_type == 1 { //日结
  28902. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  28903. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  28904. } else {
  28905. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  28906. }
  28907. data["pre"] = prescriptions
  28908. } else { //月结
  28909. start_time_str := c.GetString("start_time")
  28910. end_time_str := c.GetString("end_time")
  28911. timeLayout := "2006-01-02"
  28912. loc, _ := time.LoadLocation("Local")
  28913. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  28914. if err != nil {
  28915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28916. return
  28917. }
  28918. recordStartTime := theStartTime.Unix()
  28919. start_time = recordStartTime
  28920. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  28921. if err != nil {
  28922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28923. return
  28924. }
  28925. recordEndTime := theEndTime.Unix()
  28926. end_time = recordEndTime
  28927. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  28928. data["pre"] = prescriptions
  28929. }
  28930. client := &http.Client{}
  28931. data["psn_no"] = his.PsnNo
  28932. data["mdtrt_id"] = his.Number
  28933. data["chrg_bchno"] = new_chrg_bchno
  28934. data["org_name"] = miConfig.OrgName
  28935. data["doctor"] = doctor_info.UserName
  28936. data["doctor_id"] = doctor_info.DoctorNumber
  28937. data["dept"] = department.Name
  28938. data["fixmedins_code"] = miConfig.Code
  28939. data["opter"] = roles.UserName
  28940. data["dept_code"] = department.Number
  28941. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28942. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28943. data["secret_key"] = miConfig.SecretKey
  28944. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  28945. data["url"] = miConfig.Url
  28946. data["ak"] = miConfig.AccessKey
  28947. data["new_doctor_name"] = patientPrescription.Doctor
  28948. if his.Insutype == "390" {
  28949. if reg_type == 992102 {
  28950. data["diag_code"] = "ZDZ940"
  28951. }
  28952. if reg_type == 140104 {
  28953. data["diag_code"] = sickConfig.CountryCode
  28954. }
  28955. if reg_type == 140201 {
  28956. data["diag_code"] = sickConfig.CountryCode
  28957. }
  28958. if reg_type == 14 {
  28959. data["diag_code"] = sickConfig.CountryCode
  28960. }
  28961. } else if his.Insutype == "310" {
  28962. if miConfig.MdtrtareaAdmvs == "341203" {
  28963. if reg_type == 992102 {
  28964. data["diag_code"] = "ZDZ940"
  28965. }
  28966. if reg_type != 992102 {
  28967. data["diag_code"] = sickConfig.CountryCode
  28968. }
  28969. } else {
  28970. data["diag_code"] = sickConfig.CountryCode
  28971. }
  28972. }
  28973. data["cainfo"] = miConfig.Cainfo
  28974. data["opter"] = roles.UserName
  28975. var ids []int64
  28976. for _, item := range prescriptions {
  28977. ids = append(ids, item.ID)
  28978. }
  28979. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28980. if config.IsOpen == 1 { //对接了医保,走医保流程
  28981. var res ResultFour
  28982. var resFour10265 ResultFour10265
  28983. if miConfig.MdtrtareaAdmvs == "421300" {
  28984. bytesData, _ := json.Marshal(data)
  28985. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28986. resp, _ := client.Do(req)
  28987. defer resp.Body.Close()
  28988. body, ioErr := ioutil.ReadAll(resp.Body)
  28989. if ioErr != nil {
  28990. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28992. return
  28993. }
  28994. var respJSON map[string]interface{}
  28995. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28996. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28998. return
  28999. }
  29000. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29001. userJSONBytes, _ := json.Marshal(respJSON)
  29002. fmt.Println("log")
  29003. fmt.Println(string(userJSONBytes))
  29004. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29005. utils.ErrorLog("解析失败:%v", err)
  29006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29007. return
  29008. }
  29009. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29010. bytesData, _ := json.Marshal(data)
  29011. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  29012. resp, _ := client.Do(req)
  29013. defer resp.Body.Close()
  29014. body, ioErr := ioutil.ReadAll(resp.Body)
  29015. if ioErr != nil {
  29016. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29018. return
  29019. }
  29020. var respJSON map[string]interface{}
  29021. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29022. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29024. return
  29025. }
  29026. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29027. userJSONBytes, _ := json.Marshal(respJSON)
  29028. fmt.Println("log")
  29029. fmt.Println(string(userJSONBytes))
  29030. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29031. utils.ErrorLog("解析失败:%v", err)
  29032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29033. return
  29034. }
  29035. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29036. bytesData, _ := json.Marshal(data)
  29037. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  29038. resp, _ := client.Do(req)
  29039. defer resp.Body.Close()
  29040. body, ioErr := ioutil.ReadAll(resp.Body)
  29041. if ioErr != nil {
  29042. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29044. return
  29045. }
  29046. var respJSON map[string]interface{}
  29047. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29048. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29050. return
  29051. }
  29052. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29053. userJSONBytes, _ := json.Marshal(respJSON)
  29054. fmt.Println("log")
  29055. fmt.Println(string(userJSONBytes))
  29056. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29057. utils.ErrorLog("解析失败:%v", err)
  29058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29059. return
  29060. }
  29061. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29062. bytesData, _ := json.Marshal(data)
  29063. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  29064. resp, _ := client.Do(req)
  29065. defer resp.Body.Close()
  29066. body, ioErr := ioutil.ReadAll(resp.Body)
  29067. if ioErr != nil {
  29068. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29070. return
  29071. }
  29072. var respJSON map[string]interface{}
  29073. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29074. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29076. return
  29077. }
  29078. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29079. userJSONBytes, _ := json.Marshal(respJSON)
  29080. fmt.Println("log")
  29081. fmt.Println(string(userJSONBytes))
  29082. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29083. utils.ErrorLog("解析失败:%v", err)
  29084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29085. return
  29086. }
  29087. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29088. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29089. if result3101.Infcode == "0" {
  29090. if len(result3101.Output.Result) > 0 {
  29091. var errMsgs []string
  29092. for _, item := range result3101.Output.Result {
  29093. errMsgs = append(errMsgs, item.VolaCont)
  29094. }
  29095. c.ServeSuccessJSON(map[string]interface{}{
  29096. "failed_code": -10,
  29097. "msg": errMsgs,
  29098. })
  29099. return
  29100. } else {
  29101. if miConfig.MdtrtareaAdmvs == "320921" {
  29102. data["doctor_id"] = "D320923012139"
  29103. } else {
  29104. data["doctor_id"] = "D371621008686"
  29105. }
  29106. bytesData, _ := json.Marshal(data)
  29107. var req *http.Request
  29108. if miConfig.MdtrtareaAdmvs == "320921" {
  29109. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29110. } else {
  29111. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29112. }
  29113. resp, _ := client.Do(req)
  29114. defer resp.Body.Close()
  29115. body, ioErr := ioutil.ReadAll(resp.Body)
  29116. if ioErr != nil {
  29117. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29119. return
  29120. }
  29121. var respJSON map[string]interface{}
  29122. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29123. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29125. return
  29126. }
  29127. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29128. userJSONBytes, _ := json.Marshal(respJSON)
  29129. fmt.Println("log")
  29130. fmt.Println(string(userJSONBytes))
  29131. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29132. utils.ErrorLog("解析失败:%v", err)
  29133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29134. return
  29135. }
  29136. res.InfRefmsgid = resFour10265.InfRefmsgid
  29137. res.Output = resFour10265.Output
  29138. res.ErrMsg = resFour10265.ErrMsg
  29139. res.Cainfo = resFour10265.Cainfo
  29140. res.WarnMsg = resFour10265.WarnMsg
  29141. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29142. res.Infcode = infocode
  29143. }
  29144. }
  29145. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29146. var pagesize int = 5
  29147. var start int = 1
  29148. var stop int
  29149. var pagecount int
  29150. var curpage int
  29151. data["doctor_id"] = doctor_info.DoctorNumber
  29152. var res2 ResultFour
  29153. //var result res.
  29154. //总页数,向上取整,注意除之前要先转换类型为float64
  29155. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  29156. for curpage = 1; curpage <= pagecount; curpage++ {
  29157. if curpage == 1 {
  29158. start = 1
  29159. } else {
  29160. start = (curpage-1)*pagesize + 1
  29161. }
  29162. stop = curpage * pagesize
  29163. if stop > len(prescriptions) {
  29164. stop = len(prescriptions)
  29165. }
  29166. //var requestLog string
  29167. data["pre"] = prescriptions[start-1 : stop]
  29168. fmt.Println(data["pre"])
  29169. bytesData, _ := json.Marshal(data)
  29170. var req *http.Request
  29171. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  29172. resp, _ := client.Do(req)
  29173. defer resp.Body.Close()
  29174. body, ioErr := ioutil.ReadAll(resp.Body)
  29175. if ioErr != nil {
  29176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29178. return
  29179. }
  29180. var respJSON map[string]interface{}
  29181. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29184. return
  29185. }
  29186. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29187. userJSONBytes, _ := json.Marshal(respJSON)
  29188. fmt.Println("log")
  29189. fmt.Println(string(userJSONBytes))
  29190. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29191. utils.ErrorLog("解析失败:%v", err)
  29192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29193. return
  29194. }
  29195. res.InfRefmsgid = resFour10265.InfRefmsgid
  29196. res.Output = resFour10265.Output
  29197. res.ErrMsg = resFour10265.ErrMsg
  29198. res.Cainfo = resFour10265.Cainfo
  29199. res.WarnMsg = resFour10265.WarnMsg
  29200. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29201. res.Infcode = infocode
  29202. if infocode == 0 {
  29203. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  29204. } else {
  29205. isSuccess = false
  29206. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  29207. res.Infcode = -1
  29208. res.ErrMsg = resFour10265.ErrMsg
  29209. errlog := &models.HisOrderError{
  29210. UserOrgId: adminUser.CurrentOrgId,
  29211. Ctime: time.Now().Unix(),
  29212. Mtime: time.Now().Unix(),
  29213. Number: chrg_bchno,
  29214. ErrMsg: "",
  29215. Status: 1,
  29216. PatientId: id,
  29217. RecordTime: recordDateTime,
  29218. Stage: 4,
  29219. }
  29220. service.CreateErrMsgLog(errlog)
  29221. }
  29222. }
  29223. if isSuccess {
  29224. res.Infcode = 0
  29225. res.Output.Result = res2.Output.Result
  29226. } else {
  29227. order := &models.HisOrder{
  29228. UserOrgId: adminUser.CurrentOrgId,
  29229. HisPatientId: his.ID,
  29230. PatientId: his.PatientId,
  29231. SettleAccountsDate: recordDateTime,
  29232. Ctime: time.Now().Unix(),
  29233. Mtime: time.Now().Unix(),
  29234. MdtrtId: his.Number,
  29235. PsnNo: his.PsnNo,
  29236. MedType: strconv.FormatInt(reg_type, 10),
  29237. Status: 1,
  29238. Number: chrg_bchno,
  29239. Infcode: res.Infcode,
  29240. WarnMsg: res.WarnMsg,
  29241. Cainfo: res.Cainfo,
  29242. ErrMsg: res.ErrMsg,
  29243. RespondTime: res.RefmsgTime,
  29244. InfRefmsgid: res.InfRefmsgid,
  29245. OrderStatus: 1,
  29246. IsMedicineInsurance: 1,
  29247. SettleType: settle_accounts_type,
  29248. SettleStartTime: start_time,
  29249. SettleEndTime: end_time,
  29250. Creator: roles.AdminUserId,
  29251. Modify: roles.AdminUserId,
  29252. PType: 2,
  29253. Diagnosis: diagnosis_id,
  29254. }
  29255. err = service.CreateOrder(order)
  29256. if err != nil {
  29257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29258. return
  29259. }
  29260. c.ServeSuccessJSON(map[string]interface{}{
  29261. "failed_code": -10,
  29262. "msg": res2.ErrMsg,
  29263. })
  29264. return
  29265. }
  29266. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29267. 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)
  29268. var dat map[string]interface{}
  29269. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29270. fmt.Println(dat)
  29271. } else {
  29272. fmt.Println(err)
  29273. }
  29274. saveLog(result, request_log, "2204", "上传费用明细")
  29275. userJSONBytes, _ := json.Marshal(dat)
  29276. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29277. utils.ErrorLog("解析失败:%v", err)
  29278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29279. return
  29280. }
  29281. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29282. 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, "", "")
  29283. var dat map[string]interface{}
  29284. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29285. fmt.Println(dat)
  29286. } else {
  29287. fmt.Println(err)
  29288. }
  29289. saveLog(result, request_log, "2204", "上传费用明细")
  29290. userJSONBytes, _ := json.Marshal(dat)
  29291. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29292. utils.ErrorLog("解析失败:%v", err)
  29293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29294. return
  29295. }
  29296. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29297. 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, "", "")
  29298. var dat map[string]interface{}
  29299. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29300. fmt.Println(dat)
  29301. } else {
  29302. fmt.Println(err)
  29303. }
  29304. saveLog(result, request_log, "2204", "上传费用明细")
  29305. userJSONBytes, _ := json.Marshal(dat)
  29306. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29307. utils.ErrorLog("解析失败:%v", err)
  29308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29309. return
  29310. }
  29311. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29312. bytesData, _ := json.Marshal(data)
  29313. var req *http.Request
  29314. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29315. resp, _ := client.Do(req)
  29316. defer resp.Body.Close()
  29317. body, ioErr := ioutil.ReadAll(resp.Body)
  29318. if ioErr != nil {
  29319. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29321. return
  29322. }
  29323. var respJSON map[string]interface{}
  29324. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29325. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29327. return
  29328. }
  29329. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29330. if status == "0" {
  29331. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29332. c.ServeSuccessJSON(map[string]interface{}{
  29333. "failed_code": -10,
  29334. "msg": err_msg,
  29335. })
  29336. return
  29337. }
  29338. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29339. userJSONBytes, _ := json.Marshal(respJSON)
  29340. fmt.Println("log")
  29341. fmt.Println(string(userJSONBytes))
  29342. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29343. utils.ErrorLog("解析失败:%v", err)
  29344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29345. return
  29346. }
  29347. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29348. bytesData, _ := json.Marshal(data)
  29349. var req *http.Request
  29350. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29351. resp, _ := client.Do(req)
  29352. defer resp.Body.Close()
  29353. body, ioErr := ioutil.ReadAll(resp.Body)
  29354. if ioErr != nil {
  29355. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29357. return
  29358. }
  29359. var respJSON map[string]interface{}
  29360. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29361. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29363. return
  29364. }
  29365. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29366. if status == "0" {
  29367. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29368. c.ServeSuccessJSON(map[string]interface{}{
  29369. "failed_code": -10,
  29370. "msg": err_msg,
  29371. })
  29372. return
  29373. }
  29374. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29375. userJSONBytes, _ := json.Marshal(respJSON)
  29376. fmt.Println("log")
  29377. fmt.Println(string(userJSONBytes))
  29378. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29379. utils.ErrorLog("解析失败:%v", err)
  29380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29381. return
  29382. }
  29383. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29384. 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, "", "")
  29385. var dat map[string]interface{}
  29386. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29387. fmt.Println(dat)
  29388. } else {
  29389. fmt.Println(err)
  29390. }
  29391. saveLog(result, request_log, "2204", "上传费用明细")
  29392. userJSONBytes, _ := json.Marshal(dat)
  29393. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29394. utils.ErrorLog("解析失败:%v", err)
  29395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29396. return
  29397. }
  29398. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29399. bytesData, _ := json.Marshal(data)
  29400. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  29401. resp, _ := client.Do(req)
  29402. defer resp.Body.Close()
  29403. body, ioErr := ioutil.ReadAll(resp.Body)
  29404. if ioErr != nil {
  29405. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29407. return
  29408. }
  29409. var respJSON map[string]interface{}
  29410. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29411. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29413. return
  29414. }
  29415. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29416. userJSONBytes, _ := json.Marshal(respJSON)
  29417. fmt.Println("log")
  29418. fmt.Println(string(userJSONBytes))
  29419. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29420. utils.ErrorLog("解析失败:%v", err)
  29421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29422. return
  29423. }
  29424. } else {
  29425. if miConfig.MdtrtareaAdmvs == "441202" {
  29426. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29427. if result3101.Infcode == 0 {
  29428. if len(result3101.Output.Result) > 0 {
  29429. var errMsgs []string
  29430. for _, item := range result3101.Output.Result {
  29431. errMsgs = append(errMsgs, item.VolaCont)
  29432. }
  29433. c.ServeSuccessJSON(map[string]interface{}{
  29434. "failed_code": -10,
  29435. "msg": errMsgs,
  29436. })
  29437. return
  29438. } else {
  29439. 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)
  29440. var dat map[string]interface{}
  29441. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29442. fmt.Println(dat)
  29443. } else {
  29444. fmt.Println(err)
  29445. }
  29446. saveLog(result, request_log, "2204", "上传费用明细")
  29447. userJSONBytes, _ := json.Marshal(dat)
  29448. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29449. utils.ErrorLog("解析失败:%v", err)
  29450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29451. return
  29452. }
  29453. }
  29454. } else {
  29455. c.ServeSuccessJSON(map[string]interface{}{
  29456. "failed_code": -10,
  29457. "msg": result3101.ErrMsg,
  29458. })
  29459. return
  29460. }
  29461. } else if miConfig.MdtrtareaAdmvs == "440205" {
  29462. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29463. if result3101.Infcode == 0 {
  29464. if len(result3101.Output.Result) > 0 {
  29465. var errMsgs []string
  29466. for _, item := range result3101.Output.Result {
  29467. errMsgs = append(errMsgs, item.VolaCont)
  29468. }
  29469. c.ServeSuccessJSON(map[string]interface{}{
  29470. "failed_code": -10,
  29471. "msg": errMsgs,
  29472. })
  29473. return
  29474. } else {
  29475. 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)
  29476. var dat map[string]interface{}
  29477. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29478. fmt.Println(dat)
  29479. } else {
  29480. fmt.Println(err)
  29481. }
  29482. saveLog(result, request_log, "2204", "上传费用明细")
  29483. userJSONBytes, _ := json.Marshal(dat)
  29484. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29485. utils.ErrorLog("解析失败:%v", err)
  29486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29487. return
  29488. }
  29489. }
  29490. } else {
  29491. c.ServeSuccessJSON(map[string]interface{}{
  29492. "failed_code": -10,
  29493. "msg": result3101.ErrMsg,
  29494. })
  29495. return
  29496. }
  29497. } else {
  29498. if miConfig.Code == "H15049901371" {
  29499. 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)
  29500. var dat map[string]interface{}
  29501. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29502. fmt.Println(dat)
  29503. } else {
  29504. fmt.Println(err)
  29505. }
  29506. saveLog(result, request_log, "2204", "上传费用明细")
  29507. userJSONBytes, _ := json.Marshal(dat)
  29508. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29509. utils.ErrorLog("解析失败:%v", err)
  29510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29511. return
  29512. }
  29513. res.InfRefmsgid = resFour10265.InfRefmsgid
  29514. res.Output = resFour10265.Output
  29515. res.ErrMsg = resFour10265.ErrMsg
  29516. res.Cainfo = resFour10265.Cainfo
  29517. res.WarnMsg = resFour10265.WarnMsg
  29518. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29519. res.Infcode = infocode
  29520. } else {
  29521. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" || miConfig.Code == "H44030500255" {
  29522. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29523. if result3101.Infcode == 0 {
  29524. if len(result3101.Output.Result) > 0 {
  29525. c.ServeSuccessJSON(map[string]interface{}{
  29526. "failed_code": -10,
  29527. "failed_type": 100,
  29528. "warm_type": 1,
  29529. "msg": result3101,
  29530. })
  29531. return
  29532. } else {
  29533. 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)
  29534. var dat map[string]interface{}
  29535. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29536. fmt.Println(dat)
  29537. } else {
  29538. fmt.Println(err)
  29539. }
  29540. saveLog(result, request_log, "2204", "上传费用明细")
  29541. userJSONBytes, _ := json.Marshal(dat)
  29542. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29543. utils.ErrorLog("解析失败:%v", err)
  29544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29545. return
  29546. }
  29547. }
  29548. } else {
  29549. c.ServeSuccessJSON(map[string]interface{}{
  29550. "failed_code": -10,
  29551. "msg": result3101.ErrMsg,
  29552. })
  29553. return
  29554. }
  29555. } else {
  29556. 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)
  29557. var dat map[string]interface{}
  29558. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29559. fmt.Println(dat)
  29560. } else {
  29561. fmt.Println(err)
  29562. }
  29563. saveLog(result, request_log, "2204", "上传费用明细")
  29564. userJSONBytes, _ := json.Marshal(dat)
  29565. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29566. utils.ErrorLog("解析失败:%v", err)
  29567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29568. return
  29569. }
  29570. }
  29571. }
  29572. }
  29573. }
  29574. var total_two float64
  29575. if res.Infcode == -1 {
  29576. errlog := &models.HisOrderError{
  29577. UserOrgId: adminUser.CurrentOrgId,
  29578. Ctime: time.Now().Unix(),
  29579. Mtime: time.Now().Unix(),
  29580. Number: chrg_bchno,
  29581. ErrMsg: res.ErrMsg,
  29582. Status: 1,
  29583. PatientId: id,
  29584. RecordTime: recordDateTime,
  29585. Stage: 4,
  29586. }
  29587. service.CreateErrMsgLog(errlog)
  29588. c.ServeSuccessJSON(map[string]interface{}{
  29589. "failed_code": -10,
  29590. "msg": res.ErrMsg,
  29591. })
  29592. return
  29593. }
  29594. if res.Infcode == 0 {
  29595. order := &models.HisOrder{
  29596. UserOrgId: adminUser.CurrentOrgId,
  29597. HisPatientId: his.ID,
  29598. PatientId: his.PatientId,
  29599. SettleAccountsDate: recordDateTime,
  29600. Ctime: time.Now().Unix(),
  29601. Mtime: time.Now().Unix(),
  29602. MdtrtId: his.Number,
  29603. PsnNo: his.PsnNo,
  29604. MedType: strconv.FormatInt(reg_type, 10),
  29605. Status: 1,
  29606. Number: chrg_bchno,
  29607. Infcode: res.Infcode,
  29608. WarnMsg: res.WarnMsg,
  29609. Cainfo: res.Cainfo,
  29610. ErrMsg: res.ErrMsg,
  29611. RespondTime: res.RefmsgTime,
  29612. InfRefmsgid: res.InfRefmsgid,
  29613. OrderStatus: 1,
  29614. IsMedicineInsurance: 1,
  29615. SettleType: settle_accounts_type,
  29616. SettleStartTime: start_time,
  29617. SettleEndTime: end_time,
  29618. Creator: roles.AdminUserId,
  29619. Modify: roles.AdminUserId,
  29620. PType: 2,
  29621. Diagnosis: diagnosis_id,
  29622. }
  29623. err = service.CreateOrder(order)
  29624. if err != nil {
  29625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29626. return
  29627. }
  29628. for _, item := range res.Output.Result {
  29629. temp := strings.Split(item.FeedetlSn, "-")
  29630. var advice_id int64 = 0
  29631. var project_id int64 = 0
  29632. var types int64 = 0
  29633. id, _ := strconv.ParseInt(temp[2], 10, 64)
  29634. types, _ = strconv.ParseInt(temp[1], 10, 64)
  29635. if temp[1] == "1" {
  29636. advice_id = id
  29637. project_id = 0
  29638. } else if temp[1] == "2" {
  29639. advice_id = 0
  29640. project_id = id
  29641. }
  29642. total_two = total_two + item.DetItemFeeSumamt
  29643. info := &models.HisOrderInfo{
  29644. OrderNumber: order.Number,
  29645. FeedetlSn: item.FeedetlSn,
  29646. UploadDate: time.Now().Unix(),
  29647. AdviceId: advice_id,
  29648. DetItemFeeSumamt: item.DetItemFeeSumamt,
  29649. Cnt: item.Cnt,
  29650. Pric: float64(item.Pric),
  29651. PatientId: his.PatientId,
  29652. PricUplmtAmt: item.PricUplmtAmt,
  29653. SelfpayProp: item.SelfpayProp,
  29654. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  29655. OverlmtAmt: item.OverlmtAmt,
  29656. PreselfpayAmt: item.PreselfpayAmt,
  29657. BasMednFlag: item.BasMednFlag,
  29658. MedChrgitmType: item.MedChrgitmType,
  29659. HiNegoDrugFlag: item.HiNegoDrugFlag,
  29660. Status: 1,
  29661. Memo: item.Memo,
  29662. Mtime: time.Now().Unix(),
  29663. InscpScpAmt: item.InscpScpAmt,
  29664. DrtReimFlag: item.DrtReimFlag,
  29665. Ctime: time.Now().Unix(),
  29666. ListSpItemFlag: item.ListSpItemFlag,
  29667. ChldMedcFlag: item.ChldMedcFlag,
  29668. LmtUsedFlag: item.LmtUsedFlag,
  29669. ChrgitmLv: item.ChrgitmLv,
  29670. UserOrgId: adminUser.CurrentOrgId,
  29671. HisPatientId: his.ID,
  29672. OrderId: order.ID,
  29673. ProjectId: project_id,
  29674. Type: types,
  29675. }
  29676. service.CreateOrderInfo(info)
  29677. }
  29678. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  29679. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  29680. var total float64
  29681. for _, item := range prescriptions {
  29682. if item.Type == 1 { //药品
  29683. for _, subItem := range item.HisDoctorAdviceInfo {
  29684. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29685. total_one := price * subItem.PrescribingNumber
  29686. fmt.Println("subItem")
  29687. fmt.Println(subItem.Price)
  29688. fmt.Println("price")
  29689. fmt.Println(price)
  29690. fmt.Println("total_one")
  29691. fmt.Println(total_one)
  29692. total = total + total_one
  29693. fmt.Println(total)
  29694. }
  29695. }
  29696. if item.Type == 2 { //项目
  29697. for _, subItem := range item.HisPrescriptionProject {
  29698. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  29699. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29700. total_one := price * cnt
  29701. total = total + total_one
  29702. }
  29703. }
  29704. }
  29705. allTotal := fmt.Sprintf("%.2f", total)
  29706. if res.Infcode == 0 {
  29707. var rf []*ResultFive
  29708. json.Unmarshal([]byte(his.Iinfo), &rf)
  29709. chrg_bchno := chrg_bchno
  29710. cert_no := his.Certno
  29711. var insutypes []string
  29712. var insutype string
  29713. var is390 int = 0
  29714. var is310 int = 0
  29715. for _, item := range rf {
  29716. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  29717. insutypes = append(insutypes, item.Insutype)
  29718. }
  29719. }
  29720. if len(insutypes) == 1 {
  29721. insutype = insutypes[0]
  29722. } else {
  29723. for _, i := range insutypes {
  29724. if i == "390" {
  29725. is390 = 1
  29726. }
  29727. if i == "310" {
  29728. is310 = 1
  29729. }
  29730. }
  29731. }
  29732. if is390 == 1 {
  29733. insutype = "390"
  29734. }
  29735. if is310 == 1 {
  29736. insutype = "310"
  29737. }
  29738. if len(insutypes) == 0 {
  29739. insutype = "390"
  29740. }
  29741. if len(insutypes) == 2 {
  29742. insutype = strconv.FormatInt(his.SocialType, 10)
  29743. }
  29744. //insutype = "390"
  29745. if his.IdCardType == 1 {
  29746. cert_no = his.MedicalInsuranceNumber
  29747. } else {
  29748. cert_no = his.Certno
  29749. }
  29750. var res ResultSeven
  29751. var ahres ResultSevenAH
  29752. var resSeven10265 ResultSeven10265
  29753. var resSeven10265Two ResultSeven10265Two
  29754. var gzresSeven10265Two GZResultSeven10265Two
  29755. if miConfig.MdtrtareaAdmvs == "421300" {
  29756. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  29757. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29758. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29759. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29760. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29761. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29762. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29763. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29764. resp, requestErr := http.Get(api)
  29765. if requestErr != nil {
  29766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29767. return
  29768. }
  29769. body, ioErr := ioutil.ReadAll(resp.Body)
  29770. if ioErr != nil {
  29771. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29773. return
  29774. }
  29775. var respJSON map[string]interface{}
  29776. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29777. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29779. return
  29780. }
  29781. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29782. result, _ := json.Marshal(respJSON)
  29783. fmt.Println("log")
  29784. fmt.Println(string(result))
  29785. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29786. utils.ErrorLog("解析失败:%v", err)
  29787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29788. return
  29789. }
  29790. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29791. if reg_type == 11 && his.Insutype == "390" {
  29792. reg_type = 110104
  29793. }
  29794. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29795. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29796. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29797. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29798. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29799. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29800. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29801. resp, requestErr := http.Get(api)
  29802. if requestErr != nil {
  29803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29804. return
  29805. }
  29806. body, ioErr := ioutil.ReadAll(resp.Body)
  29807. if ioErr != nil {
  29808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29810. return
  29811. }
  29812. var respJSON map[string]interface{}
  29813. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29814. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29816. return
  29817. }
  29818. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29819. result, _ := json.Marshal(respJSON)
  29820. fmt.Println("log")
  29821. fmt.Println(string(result))
  29822. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29823. utils.ErrorLog("解析失败:%v", err)
  29824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29825. return
  29826. }
  29827. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29828. if reg_type == 11 && his.Insutype == "390" {
  29829. reg_type = 110104
  29830. }
  29831. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29832. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29833. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29834. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29835. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29836. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29837. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29838. resp, requestErr := http.Get(api)
  29839. if requestErr != nil {
  29840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29841. return
  29842. }
  29843. body, ioErr := ioutil.ReadAll(resp.Body)
  29844. if ioErr != nil {
  29845. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29847. return
  29848. }
  29849. var respJSON map[string]interface{}
  29850. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29851. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29853. return
  29854. }
  29855. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29856. result, _ := json.Marshal(respJSON)
  29857. fmt.Println("log")
  29858. fmt.Println(string(result))
  29859. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29860. utils.ErrorLog("解析失败:%v", err)
  29861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29862. return
  29863. }
  29864. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29865. if reg_type == 11 && his.Insutype == "390" {
  29866. reg_type = 110104
  29867. }
  29868. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29869. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29870. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29871. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29872. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29873. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29874. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29875. resp, requestErr := http.Get(api)
  29876. if requestErr != nil {
  29877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29878. return
  29879. }
  29880. body, ioErr := ioutil.ReadAll(resp.Body)
  29881. if ioErr != nil {
  29882. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29884. return
  29885. }
  29886. var respJSON map[string]interface{}
  29887. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29888. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29890. return
  29891. }
  29892. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29893. result, _ := json.Marshal(respJSON)
  29894. fmt.Println("log")
  29895. fmt.Println(string(result))
  29896. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29897. utils.ErrorLog("解析失败:%v", err)
  29898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29899. return
  29900. }
  29901. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29902. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  29903. if result3101.Infcode == "0" {
  29904. if len(result3101.Output.Result) > 0 {
  29905. var errMsgs []string
  29906. for _, item := range result3101.Output.Result {
  29907. errMsgs = append(errMsgs, item.VolaCont)
  29908. }
  29909. c.ServeSuccessJSON(map[string]interface{}{
  29910. "failed_code": -10,
  29911. "msg": errMsgs,
  29912. })
  29913. return
  29914. } else {
  29915. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29916. if his.IdCardType != 4 {
  29917. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29918. bas := strings.Split(psn_info.CardInfo, "|")
  29919. if his.IdCardType == 1 {
  29920. cert_no = bas[2]
  29921. } else {
  29922. cert_no = bas[1]
  29923. }
  29924. } else {
  29925. cert_no = his.Certno
  29926. }
  29927. //江苏地区国家医保医疗类别
  29928. //职工透析:医疗类别选特殊情况门诊9933
  29929. //居民血透门慢: 医疗类别选门诊慢病1402
  29930. //var med_type string
  29931. //if his.Insutype == "310" {
  29932. // if reg_type == 14 {
  29933. // med_type = "9933"
  29934. // } else if reg_type == 11 {
  29935. // med_type = "11"
  29936. //
  29937. // }
  29938. //} else if his.Insutype == "390" {
  29939. // if reg_type == 14 {
  29940. // med_type = "1402"
  29941. // } else if reg_type == 11 {
  29942. // med_type = "11"
  29943. // }
  29944. //}
  29945. var api string
  29946. if miConfig.MdtrtareaAdmvs == "320921" {
  29947. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29948. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29949. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29950. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29951. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29952. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29953. "&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
  29954. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29955. } else {
  29956. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29957. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29958. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29959. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29960. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29961. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29962. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29963. "&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
  29964. }
  29965. resp, requestErr := http.Get(api)
  29966. if requestErr != nil {
  29967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29968. return
  29969. }
  29970. body, ioErr := ioutil.ReadAll(resp.Body)
  29971. if ioErr != nil {
  29972. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29974. return
  29975. }
  29976. var respJSON map[string]interface{}
  29977. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29978. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29980. return
  29981. }
  29982. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29983. result, _ := json.Marshal(respJSON)
  29984. fmt.Println("log")
  29985. fmt.Println(string(result))
  29986. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  29987. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  29988. utils.ErrorLog("解析失败:%v", err)
  29989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29990. return
  29991. }
  29992. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29993. res.Output = resSeven10265.Output
  29994. res.ErrMsg = resSeven10265.ErrMsg
  29995. res.Cainfo = resSeven10265.Cainfo
  29996. res.WarnMsg = resSeven10265.WarnMsg
  29997. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29998. res.Infcode = infocode
  29999. } else {
  30000. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  30001. utils.ErrorLog("解析失败:%v", err)
  30002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30003. return
  30004. }
  30005. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  30006. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  30007. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  30008. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  30009. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  30010. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  30011. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  30012. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  30013. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  30014. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  30015. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  30016. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  30017. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  30018. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  30019. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  30020. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  30021. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  30022. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  30023. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  30024. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  30025. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  30026. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30027. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  30028. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  30029. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  30030. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  30031. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  30032. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  30033. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  30034. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  30035. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  30036. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  30037. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  30038. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  30039. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  30040. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30041. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  30042. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  30043. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  30044. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  30045. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  30046. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  30047. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  30048. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  30049. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  30050. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  30051. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  30052. res.ErrMsg = resSeven10265Two.ErrMsg
  30053. res.Cainfo = resSeven10265Two.Cainfo
  30054. res.WarnMsg = resSeven10265Two.WarnMsg
  30055. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  30056. res.Infcode = infocode
  30057. }
  30058. }
  30059. }
  30060. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30061. psn_info, _ := service.GetPsnByPatientId(id)
  30062. var verify_number string
  30063. if psn_info.IdCardType == 4 {
  30064. verify_number = psn_info.VerifyNumber
  30065. } else if psn_info.IdCardType == 1 {
  30066. bas := strings.Split(psn_info.CardInfo, "|")
  30067. cardNumber := bas[2]
  30068. verify_number = cardNumber
  30069. } else {
  30070. psn_info.IdCardType = 2
  30071. verify_number = psn_info.Certno
  30072. }
  30073. var api string
  30074. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30075. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  30076. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30077. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30078. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  30079. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30080. "&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
  30081. resp, requestErr := http.Get(api)
  30082. if requestErr != nil {
  30083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30084. return
  30085. }
  30086. body, ioErr := ioutil.ReadAll(resp.Body)
  30087. if ioErr != nil {
  30088. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30090. return
  30091. }
  30092. var respJSON map[string]interface{}
  30093. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30094. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30096. return
  30097. }
  30098. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30099. result, _ := json.Marshal(respJSON)
  30100. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  30101. utils.ErrorLog("解析失败:%v", err)
  30102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30103. return
  30104. }
  30105. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30106. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  30107. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  30108. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  30109. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  30110. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  30111. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  30112. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  30113. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  30114. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  30115. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  30116. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  30117. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  30118. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  30119. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  30120. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  30121. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  30122. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  30123. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  30124. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  30125. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30126. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  30127. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  30128. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  30129. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  30130. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  30131. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  30132. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  30133. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  30134. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  30135. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  30136. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  30137. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  30138. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  30139. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30140. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  30141. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  30142. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  30143. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  30144. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  30145. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  30146. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  30147. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  30148. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  30149. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  30150. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  30151. res.ErrMsg = resSeven10265.ErrMsg
  30152. res.Cainfo = resSeven10265.Cainfo
  30153. res.WarnMsg = resSeven10265.WarnMsg
  30154. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30155. res.Infcode = infocode
  30156. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30157. acct_used_flag := "1"
  30158. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  30159. var result string
  30160. var request_log string
  30161. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  30162. 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)
  30163. } else {
  30164. 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)
  30165. }
  30166. var dat map[string]interface{}
  30167. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30168. fmt.Println(dat)
  30169. } else {
  30170. fmt.Println(err)
  30171. }
  30172. saveLog(result, request_log, "2206", "预结算")
  30173. userJSONBytes, _ := json.Marshal(dat)
  30174. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30175. utils.ErrorLog("解析失败:%v", err)
  30176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30177. return
  30178. }
  30179. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30180. var result string
  30181. var request_log string
  30182. if his.IdCardType == 2 {
  30183. insutype = strconv.FormatInt(his.SocialType, 10)
  30184. 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, "")
  30185. } else if his.IdCardType == 1 {
  30186. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30187. bas := strings.Split(psn_info.CardInfo, "|")
  30188. basNumber := bas[2]
  30189. card_sn := bas[3]
  30190. var rf []*ResultFive
  30191. json.Unmarshal([]byte(his.Iinfo), &rf)
  30192. var psn_type string
  30193. for _, item := range rf {
  30194. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30195. psn_type = item.PsnType
  30196. }
  30197. }
  30198. insutype = strconv.FormatInt(his.SocialType, 10)
  30199. 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)
  30200. } else {
  30201. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30202. //bas := strings.Split(psn_info.CardInfo, "|")
  30203. //basNumber := bas[2]
  30204. //card_sn := bas[3]
  30205. var rf []*ResultFive
  30206. json.Unmarshal([]byte(his.Iinfo), &rf)
  30207. var psn_type string
  30208. for _, item := range rf {
  30209. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30210. psn_type = item.PsnType
  30211. }
  30212. }
  30213. insutype = strconv.FormatInt(his.SocialType, 10)
  30214. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30215. 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)
  30216. }
  30217. var dat map[string]interface{}
  30218. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30219. fmt.Println(dat)
  30220. } else {
  30221. fmt.Println(err)
  30222. }
  30223. saveLog(result, request_log, "2206", "预结算")
  30224. userJSONBytes, _ := json.Marshal(dat)
  30225. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30226. utils.ErrorLog("解析失败:%v", err)
  30227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30228. return
  30229. }
  30230. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30231. var result string
  30232. var request_log string
  30233. if his.IdCardType == 2 {
  30234. insutype = strconv.FormatInt(his.SocialType, 10)
  30235. 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, "")
  30236. } else if his.IdCardType == 1 {
  30237. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30238. bas := strings.Split(psn_info.CardInfo, "|")
  30239. basNumber := bas[0]
  30240. card_sn := ""
  30241. var rf []*ResultFive
  30242. json.Unmarshal([]byte(his.Iinfo), &rf)
  30243. var psn_type string
  30244. for _, item := range rf {
  30245. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30246. psn_type = item.PsnType
  30247. }
  30248. }
  30249. insutype = strconv.FormatInt(his.SocialType, 10)
  30250. 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)
  30251. } else {
  30252. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30253. //bas := strings.Split(psn_info.CardInfo, "|")
  30254. //basNumber := bas[2]
  30255. //card_sn := bas[3]
  30256. var rf []*ResultFive
  30257. json.Unmarshal([]byte(his.Iinfo), &rf)
  30258. var psn_type string
  30259. for _, item := range rf {
  30260. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30261. psn_type = item.PsnType
  30262. }
  30263. }
  30264. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30265. 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)
  30266. }
  30267. var dat map[string]interface{}
  30268. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30269. fmt.Println(dat)
  30270. } else {
  30271. fmt.Println(err)
  30272. }
  30273. saveLog(result, request_log, "2206", "预结算")
  30274. userJSONBytes, _ := json.Marshal(dat)
  30275. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30276. utils.ErrorLog("解析失败:%v", err)
  30277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30278. return
  30279. }
  30280. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30281. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30282. if his.IdCardType == 4 {
  30283. psn_info.VerifyNumber = psn_info.VerifyNumber
  30284. cert_no = psn_info.VerifyNumber
  30285. } else if his.IdCardType == 2 {
  30286. cert_no = psn_info.Certno
  30287. psn_info.VerifyNumber = psn_info.Certno
  30288. } else {
  30289. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30290. bas := strings.Split(psn_info.CardInfo, "|")
  30291. if his.IdCardType == 1 {
  30292. cert_no = bas[2]
  30293. } else {
  30294. cert_no = bas[1]
  30295. }
  30296. }
  30297. var api string
  30298. var med_type string
  30299. if his.Insutype == "390" {
  30300. if reg_type == 992102 {
  30301. med_type = "992102"
  30302. }
  30303. if reg_type == 140104 {
  30304. med_type = "140104"
  30305. }
  30306. if reg_type == 140201 {
  30307. med_type = "140201"
  30308. }
  30309. if reg_type == 14 {
  30310. med_type = "140104"
  30311. }
  30312. } else if his.Insutype == "310" {
  30313. if reg_type == 992102 {
  30314. med_type = "992102"
  30315. }
  30316. if reg_type == 140104 {
  30317. med_type = "140104"
  30318. }
  30319. if reg_type == 140201 {
  30320. med_type = "140201"
  30321. }
  30322. if reg_type == 14 {
  30323. med_type = "140104"
  30324. }
  30325. }
  30326. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30327. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30328. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30329. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30330. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30331. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30332. "&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
  30333. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30334. resp, requestErr := http.Get(api)
  30335. if requestErr != nil {
  30336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30337. return
  30338. }
  30339. body, ioErr := ioutil.ReadAll(resp.Body)
  30340. if ioErr != nil {
  30341. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30343. return
  30344. }
  30345. var respJSON map[string]interface{}
  30346. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30347. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30349. return
  30350. }
  30351. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30352. if status == "0" {
  30353. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30354. c.ServeSuccessJSON(map[string]interface{}{
  30355. "failed_code": -10,
  30356. "msg": err_msg,
  30357. })
  30358. return
  30359. }
  30360. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30361. result, _ := json.Marshal(respJSON)
  30362. fmt.Println("log")
  30363. fmt.Println(string(result))
  30364. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30365. utils.ErrorLog("解析失败:%v", err)
  30366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30367. return
  30368. }
  30369. res.InfRefmsgid = ahres.InfRefmsgid
  30370. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30371. // 创建对应的Time类型
  30372. t := time.UnixMilli(timestamp)
  30373. // 格式化成指定的日期字符串
  30374. str := t.Format("2006-01-02 15:04:05")
  30375. res.Output.Setlinfo.SetlTime = str
  30376. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30377. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30378. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30379. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30380. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30381. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30382. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30383. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30384. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30385. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30386. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30387. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30388. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30389. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30390. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30391. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30392. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30393. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30394. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30395. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30396. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30397. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30398. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30399. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30400. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30401. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30402. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30403. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30404. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30405. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30406. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30407. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30408. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30409. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30410. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30411. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30412. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30413. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30414. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30415. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30416. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30417. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30418. //res.Output.Setldetail = ahres.Output.Setldetail
  30419. res.ErrMsg = ahres.ErrMsg
  30420. res.Cainfo = ahres.Cainfo
  30421. res.WarnMsg = ahres.WarnMsg
  30422. res.Infcode = ahres.Infcode
  30423. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30424. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30425. if his.IdCardType == 4 {
  30426. psn_info.VerifyNumber = psn_info.VerifyNumber
  30427. cert_no = psn_info.Certno
  30428. } else if his.IdCardType == 2 {
  30429. cert_no = psn_info.Certno
  30430. psn_info.VerifyNumber = psn_info.Certno
  30431. } else {
  30432. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30433. bas := strings.Split(psn_info.CardInfo, "|")
  30434. if his.IdCardType == 1 {
  30435. cert_no = bas[2]
  30436. } else {
  30437. cert_no = bas[1]
  30438. }
  30439. }
  30440. var api string
  30441. var med_type string
  30442. if his.Insutype == "390" {
  30443. if reg_type == 992102 {
  30444. med_type = "992102"
  30445. }
  30446. if reg_type == 140104 {
  30447. med_type = "140104"
  30448. }
  30449. if reg_type == 140201 {
  30450. med_type = "140201"
  30451. }
  30452. if reg_type == 14 {
  30453. med_type = "14"
  30454. }
  30455. } else if his.Insutype == "310" {
  30456. if reg_type == 992102 {
  30457. med_type = "992102"
  30458. }
  30459. if reg_type == 140104 {
  30460. med_type = "140104"
  30461. }
  30462. if reg_type == 140201 {
  30463. med_type = "140201"
  30464. }
  30465. if reg_type == 14 {
  30466. med_type = "14"
  30467. }
  30468. }
  30469. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30470. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30471. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30472. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30473. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30474. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30475. "&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
  30476. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30477. resp, requestErr := http.Get(api)
  30478. if requestErr != nil {
  30479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30480. return
  30481. }
  30482. body, ioErr := ioutil.ReadAll(resp.Body)
  30483. if ioErr != nil {
  30484. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30486. return
  30487. }
  30488. var respJSON map[string]interface{}
  30489. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30490. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30492. return
  30493. }
  30494. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30495. if status == "0" {
  30496. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30497. c.ServeSuccessJSON(map[string]interface{}{
  30498. "failed_code": -10,
  30499. "msg": err_msg,
  30500. })
  30501. return
  30502. }
  30503. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30504. result, _ := json.Marshal(respJSON)
  30505. fmt.Println("log")
  30506. fmt.Println(string(result))
  30507. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30508. utils.ErrorLog("解析失败:%v", err)
  30509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30510. return
  30511. }
  30512. res.InfRefmsgid = ahres.InfRefmsgid
  30513. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30514. // 创建对应的Time类型
  30515. t := time.UnixMilli(timestamp)
  30516. // 格式化成指定的日期字符串
  30517. str := t.Format("2006-01-02 15:04:05")
  30518. res.Output.Setlinfo.SetlTime = str
  30519. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30520. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30521. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30522. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30523. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30524. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30525. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30526. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30527. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30528. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30529. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30530. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30531. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30532. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30533. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30534. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30535. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30536. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30537. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30538. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30539. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30540. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30541. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30542. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30543. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30544. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30545. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30546. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30547. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30548. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30549. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30550. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30551. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30552. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30553. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30554. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30555. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30556. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30557. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30558. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30559. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30560. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30561. //res.Output.Setldetail = ahres.Output.Setldetail
  30562. res.ErrMsg = ahres.ErrMsg
  30563. res.Cainfo = ahres.Cainfo
  30564. res.WarnMsg = ahres.WarnMsg
  30565. res.Infcode = ahres.Infcode
  30566. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30567. var result string
  30568. var request_log string
  30569. if his.IdCardType == 2 {
  30570. 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")
  30571. } else if his.IdCardType == 1 {
  30572. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30573. bas := strings.Split(psn_info.CardInfo, "|")
  30574. basNumber := bas[2]
  30575. card_sn := bas[3]
  30576. 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")
  30577. } else {
  30578. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30579. 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")
  30580. }
  30581. var dat map[string]interface{}
  30582. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30583. fmt.Println(dat)
  30584. } else {
  30585. fmt.Println(err)
  30586. }
  30587. saveLog(result, request_log, "2206", "预结算")
  30588. userJSONBytes, _ := json.Marshal(dat)
  30589. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30590. utils.ErrorLog("解析失败:%v", err)
  30591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30592. return
  30593. }
  30594. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30595. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30596. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30597. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30598. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30599. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30600. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30601. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30602. resp, requestErr := http.Get(api)
  30603. if requestErr != nil {
  30604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30605. return
  30606. }
  30607. body, ioErr := ioutil.ReadAll(resp.Body)
  30608. if ioErr != nil {
  30609. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30611. return
  30612. }
  30613. var respJSON map[string]interface{}
  30614. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30615. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30617. return
  30618. }
  30619. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30620. result, _ := json.Marshal(respJSON)
  30621. fmt.Println("log")
  30622. fmt.Println(string(result))
  30623. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30624. utils.ErrorLog("解析失败:%v", err)
  30625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30626. return
  30627. }
  30628. } else {
  30629. if miConfig.MdtrtareaAdmvs == "441202" {
  30630. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30631. if result3101.Infcode == 0 {
  30632. if len(result3101.Output.Result) > 0 {
  30633. c.ServeSuccessJSON(map[string]interface{}{
  30634. "failed_code": -10,
  30635. "failed_type": 100,
  30636. "msg": result3101.Output.Result,
  30637. })
  30638. return
  30639. } else {
  30640. var result string
  30641. var request_log string
  30642. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30643. allTotal = fmt.Sprintf("%.2f", total_two)
  30644. if his.IdCardType == 4 {
  30645. 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)
  30646. } else {
  30647. 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)
  30648. }
  30649. var dat map[string]interface{}
  30650. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30651. fmt.Println(dat)
  30652. } else {
  30653. fmt.Println(err)
  30654. }
  30655. saveLog(result, request_log, "2206", "预结算")
  30656. //userJSONBytes, _ := json.Marshal(dat)
  30657. //
  30658. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30659. // utils.ErrorLog("解析失败:%v", err)
  30660. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30661. // return
  30662. //}
  30663. userJSONBytes, _ := json.Marshal(dat)
  30664. if miConfig.Code == "H15049901371" {
  30665. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30666. utils.ErrorLog("解析失败:%v", err)
  30667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30668. return
  30669. }
  30670. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30671. res.Output = resSeven10265.Output
  30672. res.ErrMsg = resSeven10265.ErrMsg
  30673. res.Cainfo = resSeven10265.Cainfo
  30674. res.WarnMsg = resSeven10265.WarnMsg
  30675. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30676. res.Infcode = infocode
  30677. } else {
  30678. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30679. utils.ErrorLog("解析失败:%v", err)
  30680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30681. return
  30682. }
  30683. }
  30684. }
  30685. } else {
  30686. c.ServeSuccessJSON(map[string]interface{}{
  30687. "failed_code": -10,
  30688. "msg": result3101.ErrMsg,
  30689. })
  30690. return
  30691. }
  30692. } else if miConfig.MdtrtareaAdmvs == "440205" {
  30693. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30694. if result3101.Infcode == 0 {
  30695. if len(result3101.Output.Result) > 0 {
  30696. var errMsgs []string
  30697. for _, item := range result3101.Output.Result {
  30698. errMsgs = append(errMsgs, item.VolaCont)
  30699. }
  30700. c.ServeSuccessJSON(map[string]interface{}{
  30701. "failed_code": -10,
  30702. "msg": errMsgs,
  30703. })
  30704. return
  30705. } else {
  30706. var result string
  30707. var request_log string
  30708. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30709. allTotal = fmt.Sprintf("%.2f", total_two)
  30710. if his.IdCardType == 4 {
  30711. 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)
  30712. } else {
  30713. 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)
  30714. }
  30715. var dat map[string]interface{}
  30716. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30717. fmt.Println(dat)
  30718. } else {
  30719. fmt.Println(err)
  30720. }
  30721. saveLog(result, request_log, "2206", "预结算")
  30722. //userJSONBytes, _ := json.Marshal(dat)
  30723. //
  30724. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30725. // utils.ErrorLog("解析失败:%v", err)
  30726. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30727. // return
  30728. //}
  30729. userJSONBytes, _ := json.Marshal(dat)
  30730. if miConfig.Code == "H15049901371" {
  30731. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30732. utils.ErrorLog("解析失败:%v", err)
  30733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30734. return
  30735. }
  30736. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30737. res.Output = resSeven10265.Output
  30738. res.ErrMsg = resSeven10265.ErrMsg
  30739. res.Cainfo = resSeven10265.Cainfo
  30740. res.WarnMsg = resSeven10265.WarnMsg
  30741. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30742. res.Infcode = infocode
  30743. } else {
  30744. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30745. utils.ErrorLog("解析失败:%v", err)
  30746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30747. return
  30748. }
  30749. }
  30750. }
  30751. } else {
  30752. c.ServeSuccessJSON(map[string]interface{}{
  30753. "failed_code": -10,
  30754. "msg": result3101.ErrMsg,
  30755. })
  30756. return
  30757. }
  30758. } else {
  30759. var result string
  30760. var request_log string
  30761. var dat map[string]interface{}
  30762. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30763. allTotal = fmt.Sprintf("%.2f", total_two)
  30764. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" {
  30765. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30766. if result3101.Infcode == 0 {
  30767. if len(result3101.Output.Result) > 0 {
  30768. c.ServeSuccessJSON(map[string]interface{}{
  30769. "failed_code": -10,
  30770. "failed_type": 100,
  30771. "warm_type": 2,
  30772. "msg": result3101,
  30773. })
  30774. return
  30775. } else {
  30776. var result string
  30777. var request_log string
  30778. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30779. allTotal = fmt.Sprintf("%.2f", total_two)
  30780. if his.IdCardType == 4 {
  30781. 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)
  30782. } else {
  30783. if his.IdCardType == 2 {
  30784. cert_no = psn_info.Certno
  30785. psn_info.VerifyNumber = psn_info.Certno
  30786. } else {
  30787. bas := strings.Split(psn_info.CardInfo, "|")
  30788. cert_no = bas[2]
  30789. }
  30790. 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)
  30791. }
  30792. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30793. fmt.Println(dat)
  30794. } else {
  30795. fmt.Println(err)
  30796. }
  30797. saveLog(result, request_log, "2206", "预结算")
  30798. }
  30799. } else {
  30800. c.ServeSuccessJSON(map[string]interface{}{
  30801. "failed_code": -10,
  30802. "msg": result3101.ErrMsg,
  30803. })
  30804. return
  30805. }
  30806. } else {
  30807. if his.IdCardType == 4 {
  30808. 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)
  30809. } else {
  30810. if his.IdCardType == 2 {
  30811. cert_no = psn_info.Certno
  30812. psn_info.VerifyNumber = psn_info.Certno
  30813. } else {
  30814. bas := strings.Split(psn_info.CardInfo, "|")
  30815. cert_no = bas[2]
  30816. }
  30817. 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)
  30818. }
  30819. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30820. fmt.Println(dat)
  30821. } else {
  30822. fmt.Println(err)
  30823. }
  30824. saveLog(result, request_log, "2206", "预结算")
  30825. }
  30826. //userJSONBytes, _ := json.Marshal(dat)
  30827. //
  30828. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30829. // utils.ErrorLog("解析失败:%v", err)
  30830. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30831. // return
  30832. //}
  30833. userJSONBytes, _ := json.Marshal(dat)
  30834. if miConfig.Code == "H15049901371" {
  30835. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30836. utils.ErrorLog("解析失败:%v", err)
  30837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30838. return
  30839. }
  30840. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30841. res.Output = resSeven10265.Output
  30842. res.ErrMsg = resSeven10265.ErrMsg
  30843. res.Cainfo = resSeven10265.Cainfo
  30844. res.WarnMsg = resSeven10265.WarnMsg
  30845. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30846. res.Infcode = infocode
  30847. } else {
  30848. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30849. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  30850. utils.ErrorLog("解析失败:%v", err)
  30851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30852. return
  30853. }
  30854. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  30855. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  30856. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  30857. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30858. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  30859. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  30860. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  30861. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30862. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  30863. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30864. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30865. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30866. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30867. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30868. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  30869. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  30870. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  30871. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  30872. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  30873. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  30874. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30875. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  30876. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  30877. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  30878. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  30879. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  30880. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  30881. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  30882. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  30883. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  30884. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  30885. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  30886. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  30887. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  30888. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30889. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  30890. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  30891. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  30892. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30893. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  30894. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  30895. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  30896. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  30897. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  30898. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  30899. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  30900. res.ErrMsg = gzresSeven10265Two.ErrMsg
  30901. res.Cainfo = gzresSeven10265Two.Cainfo
  30902. res.WarnMsg = gzresSeven10265Two.WarnMsg
  30903. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  30904. //res.Infcode = infocode
  30905. } else {
  30906. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30907. utils.ErrorLog("解析失败:%v", err)
  30908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30909. return
  30910. }
  30911. }
  30912. }
  30913. }
  30914. }
  30915. utils.ErrorLog("解析失败:%v", res.Infcode)
  30916. if res.Infcode == -1 {
  30917. errlog := &models.HisOrderError{
  30918. UserOrgId: adminUser.CurrentOrgId,
  30919. Ctime: time.Now().Unix(),
  30920. Mtime: time.Now().Unix(),
  30921. Number: chrg_bchno,
  30922. ErrMsg: res.ErrMsg,
  30923. Status: 1,
  30924. PatientId: id,
  30925. RecordTime: recordDateTime,
  30926. Stage: 20,
  30927. }
  30928. service.CreateErrMsgLog(errlog)
  30929. c.ServeSuccessJSON(map[string]interface{}{
  30930. "failed_code": -10,
  30931. "msg": res.ErrMsg,
  30932. })
  30933. return
  30934. }
  30935. if res.Infcode != 0 {
  30936. errlog := &models.HisOrderError{
  30937. UserOrgId: adminUser.CurrentOrgId,
  30938. Ctime: time.Now().Unix(),
  30939. Mtime: time.Now().Unix(),
  30940. Number: chrg_bchno,
  30941. ErrMsg: res.ErrMsg,
  30942. Status: 1,
  30943. PatientId: id,
  30944. RecordTime: recordDateTime,
  30945. Stage: 20,
  30946. }
  30947. service.CreateErrMsgLog(errlog)
  30948. c.ServeSuccessJSON(map[string]interface{}{
  30949. "failed_code": -10,
  30950. "msg": res.ErrMsg,
  30951. })
  30952. return
  30953. } else {
  30954. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  30955. order.OrderStatus = 1
  30956. order.IsPre = 1
  30957. order.Status = 1
  30958. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  30959. order.SetlId = res.Output.Setlinfo.SetlID
  30960. order.PsnNo = res.Output.Setlinfo.PsnNo
  30961. order.PsnName = res.Output.Setlinfo.PsnName
  30962. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  30963. order.Certno = res.Output.Setlinfo.Certno
  30964. order.Gend = res.Output.Setlinfo.Gend
  30965. order.Naty = res.Output.Setlinfo.Naty
  30966. order.Age = res.Output.Setlinfo.Age
  30967. order.Insutype = res.Output.Setlinfo.Insutype
  30968. order.PsnType = res.Output.Setlinfo.PsnType
  30969. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  30970. order.SetlTime = res.Output.Setlinfo.SetlTime
  30971. order.AcctUsedFlag = acct_used_flag
  30972. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  30973. if res.Output.Setlinfo.MedType == "140101" {
  30974. order.MedType = "14"
  30975. } else {
  30976. if res.Output.Setlinfo.MedType == "110104" {
  30977. order.MedType = "11"
  30978. } else {
  30979. order.MedType = res.Output.Setlinfo.MedType
  30980. }
  30981. }
  30982. if res.Output.Setlinfo.MedType == "992102" {
  30983. order.MedType = "992102"
  30984. }
  30985. if res.Output.Setlinfo.MedType == "140104" {
  30986. order.MedType = "140104"
  30987. }
  30988. if res.Output.Setlinfo.MedType == "140201" {
  30989. order.MedType = "140201"
  30990. }
  30991. if res.Output.Setlinfo.MedType == "14" {
  30992. order.MedType = "14"
  30993. }
  30994. if reg_type == 1112 {
  30995. order.MedType = "1112"
  30996. }
  30997. if reg_type == 1111 {
  30998. order.MedType = "1111"
  30999. }
  31000. order.ClrType = res.Output.Setlinfo.ClrType
  31001. if adminUser.CurrentOrgId == 10480 {
  31002. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  31003. order.ClrType = "11"
  31004. } else {
  31005. order.ClrType = "9903"
  31006. }
  31007. }
  31008. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  31009. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  31010. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  31011. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  31012. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  31013. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  31014. order.HifpPay = res.Output.Setlinfo.HifpPay
  31015. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  31016. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  31017. order.HifesPay = res.Output.Setlinfo.HifesPay
  31018. order.HifobPay = res.Output.Setlinfo.HifobPay
  31019. order.MafPay = res.Output.Setlinfo.MafPay
  31020. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  31021. order.OthPay = res.Output.Setlinfo.OthPay
  31022. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  31023. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  31024. order.AcctPay = res.Output.Setlinfo.AcctPay
  31025. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  31026. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  31027. order.Balc = res.Output.Setlinfo.Balc
  31028. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  31029. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  31030. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  31031. order.ClrWay = res.Output.Setlinfo.ClrWay
  31032. order.Creator = order.Creator
  31033. order.Modify = roles.AdminUserId
  31034. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  31035. //detailStr := string(setlDetail)
  31036. //order.SetlDetail = detailStr
  31037. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  31038. err = service.UpDateOrder(order)
  31039. if err == nil {
  31040. c.ServeSuccessJSON(map[string]interface{}{
  31041. "msg": "预结算成功",
  31042. })
  31043. } else {
  31044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  31045. return
  31046. }
  31047. }
  31048. } else {
  31049. adminUser := c.GetAdminUserInfo()
  31050. errlog := &models.HisOrderError{
  31051. UserOrgId: adminUser.CurrentOrgId,
  31052. Ctime: time.Now().Unix(),
  31053. Mtime: time.Now().Unix(),
  31054. ErrMsg: res.ErrMsg,
  31055. Status: 1,
  31056. PatientId: id,
  31057. RecordTime: recordDateTime,
  31058. Stage: 4,
  31059. }
  31060. service.CreateErrMsgLog(errlog)
  31061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  31062. return
  31063. }
  31064. } else {
  31065. if miConfig.MdtrtareaAdmvs == "150499" {
  31066. order := &models.HisOrder{
  31067. UserOrgId: adminUser.CurrentOrgId,
  31068. HisPatientId: his.ID,
  31069. PatientId: his.PatientId,
  31070. SettleAccountsDate: recordDateTime,
  31071. Ctime: time.Now().Unix(),
  31072. Mtime: time.Now().Unix(),
  31073. MdtrtId: his.Number,
  31074. PsnNo: his.PsnNo,
  31075. MedType: strconv.FormatInt(reg_type, 10),
  31076. Status: 1,
  31077. Number: chrg_bchno,
  31078. Infcode: res.Infcode,
  31079. WarnMsg: res.WarnMsg,
  31080. Cainfo: res.Cainfo,
  31081. ErrMsg: res.ErrMsg,
  31082. RespondTime: res.RefmsgTime,
  31083. InfRefmsgid: res.InfRefmsgid,
  31084. OrderStatus: 1,
  31085. IsMedicineInsurance: 1,
  31086. SettleType: settle_accounts_type,
  31087. SettleStartTime: start_time,
  31088. SettleEndTime: end_time,
  31089. Creator: roles.AdminUserId,
  31090. Modify: roles.AdminUserId,
  31091. PType: 2,
  31092. Diagnosis: diagnosis_id,
  31093. }
  31094. err = service.CreateOrder(order)
  31095. if err != nil {
  31096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  31097. return
  31098. }
  31099. }
  31100. adminUser := c.GetAdminUserInfo()
  31101. errlog := &models.HisOrderError{
  31102. UserOrgId: adminUser.CurrentOrgId,
  31103. Ctime: time.Now().Unix(),
  31104. Mtime: time.Now().Unix(),
  31105. ErrMsg: res.ErrMsg,
  31106. Status: 1,
  31107. PatientId: id,
  31108. RecordTime: recordDateTime,
  31109. Stage: 4,
  31110. }
  31111. service.CreateErrMsgLog(errlog)
  31112. c.ServeSuccessJSON(map[string]interface{}{
  31113. "failed_code": -10,
  31114. "msg": res.ErrMsg,
  31115. })
  31116. return
  31117. }
  31118. }
  31119. }
  31120. }
  31121. // 退款
  31122. func (c *HisApiController) Refund() {
  31123. order_id, _ := c.GetInt64("order_id")
  31124. admin_user_id, _ := c.GetInt64("admin_user_id")
  31125. adminUser := c.GetAdminUserInfo()
  31126. var order models.HisOrder
  31127. order, _ = service.GetHisOrderByID(order_id)
  31128. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  31129. if fapiao.ID > 0 {
  31130. c.ServeSuccessJSON(map[string]interface{}{
  31131. "failed_code": -10,
  31132. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  31133. })
  31134. return
  31135. }
  31136. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31137. if order.ID == 0 {
  31138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31139. return
  31140. }
  31141. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  31142. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31143. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31144. if config.IsOpen == 1 { //对接了医保,走医保流程
  31145. var res ResultSixteen
  31146. var ahres ResultSevenAH
  31147. var resSixteen10265 ResultSixteen10265
  31148. var resSixteen10265Two ResultSixteen10265Two
  31149. var gz ResultgzSixteen10265Two
  31150. var src_resquest string
  31151. var result string
  31152. if miConfig.MdtrtareaAdmvs == "421300" {
  31153. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  31154. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31155. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31156. resp3, requestErr3 := http.Get(api3)
  31157. if requestErr3 != nil {
  31158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31159. return
  31160. }
  31161. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31162. if ioErr3 != nil {
  31163. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31165. return
  31166. }
  31167. var respJSON3 map[string]interface{}
  31168. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31169. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31171. return
  31172. }
  31173. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31174. userJSONBytes3, _ := json.Marshal(respJSON3)
  31175. fmt.Println("log")
  31176. fmt.Println(string(userJSONBytes3))
  31177. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31178. utils.ErrorLog("解析失败:%v", err)
  31179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31180. return
  31181. }
  31182. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31183. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  31184. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31185. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31186. resp3, requestErr3 := http.Get(api3)
  31187. if requestErr3 != nil {
  31188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31189. return
  31190. }
  31191. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31192. if ioErr3 != nil {
  31193. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31195. return
  31196. }
  31197. var respJSON3 map[string]interface{}
  31198. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31199. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31201. return
  31202. }
  31203. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31204. userJSONBytes3, _ := json.Marshal(respJSON3)
  31205. fmt.Println("log")
  31206. fmt.Println(string(userJSONBytes3))
  31207. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31208. utils.ErrorLog("解析失败:%v", err)
  31209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31210. return
  31211. }
  31212. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31213. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31214. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31215. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31216. resp3, requestErr3 := http.Get(api3)
  31217. if requestErr3 != nil {
  31218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31219. return
  31220. }
  31221. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31222. if ioErr3 != nil {
  31223. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31225. return
  31226. }
  31227. var respJSON3 map[string]interface{}
  31228. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31229. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31231. return
  31232. }
  31233. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31234. userJSONBytes3, _ := json.Marshal(respJSON3)
  31235. fmt.Println("log")
  31236. fmt.Println(string(userJSONBytes3))
  31237. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31238. utils.ErrorLog("解析失败:%v", err)
  31239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31240. return
  31241. }
  31242. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31243. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31244. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31245. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31246. resp3, requestErr3 := http.Get(api3)
  31247. if requestErr3 != nil {
  31248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31249. return
  31250. }
  31251. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31252. if ioErr3 != nil {
  31253. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31255. return
  31256. }
  31257. var respJSON3 map[string]interface{}
  31258. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31261. return
  31262. }
  31263. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31264. userJSONBytes3, _ := json.Marshal(respJSON3)
  31265. fmt.Println("log")
  31266. fmt.Println(string(userJSONBytes3))
  31267. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31268. utils.ErrorLog("解析失败:%v", err)
  31269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31270. return
  31271. }
  31272. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31273. var api3 string
  31274. if miConfig.MdtrtareaAdmvs == "320921" {
  31275. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31276. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31277. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31278. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31279. } else {
  31280. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31281. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31282. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31283. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31284. }
  31285. resp3, requestErr3 := http.Get(api3)
  31286. if requestErr3 != nil {
  31287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31288. return
  31289. }
  31290. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31291. if ioErr3 != nil {
  31292. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31294. return
  31295. }
  31296. var respJSON3 map[string]interface{}
  31297. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31300. return
  31301. }
  31302. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31303. userJSONBytes3, _ := json.Marshal(respJSON3)
  31304. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31305. utils.ErrorLog("解析失败:%v", err)
  31306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31307. return
  31308. }
  31309. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31310. res.Output = resSixteen10265.Output
  31311. res.ErrMsg = resSixteen10265.ErrMsg
  31312. res.Cainfo = resSixteen10265.Cainfo
  31313. res.WarnMsg = resSixteen10265.WarnMsg
  31314. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31315. res.Infcode = infocode
  31316. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31317. var api3 string
  31318. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  31319. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31320. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31321. resp3, requestErr3 := http.Get(api3)
  31322. if requestErr3 != nil {
  31323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31324. return
  31325. }
  31326. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31327. if ioErr3 != nil {
  31328. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31330. return
  31331. }
  31332. var respJSON3 map[string]interface{}
  31333. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31336. return
  31337. }
  31338. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31339. userJSONBytes3, _ := json.Marshal(respJSON3)
  31340. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31341. utils.ErrorLog("解析失败:%v", err)
  31342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31343. return
  31344. }
  31345. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31346. res.Output = resSixteen10265.Output
  31347. res.ErrMsg = resSixteen10265.ErrMsg
  31348. res.Cainfo = resSixteen10265.Cainfo
  31349. res.WarnMsg = resSixteen10265.WarnMsg
  31350. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31351. res.Infcode = infocode
  31352. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31353. 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)
  31354. var dat map[string]interface{}
  31355. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31356. fmt.Println(dat)
  31357. } else {
  31358. fmt.Println(err)
  31359. }
  31360. saveLog(result, src_resquest, "2208", "退费")
  31361. userJSONBytes, _ := json.Marshal(dat)
  31362. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31363. utils.ErrorLog("解析失败:%v", err)
  31364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31365. return
  31366. }
  31367. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31368. 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, "")
  31369. var dat map[string]interface{}
  31370. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31371. fmt.Println(dat)
  31372. } else {
  31373. fmt.Println(err)
  31374. }
  31375. saveLog(result, src_resquest, "2208", "退费")
  31376. userJSONBytes, _ := json.Marshal(dat)
  31377. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31378. utils.ErrorLog("解析失败:%v", err)
  31379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31380. return
  31381. }
  31382. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31383. 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, "")
  31384. var dat map[string]interface{}
  31385. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31386. fmt.Println(dat)
  31387. } else {
  31388. fmt.Println(err)
  31389. }
  31390. saveLog(result, src_resquest, "2208", "退费")
  31391. userJSONBytes, _ := json.Marshal(dat)
  31392. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31393. utils.ErrorLog("解析失败:%v", err)
  31394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31395. return
  31396. }
  31397. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31398. var api3 string
  31399. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31400. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31401. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31402. resp3, requestErr3 := http.Get(api3)
  31403. if requestErr3 != nil {
  31404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31405. return
  31406. }
  31407. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31408. if ioErr3 != nil {
  31409. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31411. return
  31412. }
  31413. var respJSON3 map[string]interface{}
  31414. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31415. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31417. return
  31418. }
  31419. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31420. if status == "0" {
  31421. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31422. c.ServeSuccessJSON(map[string]interface{}{
  31423. "failed_code": -10,
  31424. "msg": err_msg,
  31425. })
  31426. return
  31427. }
  31428. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31429. userJSONBytes3, _ := json.Marshal(respJSON3)
  31430. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31431. // utils.ErrorLog("解析失败:%v", err)
  31432. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31433. // return
  31434. //}
  31435. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31436. utils.ErrorLog("解析失败:%v", err)
  31437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31438. return
  31439. }
  31440. res.InfRefmsgid = ahres.InfRefmsgid
  31441. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31442. // 创建对应的Time类型
  31443. t := time.UnixMilli(timestamp)
  31444. // 格式化成指定的日期字符串
  31445. str := t.Format("2006-01-02 15:04:05")
  31446. res.Output.Setlinfo.SetlTime = str
  31447. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31448. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31449. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31450. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31451. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31452. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31453. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31454. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31455. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31456. //
  31457. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31458. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31459. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31460. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31461. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31462. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31463. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31464. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31465. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31466. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31467. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31468. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31469. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31470. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31471. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31472. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31473. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31474. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31475. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31476. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31477. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31478. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31479. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31480. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31481. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31482. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31483. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31484. //res.Output.Setldetail = ahres.Output.Setldetail
  31485. res.ErrMsg = ahres.ErrMsg
  31486. res.Cainfo = ahres.Cainfo
  31487. res.WarnMsg = ahres.WarnMsg
  31488. res.Infcode = ahres.Infcode
  31489. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31490. var api3 string
  31491. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31492. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31493. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31494. resp3, requestErr3 := http.Get(api3)
  31495. if requestErr3 != nil {
  31496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31497. return
  31498. }
  31499. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31500. if ioErr3 != nil {
  31501. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31503. return
  31504. }
  31505. var respJSON3 map[string]interface{}
  31506. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31509. return
  31510. }
  31511. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31512. if status == "0" {
  31513. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31514. c.ServeSuccessJSON(map[string]interface{}{
  31515. "failed_code": -10,
  31516. "msg": err_msg,
  31517. })
  31518. return
  31519. }
  31520. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31521. userJSONBytes3, _ := json.Marshal(respJSON3)
  31522. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31523. // utils.ErrorLog("解析失败:%v", err)
  31524. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31525. // return
  31526. //}
  31527. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31528. utils.ErrorLog("解析失败:%v", err)
  31529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31530. return
  31531. }
  31532. res.InfRefmsgid = ahres.InfRefmsgid
  31533. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31534. // 创建对应的Time类型
  31535. t := time.UnixMilli(timestamp)
  31536. // 格式化成指定的日期字符串
  31537. str := t.Format("2006-01-02 15:04:05")
  31538. res.Output.Setlinfo.SetlTime = str
  31539. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31540. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31541. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31542. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31543. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31544. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31545. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31546. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31547. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31548. //
  31549. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31550. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31551. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31552. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31553. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31554. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31555. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31556. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31557. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31558. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31559. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31560. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31561. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31562. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31563. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31564. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31565. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31566. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31567. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31568. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31569. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31570. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31571. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31572. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31573. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31574. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31575. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31576. //res.Output.Setldetail = ahres.Output.Setldetail
  31577. res.ErrMsg = ahres.ErrMsg
  31578. res.Cainfo = ahres.Cainfo
  31579. res.WarnMsg = ahres.WarnMsg
  31580. res.Infcode = ahres.Infcode
  31581. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31582. 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, "")
  31583. var dat map[string]interface{}
  31584. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31585. fmt.Println(dat)
  31586. } else {
  31587. fmt.Println(err)
  31588. }
  31589. saveLog(result, src_resquest, "2208", "退费")
  31590. userJSONBytes, _ := json.Marshal(dat)
  31591. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31592. utils.ErrorLog("解析失败:%v", err)
  31593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31594. return
  31595. }
  31596. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31597. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  31598. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31599. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31600. resp3, requestErr3 := http.Get(api3)
  31601. if requestErr3 != nil {
  31602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31603. return
  31604. }
  31605. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31606. if ioErr3 != nil {
  31607. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31609. return
  31610. }
  31611. var respJSON3 map[string]interface{}
  31612. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31613. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31615. return
  31616. }
  31617. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31618. userJSONBytes3, _ := json.Marshal(respJSON3)
  31619. fmt.Println("log")
  31620. fmt.Println(string(userJSONBytes3))
  31621. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31622. utils.ErrorLog("解析失败:%v", err)
  31623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31624. return
  31625. }
  31626. } else {
  31627. if miConfig.Code == "H15049901371" {
  31628. 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)
  31629. var dat map[string]interface{}
  31630. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31631. fmt.Println(dat)
  31632. } else {
  31633. fmt.Println(err)
  31634. }
  31635. saveLog(result, src_resquest, "2208", "退费")
  31636. if strings.Contains(result, "Post") {
  31637. res.Infcode = -1
  31638. res.ErrMsg = result
  31639. }
  31640. userJSONBytes, _ := json.Marshal(dat)
  31641. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  31642. utils.ErrorLog("解析失败:%v", err)
  31643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31644. return
  31645. }
  31646. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31647. res.Output = resSixteen10265.Output
  31648. res.ErrMsg = resSixteen10265.ErrMsg
  31649. res.Cainfo = resSixteen10265.Cainfo
  31650. res.WarnMsg = resSixteen10265.WarnMsg
  31651. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31652. res.Infcode = infocode
  31653. } else {
  31654. 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)
  31655. var dat map[string]interface{}
  31656. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31657. fmt.Println(dat)
  31658. } else {
  31659. fmt.Println(err)
  31660. }
  31661. saveLog(result, src_resquest, "2208", "退费")
  31662. userJSONBytes, _ := json.Marshal(dat)
  31663. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31664. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  31665. utils.ErrorLog("解析失败:%v", err)
  31666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31667. return
  31668. }
  31669. res.Infcode = gz.Infcode
  31670. } else {
  31671. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31672. utils.ErrorLog("解析失败:%v", err)
  31673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31674. return
  31675. }
  31676. }
  31677. if strings.Contains(result, "Post") {
  31678. res.Infcode = -1
  31679. res.ErrMsg = result
  31680. }
  31681. }
  31682. }
  31683. if res.Infcode == -1 {
  31684. c.ServeSuccessJSON(map[string]interface{}{
  31685. "failed_code": -10,
  31686. "msg": res.ErrMsg,
  31687. })
  31688. return
  31689. }
  31690. if res.Infcode != -1 {
  31691. var res2 ResultSix
  31692. var resSix10265 ResultSix10265
  31693. if miConfig.MdtrtareaAdmvs == "421300" {
  31694. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31695. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31696. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31697. resp3, requestErr3 := http.Get(api3)
  31698. if requestErr3 != nil {
  31699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31700. return
  31701. }
  31702. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31703. if ioErr3 != nil {
  31704. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31706. return
  31707. }
  31708. var respJSON3 map[string]interface{}
  31709. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31710. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31712. return
  31713. }
  31714. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31715. userJSONBytes3, _ := json.Marshal(respJSON3)
  31716. fmt.Println("log")
  31717. fmt.Println(string(userJSONBytes3))
  31718. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31719. utils.ErrorLog("解析失败:%v", err)
  31720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31721. return
  31722. }
  31723. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31724. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31725. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31726. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31727. resp3, requestErr3 := http.Get(api3)
  31728. if requestErr3 != nil {
  31729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31730. return
  31731. }
  31732. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31733. if ioErr3 != nil {
  31734. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31736. return
  31737. }
  31738. var respJSON3 map[string]interface{}
  31739. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31740. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31742. return
  31743. }
  31744. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31745. userJSONBytes3, _ := json.Marshal(respJSON3)
  31746. fmt.Println("log")
  31747. fmt.Println(string(userJSONBytes3))
  31748. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31749. utils.ErrorLog("解析失败:%v", err)
  31750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31751. return
  31752. }
  31753. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31754. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31755. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31756. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31757. resp3, requestErr3 := http.Get(api3)
  31758. if requestErr3 != nil {
  31759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31760. return
  31761. }
  31762. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31763. if ioErr3 != nil {
  31764. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31766. return
  31767. }
  31768. var respJSON3 map[string]interface{}
  31769. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31770. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31772. return
  31773. }
  31774. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31775. userJSONBytes3, _ := json.Marshal(respJSON3)
  31776. fmt.Println("log")
  31777. fmt.Println(string(userJSONBytes3))
  31778. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31779. utils.ErrorLog("解析失败:%v", err)
  31780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31781. return
  31782. }
  31783. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31784. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31785. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31786. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31787. resp3, requestErr3 := http.Get(api3)
  31788. if requestErr3 != nil {
  31789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31790. return
  31791. }
  31792. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31793. if ioErr3 != nil {
  31794. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31796. return
  31797. }
  31798. var respJSON3 map[string]interface{}
  31799. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31800. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31802. return
  31803. }
  31804. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31805. userJSONBytes3, _ := json.Marshal(respJSON3)
  31806. fmt.Println("log")
  31807. fmt.Println(string(userJSONBytes3))
  31808. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31809. utils.ErrorLog("解析失败:%v", err)
  31810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31811. return
  31812. }
  31813. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31814. var api3 string
  31815. if miConfig.MdtrtareaAdmvs == "320921" {
  31816. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31817. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31818. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31819. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31820. } else {
  31821. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31822. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31823. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31824. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31825. }
  31826. resp3, requestErr3 := http.Get(api3)
  31827. if requestErr3 != nil {
  31828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31829. return
  31830. }
  31831. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31832. if ioErr3 != nil {
  31833. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31835. return
  31836. }
  31837. var respJSON3 map[string]interface{}
  31838. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31839. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31841. return
  31842. }
  31843. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31844. userJSONBytes3, _ := json.Marshal(respJSON3)
  31845. fmt.Println("log")
  31846. fmt.Println(string(userJSONBytes3))
  31847. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31848. utils.ErrorLog("解析失败:%v", err)
  31849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31850. return
  31851. }
  31852. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31853. res2.Output = resSix10265.Output
  31854. res2.ErrMsg = resSix10265.ErrMsg
  31855. res2.Cainfo = resSix10265.Cainfo
  31856. res2.WarnMsg = resSix10265.WarnMsg
  31857. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31858. res2.Infcode = infocode
  31859. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31860. var api3 string
  31861. new_chrg_bchno := order.Number
  31862. if adminUser.CurrentOrgId == 10265 {
  31863. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  31864. new_chrg_bchno = "0000"
  31865. }
  31866. }
  31867. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  31868. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31869. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31870. resp3, requestErr3 := http.Get(api3)
  31871. if requestErr3 != nil {
  31872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31873. return
  31874. }
  31875. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31876. if ioErr3 != nil {
  31877. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31879. return
  31880. }
  31881. var respJSON3 map[string]interface{}
  31882. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31885. return
  31886. }
  31887. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31888. userJSONBytes3, _ := json.Marshal(respJSON3)
  31889. fmt.Println("log")
  31890. fmt.Println(string(userJSONBytes3))
  31891. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31892. utils.ErrorLog("解析失败:%v", err)
  31893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31894. return
  31895. }
  31896. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31897. res2.Output = resSix10265.Output
  31898. res2.ErrMsg = resSix10265.ErrMsg
  31899. res2.Cainfo = resSix10265.Cainfo
  31900. res2.WarnMsg = resSix10265.WarnMsg
  31901. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31902. res2.Infcode = infocode
  31903. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31904. 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)
  31905. var dat map[string]interface{}
  31906. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31907. fmt.Println(dat)
  31908. } else {
  31909. fmt.Println(err)
  31910. }
  31911. saveLog(result2, src_request, "2205", "撤销明细")
  31912. userJSONBytes, _ := json.Marshal(dat)
  31913. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31914. utils.ErrorLog("解析失败:%v", err)
  31915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31916. return
  31917. }
  31918. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31919. 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, "")
  31920. var dat map[string]interface{}
  31921. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31922. fmt.Println(dat)
  31923. } else {
  31924. fmt.Println(err)
  31925. }
  31926. saveLog(result2, src_request, "2205", "撤销明细")
  31927. userJSONBytes, _ := json.Marshal(dat)
  31928. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31929. utils.ErrorLog("解析失败:%v", err)
  31930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31931. return
  31932. }
  31933. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31934. 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, "")
  31935. var dat map[string]interface{}
  31936. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31937. fmt.Println(dat)
  31938. } else {
  31939. fmt.Println(err)
  31940. }
  31941. saveLog(result2, src_request, "2205", "撤销明细")
  31942. userJSONBytes, _ := json.Marshal(dat)
  31943. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31944. utils.ErrorLog("解析失败:%v", err)
  31945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31946. return
  31947. }
  31948. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31949. var api3 string
  31950. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31951. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31952. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31953. resp3, requestErr3 := http.Get(api3)
  31954. if requestErr3 != nil {
  31955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31956. return
  31957. }
  31958. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31959. if ioErr3 != nil {
  31960. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31962. return
  31963. }
  31964. var respJSON3 map[string]interface{}
  31965. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31966. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31968. return
  31969. }
  31970. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31971. if status == "0" {
  31972. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31973. c.ServeSuccessJSON(map[string]interface{}{
  31974. "failed_code": -10,
  31975. "msg": err_msg,
  31976. })
  31977. return
  31978. }
  31979. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31980. userJSONBytes3, _ := json.Marshal(respJSON3)
  31981. fmt.Println("log")
  31982. fmt.Println(string(userJSONBytes3))
  31983. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31984. utils.ErrorLog("解析失败:%v", err)
  31985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31986. return
  31987. }
  31988. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31989. 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, "")
  31990. var dat map[string]interface{}
  31991. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31992. fmt.Println(dat)
  31993. } else {
  31994. fmt.Println(err)
  31995. }
  31996. saveLog(result2, src_request, "2205", "撤销明细")
  31997. userJSONBytes, _ := json.Marshal(dat)
  31998. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31999. utils.ErrorLog("解析失败:%v", err)
  32000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32001. return
  32002. }
  32003. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32004. 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, "")
  32005. var dat map[string]interface{}
  32006. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32007. fmt.Println(dat)
  32008. } else {
  32009. fmt.Println(err)
  32010. }
  32011. saveLog(result2, src_request, "2205", "撤销明细")
  32012. userJSONBytes, _ := json.Marshal(dat)
  32013. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32014. utils.ErrorLog("解析失败:%v", err)
  32015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32016. return
  32017. }
  32018. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32019. var api3 string
  32020. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32021. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32022. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32023. resp3, requestErr3 := http.Get(api3)
  32024. if requestErr3 != nil {
  32025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32026. return
  32027. }
  32028. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32029. if ioErr3 != nil {
  32030. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32032. return
  32033. }
  32034. var respJSON3 map[string]interface{}
  32035. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32036. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32038. return
  32039. }
  32040. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32041. if status == "0" {
  32042. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32043. c.ServeSuccessJSON(map[string]interface{}{
  32044. "failed_code": -10,
  32045. "msg": err_msg,
  32046. })
  32047. return
  32048. }
  32049. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32050. userJSONBytes3, _ := json.Marshal(respJSON3)
  32051. fmt.Println("log")
  32052. fmt.Println(string(userJSONBytes3))
  32053. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32054. utils.ErrorLog("解析失败:%v", err)
  32055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32056. return
  32057. }
  32058. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32059. 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, "")
  32060. var dat map[string]interface{}
  32061. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32062. fmt.Println(dat)
  32063. } else {
  32064. fmt.Println(err)
  32065. }
  32066. saveLog(result2, src_request, "2205", "撤销明细")
  32067. userJSONBytes, _ := json.Marshal(dat)
  32068. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32069. utils.ErrorLog("解析失败:%v", err)
  32070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32071. return
  32072. }
  32073. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32074. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  32075. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32076. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32077. resp3, requestErr3 := http.Get(api3)
  32078. if requestErr3 != nil {
  32079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32080. return
  32081. }
  32082. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32083. if ioErr3 != nil {
  32084. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32086. return
  32087. }
  32088. var respJSON3 map[string]interface{}
  32089. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32090. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32092. return
  32093. }
  32094. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32095. userJSONBytes3, _ := json.Marshal(respJSON3)
  32096. fmt.Println("log")
  32097. fmt.Println(string(userJSONBytes3))
  32098. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32099. utils.ErrorLog("解析失败:%v", err)
  32100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32101. return
  32102. }
  32103. } else {
  32104. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32105. res2.Infcode = 0
  32106. } else {
  32107. 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)
  32108. var dat map[string]interface{}
  32109. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32110. fmt.Println(dat)
  32111. } else {
  32112. fmt.Println(err)
  32113. }
  32114. saveLog(result2, src_request, "2205", "撤销明细")
  32115. userJSONBytes, _ := json.Marshal(dat)
  32116. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32117. utils.ErrorLog("解析失败:%v", err)
  32118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32119. return
  32120. }
  32121. }
  32122. }
  32123. if res2.Infcode == -1 {
  32124. c.ServeSuccessJSON(map[string]interface{}{
  32125. "failed_code": -10,
  32126. "msg": res2.ErrMsg,
  32127. })
  32128. return
  32129. }
  32130. if res2.Infcode == 0 {
  32131. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  32132. if err == nil {
  32133. //当押金不为零时产生退费记录
  32134. if order.Decimal != 0 {
  32135. tmp := strconv.FormatInt(order.ID, 10)
  32136. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  32137. if err != nil {
  32138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32139. return
  32140. }
  32141. }
  32142. c.ServeSuccessJSON(map[string]interface{}{
  32143. "msg": "退费成功",
  32144. })
  32145. } else {
  32146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32147. return
  32148. }
  32149. } else {
  32150. c.ServeSuccessJSON(map[string]interface{}{
  32151. "failed_code": -10,
  32152. "msg": res2.ErrMsg,
  32153. })
  32154. }
  32155. } else {
  32156. c.ServeSuccessJSON(map[string]interface{}{
  32157. "failed_code": -10,
  32158. "msg": res.ErrMsg,
  32159. })
  32160. }
  32161. }
  32162. }
  32163. func (c *HisApiController) RefundNumber() {
  32164. record_time := c.GetString("record_time")
  32165. //patient_id, _ := c.GetInt64("patient_id")
  32166. admin_user_id, _ := c.GetInt64("admin_user_id")
  32167. his_patient_id, _ := c.GetInt64("id")
  32168. timeLayout := "2006-01-02"
  32169. loc, _ := time.LoadLocation("Local")
  32170. adminUser := c.GetAdminUserInfo()
  32171. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32172. fmt.Println(err)
  32173. if err != nil {
  32174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32175. return
  32176. }
  32177. recordDateTime := theTime.Unix()
  32178. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32179. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  32180. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32181. //order, _ := service.GetHisOrderByID(order_id)
  32182. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32183. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32184. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32185. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  32186. if count > 0 {
  32187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  32188. return
  32189. }
  32190. if config.IsOpen == 1 { //对接了医保,走医保流程
  32191. var res2 ResultSix
  32192. var res3 GZResultSix
  32193. var resSix10265 ResultSix10265
  32194. if miConfig.MdtrtareaAdmvs == "421300" {
  32195. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32196. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32197. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32198. resp3, requestErr3 := http.Get(api3)
  32199. if requestErr3 != nil {
  32200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32201. return
  32202. }
  32203. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32204. if ioErr3 != nil {
  32205. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32207. return
  32208. }
  32209. var respJSON3 map[string]interface{}
  32210. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32211. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32213. return
  32214. }
  32215. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32216. userJSONBytes3, _ := json.Marshal(respJSON3)
  32217. fmt.Println("log")
  32218. fmt.Println(string(userJSONBytes3))
  32219. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32220. utils.ErrorLog("解析失败:%v", err)
  32221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32222. return
  32223. }
  32224. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32225. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32226. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32227. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32228. resp3, requestErr3 := http.Get(api3)
  32229. if requestErr3 != nil {
  32230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32231. return
  32232. }
  32233. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32234. if ioErr3 != nil {
  32235. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32237. return
  32238. }
  32239. var respJSON3 map[string]interface{}
  32240. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32241. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32243. return
  32244. }
  32245. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32246. userJSONBytes3, _ := json.Marshal(respJSON3)
  32247. fmt.Println("log")
  32248. fmt.Println(string(userJSONBytes3))
  32249. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32250. utils.ErrorLog("解析失败:%v", err)
  32251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32252. return
  32253. }
  32254. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32255. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32256. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32257. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32258. resp3, requestErr3 := http.Get(api3)
  32259. if requestErr3 != nil {
  32260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32261. return
  32262. }
  32263. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32264. if ioErr3 != nil {
  32265. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32267. return
  32268. }
  32269. var respJSON3 map[string]interface{}
  32270. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32273. return
  32274. }
  32275. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32276. userJSONBytes3, _ := json.Marshal(respJSON3)
  32277. fmt.Println("log")
  32278. fmt.Println(string(userJSONBytes3))
  32279. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32280. utils.ErrorLog("解析失败:%v", err)
  32281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32282. return
  32283. }
  32284. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32285. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32286. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32287. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32288. resp3, requestErr3 := http.Get(api3)
  32289. if requestErr3 != nil {
  32290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32291. return
  32292. }
  32293. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32294. if ioErr3 != nil {
  32295. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32297. return
  32298. }
  32299. var respJSON3 map[string]interface{}
  32300. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32301. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32303. return
  32304. }
  32305. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32306. userJSONBytes3, _ := json.Marshal(respJSON3)
  32307. fmt.Println("log")
  32308. fmt.Println(string(userJSONBytes3))
  32309. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32310. utils.ErrorLog("解析失败:%v", err)
  32311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32312. return
  32313. }
  32314. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32315. var api3 string
  32316. if miConfig.MdtrtareaAdmvs == "320921" {
  32317. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32318. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32319. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32320. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32321. } else {
  32322. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32323. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32324. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32325. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32326. }
  32327. resp3, requestErr3 := http.Get(api3)
  32328. if requestErr3 != nil {
  32329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32330. return
  32331. }
  32332. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32333. if ioErr3 != nil {
  32334. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32336. return
  32337. }
  32338. var respJSON3 map[string]interface{}
  32339. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32340. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32342. return
  32343. }
  32344. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32345. userJSONBytes3, _ := json.Marshal(respJSON3)
  32346. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32347. utils.ErrorLog("解析失败:%v", err)
  32348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32349. return
  32350. }
  32351. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32352. res2.Output = resSix10265.Output
  32353. res2.ErrMsg = resSix10265.ErrMsg
  32354. res2.Cainfo = resSix10265.Cainfo
  32355. res2.WarnMsg = resSix10265.WarnMsg
  32356. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32357. res2.Infcode = infocode
  32358. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32359. var api3 string
  32360. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  32361. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32362. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32363. resp3, requestErr3 := http.Get(api3)
  32364. if requestErr3 != nil {
  32365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32366. return
  32367. }
  32368. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32369. if ioErr3 != nil {
  32370. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32372. return
  32373. }
  32374. var respJSON3 map[string]interface{}
  32375. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32376. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32378. return
  32379. }
  32380. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32381. userJSONBytes3, _ := json.Marshal(respJSON3)
  32382. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32383. utils.ErrorLog("解析失败:%v", err)
  32384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32385. return
  32386. }
  32387. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32388. res2.Output = resSix10265.Output
  32389. res2.ErrMsg = resSix10265.ErrMsg
  32390. res2.Cainfo = resSix10265.Cainfo
  32391. res2.WarnMsg = resSix10265.WarnMsg
  32392. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32393. res2.Infcode = infocode
  32394. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32395. 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)
  32396. var dat map[string]interface{}
  32397. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32398. fmt.Println(dat)
  32399. } else {
  32400. fmt.Println(err)
  32401. }
  32402. saveLog(result, request, "2202", "退号")
  32403. userJSONBytes, _ := json.Marshal(dat)
  32404. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32405. utils.ErrorLog("解析失败:%v", err)
  32406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32407. return
  32408. }
  32409. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32410. 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, "")
  32411. var dat map[string]interface{}
  32412. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32413. fmt.Println(dat)
  32414. } else {
  32415. fmt.Println(err)
  32416. }
  32417. saveLog(result, request, "2202", "退号")
  32418. userJSONBytes, _ := json.Marshal(dat)
  32419. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32420. utils.ErrorLog("解析失败:%v", err)
  32421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32422. return
  32423. }
  32424. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32425. 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, "")
  32426. var dat map[string]interface{}
  32427. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32428. fmt.Println(dat)
  32429. } else {
  32430. fmt.Println(err)
  32431. }
  32432. saveLog(result, request, "2202", "退号")
  32433. userJSONBytes, _ := json.Marshal(dat)
  32434. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32435. utils.ErrorLog("解析失败:%v", err)
  32436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32437. return
  32438. }
  32439. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32440. var api3 string
  32441. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32442. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32443. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32444. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32445. resp3, requestErr3 := http.Get(api3)
  32446. if requestErr3 != nil {
  32447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32448. return
  32449. }
  32450. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32451. if ioErr3 != nil {
  32452. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32454. return
  32455. }
  32456. var respJSON3 map[string]interface{}
  32457. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32460. return
  32461. }
  32462. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32463. if status == "0" {
  32464. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32465. c.ServeSuccessJSON(map[string]interface{}{
  32466. "failed_code": -10,
  32467. "msg": err_msg,
  32468. })
  32469. return
  32470. }
  32471. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32472. userJSONBytes3, _ := json.Marshal(respJSON3)
  32473. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32474. utils.ErrorLog("解析失败:%v", err)
  32475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32476. return
  32477. }
  32478. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32479. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32480. var api3 string
  32481. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32482. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32483. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32484. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32485. resp3, requestErr3 := http.Get(api3)
  32486. if requestErr3 != nil {
  32487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32488. return
  32489. }
  32490. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32491. if ioErr3 != nil {
  32492. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32494. return
  32495. }
  32496. var respJSON3 map[string]interface{}
  32497. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32498. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32500. return
  32501. }
  32502. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32503. if status == "0" {
  32504. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32505. c.ServeSuccessJSON(map[string]interface{}{
  32506. "failed_code": -10,
  32507. "msg": err_msg,
  32508. })
  32509. return
  32510. }
  32511. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32512. userJSONBytes3, _ := json.Marshal(respJSON3)
  32513. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32514. utils.ErrorLog("解析失败:%v", err)
  32515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32516. return
  32517. }
  32518. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32519. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32520. 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, "")
  32521. var dat map[string]interface{}
  32522. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32523. fmt.Println(dat)
  32524. } else {
  32525. fmt.Println(err)
  32526. }
  32527. saveLog(result, request, "2202", "退号")
  32528. userJSONBytes, _ := json.Marshal(dat)
  32529. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32530. utils.ErrorLog("解析失败:%v", err)
  32531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32532. return
  32533. }
  32534. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32535. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  32536. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32537. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32538. resp3, requestErr3 := http.Get(api3)
  32539. if requestErr3 != nil {
  32540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32541. return
  32542. }
  32543. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32544. if ioErr3 != nil {
  32545. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32547. return
  32548. }
  32549. var respJSON3 map[string]interface{}
  32550. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32551. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32553. return
  32554. }
  32555. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32556. userJSONBytes3, _ := json.Marshal(respJSON3)
  32557. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32558. utils.ErrorLog("解析失败:%v", err)
  32559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32560. return
  32561. }
  32562. } else {
  32563. var api3 string
  32564. if miConfig.Code == "H15049901371" {
  32565. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  32566. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32567. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32568. } else {
  32569. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  32570. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32571. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32572. }
  32573. resp3, requestErr3 := http.Get(api3)
  32574. if requestErr3 != nil {
  32575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32576. return
  32577. }
  32578. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32579. if ioErr3 != nil {
  32580. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32582. return
  32583. }
  32584. var respJSON3 map[string]interface{}
  32585. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32586. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32588. return
  32589. }
  32590. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32591. userJSONBytes3, _ := json.Marshal(respJSON3)
  32592. if miConfig.Code == "H15049901371" {
  32593. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32594. utils.ErrorLog("解析失败:%v", err)
  32595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32596. return
  32597. }
  32598. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32599. res2.Output = resSix10265.Output
  32600. res2.ErrMsg = resSix10265.ErrMsg
  32601. res2.Cainfo = resSix10265.Cainfo
  32602. res2.WarnMsg = resSix10265.WarnMsg
  32603. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32604. res2.Infcode = infocode
  32605. } else {
  32606. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32607. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  32608. utils.ErrorLog("解析失败:%v", err)
  32609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32610. return
  32611. }
  32612. res2.Infcode = res3.Infcode
  32613. } else {
  32614. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32615. utils.ErrorLog("解析失败:%v", err)
  32616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32617. return
  32618. }
  32619. }
  32620. }
  32621. }
  32622. if res2.Infcode == -1 {
  32623. c.ServeSuccessJSON(map[string]interface{}{
  32624. "failed_code": -10,
  32625. "msg": res2.ErrMsg,
  32626. })
  32627. return
  32628. }
  32629. if res2.Infcode == 0 {
  32630. if err == nil {
  32631. c.ServeSuccessJSON(map[string]interface{}{
  32632. "msg": "退号成功",
  32633. })
  32634. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  32635. } else {
  32636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32637. return
  32638. }
  32639. }
  32640. } else {
  32641. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  32642. //if err == nil {
  32643. // c.ServeSuccessJSON(map[string]interface{}{
  32644. // "msg": "退费成功",
  32645. // })
  32646. //} else {
  32647. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32648. // return
  32649. //}
  32650. }
  32651. }
  32652. func (c *HisApiController) RefundDetail() {
  32653. order_id, _ := c.GetInt64("order_id")
  32654. admin_user_id, _ := c.GetInt64("admin_user_id")
  32655. //his_patient_id, _ := c.GetInt64("his_patient_id")
  32656. number := c.GetString("number")
  32657. record_time := c.GetString("record_time")
  32658. patient_id, _ := c.GetInt64("patient_id")
  32659. //med_type, _ := c.GetInt64("med_type")
  32660. timeLayout := "2006-01-02"
  32661. loc, _ := time.LoadLocation("Local")
  32662. adminUser := c.GetAdminUserInfo()
  32663. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32664. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32665. fmt.Println(err)
  32666. if err != nil {
  32667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32668. return
  32669. }
  32670. recordDateTime := theTime.Unix()
  32671. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  32672. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32673. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32674. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32675. var order models.HisOrder
  32676. order, _ = service.GetHisOrderByID(order_id)
  32677. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  32678. if config.IsOpen == 1 { //对接了医保,走医保流程
  32679. var res2 ResultSix
  32680. if miConfig.MdtrtareaAdmvs == "421300" {
  32681. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32682. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32683. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32684. resp3, requestErr3 := http.Get(api3)
  32685. if requestErr3 != nil {
  32686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32687. return
  32688. }
  32689. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32690. if ioErr3 != nil {
  32691. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32693. return
  32694. }
  32695. var respJSON3 map[string]interface{}
  32696. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32697. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32699. return
  32700. }
  32701. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32702. userJSONBytes3, _ := json.Marshal(respJSON3)
  32703. fmt.Println("log")
  32704. fmt.Println(string(userJSONBytes3))
  32705. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32706. utils.ErrorLog("解析失败:%v", err)
  32707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32708. return
  32709. }
  32710. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32711. if err == nil {
  32712. c.ServeSuccessJSON(map[string]interface{}{
  32713. "msg": "撤销明细成功",
  32714. })
  32715. return
  32716. } else {
  32717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32718. return
  32719. }
  32720. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32721. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32722. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32723. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32724. resp3, requestErr3 := http.Get(api3)
  32725. if requestErr3 != nil {
  32726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32727. return
  32728. }
  32729. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32730. if ioErr3 != nil {
  32731. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32733. return
  32734. }
  32735. var respJSON3 map[string]interface{}
  32736. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32737. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32739. return
  32740. }
  32741. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32742. userJSONBytes3, _ := json.Marshal(respJSON3)
  32743. fmt.Println("log")
  32744. fmt.Println(string(userJSONBytes3))
  32745. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32746. utils.ErrorLog("解析失败:%v", err)
  32747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32748. return
  32749. }
  32750. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32751. if err == nil {
  32752. c.ServeSuccessJSON(map[string]interface{}{
  32753. "msg": "撤销明细成功",
  32754. })
  32755. return
  32756. } else {
  32757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32758. return
  32759. }
  32760. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32761. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32762. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32763. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32764. resp3, requestErr3 := http.Get(api3)
  32765. if requestErr3 != nil {
  32766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32767. return
  32768. }
  32769. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32770. if ioErr3 != nil {
  32771. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32773. return
  32774. }
  32775. var respJSON3 map[string]interface{}
  32776. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32777. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32779. return
  32780. }
  32781. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32782. userJSONBytes3, _ := json.Marshal(respJSON3)
  32783. fmt.Println("log")
  32784. fmt.Println(string(userJSONBytes3))
  32785. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32786. utils.ErrorLog("解析失败:%v", err)
  32787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32788. return
  32789. }
  32790. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32791. if err == nil {
  32792. c.ServeSuccessJSON(map[string]interface{}{
  32793. "msg": "撤销明细成功",
  32794. })
  32795. return
  32796. } else {
  32797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32798. return
  32799. }
  32800. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32801. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32802. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32803. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32804. resp3, requestErr3 := http.Get(api3)
  32805. if requestErr3 != nil {
  32806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32807. return
  32808. }
  32809. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32810. if ioErr3 != nil {
  32811. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32813. return
  32814. }
  32815. var respJSON3 map[string]interface{}
  32816. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32817. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32819. return
  32820. }
  32821. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32822. userJSONBytes3, _ := json.Marshal(respJSON3)
  32823. fmt.Println("log")
  32824. fmt.Println(string(userJSONBytes3))
  32825. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32826. utils.ErrorLog("解析失败:%v", err)
  32827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32828. return
  32829. }
  32830. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32831. if err == nil {
  32832. c.ServeSuccessJSON(map[string]interface{}{
  32833. "msg": "撤销明细成功",
  32834. })
  32835. return
  32836. } else {
  32837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32838. return
  32839. }
  32840. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32841. var resSix10265 ResultSix10265
  32842. var api3 string
  32843. if miConfig.MdtrtareaAdmvs == "320921" {
  32844. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32845. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32846. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32847. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32848. } else {
  32849. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32850. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32851. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32852. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32853. }
  32854. resp3, requestErr3 := http.Get(api3)
  32855. utils.ErrorLog("接口: %v", requestErr3)
  32856. if requestErr3 != nil {
  32857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32858. return
  32859. }
  32860. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32861. if ioErr3 != nil {
  32862. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32864. return
  32865. }
  32866. var respJSON3 map[string]interface{}
  32867. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32868. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32870. return
  32871. }
  32872. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32873. userJSONBytes3, _ := json.Marshal(respJSON3)
  32874. fmt.Println("log")
  32875. fmt.Println(string(userJSONBytes3))
  32876. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32877. utils.ErrorLog("解析失败:%v", err)
  32878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32879. return
  32880. }
  32881. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32882. res2.Output = resSix10265.Output
  32883. res2.ErrMsg = resSix10265.ErrMsg
  32884. res2.Cainfo = resSix10265.Cainfo
  32885. res2.WarnMsg = resSix10265.WarnMsg
  32886. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32887. res2.Infcode = infocode
  32888. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32889. if err == nil {
  32890. c.ServeSuccessJSON(map[string]interface{}{
  32891. "msg": "撤销明细成功",
  32892. })
  32893. return
  32894. } else {
  32895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32896. return
  32897. }
  32898. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32899. var api3 string
  32900. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32901. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32902. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32903. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32904. resp3, requestErr3 := http.Get(api3)
  32905. utils.ErrorLog("接口: %v", requestErr3)
  32906. if requestErr3 != nil {
  32907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32908. return
  32909. }
  32910. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32911. if ioErr3 != nil {
  32912. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32914. return
  32915. }
  32916. var respJSON3 map[string]interface{}
  32917. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32918. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32920. return
  32921. }
  32922. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32923. if status == "0" {
  32924. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32925. c.ServeSuccessJSON(map[string]interface{}{
  32926. "failed_code": -10,
  32927. "msg": err_msg,
  32928. })
  32929. return
  32930. }
  32931. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32932. userJSONBytes3, _ := json.Marshal(respJSON3)
  32933. fmt.Println("log")
  32934. fmt.Println(string(userJSONBytes3))
  32935. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32936. utils.ErrorLog("解析失败:%v", err)
  32937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32938. return
  32939. }
  32940. fmt.Println(res2.Infcode)
  32941. if res2.Infcode == -1 {
  32942. c.ServeSuccessJSON(map[string]interface{}{
  32943. "failed_code": -10,
  32944. "msg": res2.ErrMsg,
  32945. })
  32946. return
  32947. }
  32948. if res2.Infcode == 0 {
  32949. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32950. if err == nil {
  32951. c.ServeSuccessJSON(map[string]interface{}{
  32952. "msg": "撤销明细成功",
  32953. })
  32954. return
  32955. } else {
  32956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32957. return
  32958. }
  32959. } else {
  32960. c.ServeSuccessJSON(map[string]interface{}{
  32961. "failed_code": -10,
  32962. "msg": res2.ErrMsg,
  32963. })
  32964. }
  32965. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32966. if err == nil {
  32967. c.ServeSuccessJSON(map[string]interface{}{
  32968. "msg": "撤销明细成功",
  32969. })
  32970. return
  32971. } else {
  32972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32973. return
  32974. }
  32975. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32976. var api3 string
  32977. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32978. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32979. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32980. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32981. resp3, requestErr3 := http.Get(api3)
  32982. utils.ErrorLog("接口: %v", requestErr3)
  32983. if requestErr3 != nil {
  32984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32985. return
  32986. }
  32987. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32988. if ioErr3 != nil {
  32989. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32991. return
  32992. }
  32993. var respJSON3 map[string]interface{}
  32994. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32995. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32997. return
  32998. }
  32999. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33000. if status == "0" {
  33001. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33002. c.ServeSuccessJSON(map[string]interface{}{
  33003. "failed_code": -10,
  33004. "msg": err_msg,
  33005. })
  33006. return
  33007. }
  33008. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33009. userJSONBytes3, _ := json.Marshal(respJSON3)
  33010. fmt.Println("log")
  33011. fmt.Println(string(userJSONBytes3))
  33012. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33013. utils.ErrorLog("解析失败:%v", err)
  33014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33015. return
  33016. }
  33017. fmt.Println(res2.Infcode)
  33018. if res2.Infcode == -1 {
  33019. c.ServeSuccessJSON(map[string]interface{}{
  33020. "failed_code": -10,
  33021. "msg": res2.ErrMsg,
  33022. })
  33023. return
  33024. }
  33025. if res2.Infcode == 0 {
  33026. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33027. if err == nil {
  33028. c.ServeSuccessJSON(map[string]interface{}{
  33029. "msg": "撤销明细成功",
  33030. })
  33031. return
  33032. } else {
  33033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33034. return
  33035. }
  33036. } else {
  33037. c.ServeSuccessJSON(map[string]interface{}{
  33038. "failed_code": -10,
  33039. "msg": res2.ErrMsg,
  33040. })
  33041. }
  33042. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33043. if err == nil {
  33044. c.ServeSuccessJSON(map[string]interface{}{
  33045. "msg": "撤销明细成功",
  33046. })
  33047. return
  33048. } else {
  33049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33050. return
  33051. }
  33052. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33053. var resSix10265 ResultSix10265
  33054. new_chrg_bchno := order.Number
  33055. if adminUser.CurrentOrgId == 10265 {
  33056. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  33057. new_chrg_bchno = "0000"
  33058. }
  33059. }
  33060. var api3 string
  33061. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  33062. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33063. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33064. resp3, requestErr3 := http.Get(api3)
  33065. if requestErr3 != nil {
  33066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33067. return
  33068. }
  33069. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33070. if ioErr3 != nil {
  33071. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33073. return
  33074. }
  33075. var respJSON3 map[string]interface{}
  33076. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33077. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33079. return
  33080. }
  33081. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33082. userJSONBytes3, _ := json.Marshal(respJSON3)
  33083. fmt.Println("log")
  33084. fmt.Println(string(userJSONBytes3))
  33085. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33086. utils.ErrorLog("解析失败:%v", err)
  33087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33088. return
  33089. }
  33090. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33091. res2.Output = resSix10265.Output
  33092. res2.ErrMsg = resSix10265.ErrMsg
  33093. res2.Cainfo = resSix10265.Cainfo
  33094. res2.WarnMsg = resSix10265.WarnMsg
  33095. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33096. res2.Infcode = infocode
  33097. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33098. if err == nil {
  33099. c.ServeSuccessJSON(map[string]interface{}{
  33100. "msg": "撤销明细成功",
  33101. })
  33102. return
  33103. } else {
  33104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33105. return
  33106. }
  33107. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33108. 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)
  33109. var dat map[string]interface{}
  33110. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33111. fmt.Println(dat)
  33112. } else {
  33113. fmt.Println(err)
  33114. }
  33115. saveLog(result2, src_request, "2205", "撤销明细")
  33116. userJSONBytes, _ := json.Marshal(dat)
  33117. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33118. utils.ErrorLog("解析失败:%v", err)
  33119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33120. return
  33121. }
  33122. if res2.Infcode == 0 {
  33123. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33124. if err == nil {
  33125. c.ServeSuccessJSON(map[string]interface{}{
  33126. "msg": "撤销明细成功",
  33127. })
  33128. return
  33129. } else {
  33130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33131. return
  33132. }
  33133. } else {
  33134. c.ServeSuccessJSON(map[string]interface{}{
  33135. "failed_code": -10,
  33136. "msg": res2.ErrMsg,
  33137. })
  33138. }
  33139. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33140. 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, "")
  33141. var dat map[string]interface{}
  33142. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33143. fmt.Println(dat)
  33144. } else {
  33145. fmt.Println(err)
  33146. }
  33147. saveLog(result2, src_request, "2205", "撤销明细")
  33148. userJSONBytes, _ := json.Marshal(dat)
  33149. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33150. utils.ErrorLog("解析失败:%v", err)
  33151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33152. return
  33153. }
  33154. if res2.Infcode == 0 {
  33155. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33156. if err == nil {
  33157. c.ServeSuccessJSON(map[string]interface{}{
  33158. "msg": "撤销明细成功",
  33159. })
  33160. return
  33161. } else {
  33162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33163. return
  33164. }
  33165. } else {
  33166. c.ServeSuccessJSON(map[string]interface{}{
  33167. "failed_code": -10,
  33168. "msg": res2.ErrMsg,
  33169. })
  33170. }
  33171. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33172. 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, "")
  33173. var dat map[string]interface{}
  33174. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33175. fmt.Println(dat)
  33176. } else {
  33177. fmt.Println(err)
  33178. }
  33179. saveLog(result2, src_request, "2205", "撤销明细")
  33180. userJSONBytes, _ := json.Marshal(dat)
  33181. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33182. utils.ErrorLog("解析失败:%v", err)
  33183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33184. return
  33185. }
  33186. if res2.Infcode == 0 {
  33187. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33188. if err == nil {
  33189. c.ServeSuccessJSON(map[string]interface{}{
  33190. "msg": "撤销明细成功",
  33191. })
  33192. return
  33193. } else {
  33194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33195. return
  33196. }
  33197. } else {
  33198. c.ServeSuccessJSON(map[string]interface{}{
  33199. "failed_code": -10,
  33200. "msg": res2.ErrMsg,
  33201. })
  33202. }
  33203. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33204. 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, "")
  33205. var dat map[string]interface{}
  33206. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33207. fmt.Println(dat)
  33208. } else {
  33209. fmt.Println(err)
  33210. }
  33211. saveLog(result2, src_request, "2205", "撤销明细")
  33212. userJSONBytes, _ := json.Marshal(dat)
  33213. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33214. utils.ErrorLog("解析失败:%v", err)
  33215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33216. return
  33217. }
  33218. if res2.Infcode == 0 {
  33219. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33220. if err == nil {
  33221. c.ServeSuccessJSON(map[string]interface{}{
  33222. "msg": "撤销明细成功",
  33223. })
  33224. return
  33225. } else {
  33226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33227. return
  33228. }
  33229. } else {
  33230. c.ServeSuccessJSON(map[string]interface{}{
  33231. "failed_code": -10,
  33232. "msg": res2.ErrMsg,
  33233. })
  33234. }
  33235. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33236. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  33237. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33238. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33239. resp2, requestErr2 := http.Get(api2)
  33240. if requestErr2 != nil {
  33241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33242. return
  33243. }
  33244. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33245. if ioErr2 != nil {
  33246. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33248. return
  33249. }
  33250. var respJSON2 map[string]interface{}
  33251. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33254. return
  33255. }
  33256. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33257. userJSONBytes3, _ := json.Marshal(respJSON2)
  33258. fmt.Println("log")
  33259. fmt.Println(string(userJSONBytes3))
  33260. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33261. utils.ErrorLog("解析失败:%v", err)
  33262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33263. return
  33264. }
  33265. if res2.Infcode == 0 {
  33266. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33267. if err == nil {
  33268. c.ServeSuccessJSON(map[string]interface{}{
  33269. "msg": "撤销明细成功",
  33270. })
  33271. return
  33272. } else {
  33273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33274. return
  33275. }
  33276. } else {
  33277. c.ServeSuccessJSON(map[string]interface{}{
  33278. "failed_code": -10,
  33279. "msg": res2.ErrMsg,
  33280. })
  33281. }
  33282. } else {
  33283. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  33284. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33285. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33286. resp2, requestErr2 := http.Get(api2)
  33287. if requestErr2 != nil {
  33288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33289. return
  33290. }
  33291. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33292. if ioErr2 != nil {
  33293. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33295. return
  33296. }
  33297. var respJSON2 map[string]interface{}
  33298. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33301. return
  33302. }
  33303. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33304. userJSONBytes3, _ := json.Marshal(respJSON2)
  33305. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33306. utils.ErrorLog("解析失败:%v", err)
  33307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33308. return
  33309. }
  33310. if res2.Infcode == -1 {
  33311. c.ServeSuccessJSON(map[string]interface{}{
  33312. "failed_code": -10,
  33313. "msg": res2.ErrMsg,
  33314. })
  33315. return
  33316. } else {
  33317. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33318. if err == nil {
  33319. c.ServeSuccessJSON(map[string]interface{}{
  33320. "msg": "撤销明细成功",
  33321. })
  33322. return
  33323. } else {
  33324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33325. return
  33326. }
  33327. }
  33328. }
  33329. } else {
  33330. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33331. if err == nil {
  33332. c.ServeSuccessJSON(map[string]interface{}{
  33333. "msg": "退费成功",
  33334. })
  33335. } else {
  33336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33337. return
  33338. }
  33339. }
  33340. }
  33341. // 对账
  33342. func (c *HisApiController) GetCheckAccount() {
  33343. start_time := c.GetString("start_time")
  33344. end_time := c.GetString("end_time")
  33345. insutype := c.GetString("insutype")
  33346. clr_type := c.GetString("clr_type")
  33347. clr_org := c.GetString("clr_optins")
  33348. admin_user_id, _ := c.GetInt64("admin_user_id")
  33349. adminUser := c.GetAdminUserInfo()
  33350. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33351. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33352. if len(clr_org) == 0 {
  33353. clr_org = miConfig.InsuplcAdmdvs
  33354. }
  33355. timeLayout := "2006-01-02"
  33356. loc, _ := time.LoadLocation("Local")
  33357. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33358. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33359. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33360. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33361. fixmedins_setl_cnt := int64(len(orders))
  33362. var medfee_sumamt float64
  33363. var acct_pay float64
  33364. var fund_pay_sumamt float64
  33365. for _, item := range orders {
  33366. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33367. acct_pay = acct_pay + item.AcctPay
  33368. if miConfig.MdtrtareaAdmvs == "361025" {
  33369. fund_pay_sumamt = fund_pay_sumamt + item.HifpPay + item.HifmiPay + item.MafPay + item.HifobPay + item.HifesPay
  33370. } else {
  33371. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33372. }
  33373. }
  33374. var user_name string
  33375. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33376. if role.ID == 0 {
  33377. user_name = "xxx"
  33378. } else {
  33379. user_name = role.UserName
  33380. }
  33381. var res ResultEight
  33382. var res10188 ResultEightFor10188
  33383. if config.IsOpen == 1 {
  33384. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33385. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  33386. "insutype=" + insutype +
  33387. "&clr_type=" + clr_type +
  33388. "&setl_optins=" + clr_org +
  33389. "&stmt_begndate=" + start_time +
  33390. "&stm_enddate=" + end_time +
  33391. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33392. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33393. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33394. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33395. "&fixmedins_code=" + miConfig.Code +
  33396. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33397. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33398. "&secret_key=" + miConfig.SecretKey +
  33399. "&org_name=" + miConfig.OrgName +
  33400. "&doctor=" + user_name +
  33401. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33402. fmt.Println(api)
  33403. resp, requestErr := http.Get(api)
  33404. if requestErr != nil {
  33405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33406. return
  33407. }
  33408. body, ioErr := ioutil.ReadAll(resp.Body)
  33409. fmt.Println(body)
  33410. if ioErr != nil {
  33411. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33413. return
  33414. }
  33415. var respJSON map[string]interface{}
  33416. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33417. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33419. return
  33420. }
  33421. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33422. userJSONBytes, _ := json.Marshal(respJSON)
  33423. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33424. utils.ErrorLog("解析失败:%v", err)
  33425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33426. return
  33427. }
  33428. res.InfRefmsgid = res10188.InfRefmsgid
  33429. res.Output = res10188.Output
  33430. res.ErrMsg = res10188.ErrMsg
  33431. res.Cainfo = res10188.Cainfo
  33432. res.WarnMsg = res10188.WarnMsg
  33433. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33434. res.Infcode = infocode
  33435. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33436. if clr_type != "9903" {
  33437. clr_type = "99" // 就诊 ID(来自2201接口返回)
  33438. }
  33439. if clr_type == "9903" {
  33440. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  33441. }
  33442. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  33443. "insutype=" + insutype +
  33444. "&clr_type=" + clr_type +
  33445. "&setl_optins=" + clr_org +
  33446. "&stmt_begndate=" + start_time +
  33447. "&stm_enddate=" + end_time +
  33448. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33449. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33450. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33451. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33452. "&fixmedins_code=" + miConfig.Code +
  33453. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33454. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33455. "&secret_key=" + miConfig.SecretKey +
  33456. "&org_name=" + miConfig.OrgName +
  33457. "&doctor=" + user_name
  33458. resp, requestErr := http.Get(api)
  33459. if requestErr != nil {
  33460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33461. return
  33462. }
  33463. body, ioErr := ioutil.ReadAll(resp.Body)
  33464. if ioErr != nil {
  33465. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33467. return
  33468. }
  33469. var respJSON map[string]interface{}
  33470. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33471. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33473. return
  33474. }
  33475. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33476. result, _ := json.Marshal(respJSON)
  33477. fmt.Println("log")
  33478. fmt.Println(string(result))
  33479. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  33480. utils.ErrorLog("解析失败:%v", err)
  33481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33482. return
  33483. }
  33484. res.InfRefmsgid = res10188.InfRefmsgid
  33485. res.Output = res10188.Output
  33486. res.ErrMsg = res10188.ErrMsg
  33487. res.Cainfo = res10188.Cainfo
  33488. res.WarnMsg = res10188.WarnMsg
  33489. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33490. res.Infcode = infocode
  33491. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33492. var baseParams models.BaseParams
  33493. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33494. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33495. baseParams.SecretKey = miConfig.SecretKey
  33496. baseParams.OrgName = miConfig.OrgName
  33497. baseParams.FixmedinsCode = miConfig.Code
  33498. baseParams.EncKey = miConfig.EncKey
  33499. baseParams.AppSecret = miConfig.AppSecret
  33500. baseParams.SignKey = miConfig.SignKey
  33501. baseParams.AppID = miConfig.Code
  33502. baseParams.Doctor = role.UserName
  33503. baseParams.RequestUrl = miConfig.Url
  33504. businessParams := models.BusinessParams{
  33505. Insutype: insutype,
  33506. ClrType: clr_type,
  33507. SetlOptins: clr_org,
  33508. StmtBegndate: start_time,
  33509. StmtEnddate: end_time,
  33510. MedfeeSumamt: medfee_sumamt,
  33511. FundPaySumamt: fund_pay_sumamt,
  33512. AcctPay: acct_pay,
  33513. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33514. }
  33515. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33516. fmt.Println(requestLog)
  33517. fmt.Println(result)
  33518. fmt.Println(err_msg)
  33519. var dat map[string]interface{}
  33520. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33521. fmt.Println(dat)
  33522. } else {
  33523. fmt.Println(err)
  33524. }
  33525. userJSONBytes, _ := json.Marshal(dat)
  33526. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33527. utils.ErrorLog("解析失败:%v", err)
  33528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33529. return
  33530. }
  33531. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33532. var baseParams models.BaseParams
  33533. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33534. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33535. baseParams.SecretKey = miConfig.SecretKey
  33536. baseParams.OrgName = miConfig.OrgName
  33537. baseParams.FixmedinsCode = miConfig.Code
  33538. baseParams.EncKey = miConfig.EncKey
  33539. baseParams.AppSecret = miConfig.AppSecret
  33540. baseParams.SignKey = miConfig.SignKey
  33541. baseParams.AppID = miConfig.Code
  33542. baseParams.Doctor = role.UserName
  33543. baseParams.RequestUrl = miConfig.Url
  33544. baseParams.AccessKey = miConfig.AccessKey
  33545. businessParams := models.BusinessParams{
  33546. Insutype: insutype,
  33547. ClrType: clr_type,
  33548. SetlOptins: "430822",
  33549. StmtBegndate: start_time,
  33550. StmtEnddate: end_time,
  33551. MedfeeSumamt: medfee_sumamt,
  33552. FundPaySumamt: fund_pay_sumamt,
  33553. AcctPay: acct_pay,
  33554. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33555. }
  33556. 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)
  33557. fmt.Println(requestLog)
  33558. fmt.Println(result)
  33559. var dat map[string]interface{}
  33560. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33561. fmt.Println(dat)
  33562. } else {
  33563. fmt.Println(err)
  33564. }
  33565. userJSONBytes, _ := json.Marshal(dat)
  33566. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33567. utils.ErrorLog("解析失败:%v", err)
  33568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33569. return
  33570. }
  33571. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33572. var baseParams models.BaseParams
  33573. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33574. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33575. baseParams.SecretKey = miConfig.SecretKey
  33576. baseParams.OrgName = miConfig.OrgName
  33577. baseParams.FixmedinsCode = miConfig.Code
  33578. baseParams.EncKey = miConfig.EncKey
  33579. baseParams.AppSecret = miConfig.AppSecret
  33580. baseParams.SignKey = miConfig.SignKey
  33581. baseParams.AppID = miConfig.Code
  33582. baseParams.Doctor = role.UserName
  33583. baseParams.RequestUrl = miConfig.Url
  33584. businessParams := models.BusinessParams{
  33585. Insutype: insutype,
  33586. ClrType: clr_type,
  33587. SetlOptins: clr_org,
  33588. StmtBegndate: start_time,
  33589. StmtEnddate: end_time,
  33590. MedfeeSumamt: medfee_sumamt,
  33591. FundPaySumamt: fund_pay_sumamt,
  33592. AcctPay: acct_pay,
  33593. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33594. }
  33595. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33596. fmt.Println(requestLog)
  33597. fmt.Println(result)
  33598. fmt.Println(err_msg)
  33599. var dat map[string]interface{}
  33600. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33601. fmt.Println(dat)
  33602. } else {
  33603. fmt.Println(err)
  33604. }
  33605. userJSONBytes, _ := json.Marshal(dat)
  33606. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33607. utils.ErrorLog("解析失败:%v", err)
  33608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33609. return
  33610. }
  33611. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33612. if len(clr_type) == 0 {
  33613. clr_type = "11"
  33614. }
  33615. api := miConfig.Url + "gdyb/ten?" +
  33616. "insutype=" + insutype +
  33617. "&clr_type=" + clr_type +
  33618. "&setl_optins=" + clr_org +
  33619. "&stmt_begndate=" + start_time +
  33620. "&stm_enddate=" + end_time +
  33621. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33622. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33623. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33624. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33625. "&fixmedins_code=" + miConfig.Code +
  33626. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33627. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33628. "&secret_key=" + miConfig.SecretKey +
  33629. "&org_name=" + miConfig.OrgName +
  33630. "&doctor=" + user_name
  33631. fmt.Println(api)
  33632. resp, requestErr := http.Get(api)
  33633. if requestErr != nil {
  33634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33635. return
  33636. }
  33637. body, ioErr := ioutil.ReadAll(resp.Body)
  33638. fmt.Println(body)
  33639. if ioErr != nil {
  33640. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33642. return
  33643. }
  33644. var respJSON map[string]interface{}
  33645. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33646. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33648. return
  33649. }
  33650. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33651. userJSONBytes, _ := json.Marshal(respJSON)
  33652. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33653. utils.ErrorLog("解析失败:%v", err)
  33654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33655. return
  33656. }
  33657. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33658. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33659. //fixmedins_setl_cnt := int64(len(orders_two))
  33660. //var medfee_sumamt float64
  33661. //var acct_pay float64
  33662. //var fund_pay_sumamt float64
  33663. //for _, item := range orders_two {
  33664. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33665. // acct_pay = acct_pay + item.AcctPay
  33666. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33667. //}
  33668. var baseParams models.BaseParams
  33669. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33670. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33671. baseParams.SecretKey = miConfig.SecretKey
  33672. baseParams.OrgName = miConfig.OrgName
  33673. baseParams.FixmedinsCode = miConfig.Code
  33674. baseParams.EncKey = miConfig.EncKey
  33675. baseParams.AppSecret = miConfig.AppSecret
  33676. baseParams.SignKey = miConfig.SignKey
  33677. baseParams.AppID = miConfig.Code
  33678. baseParams.Doctor = role.UserName
  33679. baseParams.RequestUrl = miConfig.Url
  33680. if clr_type == "9903" {
  33681. clr_type = "9994"
  33682. }
  33683. businessParams := models.BusinessParams{
  33684. Insutype: insutype,
  33685. ClrType: clr_type,
  33686. SetlOptins: "360302",
  33687. StmtBegndate: start_time,
  33688. StmtEnddate: end_time,
  33689. MedfeeSumamt: 0,
  33690. FundPaySumamt: 0,
  33691. AcctPay: 0,
  33692. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33693. }
  33694. 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))
  33695. fmt.Println(requestLog)
  33696. fmt.Println(result)
  33697. var dat map[string]interface{}
  33698. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33699. fmt.Println(dat)
  33700. } else {
  33701. fmt.Println(err)
  33702. }
  33703. userJSONBytes, _ := json.Marshal(dat)
  33704. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33705. utils.ErrorLog("解析失败:%v", err)
  33706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33707. return
  33708. }
  33709. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33710. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33711. //fixmedins_setl_cnt := int64(len(orders_two))
  33712. //var medfee_sumamt float64
  33713. //var acct_pay float64
  33714. //var fund_pay_sumamt float64
  33715. //for _, item := range orders_two {
  33716. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33717. // acct_pay = acct_pay + item.AcctPay
  33718. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33719. //}
  33720. var baseParams models.BaseParams
  33721. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33722. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33723. baseParams.SecretKey = miConfig.SecretKey
  33724. baseParams.OrgName = miConfig.OrgName
  33725. baseParams.FixmedinsCode = miConfig.Code
  33726. baseParams.EncKey = miConfig.EncKey
  33727. baseParams.AppSecret = miConfig.AppSecret
  33728. baseParams.SignKey = miConfig.SignKey
  33729. baseParams.AppID = miConfig.Code
  33730. baseParams.Doctor = role.UserName
  33731. baseParams.RequestUrl = miConfig.Url
  33732. if clr_type == "9903" {
  33733. clr_type = "9994"
  33734. }
  33735. businessParams := models.BusinessParams{
  33736. Insutype: insutype,
  33737. ClrType: clr_type,
  33738. SetlOptins: "361025",
  33739. StmtBegndate: start_time,
  33740. StmtEnddate: end_time,
  33741. MedfeeSumamt: 0,
  33742. FundPaySumamt: 0,
  33743. AcctPay: 0,
  33744. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33745. }
  33746. result, requestLog := service.Jxyb32012(businessParams.FixmedinsSetlCnt, businessParams.StmtBegndate, businessParams.StmtEnddate, businessParams.ClrType, businessParams.Insutype, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.RequestUrl, miConfig.AccessKey, miConfig.SecretKey, fmt.Sprintf("%.2f", medfee_sumamt), fmt.Sprintf("%.2f", fund_pay_sumamt), fmt.Sprintf("%.2f", acct_pay))
  33747. fmt.Println(requestLog)
  33748. fmt.Println(result)
  33749. var dat map[string]interface{}
  33750. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33751. fmt.Println(dat)
  33752. } else {
  33753. fmt.Println(err)
  33754. }
  33755. userJSONBytes, _ := json.Marshal(dat)
  33756. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33757. utils.ErrorLog("解析失败:%v", err)
  33758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33759. return
  33760. }
  33761. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33762. var api string
  33763. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33764. "&clr_type=" + clr_type +
  33765. "&setl_optins=" + clr_org +
  33766. "&stmt_begndate=" + start_time +
  33767. "&stm_enddate=" + end_time +
  33768. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33769. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33770. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33771. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33772. "&fixmedins_code=" + miConfig.Code +
  33773. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33774. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33775. "&secret_key=" + miConfig.SecretKey +
  33776. "&org_name=" + miConfig.OrgName +
  33777. "&doctor=" + user_name + "&url=" + miConfig.Url
  33778. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33779. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33780. resp, requestErr := http.Get(api)
  33781. if requestErr != nil {
  33782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33783. return
  33784. }
  33785. body, ioErr := ioutil.ReadAll(resp.Body)
  33786. if ioErr != nil {
  33787. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33789. return
  33790. }
  33791. var respJSON map[string]interface{}
  33792. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33793. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33795. return
  33796. }
  33797. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33798. if status == "0" {
  33799. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33800. c.ServeSuccessJSON(map[string]interface{}{
  33801. "failed_code": -10,
  33802. "msg": err_msg,
  33803. })
  33804. return
  33805. }
  33806. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33807. userJSONBytes, _ := json.Marshal(respJSON)
  33808. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33809. utils.ErrorLog("解析失败:%v", err)
  33810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33811. return
  33812. }
  33813. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33814. var api string
  33815. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33816. "&clr_type=" + clr_type +
  33817. "&setl_optins=" + clr_org +
  33818. "&stmt_begndate=" + start_time +
  33819. "&stm_enddate=" + end_time +
  33820. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33821. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33822. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33823. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33824. "&fixmedins_code=" + miConfig.Code +
  33825. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33826. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33827. "&secret_key=" + miConfig.SecretKey +
  33828. "&org_name=" + miConfig.OrgName +
  33829. "&doctor=" + user_name + "&url=" + miConfig.Url
  33830. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33831. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33832. resp, requestErr := http.Get(api)
  33833. if requestErr != nil {
  33834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33835. return
  33836. }
  33837. body, ioErr := ioutil.ReadAll(resp.Body)
  33838. if ioErr != nil {
  33839. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33841. return
  33842. }
  33843. var respJSON map[string]interface{}
  33844. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33845. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33847. return
  33848. }
  33849. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33850. if status == "0" {
  33851. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33852. c.ServeSuccessJSON(map[string]interface{}{
  33853. "failed_code": -10,
  33854. "msg": err_msg,
  33855. })
  33856. return
  33857. }
  33858. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33859. userJSONBytes, _ := json.Marshal(respJSON)
  33860. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33861. utils.ErrorLog("解析失败:%v", err)
  33862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33863. return
  33864. }
  33865. } else {
  33866. if len(clr_type) == 0 {
  33867. clr_type = "11"
  33868. }
  33869. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33870. "insutype=" + insutype +
  33871. "&clr_type=" + clr_type +
  33872. "&setl_optins=" + clr_org +
  33873. "&stmt_begndate=" + start_time +
  33874. "&stm_enddate=" + end_time +
  33875. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33876. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33877. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33878. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33879. "&fixmedins_code=" + miConfig.Code +
  33880. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33881. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33882. "&secret_key=" + miConfig.SecretKey +
  33883. "&org_name=" + miConfig.OrgName +
  33884. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33885. fmt.Println(api)
  33886. resp, requestErr := http.Get(api)
  33887. if requestErr != nil {
  33888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33889. return
  33890. }
  33891. body, ioErr := ioutil.ReadAll(resp.Body)
  33892. fmt.Println(body)
  33893. if ioErr != nil {
  33894. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33896. return
  33897. }
  33898. var respJSON map[string]interface{}
  33899. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33902. return
  33903. }
  33904. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33905. userJSONBytes, _ := json.Marshal(respJSON)
  33906. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33907. utils.ErrorLog("解析失败:%v", err)
  33908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33909. return
  33910. }
  33911. }
  33912. if res.Infcode == 0 {
  33913. if res.Output.Stmtinfo.StmtRslt == "0" {
  33914. micc := &models.MedicalInsuranceCostCompare{
  33915. StartTime: startime.Unix(),
  33916. EndTime: endtime.Unix(),
  33917. Insutype: insutype,
  33918. CheckType: 1,
  33919. Num: fixmedins_setl_cnt,
  33920. Mtime: time.Now().Unix(),
  33921. Status: 1,
  33922. UserOrgId: adminUser.CurrentOrgId,
  33923. CostTotal: medfee_sumamt,
  33924. FuncTotal: fund_pay_sumamt,
  33925. PsnPay: acct_pay,
  33926. Creator: admin_user_id,
  33927. Ctime: time.Now().Unix(),
  33928. ClrType: clr_type,
  33929. }
  33930. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  33931. if err == nil {
  33932. c.ServeSuccessJSON(map[string]interface{}{
  33933. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33934. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33935. })
  33936. } else {
  33937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33938. }
  33939. } else {
  33940. c.ServeSuccessJSON(map[string]interface{}{
  33941. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33942. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33943. })
  33944. }
  33945. } else {
  33946. c.ServeSuccessJSON(map[string]interface{}{
  33947. "failed_code": -10,
  33948. "msg": res.ErrMsg,
  33949. })
  33950. }
  33951. }
  33952. }
  33953. func (c *HisApiController) Check310() {
  33954. adminUser := c.GetAdminUserInfo()
  33955. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33956. var user_name string
  33957. user_name = "高慧裕"
  33958. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33959. "insutype=" + "310" +
  33960. "&clr_type=" + "" +
  33961. "&setl_optins=" + "441202" +
  33962. "&stmt_begndate=" + "2022-03-01" +
  33963. "&stm_enddate=" + "2022-03-31" +
  33964. "&medfee_sumamt=" + "194930.12" +
  33965. "&fund_pay_sumamt=" + "188741.46" +
  33966. "&acct_pay=" + "0" +
  33967. "&fixmedins_setl_cnt=" + "452" +
  33968. "&fixmedins_code=" + miConfig.Code +
  33969. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33970. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33971. "&secret_key=" + miConfig.SecretKey +
  33972. "&org_name=" + miConfig.OrgName +
  33973. "&doctor=" + user_name
  33974. fmt.Println(api)
  33975. resp, requestErr := http.Get(api)
  33976. if requestErr != nil {
  33977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33978. return
  33979. }
  33980. body, ioErr := ioutil.ReadAll(resp.Body)
  33981. fmt.Println(body)
  33982. if ioErr != nil {
  33983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33985. return
  33986. }
  33987. var respJSON map[string]interface{}
  33988. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33991. return
  33992. }
  33993. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33994. userJSONBytes, _ := json.Marshal(respJSON)
  33995. var res ResultEight
  33996. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33997. utils.ErrorLog("解析失败:%v", err)
  33998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33999. return
  34000. }
  34001. }
  34002. func (c *HisApiController) Check390() {
  34003. adminUser := c.GetAdminUserInfo()
  34004. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34005. var user_name string
  34006. user_name = "高慧裕"
  34007. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  34008. "insutype=" + "390" +
  34009. "&clr_type=" + "" +
  34010. "&setl_optins=" + "441202" +
  34011. "&stmt_begndate=" + "2022-03-01" +
  34012. "&stm_enddate=" + "2022-03-31" +
  34013. "&medfee_sumamt=" + "1068448.89" +
  34014. "&fund_pay_sumamt=" + "1014677.62" +
  34015. "&acct_pay=" + "0" +
  34016. "&fixmedins_setl_cnt=" + "1950" +
  34017. "&fixmedins_code=" + miConfig.Code +
  34018. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34019. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34020. "&secret_key=" + miConfig.SecretKey +
  34021. "&org_name=" + miConfig.OrgName +
  34022. "&doctor=" + user_name
  34023. fmt.Println(api)
  34024. resp, requestErr := http.Get(api)
  34025. if requestErr != nil {
  34026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34027. return
  34028. }
  34029. body, ioErr := ioutil.ReadAll(resp.Body)
  34030. fmt.Println(body)
  34031. if ioErr != nil {
  34032. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34034. return
  34035. }
  34036. var respJSON map[string]interface{}
  34037. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34038. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34040. return
  34041. }
  34042. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34043. userJSONBytes, _ := json.Marshal(respJSON)
  34044. var res ResultEight
  34045. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34046. utils.ErrorLog("解析失败:%v", err)
  34047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34048. return
  34049. }
  34050. }
  34051. // 对账明细
  34052. func (c *HisApiController) GetCheckDetailAccount() {
  34053. start_time := c.GetString("start_time")
  34054. end_time := c.GetString("end_time")
  34055. admin_user_id, _ := c.GetInt64("admin_user_id")
  34056. adminUser := c.GetAdminUserInfo()
  34057. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34058. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34059. timeLayout := "2006-01-02"
  34060. loc, _ := time.LoadLocation("Local")
  34061. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34062. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34063. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34064. rand.Seed(time.Now().UnixNano())
  34065. num := rand.Intn(30000)
  34066. Mkdir(miConfig.OrgName)
  34067. file := strconv.FormatInt(int64(num), 10)
  34068. file_name := file + ".txt"
  34069. zip_name := file + ".zip"
  34070. zip_path := miConfig.OrgName + "/" + zip_name
  34071. file_path := miConfig.OrgName + "/" + file_name
  34072. decimal.DivisionPrecision = 2
  34073. var medfee_sumamt float64
  34074. var psn_cash_pay float64
  34075. var fund_pay_sumamt float64
  34076. fixmedins_setl_cnt := int64(len(orders))
  34077. for _, item := range orders {
  34078. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34079. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  34080. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34081. }
  34082. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  34083. defer f.Close()
  34084. if err != nil {
  34085. fmt.Println(err.Error())
  34086. } else {
  34087. for _, item := range orders {
  34088. var refd_setl_flag string
  34089. if item.OrderStatus == 2 {
  34090. refd_setl_flag = "0"
  34091. var str string
  34092. str = item.SetlId + " " +
  34093. item.MdtrtId + " " +
  34094. item.PsnNo + " " +
  34095. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  34096. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  34097. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  34098. _, err = f.Write([]byte(str))
  34099. }
  34100. if item.OrderStatus == 3 {
  34101. var str string
  34102. str = item.SetlId + " " +
  34103. item.MdtrtId + " " +
  34104. item.PsnNo + " " +
  34105. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  34106. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  34107. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  34108. _, err = f.Write([]byte(str))
  34109. var str2 string
  34110. str2 = item.SetlId + " " +
  34111. item.MdtrtId + " " +
  34112. item.PsnNo + " " +
  34113. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  34114. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  34115. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  34116. _, err = f.Write([]byte(str2))
  34117. }
  34118. }
  34119. }
  34120. Zip(file_path, zip_path)
  34121. fmt.Println(ReadFile(zip_path))
  34122. fmt.Println(string(ReadFile(zip_path)))
  34123. if config.IsOpen == 1 {
  34124. var user_name string
  34125. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34126. if role.ID == 0 {
  34127. user_name = "管理员"
  34128. } else {
  34129. user_name = role.UserName
  34130. }
  34131. baseParams := models.BaseParams{
  34132. SecretKey: miConfig.SecretKey,
  34133. FixmedinsCode: miConfig.Code,
  34134. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34135. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34136. OrgName: miConfig.OrgName,
  34137. Doctor: user_name,
  34138. }
  34139. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  34140. var dat map[string]interface{}
  34141. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34142. fmt.Println(dat)
  34143. } else {
  34144. fmt.Println(err)
  34145. }
  34146. userJSONBytes, _ := json.Marshal(dat)
  34147. var res ResultNine
  34148. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34149. utils.ErrorLog("解析失败:%v", err)
  34150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34151. return
  34152. }
  34153. if res.Infcode == 0 {
  34154. fileNo := res.Output.FileQuryNo
  34155. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  34156. "file_qury_no=" + fileNo +
  34157. "&setl_optins=" + "定点医保中心" +
  34158. "&stmt_begndate=" + start_time +
  34159. "&stm_enddate=" + end_time +
  34160. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34161. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34162. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  34163. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  34164. "&fixmedins_code=" + miConfig.Code +
  34165. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34166. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34167. "&secret_key=" + miConfig.SecretKey +
  34168. "&org_name=" + miConfig.OrgName +
  34169. "&doctor=" + user_name
  34170. resp, requestErr := http.Get(api)
  34171. if requestErr != nil {
  34172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34173. return
  34174. }
  34175. body, ioErr := ioutil.ReadAll(resp.Body)
  34176. if ioErr != nil {
  34177. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34179. return
  34180. }
  34181. var respJSON map[string]interface{}
  34182. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34183. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34185. return
  34186. }
  34187. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34188. userJSONBytes, _ := json.Marshal(respJSON)
  34189. var res ResultTen
  34190. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34191. utils.ErrorLog("解析失败:%v", err)
  34192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34193. return
  34194. }
  34195. if res.Infcode == 0 {
  34196. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  34197. micc := &models.MedicalInsuranceCostCompare{
  34198. StartTime: startime.Unix(),
  34199. EndTime: endtime.Unix(),
  34200. Insutype: "0",
  34201. CheckType: 2,
  34202. Num: fixmedins_setl_cnt,
  34203. Mtime: time.Now().Unix(),
  34204. Status: 1,
  34205. UserOrgId: adminUser.CurrentOrgId,
  34206. CostTotal: medfee_sumamt,
  34207. FuncTotal: fund_pay_sumamt,
  34208. PsnPay: psn_cash_pay,
  34209. Creator: admin_user_id,
  34210. Ctime: time.Now().Unix(),
  34211. }
  34212. service.CreateMedicalInsuranceCostCompareRecord(micc)
  34213. c.ServeSuccessJSON(map[string]interface{}{
  34214. "msg": "明细对账成功",
  34215. })
  34216. }
  34217. } else {
  34218. }
  34219. }
  34220. }
  34221. type CustomOrderInfo struct {
  34222. Name string
  34223. Spec string
  34224. Unit string
  34225. Count float64
  34226. Price float64
  34227. Total float64
  34228. }
  34229. func (c *HisApiController) GetBatchSettleAccounts() {
  34230. admin_user_id, _ := c.GetInt64("admin_user_id")
  34231. order_ids := c.GetString("order_ids")
  34232. order_ids_arr := strings.Split(order_ids, ",")
  34233. data3 := []map[string]interface{}{}
  34234. for _, item := range order_ids_arr {
  34235. id, _ := strconv.ParseInt(item, 10, 64)
  34236. order_id := id
  34237. adminUser := c.GetAdminUserInfo()
  34238. order, _ := service.GetHisOrderByID(order_id)
  34239. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34240. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34241. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34242. orderInfos = append(orderInfos, orderInfos_two...)
  34243. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34244. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34245. var diagnosis_ids []string
  34246. if his.ID > 0 {
  34247. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34248. } else {
  34249. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34250. }
  34251. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34252. var dia_config []*models.HisXtDiagnoseConfig
  34253. var name string
  34254. for _, item := range diagnosis_ids {
  34255. id, _ := strconv.ParseInt(item, 10, 64)
  34256. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34257. dia_config = append(dia_config, &diagnosisConfig)
  34258. if len(name) == 0 {
  34259. name = diagnosisConfig.ClassName
  34260. }
  34261. //} else {
  34262. // name = name + "," + diagnosisConfig.ClassName
  34263. //}
  34264. }
  34265. var bedCostTotal float64 = 0 //床位总费
  34266. var bedCostSelfTotal float64 = 0 //床位自费
  34267. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34268. var bedSelfTotal float64 = 0 //床位部分项目自费
  34269. var bedInscpTotal float64 = 0 //床位部分项目自费
  34270. var operationCostTotal float64 = 0 //手术费
  34271. var operationCostSelfTotal float64 = 0 //手术费
  34272. var operationCostPartSelfTotal float64 = 0 //手术费
  34273. var operationSelfTotal float64 = 0 //床位部分项目自费
  34274. var operationInscpTotal float64 = 0 //床位部分项目自费
  34275. var otherCostTotal float64 = 0 //其他费用
  34276. var otherCostSelfTotal float64 = 0 //其他费用
  34277. var otherCostPartSelfTotal float64 = 0 //其他费用
  34278. var otherSelfTotal float64 = 0 //床位部分项目自费
  34279. var otherInscpTotal float64 = 0 //床位部分项目自费
  34280. var materialCostTotal float64 = 0 //材料费
  34281. var materialCostSelfTotal float64 = 0 //材料费
  34282. var materialCostPartSelfTotal float64 = 0 //材料费
  34283. var materialSelfTotal float64 = 0 //床位部分项目自费
  34284. var materialInscpTotal float64 = 0 //床位部分项目自费
  34285. var westernMedicineCostTotal float64 = 0 //西药费
  34286. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34287. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34288. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34289. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34290. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34291. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34292. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34293. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34294. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34295. var checkCostTotal float64 = 0 //检查费
  34296. var checkCostSelfTotal float64 = 0 //检查费
  34297. var checkCostPartSelfTotal float64 = 0 //检查费
  34298. var checkSelfTotal float64 = 0 //床位部分项目自费
  34299. var checkInscpTotal float64 = 0 //床位部分项目自费
  34300. var laboratoryCostTotal float64 = 0 //化验费
  34301. var laboratoryCostSelfTotal float64 = 0 //化验费
  34302. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34303. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34304. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34305. var treatCostTotal float64 = 0 //治疗费用
  34306. var treatCostSelfTotal float64 = 0 //治疗费用
  34307. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34308. var treatSelfTotal float64 = 0 //床位部分项目自费
  34309. var treatInscpTotal float64 = 0 //床位部分项目自费
  34310. decimal.DivisionPrecision = 2
  34311. for _, item := range orderInfos {
  34312. if item.MedChrgitmType == "01" { //床位费
  34313. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34314. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34315. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34316. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34317. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34318. }
  34319. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34320. if item.MedChrgitmType == "03" { //检查费
  34321. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34322. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34323. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34324. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34325. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34326. }
  34327. } else {
  34328. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34329. fmt.Println("------------")
  34330. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34331. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34332. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34333. }
  34334. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34335. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34336. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34337. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34338. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34339. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34340. }
  34341. }
  34342. if item.MedChrgitmType == "04" { //化验费
  34343. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34344. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34345. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34346. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34347. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34348. }
  34349. if item.MedChrgitmType == "05" { //治疗费
  34350. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34351. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34352. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34353. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34354. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34355. }
  34356. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34357. fmt.Println("------------")
  34358. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34359. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34360. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34361. }
  34362. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34363. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34364. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34365. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34366. }
  34367. //if item.MedChrgitmType == "06" { //手术费
  34368. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34369. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34370. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34371. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34372. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34373. //
  34374. //}
  34375. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34376. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34377. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34378. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34379. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34380. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34381. }
  34382. if item.MedChrgitmType == "09" { //西药费
  34383. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34384. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34385. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34386. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34387. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34388. }
  34389. if item.MedChrgitmType == "11" { //中成费
  34390. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34391. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34392. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34393. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34394. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34395. }
  34396. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  34397. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34398. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34399. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34400. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34401. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34402. }
  34403. }
  34404. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34405. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34406. var user_name string
  34407. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34408. if role.ID == 0 {
  34409. user_name = "管理员"
  34410. } else {
  34411. user_name = role.UserName
  34412. }
  34413. baseParams := models.BaseParams{
  34414. SecretKey: miConfig.SecretKey,
  34415. FixmedinsCode: miConfig.Code,
  34416. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34417. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34418. OrgName: miConfig.OrgName,
  34419. Doctor: user_name,
  34420. RequestUrl: miConfig.Url,
  34421. AccessKey: miConfig.AccessKey,
  34422. }
  34423. businessParams := models.BusinessParams{
  34424. PsnNo: order.PsnNo,
  34425. MdtrtId: order.MdtrtId,
  34426. SetlId: order.SetlId,
  34427. }
  34428. var res ResultEleven
  34429. var resEleven10265 ResultEleven10265
  34430. if config.IsOpen == 1 {
  34431. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34432. result := service.Gdyb5203(baseParams, businessParams)
  34433. service.Gdyb5204(baseParams, businessParams)
  34434. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  34435. var dat map[string]interface{}
  34436. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34437. fmt.Println(dat)
  34438. } else {
  34439. fmt.Println(err)
  34440. }
  34441. userJSONBytes, _ := json.Marshal(dat)
  34442. if miConfig.Code == "H15049901371" {
  34443. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  34444. utils.ErrorLog("解析失败:%v", err)
  34445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34446. return
  34447. }
  34448. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34449. res.Output = resEleven10265.Output
  34450. res.ErrMsg = resEleven10265.ErrMsg
  34451. res.Cainfo = resEleven10265.Cainfo
  34452. res.WarnMsg = resEleven10265.WarnMsg
  34453. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34454. res.Infcode = infocode
  34455. } else {
  34456. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34457. utils.ErrorLog("解析失败:%v", err)
  34458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34459. return
  34460. }
  34461. }
  34462. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34463. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  34464. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  34465. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  34466. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  34467. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34468. var doctor_name string
  34469. if roles.ID == 0 {
  34470. doctor_name = "管理员"
  34471. } else {
  34472. doctor_name = roles.UserName
  34473. }
  34474. yiliao_leibie := ""
  34475. switch order.MedType {
  34476. case "11":
  34477. yiliao_leibie = "普通门诊"
  34478. break
  34479. case "12":
  34480. yiliao_leibie = "门诊挂号"
  34481. break
  34482. case "13":
  34483. yiliao_leibie = "急诊"
  34484. break
  34485. case "14":
  34486. yiliao_leibie = "门诊特殊病"
  34487. break
  34488. case "15":
  34489. yiliao_leibie = "门诊统筹"
  34490. break
  34491. case "16":
  34492. yiliao_leibie = "门诊慢性病"
  34493. break
  34494. case "21":
  34495. yiliao_leibie = "普通住院"
  34496. break
  34497. }
  34498. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  34499. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  34500. if res.Infcode == 0 {
  34501. data2 := map[string]interface{}{
  34502. "diagnosis": name,
  34503. "order_infos": orderInfos,
  34504. "number": order.MdtrtId,
  34505. "date": order.SettleAccountsDate,
  34506. "charge_admin": charge_admin,
  34507. "printor_admin": printor_admin,
  34508. "info": res.Output.Setlinfo,
  34509. "order": order,
  34510. "bedCostTotal": bedCostTotal,
  34511. "bedCostSelfTotal": bedCostSelfTotal,
  34512. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  34513. "bedSelfTotal": bedSelfTotal,
  34514. "bedInscpTotal": bedInscpTotal,
  34515. "operationCostTotal": operationCostTotal,
  34516. "operationCostSelfTotal": operationCostSelfTotal,
  34517. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  34518. "operationSelfTotal": operationSelfTotal,
  34519. "operationInscpTotal": operationInscpTotal,
  34520. "otherCostTotal": otherCostTotal,
  34521. "otherCostSelfTotal": otherCostSelfTotal,
  34522. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  34523. "otherSelfTotal": otherSelfTotal,
  34524. "otherInscpTotal": otherInscpTotal,
  34525. "materialCostTotal": materialCostTotal,
  34526. "materialCostSelfTotal": materialCostSelfTotal,
  34527. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  34528. "materialSelfTotal": materialSelfTotal,
  34529. "materialInscpTotal": materialInscpTotal,
  34530. "westernMedicineCostTotal": westernMedicineCostTotal,
  34531. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  34532. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  34533. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  34534. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  34535. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  34536. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  34537. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  34538. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  34539. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  34540. "checkCostTotal": checkCostTotal,
  34541. "checkCostSelfTotal": checkCostSelfTotal,
  34542. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  34543. "checkSelfTotal": checkSelfTotal,
  34544. "checkInscpTotal": checkInscpTotal,
  34545. "laboratoryCostTotal": laboratoryCostTotal,
  34546. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  34547. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  34548. "laboratorySelfTotal": laboratorySelfTotal,
  34549. "laboratoryInscpTotal": laboratoryInscpTotal,
  34550. "treatCostTotal": treatCostTotal,
  34551. "treatCostSelfTotal": treatCostSelfTotal,
  34552. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  34553. "treatSelfTotal": treatSelfTotal,
  34554. "treatInscpTotal": treatInscpTotal,
  34555. "doctor_info": doctor_info,
  34556. "doctor_code": adminRole_two.DoctorCode,
  34557. "doctor_name": doctor_name,
  34558. "health_card_no": order.PsnNo,
  34559. "department": departments.Name,
  34560. "yiliao_leibie": yiliao_leibie,
  34561. "after_money": order.AccountPrice,
  34562. "patient": patient,
  34563. "org_name": miConfig.OrgName,
  34564. "org_code": miConfig.Code,
  34565. "order_number": order.Number,
  34566. "his_hospital": his_hospital,
  34567. "his": his,
  34568. "dia_config": dia_config,
  34569. "psn_cash_pay": order.PsnCashPay,
  34570. //"check_order_info": cus_slice,
  34571. }
  34572. data3 = append(data3, data2)
  34573. }
  34574. }
  34575. }
  34576. c.ServeSuccessJSON(map[string]interface{}{
  34577. "infos": data3,
  34578. })
  34579. }
  34580. func (c *HisApiController) GetSettleAccounts() {
  34581. //id, _ := c.GetInt64("id")
  34582. //record_time := c.GetString("record_time")
  34583. order_id, _ := c.GetInt64("order_id")
  34584. admin_user_id, _ := c.GetInt64("admin_user_id")
  34585. //timeLayout := "2006-01-02"
  34586. //loc, _ := time.LoadLocation("Local")
  34587. //
  34588. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34589. //if err != nil {
  34590. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34591. // return
  34592. //}Hbyb5203
  34593. //recordDateTime := theTime.Unix()
  34594. adminUser := c.GetAdminUserInfo()
  34595. order, _ := service.GetHisOrderByID(order_id)
  34596. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34597. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34598. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34599. orderInfos = append(orderInfos, orderInfos_two...)
  34600. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34601. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34602. var diagnosis_ids []string
  34603. if his.ID > 0 {
  34604. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34605. } else {
  34606. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34607. }
  34608. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34609. var dia_config []*models.HisXtDiagnoseConfig
  34610. var name string
  34611. for _, item := range diagnosis_ids {
  34612. id, _ := strconv.ParseInt(item, 10, 64)
  34613. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34614. dia_config = append(dia_config, &diagnosisConfig)
  34615. if len(name) == 0 {
  34616. name = diagnosisConfig.ClassName
  34617. } else {
  34618. name = name + "," + diagnosisConfig.ClassName
  34619. }
  34620. }
  34621. if patient.UserOrgId == 10215 {
  34622. name = "慢性肾功能不全(血透治疗)"
  34623. }
  34624. var bedCostTotal float64 = 0 //床位总费
  34625. var bedCostSelfTotal float64 = 0 //床位自费
  34626. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34627. var bedSelfTotal float64 = 0 //床位部分项目自费
  34628. var bedInscpTotal float64 = 0 //床位部分项目自费
  34629. var operationCostTotal float64 = 0 //手术费
  34630. var operationCostSelfTotal float64 = 0 //手术费
  34631. var operationCostPartSelfTotal float64 = 0 //手术费
  34632. var operationSelfTotal float64 = 0 //床位部分项目自费
  34633. var operationInscpTotal float64 = 0 //床位部分项目自费
  34634. var otherCostTotal float64 = 0 //其他费用
  34635. var otherCostSelfTotal float64 = 0 //其他费用
  34636. var otherCostPartSelfTotal float64 = 0 //其他费用
  34637. var otherSelfTotal float64 = 0 //床位部分项目自费
  34638. var otherInscpTotal float64 = 0 //床位部分项目自费
  34639. var materialCostTotal float64 = 0 //材料费
  34640. var materialCostSelfTotal float64 = 0 //材料费
  34641. var materialCostPartSelfTotal float64 = 0 //材料费
  34642. var materialSelfTotal float64 = 0 //床位部分项目自费
  34643. var materialInscpTotal float64 = 0 //床位部分项目自费
  34644. var westernMedicineCostTotal float64 = 0 //西药费
  34645. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34646. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34647. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34648. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34649. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34650. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34651. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34652. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34653. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34654. var checkCostTotal float64 = 0 //检查费
  34655. var checkCostSelfTotal float64 = 0 //检查费
  34656. var checkCostPartSelfTotal float64 = 0 //检查费
  34657. var checkSelfTotal float64 = 0 //床位部分项目自费
  34658. var checkInscpTotal float64 = 0 //床位部分项目自费
  34659. var laboratoryCostTotal float64 = 0 //化验费
  34660. var laboratoryCostSelfTotal float64 = 0 //化验费
  34661. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34662. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34663. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34664. var treatCostTotal float64 = 0 //治疗费用
  34665. var treatCostSelfTotal float64 = 0 //治疗费用
  34666. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34667. var treatSelfTotal float64 = 0 //床位部分项目自费
  34668. var treatInscpTotal float64 = 0 //床位部分项目自费
  34669. var zcCostTotal float64 = 0 //治疗费用
  34670. var zcCostSelfTotal float64 = 0 //治疗费用
  34671. var zcCostPartSelfTotal float64 = 0 //治疗费用
  34672. var zcSelfTotal float64 = 0 //床位部分项目自费
  34673. var zcInscpTotal float64 = 0 //床位部分项目自费
  34674. var huliCostTotal float64 = 0 //治疗费用
  34675. var huliCostSelfTotal float64 = 0 //治疗费用
  34676. var huliCostPartSelfTotal float64 = 0 //治疗费用
  34677. var huliSelfTotal float64 = 0 //床位部分项目自费
  34678. var huliInscpTotal float64 = 0 //床位部分项目自费
  34679. decimal.DivisionPrecision = 2
  34680. for _, item := range orderInfos {
  34681. if item.MedChrgitmType == "01" { //床位费
  34682. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34683. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34684. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34685. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34686. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34687. }
  34688. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34689. if item.MedChrgitmType == "03" { //检查费
  34690. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34691. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34692. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34693. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34694. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34695. }
  34696. } else {
  34697. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34698. fmt.Println("------------")
  34699. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34700. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34701. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34702. }
  34703. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34704. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34705. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34706. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34707. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34708. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34709. }
  34710. }
  34711. if item.MedChrgitmType == "04" { //化验费
  34712. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34713. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34714. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34715. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34716. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34717. }
  34718. if item.MedChrgitmType == "05" { //治疗费
  34719. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34720. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34721. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34722. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34723. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34724. }
  34725. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34726. fmt.Println("------------")
  34727. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34728. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34729. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34730. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34731. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34732. }
  34733. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34734. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34735. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34736. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34737. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34738. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34739. }
  34740. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34741. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34742. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34743. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34744. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34745. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34746. }
  34747. if item.MedChrgitmType == "09" { //西药费
  34748. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34749. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34750. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34751. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34752. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34753. }
  34754. if item.MedChrgitmType == "11" { //中成费
  34755. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34756. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34757. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34758. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34759. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34760. }
  34761. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  34762. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34763. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34764. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34765. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34766. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34767. }
  34768. if item.MedChrgitmType == "02" { //其他费
  34769. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34770. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34771. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34772. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34773. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34774. }
  34775. if item.MedChrgitmType == "07" { //其他费
  34776. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34777. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34778. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34779. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34780. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34781. }
  34782. }
  34783. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34784. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34785. var user_name string
  34786. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34787. if role.ID == 0 {
  34788. user_name = "管理员"
  34789. } else {
  34790. user_name = role.UserName
  34791. }
  34792. baseParams := models.BaseParams{
  34793. SecretKey: miConfig.SecretKey,
  34794. FixmedinsCode: miConfig.Code,
  34795. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34796. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34797. OrgName: miConfig.OrgName,
  34798. Doctor: user_name,
  34799. RequestUrl: miConfig.Url,
  34800. AccessKey: miConfig.AccessKey,
  34801. }
  34802. businessParams := models.BusinessParams{
  34803. PsnNo: order.PsnNo,
  34804. MdtrtId: order.MdtrtId,
  34805. SetlId: order.SetlId,
  34806. }
  34807. var res ResultEleven
  34808. var resah ResultElevenah
  34809. var resEleven10265 ResultEleven10265
  34810. if config.IsOpen == 1 {
  34811. if miConfig.MdtrtareaAdmvs == "421300" {
  34812. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34813. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34814. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34815. resp, requestErr := http.Get(api)
  34816. if requestErr != nil {
  34817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34818. return
  34819. }
  34820. body, ioErr := ioutil.ReadAll(resp.Body)
  34821. if ioErr != nil {
  34822. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34824. return
  34825. }
  34826. var respJSON map[string]interface{}
  34827. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34828. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34830. return
  34831. }
  34832. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34833. result, _ := json.Marshal(respJSON)
  34834. fmt.Println("log")
  34835. fmt.Println(string(result))
  34836. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34837. utils.ErrorLog("解析失败:%v", err)
  34838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34839. return
  34840. }
  34841. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34842. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34843. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34844. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34845. resp, requestErr := http.Get(api)
  34846. if requestErr != nil {
  34847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34848. return
  34849. }
  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(string(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. result, _ := json.Marshal(respJSON)
  34864. fmt.Println("log")
  34865. fmt.Println(string(result))
  34866. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34867. utils.ErrorLog("解析失败:%v", err)
  34868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34869. return
  34870. }
  34871. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34872. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34873. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34874. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34875. resp, requestErr := http.Get(api)
  34876. if requestErr != nil {
  34877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34878. return
  34879. }
  34880. body, ioErr := ioutil.ReadAll(resp.Body)
  34881. if ioErr != nil {
  34882. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34884. return
  34885. }
  34886. var respJSON map[string]interface{}
  34887. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34888. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34890. return
  34891. }
  34892. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34893. result, _ := json.Marshal(respJSON)
  34894. fmt.Println("log")
  34895. fmt.Println(string(result))
  34896. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34897. utils.ErrorLog("解析失败:%v", err)
  34898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34899. return
  34900. }
  34901. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34902. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34903. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34904. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  34905. resp, requestErr := http.Get(api)
  34906. if requestErr != nil {
  34907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34908. return
  34909. }
  34910. body, ioErr := ioutil.ReadAll(resp.Body)
  34911. if ioErr != nil {
  34912. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34914. return
  34915. }
  34916. var respJSON map[string]interface{}
  34917. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34918. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34920. return
  34921. }
  34922. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34923. result, _ := json.Marshal(respJSON)
  34924. fmt.Println("log")
  34925. fmt.Println(string(result))
  34926. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34927. utils.ErrorLog("解析失败:%v", err)
  34928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34929. return
  34930. }
  34931. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34932. var api string
  34933. if miConfig.MdtrtareaAdmvs == "320921" {
  34934. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34935. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34936. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34937. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34938. } else {
  34939. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34940. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34941. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34942. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34943. }
  34944. resp, requestErr := http.Get(api)
  34945. if requestErr != nil {
  34946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34947. return
  34948. }
  34949. body, ioErr := ioutil.ReadAll(resp.Body)
  34950. if ioErr != nil {
  34951. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34953. return
  34954. }
  34955. var respJSON map[string]interface{}
  34956. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34957. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34959. return
  34960. }
  34961. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34962. result, _ := json.Marshal(respJSON)
  34963. fmt.Println("log")
  34964. fmt.Println(string(result))
  34965. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  34966. utils.ErrorLog("解析失败:%v", err)
  34967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34968. return
  34969. }
  34970. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34971. res.Output = resEleven10265.Output
  34972. res.ErrMsg = resEleven10265.ErrMsg
  34973. res.Cainfo = resEleven10265.Cainfo
  34974. res.WarnMsg = resEleven10265.WarnMsg
  34975. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34976. res.Infcode = infocode
  34977. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34978. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  34979. saveLog(result, requestLog, "5203", "结算单")
  34980. var dat map[string]interface{}
  34981. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34982. fmt.Println(dat)
  34983. } else {
  34984. fmt.Println(err)
  34985. }
  34986. userJSONBytes, _ := json.Marshal(dat)
  34987. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34988. utils.ErrorLog("解析失败:%v", err)
  34989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34990. return
  34991. }
  34992. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34993. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34994. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34995. saveLog(result, requestLog, "5203", "结算单")
  34996. var dat map[string]interface{}
  34997. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34998. fmt.Println(dat)
  34999. } else {
  35000. fmt.Println(err)
  35001. }
  35002. userJSONBytes, _ := json.Marshal(dat)
  35003. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35004. utils.ErrorLog("解析失败:%v", err)
  35005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35006. return
  35007. }
  35008. } else if miConfig.MdtrtareaAdmvs == "361025" {
  35009. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35010. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  35011. saveLog(result, requestLog, "5203", "结算单")
  35012. var dat map[string]interface{}
  35013. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35014. fmt.Println(dat)
  35015. } else {
  35016. fmt.Println(err)
  35017. }
  35018. userJSONBytes, _ := json.Marshal(dat)
  35019. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35020. utils.ErrorLog("解析失败:%v", err)
  35021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35022. return
  35023. }
  35024. } else if miConfig.MdtrtareaAdmvs == "341203" {
  35025. var api string
  35026. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35027. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35028. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35029. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35030. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35031. resp, requestErr := http.Get(api)
  35032. if requestErr != nil {
  35033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35034. return
  35035. }
  35036. body, ioErr := ioutil.ReadAll(resp.Body)
  35037. if ioErr != nil {
  35038. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35040. return
  35041. }
  35042. var respJSON map[string]interface{}
  35043. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35046. return
  35047. }
  35048. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35049. if status == "0" {
  35050. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35051. c.ServeSuccessJSON(map[string]interface{}{
  35052. "failed_code": -10,
  35053. "msg": err_msg,
  35054. })
  35055. return
  35056. }
  35057. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35058. result, _ := json.Marshal(respJSON)
  35059. fmt.Println("log")
  35060. fmt.Println(string(result))
  35061. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  35062. utils.ErrorLog("解析失败:%v", err)
  35063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35064. return
  35065. }
  35066. res.InfRefmsgid = resah.InfRefmsgid
  35067. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35068. // 创建对应的Time类型
  35069. t := time.UnixMilli(timestamp)
  35070. // 格式化成指定的日期字符串
  35071. str := t.Format("2006-01-02 15:04:05")
  35072. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35073. // 创建对应的Time类型
  35074. t3 := time.UnixMilli(timestamp2)
  35075. // 格式化成指定的日期字符串
  35076. str2 := t3.Format("2006-01-02 15:04:05")
  35077. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  35078. // 创建对应的Time类型
  35079. t4 := time.UnixMilli(timestamp3)
  35080. // 格式化成指定的日期字符串
  35081. str3 := t4.Format("2006-01-02 15:04:05")
  35082. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  35083. // 创建对应的Time类型
  35084. t5 := time.UnixMilli(timestamp4)
  35085. // 格式化成指定的日期字符串
  35086. str5 := t5.Format("2006-01-02 15:04:05")
  35087. res.Output.Setlinfo.Brdy = str2
  35088. res.Output.Setlinfo.SetlTime = str
  35089. res.Output.Setlinfo.Begndate = str3
  35090. res.Output.Setlinfo.Enddate = str5
  35091. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  35092. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  35093. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  35094. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  35095. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35096. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35097. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  35098. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  35099. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35100. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  35101. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  35102. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  35103. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  35104. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  35105. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  35106. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  35107. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  35108. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  35109. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35110. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  35111. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  35112. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35113. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  35114. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  35115. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  35116. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  35117. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  35118. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  35119. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  35120. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  35121. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  35122. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  35123. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35124. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  35125. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  35126. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  35127. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  35128. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  35129. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  35130. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  35131. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  35132. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  35133. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  35134. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  35135. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  35136. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35137. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35138. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35139. //res.Output.Setldetail = resah.Output.Setldetail
  35140. res.ErrMsg = resah.ErrMsg
  35141. res.Cainfo = resah.Cainfo
  35142. res.WarnMsg = resah.WarnMsg
  35143. } else if miConfig.MdtrtareaAdmvs == "340699" {
  35144. var api string
  35145. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35146. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35147. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35148. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35149. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35150. resp, requestErr := http.Get(api)
  35151. if requestErr != nil {
  35152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35153. return
  35154. }
  35155. body, ioErr := ioutil.ReadAll(resp.Body)
  35156. if ioErr != nil {
  35157. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35159. return
  35160. }
  35161. var respJSON map[string]interface{}
  35162. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35163. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35165. return
  35166. }
  35167. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35168. if status == "0" {
  35169. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35170. c.ServeSuccessJSON(map[string]interface{}{
  35171. "failed_code": -10,
  35172. "msg": err_msg,
  35173. })
  35174. return
  35175. }
  35176. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35177. result, _ := json.Marshal(respJSON)
  35178. fmt.Println("log")
  35179. fmt.Println(string(result))
  35180. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  35181. utils.ErrorLog("解析失败:%v", err)
  35182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35183. return
  35184. }
  35185. res.InfRefmsgid = resah.InfRefmsgid
  35186. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35187. // 创建对应的Time类型
  35188. t := time.UnixMilli(timestamp)
  35189. // 格式化成指定的日期字符串
  35190. str := t.Format("2006-01-02 15:04:05")
  35191. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35192. // 创建对应的Time类型
  35193. t3 := time.UnixMilli(timestamp2)
  35194. // 格式化成指定的日期字符串
  35195. str2 := t3.Format("2006-01-02 15:04:05")
  35196. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  35197. // 创建对应的Time类型
  35198. t4 := time.UnixMilli(timestamp3)
  35199. // 格式化成指定的日期字符串
  35200. str3 := t4.Format("2006-01-02 15:04:05")
  35201. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  35202. // 创建对应的Time类型
  35203. t5 := time.UnixMilli(timestamp4)
  35204. // 格式化成指定的日期字符串
  35205. str5 := t5.Format("2006-01-02 15:04:05")
  35206. res.Output.Setlinfo.Brdy = str2
  35207. res.Output.Setlinfo.SetlTime = str
  35208. res.Output.Setlinfo.Begndate = str3
  35209. res.Output.Setlinfo.Enddate = str5
  35210. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  35211. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  35212. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  35213. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  35214. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35215. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35216. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  35217. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  35218. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35219. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  35220. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  35221. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  35222. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  35223. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  35224. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  35225. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  35226. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  35227. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  35228. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35229. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  35230. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  35231. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35232. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  35233. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  35234. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  35235. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  35236. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  35237. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  35238. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  35239. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  35240. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  35241. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  35242. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35243. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  35244. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  35245. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  35246. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  35247. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  35248. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  35249. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  35250. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  35251. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  35252. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  35253. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  35254. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  35255. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35256. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35257. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35258. //res.Output.Setldetail = resah.Output.Setldetail
  35259. res.ErrMsg = resah.ErrMsg
  35260. res.Cainfo = resah.Cainfo
  35261. res.WarnMsg = resah.WarnMsg
  35262. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35263. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  35264. saveLog(result, requestLog, "5203", "结算单")
  35265. var dat map[string]interface{}
  35266. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35267. fmt.Println(dat)
  35268. } else {
  35269. fmt.Println(err)
  35270. }
  35271. userJSONBytes, _ := json.Marshal(dat)
  35272. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35273. utils.ErrorLog("解析失败:%v", err)
  35274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35275. return
  35276. }
  35277. } else if miConfig.MdtrtareaAdmvs == "150499" {
  35278. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35279. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35280. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35281. resp, requestErr := http.Get(api)
  35282. if requestErr != nil {
  35283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35284. return
  35285. }
  35286. body, ioErr := ioutil.ReadAll(resp.Body)
  35287. if ioErr != nil {
  35288. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35290. return
  35291. }
  35292. var respJSON map[string]interface{}
  35293. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35294. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35296. return
  35297. }
  35298. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35299. result, _ := json.Marshal(respJSON)
  35300. fmt.Println("log")
  35301. fmt.Println(string(result))
  35302. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  35303. utils.ErrorLog("解析失败:%v", err)
  35304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35305. return
  35306. }
  35307. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35308. res.Output = resEleven10265.Output
  35309. res.ErrMsg = resEleven10265.ErrMsg
  35310. res.Cainfo = resEleven10265.Cainfo
  35311. res.WarnMsg = resEleven10265.WarnMsg
  35312. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35313. res.Infcode = infocode
  35314. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35315. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35316. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35317. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35318. resp, requestErr := http.Get(api)
  35319. if requestErr != nil {
  35320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35321. return
  35322. }
  35323. body, ioErr := ioutil.ReadAll(resp.Body)
  35324. if ioErr != nil {
  35325. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35327. return
  35328. }
  35329. var respJSON map[string]interface{}
  35330. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35331. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35333. return
  35334. }
  35335. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35336. result, _ := json.Marshal(respJSON)
  35337. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35338. utils.ErrorLog("解析失败:%v", err)
  35339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35340. return
  35341. }
  35342. } else if miConfig.MdtrtareaAdmvs == "450721" {
  35343. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  35344. //return
  35345. } else {
  35346. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  35347. if len(his.InsuplcAdmdvs) == 0 {
  35348. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35349. } else {
  35350. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35351. }
  35352. result := service.Gdyb5203(baseParams, businessParams)
  35353. //service.Gdyb5204(baseParams, businessParams)
  35354. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  35355. var dat map[string]interface{}
  35356. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35357. fmt.Println(dat)
  35358. } else {
  35359. fmt.Println(err)
  35360. }
  35361. userJSONBytes, _ := json.Marshal(dat)
  35362. if miConfig.Code == "H15049901371" {
  35363. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  35364. utils.ErrorLog("解析失败:%v", err)
  35365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35366. return
  35367. }
  35368. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35369. res.Output = resEleven10265.Output
  35370. res.ErrMsg = resEleven10265.ErrMsg
  35371. res.Cainfo = resEleven10265.Cainfo
  35372. res.WarnMsg = resEleven10265.WarnMsg
  35373. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35374. res.Infcode = infocode
  35375. } else {
  35376. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35377. utils.ErrorLog("解析失败:%v", err)
  35378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35379. return
  35380. }
  35381. }
  35382. }
  35383. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35384. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  35385. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  35386. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  35387. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  35388. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35389. var doctor_name string
  35390. if roles.ID == 0 {
  35391. doctor_name = "管理员"
  35392. } else {
  35393. doctor_name = roles.UserName
  35394. }
  35395. yiliao_leibie := ""
  35396. switch order.MedType {
  35397. case "11":
  35398. yiliao_leibie = "普通门诊"
  35399. break
  35400. case "12":
  35401. yiliao_leibie = "门诊挂号"
  35402. break
  35403. case "13":
  35404. yiliao_leibie = "急诊"
  35405. break
  35406. case "14":
  35407. yiliao_leibie = "门诊特殊病"
  35408. break
  35409. case "15":
  35410. yiliao_leibie = "门诊统筹"
  35411. break
  35412. case "16":
  35413. yiliao_leibie = "门诊慢性病"
  35414. break
  35415. case "21":
  35416. yiliao_leibie = "普通住院"
  35417. break
  35418. }
  35419. //var rf []CustomFundPay
  35420. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  35421. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35422. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  35423. if res.Infcode == 0 {
  35424. if adminUser.CurrentOrgId == 10215 || adminUser.CurrentOrgId == 10387 || adminUser.CurrentOrgId == 9919 || adminUser.CurrentOrgId == 10088 || adminUser.CurrentOrgId == 10150 || adminUser.CurrentOrgId == 10454 || adminUser.CurrentOrgId == 10644 || adminUser.CurrentOrgId == 10653 || adminUser.CurrentOrgId == 10210 {
  35425. c.ServeSuccessJSON(map[string]interface{}{
  35426. "diagnosis": name,
  35427. "order_infos": orderInfos,
  35428. "number": order.MdtrtId,
  35429. "date": order.SettleAccountsDate,
  35430. "charge_admin": charge_admin,
  35431. "printor_admin": printor_admin,
  35432. "info": res.Output.Setlinfo,
  35433. "order": order,
  35434. "bedCostTotal": bedCostTotal,
  35435. "bedCostSelfTotal": bedCostSelfTotal,
  35436. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35437. "bedSelfTotal": bedSelfTotal,
  35438. "bedInscpTotal": bedInscpTotal,
  35439. "operationCostTotal": operationCostTotal,
  35440. "operationCostSelfTotal": operationCostSelfTotal,
  35441. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35442. "operationSelfTotal": operationSelfTotal,
  35443. "operationInscpTotal": operationInscpTotal,
  35444. "otherCostTotal": otherCostTotal,
  35445. "otherCostSelfTotal": otherCostSelfTotal,
  35446. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35447. "otherSelfTotal": otherSelfTotal,
  35448. "otherInscpTotal": otherInscpTotal,
  35449. "materialCostTotal": materialCostTotal,
  35450. "materialCostSelfTotal": materialCostSelfTotal,
  35451. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35452. "materialSelfTotal": materialSelfTotal,
  35453. "materialInscpTotal": materialInscpTotal,
  35454. "westernMedicineCostTotal": westernMedicineCostTotal,
  35455. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35456. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35457. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35458. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35459. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35460. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35461. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35462. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35463. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35464. "checkCostTotal": checkCostTotal,
  35465. "checkCostSelfTotal": checkCostSelfTotal,
  35466. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35467. "checkSelfTotal": checkSelfTotal,
  35468. "checkInscpTotal": checkInscpTotal,
  35469. "laboratoryCostTotal": laboratoryCostTotal,
  35470. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35471. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35472. "laboratorySelfTotal": laboratorySelfTotal,
  35473. "laboratoryInscpTotal": laboratoryInscpTotal,
  35474. "treatCostTotal": treatCostTotal,
  35475. "treatCostSelfTotal": treatCostSelfTotal,
  35476. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35477. "treatSelfTotal": treatSelfTotal,
  35478. "treatInscpTotal": treatInscpTotal,
  35479. "doctor_info": doctor_info,
  35480. "doctor_code": adminRole_two.DoctorCode,
  35481. "doctor_name": doctor_name,
  35482. "health_card_no": order.PsnNo,
  35483. "department": departments.Name,
  35484. "yiliao_leibie": yiliao_leibie,
  35485. "after_money": order.AccountPrice,
  35486. "patient": patient,
  35487. "org_name": miConfig.OrgName,
  35488. "org_code": miConfig.Code,
  35489. "order_number": order.Number,
  35490. "his_hospital": his_hospital,
  35491. "his": his,
  35492. "dia_config": dia_config,
  35493. "psn_cash_pay": order.PsnCashPay,
  35494. "zcCostTotal": zcCostTotal,
  35495. "zcCostSelfTotal": zcCostSelfTotal,
  35496. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35497. "zcSelfTotal": zcSelfTotal,
  35498. "zcInscpTotal": zcInscpTotal,
  35499. "huliCostTotal": huliCostTotal,
  35500. "huliCostSelfTotal": huliCostSelfTotal,
  35501. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35502. "huliSelfTotal": huliSelfTotal,
  35503. "huliInscpTotal": huliInscpTotal,
  35504. //"funds": rf,
  35505. //"check_order_info": cus_slice,
  35506. })
  35507. } else {
  35508. c.ServeSuccessJSON(map[string]interface{}{
  35509. "diagnosis": name,
  35510. "order_infos": orderInfos,
  35511. "number": order.MdtrtId,
  35512. "date": order.SettleAccountsDate,
  35513. "charge_admin": charge_admin,
  35514. "printor_admin": printor_admin,
  35515. "info": order,
  35516. "order": order,
  35517. "bedCostTotal": bedCostTotal,
  35518. "bedCostSelfTotal": bedCostSelfTotal,
  35519. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35520. "bedSelfTotal": bedSelfTotal,
  35521. "bedInscpTotal": bedInscpTotal,
  35522. "operationCostTotal": operationCostTotal,
  35523. "operationCostSelfTotal": operationCostSelfTotal,
  35524. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35525. "operationSelfTotal": operationSelfTotal,
  35526. "operationInscpTotal": operationInscpTotal,
  35527. "otherCostTotal": otherCostTotal,
  35528. "otherCostSelfTotal": otherCostSelfTotal,
  35529. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35530. "otherSelfTotal": otherSelfTotal,
  35531. "otherInscpTotal": otherInscpTotal,
  35532. "materialCostTotal": materialCostTotal,
  35533. "materialCostSelfTotal": materialCostSelfTotal,
  35534. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35535. "materialSelfTotal": materialSelfTotal,
  35536. "materialInscpTotal": materialInscpTotal,
  35537. "westernMedicineCostTotal": westernMedicineCostTotal,
  35538. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35539. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35540. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35541. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35542. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35543. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35544. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35545. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35546. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35547. "checkCostTotal": checkCostTotal,
  35548. "checkCostSelfTotal": checkCostSelfTotal,
  35549. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35550. "checkSelfTotal": checkSelfTotal,
  35551. "checkInscpTotal": checkInscpTotal,
  35552. "laboratoryCostTotal": laboratoryCostTotal,
  35553. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35554. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35555. "laboratorySelfTotal": laboratorySelfTotal,
  35556. "laboratoryInscpTotal": laboratoryInscpTotal,
  35557. "treatCostTotal": treatCostTotal,
  35558. "treatCostSelfTotal": treatCostSelfTotal,
  35559. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35560. "treatSelfTotal": treatSelfTotal,
  35561. "treatInscpTotal": treatInscpTotal,
  35562. "doctor_info": doctor_info,
  35563. "doctor_code": adminRole_two.DoctorCode,
  35564. "doctor_name": doctor_name,
  35565. "health_card_no": order.PsnNo,
  35566. "department": departments.Name,
  35567. "yiliao_leibie": yiliao_leibie,
  35568. "after_money": order.AccountPrice,
  35569. "patient": patient,
  35570. "org_name": miConfig.OrgName,
  35571. "org_code": miConfig.Code,
  35572. "order_number": order.Number,
  35573. "his_hospital": his_hospital,
  35574. "his": his,
  35575. "dia_config": dia_config,
  35576. "psn_cash_pay": order.PsnCashPay,
  35577. "zcCostTotal": zcCostTotal,
  35578. "zcCostSelfTotal": zcCostSelfTotal,
  35579. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35580. "zcSelfTotal": zcSelfTotal,
  35581. "zcInscpTotal": zcInscpTotal,
  35582. "huliCostTotal": huliCostTotal,
  35583. "huliCostSelfTotal": huliCostSelfTotal,
  35584. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35585. "huliSelfTotal": huliSelfTotal,
  35586. "huliInscpTotal": huliInscpTotal,
  35587. //"funds": rf,
  35588. //"check_order_info": cus_slice,
  35589. })
  35590. }
  35591. }
  35592. }
  35593. }
  35594. //func (c *HisApiController) CheckTreatment() {
  35595. // patient_id, _ := c.GetInt64("patient_id")
  35596. // id_card_no := c.GetString("id_card_no")
  35597. // insutype := c.GetString("insutype")
  35598. // med_type := c.GetString("med_type")
  35599. // admin_user_id, _ := c.GetInt64("admin_user_id")
  35600. //
  35601. // adminUser := c.GetAdminUserInfo()
  35602. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  35603. //
  35604. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35605. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35606. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35607. //
  35608. // if miConfig.MdtrtareaAdmvs == "421300" {
  35609. // var res ResultTwo
  35610. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  35611. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35612. // "&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)
  35613. // resp, requestErr := http.Get(api)
  35614. // if requestErr != nil {
  35615. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35616. // return
  35617. // }
  35618. //
  35619. // body, ioErr := ioutil.ReadAll(resp.Body)
  35620. // if ioErr != nil {
  35621. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35622. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35623. // return
  35624. // }
  35625. // var respJSON map[string]interface{}
  35626. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35627. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35628. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35629. // return
  35630. // }
  35631. //
  35632. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35633. // result, _ := json.Marshal(respJSON)
  35634. //
  35635. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35636. // utils.ErrorLog("解析失败:%v", err)
  35637. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35638. // return
  35639. // }
  35640. //
  35641. // if res.Infcode == 0 {
  35642. //
  35643. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  35644. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35645. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  35646. // resp, requestErr := http.Get(api)
  35647. // if requestErr != nil {
  35648. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35649. // return
  35650. // }
  35651. //
  35652. // body, ioErr := ioutil.ReadAll(resp.Body)
  35653. // if ioErr != nil {
  35654. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35655. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35656. // return
  35657. // }
  35658. // var respJSON map[string]interface{}
  35659. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35660. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35661. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35662. // return
  35663. // }
  35664. // var res Result2001
  35665. //
  35666. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35667. // result2, _ := json.Marshal(respJSON)
  35668. //
  35669. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  35670. // utils.ErrorLog("解析失败:%v", err)
  35671. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35672. // return
  35673. // }
  35674. //
  35675. // if res.Infcode == 0 {
  35676. // c.ServeSuccessJSON(map[string]interface{}{
  35677. // "msg": res.Output.Trtinfo,
  35678. // })
  35679. // }
  35680. //
  35681. // } else {
  35682. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  35683. // return
  35684. // }
  35685. //
  35686. // } else {
  35687. //
  35688. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  35689. // var dat map[string]interface{}
  35690. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35691. // fmt.Println(dat)
  35692. // } else {
  35693. // fmt.Println(err)
  35694. // }
  35695. // userJSONBytes, _ := json.Marshal(dat)
  35696. // var res ResultTwo
  35697. // var res10265 ResultTwo10265
  35698. // if miConfig.Code == "H15049901371" {
  35699. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  35700. // utils.ErrorLog("解析失败:%v", err)
  35701. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35702. // return
  35703. // }
  35704. // res.ErrMsg = res10265.ErrMsg
  35705. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35706. // res.Infcode = infocode
  35707. // res.Output = res10265.Output
  35708. // res.InfRefmsgid = res10265.InfRefmsgid
  35709. // } else {
  35710. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35711. // utils.ErrorLog("解析失败:%v", err)
  35712. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35713. // return
  35714. // }
  35715. // }
  35716. //
  35717. // var user_name string
  35718. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  35719. // if role.ID == 0 {
  35720. // user_name = "xxx"
  35721. // } else {
  35722. // user_name = role.UserName
  35723. // }
  35724. //
  35725. // baseParams := models.BaseParams{
  35726. // SecretKey: miConfig.SecretKey,
  35727. // FixmedinsCode: miConfig.Code,
  35728. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35729. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35730. // OrgName: miConfig.OrgName,
  35731. // Doctor: user_name,
  35732. // }
  35733. //
  35734. // if config.IsOpen == 1 {
  35735. // if miConfig.Code == "H15049901371" {
  35736. // if med_type == "14" {
  35737. // if insutype == "390" {
  35738. // med_type = "9933"
  35739. // } else if insutype == "310" {
  35740. // med_type = "990502"
  35741. // }
  35742. // } else if med_type == "11" {
  35743. // med_type = "11"
  35744. // }
  35745. // }
  35746. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  35747. // var dat map[string]interface{}
  35748. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35749. // fmt.Println(dat)
  35750. // } else {
  35751. // fmt.Println(err)
  35752. // }
  35753. // var res Result2001
  35754. // var res10265 Result2001Org10265
  35755. // if miConfig.Code == "H15049901371" {
  35756. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  35757. // utils.ErrorLog("解析失败:%v", err)
  35758. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35759. // return
  35760. // }
  35761. // res.ErrMsg = res10265.ErrMsg
  35762. // res.Output = res10265.Output
  35763. // res.InfRefmsgid = res10265.InfRefmsgid
  35764. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35765. // res.Infcode = infocode
  35766. // } else {
  35767. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35768. // utils.ErrorLog("解析失败:%v", err)
  35769. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35770. // return
  35771. // }
  35772. // }
  35773. // if res.Infcode == 0 {
  35774. // c.ServeSuccessJSON(map[string]interface{}{
  35775. // "msg": res.Output.Trtinfo,
  35776. // })
  35777. // }
  35778. // }
  35779. // }
  35780. //}
  35781. //func (c *HisApiController) PutRecord() {
  35782. // id, _ := c.GetInt64("id")
  35783. // record_time := c.GetString("record_time")
  35784. // timeLayout := "2006-01-02"
  35785. // loc, _ := time.LoadLocation("Local")
  35786. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35787. // if err != nil {
  35788. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35789. // return
  35790. // }
  35791. // recordDateTime := theTime.Unix()
  35792. //
  35793. // adminInfo := c.GetAdminUserInfo()
  35794. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  35795. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35796. //
  35797. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35798. //
  35799. // fmt.Println(miConfig.SecretKey)
  35800. //
  35801. // if patient == nil {
  35802. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  35803. // return
  35804. // }
  35805. // if len(patient.IdCardNo) == 0 {
  35806. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  35807. // return
  35808. // }
  35809. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  35810. // if config.IsOpen == 1 {
  35811. // 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
  35812. // resp, requestErr := http.Get(api)
  35813. // if requestErr != nil {
  35814. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35815. // return
  35816. // }
  35817. // defer resp.Body.Close()
  35818. // body, ioErr := ioutil.ReadAll(resp.Body)
  35819. // if ioErr != nil {
  35820. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35821. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35822. // return
  35823. // }
  35824. // var respJSON map[string]interface{}
  35825. //
  35826. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35827. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35828. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35829. // return
  35830. // }
  35831. //
  35832. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35833. // userJSONBytes, _ := json.Marshal(userJSON)
  35834. // var res ResultTwo
  35835. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35836. // utils.ErrorLog("解析失败:%v", err)
  35837. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35838. // return
  35839. // }
  35840. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  35841. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  35842. // infoStr := string(Iinfos)
  35843. // idetinfoStr := string(Idetinfos)
  35844. //
  35845. // if res.Infcode == 0 {
  35846. // his := models.VMHisPatient{
  35847. // Status: 1,
  35848. // Ctime: time.Now().Unix(),
  35849. // Mtime: time.Now().Unix(),
  35850. // PsnNo: res.Output.Baseinfo.PsnNo,
  35851. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  35852. // Certno: res.Output.Baseinfo.Certno,
  35853. // PsnName: res.Output.Baseinfo.PsnName,
  35854. // Gend: res.Output.Baseinfo.Gend,
  35855. // Naty: res.Output.Baseinfo.Naty,
  35856. // Brdy: res.Output.Baseinfo.Brdy,
  35857. // Age: res.Output.Baseinfo.Age,
  35858. // Iinfo: infoStr,
  35859. // Idetinfo: idetinfoStr,
  35860. // PatientId: patient.ID,
  35861. // RecordDate: theTime.Unix(),
  35862. // UserOrgId: adminInfo.CurrentOrgId,
  35863. // AdminUserId: adminInfo.AdminUser.Id,
  35864. // IsReturn: 1,
  35865. // }
  35866. //
  35867. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  35868. // //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")
  35869. // //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")
  35870. //
  35871. // //var dat map[string]interface{}
  35872. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35873. // // fmt.Println(dat)
  35874. // //} else {
  35875. // // fmt.Println(err)
  35876. // //}
  35877. //
  35878. // var dat2 map[string]interface{}
  35879. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  35880. // fmt.Println(dat2)
  35881. // } else {
  35882. // fmt.Println(err)
  35883. // }
  35884. //
  35885. // } else {
  35886. // adminUser := c.GetAdminUserInfo()
  35887. // errlog := &models.HisOrderError{
  35888. // UserOrgId: adminUser.CurrentOrgId,
  35889. // Ctime: time.Now().Unix(),
  35890. // Mtime: time.Now().Unix(),
  35891. // ErrMsg: res.ErrMsg,
  35892. // Status: 1,
  35893. // PatientId: id,
  35894. // RecordTime: recordDateTime,
  35895. // Stage: 1,
  35896. // }
  35897. // service.CreateErrMsgLog(errlog)
  35898. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  35899. // return
  35900. // }
  35901. // }
  35902. //
  35903. //}
  35904. //func (c *HisApiController) GetUploadDiag() {
  35905. // id, _ := c.GetInt64("id")
  35906. // record_time := c.GetString("record_time")
  35907. //
  35908. // diagnosis_id, _ := c.GetInt64("diagnosis")
  35909. // sick_type, _ := c.GetInt64("sick_type")
  35910. // reg_type, _ := c.GetInt64("reg_type")
  35911. //
  35912. // timeLayout := "2006-01-02"
  35913. // loc, _ := time.LoadLocation("Local")
  35914. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35915. // if err != nil {
  35916. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35917. // return
  35918. // }
  35919. //
  35920. // var patientPrescription models.HisPrescriptionInfo
  35921. // recordDateTime := theTime.Unix()
  35922. // adminInfo := c.GetAdminUserInfo()
  35923. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35924. //
  35925. // if patientPrescription.ID == 0 {
  35926. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35927. // }
  35928. //
  35929. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35930. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  35931. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35932. // sickConfig, _ := service.FindSickById(sick_type)
  35933. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35934. //
  35935. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  35936. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  35937. // "&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 +
  35938. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  35939. // resp2, requestErr2 := http.Get(api2)
  35940. // if requestErr2 != nil {
  35941. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35942. // return
  35943. // }
  35944. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35945. // if ioErr2 != nil {
  35946. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35947. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35948. // return
  35949. // }
  35950. // var respJSON2 map[string]interface{}
  35951. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35952. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35953. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35954. // return
  35955. // }
  35956. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35957. // userJSONBytes2, _ := json.Marshal(respJSON2)
  35958. //
  35959. // var res2 ResultSix
  35960. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  35961. // utils.ErrorLog("解析失败:%v", err)
  35962. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35963. // return
  35964. // }
  35965. // if res2.Infcode != 0 {
  35966. // adminUser := c.GetAdminUserInfo()
  35967. // errlog := &models.HisOrderError{
  35968. // UserOrgId: adminUser.CurrentOrgId,
  35969. // Ctime: time.Now().Unix(),
  35970. // Mtime: time.Now().Unix(),
  35971. // ErrMsg: res2.ErrMsg,
  35972. // Status: 1,
  35973. // PatientId: id,
  35974. // RecordTime: recordDateTime,
  35975. // Stage: 3,
  35976. // }
  35977. // service.CreateErrMsgLog(errlog)
  35978. //
  35979. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  35980. // return
  35981. // }
  35982. //
  35983. // c.ServeSuccessJSON(map[string]interface{}{
  35984. // "msg": "上传成功",
  35985. // })
  35986. //
  35987. //}
  35988. type QueryResult struct {
  35989. ID int64
  35990. Name string
  35991. Code string
  35992. List_type_code string
  35993. }
  35994. func (c *HisApiController) GetCheckCode() {
  35995. ids_str := c.GetString("ids")
  35996. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  35997. ids_arr := strings.Split(ids_str, ",")
  35998. var queryResult []QueryResult
  35999. ids := make([]int64, 0)
  36000. for _, item := range ids_arr {
  36001. id, _ := strconv.ParseInt(item, 10, 64)
  36002. ids = append(ids, id)
  36003. }
  36004. if record_type == 1 {
  36005. drugs, _ := service.GetBatchDrugList(ids)
  36006. for _, item := range drugs {
  36007. result := QueryResult{
  36008. ID: item.ID,
  36009. Name: item.DrugName,
  36010. Code: item.MedicalInsuranceNumber,
  36011. List_type_code: "101",
  36012. }
  36013. queryResult = append(queryResult, result)
  36014. }
  36015. } else if record_type == 2 {
  36016. goods, _ := service.GetBatchGoodInformationList(ids)
  36017. fmt.Println(goods)
  36018. for _, item := range goods {
  36019. result := QueryResult{
  36020. ID: item.ID,
  36021. Name: item.GoodName,
  36022. Code: item.SocialSecurityDirectoryCode,
  36023. List_type_code: "301",
  36024. }
  36025. queryResult = append(queryResult, result)
  36026. }
  36027. } else if record_type == 3 {
  36028. projects, _ := service.GetBathchMyPorjecgList(ids)
  36029. for _, item := range projects {
  36030. result := QueryResult{
  36031. ID: item.ID,
  36032. Name: item.ProjectName,
  36033. Code: item.MedicalCode,
  36034. List_type_code: "201",
  36035. }
  36036. queryResult = append(queryResult, result)
  36037. }
  36038. }
  36039. admin_user_id, _ := c.GetInt64("admin_user_id")
  36040. adminUser := c.GetAdminUserInfo()
  36041. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36042. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36043. var user_name string
  36044. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36045. if role.ID == 0 {
  36046. user_name = "管理员"
  36047. } else {
  36048. user_name = role.UserName
  36049. }
  36050. baseParams := models.BaseParams{
  36051. SecretKey: miConfig.SecretKey,
  36052. FixmedinsCode: miConfig.Code,
  36053. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36054. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36055. OrgName: miConfig.OrgName,
  36056. Doctor: user_name,
  36057. }
  36058. var result string
  36059. if miConfig.MdtrtareaAdmvs == "430800" {
  36060. for _, item := range queryResult {
  36061. if record_type == 1 {
  36062. 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)
  36063. } else if record_type == 2 {
  36064. fmt.Println(item.Code)
  36065. 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)
  36066. } else if record_type == 3 {
  36067. 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)
  36068. }
  36069. var dat map[string]interface{}
  36070. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36071. fmt.Println(dat)
  36072. } else {
  36073. fmt.Println(err)
  36074. }
  36075. userJSONBytes, _ := json.Marshal(dat)
  36076. var res ResultSix
  36077. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36078. utils.ErrorLog("解析失败:%v", err)
  36079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36080. return
  36081. }
  36082. if res.Infcode == 0 {
  36083. if record_type == 1 {
  36084. service.UpdateBaseDrugById(item.ID)
  36085. } else if record_type == 2 {
  36086. service.UpdateGoodInformaitonByDetail(item.ID)
  36087. } else if record_type == 3 {
  36088. service.UpdateProjectById(item.ID)
  36089. }
  36090. c.ServeSuccessJSON(map[string]interface{}{
  36091. "failed_code": 0,
  36092. "msg": "目录对照成功",
  36093. })
  36094. } else {
  36095. c.ServeSuccessJSON(map[string]interface{}{
  36096. "failed_code": -10,
  36097. "msg": res.ErrMsg,
  36098. })
  36099. }
  36100. }
  36101. } else {
  36102. for _, item := range queryResult {
  36103. var result string
  36104. if record_type == 1 {
  36105. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36106. } else if record_type == 2 {
  36107. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36108. } else if record_type == 3 {
  36109. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36110. }
  36111. var dat map[string]interface{}
  36112. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36113. fmt.Println(dat)
  36114. } else {
  36115. fmt.Println(err)
  36116. }
  36117. userJSONBytes, _ := json.Marshal(dat)
  36118. var res ResultSix
  36119. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36120. utils.ErrorLog("解析失败:%v", err)
  36121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36122. return
  36123. }
  36124. if res.Infcode == 0 {
  36125. if record_type == 1 {
  36126. service.UpdateBaseDrugById(item.ID)
  36127. } else if record_type == 2 {
  36128. service.UpdateGoodInformaitonByDetail(item.ID)
  36129. } else if record_type == 3 {
  36130. service.UpdateProjectById(item.ID)
  36131. }
  36132. c.ServeSuccessJSON(map[string]interface{}{
  36133. "failed_code": 0,
  36134. "msg": "目录对照成功",
  36135. })
  36136. } else {
  36137. c.ServeSuccessJSON(map[string]interface{}{
  36138. "failed_code": -10,
  36139. "msg": res.ErrMsg,
  36140. })
  36141. }
  36142. }
  36143. }
  36144. }
  36145. func (c *HisApiController) UnCheckCode() {
  36146. ids_str := c.GetString("ids")
  36147. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  36148. admin_user_id, _ := c.GetInt64("admin_user_id")
  36149. ids_arr := strings.Split(ids_str, ",")
  36150. var queryResult []QueryResult
  36151. ids := make([]int64, 0)
  36152. for _, item := range ids_arr {
  36153. id, _ := strconv.ParseInt(item, 10, 64)
  36154. ids = append(ids, id)
  36155. }
  36156. if record_type == 1 {
  36157. drugs, _ := service.GetBatchDrugList(ids)
  36158. for _, item := range drugs {
  36159. result := QueryResult{
  36160. ID: item.ID,
  36161. Name: item.DrugName,
  36162. Code: item.MedicalInsuranceNumber,
  36163. List_type_code: "101",
  36164. }
  36165. queryResult = append(queryResult, result)
  36166. }
  36167. } else if record_type == 2 {
  36168. goods, _ := service.GetBatchGoodInformationList(ids)
  36169. for _, item := range goods {
  36170. result := QueryResult{
  36171. ID: item.ID,
  36172. Name: item.GoodName,
  36173. Code: item.SocialSecurityDirectoryCode,
  36174. List_type_code: "301",
  36175. }
  36176. queryResult = append(queryResult, result)
  36177. }
  36178. } else if record_type == 3 {
  36179. projects, _ := service.GetBathchMyPorjecgList(ids)
  36180. for _, item := range projects {
  36181. result := QueryResult{
  36182. ID: item.ID,
  36183. Name: item.ProjectName,
  36184. Code: item.MedicalCode,
  36185. List_type_code: "201",
  36186. }
  36187. queryResult = append(queryResult, result)
  36188. }
  36189. }
  36190. adminUser := c.GetAdminUserInfo()
  36191. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36192. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36193. var user_name string
  36194. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36195. if role.ID == 0 {
  36196. user_name = "xxx"
  36197. } else {
  36198. user_name = role.UserName
  36199. }
  36200. baseParams := &models.BaseParams{
  36201. SecretKey: miConfig.SecretKey,
  36202. FixmedinsCode: miConfig.Code,
  36203. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36204. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36205. OrgName: miConfig.OrgName,
  36206. Doctor: user_name,
  36207. }
  36208. if config.IsOpen == 1 {
  36209. if miConfig.MdtrtareaAdmvs == "430800" {
  36210. for _, item := range queryResult {
  36211. var result string
  36212. if record_type == 1 {
  36213. 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)
  36214. } else if record_type == 2 {
  36215. fmt.Println(item.Code)
  36216. 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)
  36217. } else if record_type == 3 {
  36218. 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)
  36219. }
  36220. var dat map[string]interface{}
  36221. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36222. fmt.Println(dat)
  36223. } else {
  36224. fmt.Println(err)
  36225. }
  36226. userJSONBytes, _ := json.Marshal(dat)
  36227. var res ResultSix
  36228. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36229. utils.ErrorLog("解析失败:%v", err)
  36230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36231. return
  36232. }
  36233. if res.Infcode == 0 {
  36234. if record_type == 1 {
  36235. service.UpdateBaseDrugById(item.ID)
  36236. } else if record_type == 2 {
  36237. service.UpdateGoodInformaitonByDetail(item.ID)
  36238. } else if record_type == 3 {
  36239. service.UpdateProjectById(item.ID)
  36240. }
  36241. c.ServeSuccessJSON(map[string]interface{}{
  36242. "failed_code": 0,
  36243. "msg": "目录对照成功",
  36244. })
  36245. } else {
  36246. c.ServeSuccessJSON(map[string]interface{}{
  36247. "failed_code": -10,
  36248. "msg": res.ErrMsg,
  36249. })
  36250. }
  36251. }
  36252. } else {
  36253. for _, item := range queryResult {
  36254. var result string
  36255. if record_type == 1 {
  36256. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36257. } else if record_type == 2 {
  36258. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36259. } else if record_type == 3 {
  36260. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36261. }
  36262. var dat2 map[string]interface{}
  36263. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  36264. fmt.Println(dat2)
  36265. } else {
  36266. fmt.Println(err)
  36267. }
  36268. userJSONBytes, _ := json.Marshal(dat2)
  36269. var res ResultSix
  36270. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36271. utils.ErrorLog("解析失败:%v", err)
  36272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36273. return
  36274. }
  36275. if res.Infcode == 0 {
  36276. if record_type == 1 {
  36277. service.UpdateDrugByIdDetail(item.ID)
  36278. } else if record_type == 2 {
  36279. service.UpdateGoodInfoById(item.ID)
  36280. } else if record_type == 3 {
  36281. service.UpdateMyProjectById(item.ID)
  36282. }
  36283. c.ServeSuccessJSON(map[string]interface{}{
  36284. "failed_code": 0,
  36285. "msg": "撤销目录对照成功",
  36286. })
  36287. } else {
  36288. c.ServeSuccessJSON(map[string]interface{}{
  36289. "failed_code": -10,
  36290. "msg": res.ErrMsg,
  36291. })
  36292. }
  36293. }
  36294. }
  36295. }
  36296. }
  36297. func (c *HisApiController) GetPatientInfo() {
  36298. id_card_no := c.GetString("id_card_no")
  36299. admin_user_id, _ := c.GetInt64("admin_user_id")
  36300. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  36301. if patient.ID == 0 {
  36302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  36303. return
  36304. }
  36305. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  36306. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  36307. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  36308. var res ResultTwo
  36309. var res10265 ResultTwo10265
  36310. if config.IsOpen == 1 {
  36311. if miConfig.MdtrtareaAdmvs == "150499" {
  36312. //请求内网数据
  36313. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  36314. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36315. "&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
  36316. resp, requestErr := http.Get(api)
  36317. if requestErr != nil {
  36318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36319. return
  36320. }
  36321. body, ioErr := ioutil.ReadAll(resp.Body)
  36322. if ioErr != nil {
  36323. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36325. return
  36326. }
  36327. var respJSON map[string]interface{}
  36328. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36329. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36331. return
  36332. }
  36333. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36334. result_byte, _ := json.Marshal(respJSON)
  36335. result := string(result_byte)
  36336. var dat map[string]interface{}
  36337. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36338. fmt.Println(dat)
  36339. } else {
  36340. fmt.Println(err)
  36341. }
  36342. userJSONBytes, _ := json.Marshal(dat)
  36343. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36344. utils.ErrorLog("解析失败:%v", err)
  36345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36346. return
  36347. }
  36348. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36349. res.Infcode = Infcode
  36350. res.ErrMsg = res10265.ErrMsg
  36351. res.Output = res10265.Output
  36352. res.InfRefmsgid = res10265.InfRefmsgid
  36353. res.RespondTime = res10265.RespondTime
  36354. res.WarnInfo = res10265.WarnInfo
  36355. } else {
  36356. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  36357. var dat map[string]interface{}
  36358. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36359. fmt.Println(dat)
  36360. } else {
  36361. fmt.Println(err)
  36362. }
  36363. userJSONBytes, _ := json.Marshal(dat)
  36364. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36365. utils.ErrorLog("解析失败:%v", err)
  36366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36367. return
  36368. }
  36369. }
  36370. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36371. // utils.ErrorLog("解析失败:%v", err)
  36372. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36373. // return
  36374. //}
  36375. for index, item := range res.Output.Iinfo {
  36376. if item.PsnInsuStas == "2" {
  36377. fmt.Println("--------")
  36378. res.Output.Iinfo[index].Insutype = "300"
  36379. res.Output.Iinfo[index].PsnInsuStas = "1"
  36380. }
  36381. }
  36382. fmt.Println(res.Output.Iinfo)
  36383. if res.Infcode != 0 {
  36384. c.ServeSuccessJSON(map[string]interface{}{
  36385. "failed_code": -10,
  36386. "msg": res.ErrMsg,
  36387. })
  36388. } else {
  36389. c.ServeSuccessJSON(map[string]interface{}{
  36390. "failed_code": 0,
  36391. "info": res,
  36392. })
  36393. }
  36394. }
  36395. }
  36396. func (c *HisApiController) PsnPutOnRecord() {
  36397. record_type, _ := c.GetInt64("type")
  36398. patient_id, _ := c.GetInt64("patient_id")
  36399. admin_user_id, _ := c.GetInt64("admin_user_id")
  36400. start_time := c.GetString("start_time")
  36401. end_time := c.GetString("end_time")
  36402. adminUser := c.GetAdminUserInfo()
  36403. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36404. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36405. var patients []*models.Patients
  36406. if record_type == 1 { //全部备案
  36407. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  36408. patients = append(patients, patient...)
  36409. } else { //单个备案
  36410. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36411. patients = append(patients, patient)
  36412. }
  36413. var user_name string
  36414. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36415. if role.ID == 0 {
  36416. user_name = "xxx"
  36417. } else {
  36418. user_name = role.UserName
  36419. }
  36420. if config.IsOpen == 1 {
  36421. for _, item := range patients {
  36422. 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
  36423. resp, requestErr := http.Get(api)
  36424. if requestErr != nil {
  36425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36426. return
  36427. }
  36428. defer resp.Body.Close()
  36429. body, ioErr := ioutil.ReadAll(resp.Body)
  36430. if ioErr != nil {
  36431. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36433. return
  36434. }
  36435. var respJSON map[string]interface{}
  36436. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36437. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36439. return
  36440. }
  36441. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36442. userJSONBytes, _ := json.Marshal(userJSON)
  36443. var res ResultTwo
  36444. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36445. utils.ErrorLog("解析失败:%v", err)
  36446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36447. return
  36448. }
  36449. if res.Infcode == 0 {
  36450. 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)
  36451. var dat map[string]interface{}
  36452. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36453. fmt.Println(dat)
  36454. } else {
  36455. fmt.Println(err)
  36456. }
  36457. userJSONBytes, _ := json.Marshal(dat)
  36458. var res2 ResultThirteen
  36459. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36460. utils.ErrorLog("解析失败:%v", err)
  36461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36462. return
  36463. }
  36464. if res2.Infcode == 0 {
  36465. psnResult := &models.GdybPsnRecord{
  36466. UserOrgId: adminUser.CurrentOrgId,
  36467. PatientId: item.ID,
  36468. PsnNo: res.Output.Baseinfo.PsnNo,
  36469. Ctime: time.Now().Unix(),
  36470. Mtime: time.Now().Unix(),
  36471. Status: 1,
  36472. IsCancel: 1,
  36473. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36474. }
  36475. service.CreatePsnRecord(psnResult)
  36476. } else {
  36477. c.ServeSuccessJSON(map[string]interface{}{
  36478. "failed_code": -10,
  36479. "msg": res2.ErrMsg,
  36480. })
  36481. return
  36482. }
  36483. }
  36484. }
  36485. }
  36486. }
  36487. func (c *HisApiController) PsnUnPutOnRecord() {
  36488. id, _ := c.GetInt64("id")
  36489. //record_type, _ := c.GetInt64("type")
  36490. admin_user_id, _ := c.GetInt64("admin_user_id")
  36491. adminUser := c.GetAdminUserInfo()
  36492. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36493. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36494. var user_name string
  36495. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36496. if role.ID == 0 {
  36497. user_name = "xxx"
  36498. } else {
  36499. user_name = role.UserName
  36500. }
  36501. psn_record, _ := service.GetPsnRecordById(id)
  36502. if psn_record.ID == 0 {
  36503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36504. return
  36505. }
  36506. if config.IsOpen == 1 {
  36507. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36508. var dat map[string]interface{}
  36509. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36510. fmt.Println(dat)
  36511. } else {
  36512. fmt.Println(err)
  36513. }
  36514. userJSONBytes, _ := json.Marshal(dat)
  36515. var res ResultFourteen
  36516. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36517. utils.ErrorLog("解析失败:%v", err)
  36518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36519. return
  36520. }
  36521. if res.Infcode == 0 {
  36522. psn_record.IsCancel = 2
  36523. service.CreatePsnRecord(&psn_record)
  36524. } else {
  36525. c.ServeSuccessJSON(map[string]interface{}{
  36526. "failed_code": -10,
  36527. "msg": res.ErrMsg,
  36528. })
  36529. return
  36530. }
  36531. }
  36532. }
  36533. func (c *HisApiController) PsnPutNCDSOnRecord() {
  36534. patient_id, _ := c.GetInt64("patient_id")
  36535. insutype_two := c.GetString("insutype")
  36536. psn_no := c.GetString("psn_no")
  36537. doctor_id, _ := c.GetInt64("doctor_id")
  36538. sick_id, _ := c.GetInt64("sick_id")
  36539. department_id, _ := c.GetInt64("department_id")
  36540. start_time := c.GetString("start_time")
  36541. end_time := c.GetString("end_time")
  36542. check_time := c.GetString("check_time")
  36543. hospital_code := c.GetString("hospital_code")
  36544. hospital_name := c.GetString("hospital_name")
  36545. adminUser := c.GetAdminUserInfo()
  36546. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36547. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36548. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36549. sick, _ := service.FindSickById(sick_id)
  36550. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36551. if len(hospital_code) == 0 {
  36552. hospital_code = miConfig.Code
  36553. }
  36554. if len(hospital_name) == 0 {
  36555. hospital_name = miConfig.OrgName
  36556. }
  36557. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36558. var res ResultTwo
  36559. var res10265 ResultTwo10265
  36560. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36561. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  36562. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  36563. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36564. "&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
  36565. resp, requestErr := http.Get(api)
  36566. if requestErr != nil {
  36567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36568. return
  36569. }
  36570. body, ioErr := ioutil.ReadAll(resp.Body)
  36571. if ioErr != nil {
  36572. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36574. return
  36575. }
  36576. var respJSON map[string]interface{}
  36577. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36578. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36580. return
  36581. }
  36582. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36583. result, _ := json.Marshal(respJSON)
  36584. fmt.Println("log")
  36585. fmt.Println(string(result))
  36586. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36587. utils.ErrorLog("解析失败:%v", err)
  36588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36589. return
  36590. }
  36591. res.ErrMsg = res10265.ErrMsg
  36592. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36593. res.Infcode = infocode
  36594. res.Output = res10265.Output
  36595. res.InfRefmsgid = res10265.InfRefmsgid
  36596. } else {
  36597. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36598. if miConfig.Code == "H15049901371" {
  36599. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36600. utils.ErrorLog("解析失败:%v", err)
  36601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36602. return
  36603. }
  36604. res.ErrMsg = res10265.ErrMsg
  36605. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36606. res.Infcode = infocode
  36607. res.Output = res10265.Output
  36608. res.InfRefmsgid = res10265.InfRefmsgid
  36609. } else {
  36610. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36611. utils.ErrorLog("解析失败:%v", err)
  36612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36613. return
  36614. }
  36615. }
  36616. }
  36617. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36618. infoStr := string(Iinfos)
  36619. var rf []*ResultFive
  36620. json.Unmarshal([]byte(infoStr), &rf)
  36621. var insuplc_admdvs string
  36622. var insutype string
  36623. var is390 int = 0
  36624. var is310 int = 0
  36625. var insutypes []*ResultFive
  36626. for _, item := range rf {
  36627. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36628. insutypes = append(insutypes, item)
  36629. }
  36630. }
  36631. if len(insutypes) == 1 {
  36632. insutype = insutypes[0].Insutype
  36633. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36634. } else {
  36635. for _, i := range insutypes {
  36636. if i.Insutype == "390" {
  36637. is390 = 1
  36638. }
  36639. if i.Insutype == "310" {
  36640. is310 = 1
  36641. }
  36642. }
  36643. }
  36644. if is390 == 1 {
  36645. insutype = "390"
  36646. }
  36647. if is310 == 1 {
  36648. insutype = "310"
  36649. }
  36650. if len(insutypes) == 2 {
  36651. insutype = insutype_two
  36652. }
  36653. if len(insutypes) == 0 {
  36654. insutype = "310"
  36655. }
  36656. insutype = insutype_two
  36657. fmt.Println(insutype)
  36658. for _, item := range rf {
  36659. fmt.Println(item.Insutype)
  36660. fmt.Println(insutype)
  36661. if item.Insutype == insutype {
  36662. fmt.Println(item.Insutype)
  36663. fmt.Println(insutype)
  36664. insuplc_admdvs = item.InsuplcAdmdvs
  36665. }
  36666. }
  36667. fmt.Println(insuplc_admdvs)
  36668. var res2 ResultThirteen
  36669. var res10265_2 ResultThirteen10265
  36670. if config.IsOpen == 1 {
  36671. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36672. } else {
  36673. if miConfig.MdtrtareaAdmvs == "150499" {
  36674. //
  36675. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  36676. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36677. // "&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
  36678. //resp, requestErr := http.Get(api)
  36679. //if requestErr != nil {
  36680. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36681. // return
  36682. //}
  36683. //
  36684. //body, ioErr := ioutil.ReadAll(resp.Body)
  36685. //if ioErr != nil {
  36686. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36687. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36688. // return
  36689. //}
  36690. //var respJSON map[string]interface{}
  36691. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36692. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36693. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36694. // return
  36695. //}
  36696. //
  36697. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36698. //result, _ := json.Marshal(respJSON)
  36699. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  36700. // utils.ErrorLog("解析失败:%v", err)
  36701. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36702. // return
  36703. //}
  36704. //infocode = resThree.Infcode
  36705. //result, _ := json.Marshal(respJSON)
  36706. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  36707. // utils.ErrorLog("解析失败:%v", err)
  36708. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36709. // return
  36710. //}
  36711. //
  36712. //resThree.ErrMsg = resThree10265.ErrMsg
  36713. //
  36714. //resThree.Output = resThree10265.Output
  36715. //
  36716. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  36717. //
  36718. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  36719. //
  36720. } else {
  36721. 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)
  36722. var dat map[string]interface{}
  36723. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36724. fmt.Println(dat)
  36725. } else {
  36726. fmt.Println(err)
  36727. }
  36728. userJSONBytes, _ := json.Marshal(dat)
  36729. if miConfig.Code == "H15049901371" {
  36730. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  36731. utils.ErrorLog("解析失败:%v", err)
  36732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36733. return
  36734. }
  36735. res2.ErrMsg = res10265_2.ErrMsg
  36736. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  36737. res2.Infcode = infocode
  36738. res2.Output = res10265_2.Output
  36739. res2.InfRefmsgid = res10265_2.InfRefmsgid
  36740. } else {
  36741. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36742. utils.ErrorLog("解析失败:%v", err)
  36743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36744. return
  36745. }
  36746. }
  36747. }
  36748. }
  36749. if res2.Infcode == 0 {
  36750. psnResult := &models.GdybPsnNcdsRecord{
  36751. UserOrgId: adminUser.CurrentOrgId,
  36752. PatientId: patient.ID,
  36753. PsnNo: psn_no,
  36754. DoctorId: doctor.AdminUserId,
  36755. DepartmentId: department_id,
  36756. SickType: sick_id,
  36757. Insutype: insutype,
  36758. Ctime: time.Now().Unix(),
  36759. Mtime: time.Now().Unix(),
  36760. Status: 1,
  36761. IsCancel: 1,
  36762. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36763. }
  36764. service.CreatePsnNCDSRecord(psnResult)
  36765. c.ServeSuccessJSON(map[string]interface{}{
  36766. "failed_code": 0,
  36767. "msg": "备案成功",
  36768. "result": psnResult,
  36769. })
  36770. } else {
  36771. c.ServeSuccessJSON(map[string]interface{}{
  36772. "failed_code": -10,
  36773. "msg": res2.ErrMsg,
  36774. })
  36775. return
  36776. }
  36777. }
  36778. }
  36779. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  36780. id, _ := c.GetInt64("id")
  36781. admin_user_id, _ := c.GetInt64("admin_user_id")
  36782. adminUser := c.GetAdminUserInfo()
  36783. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36784. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36785. //config, _ := service.Ge(adminUser.CurrentOrgId)
  36786. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  36787. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36788. //var user_name string
  36789. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36790. //if role.ID == 0 {
  36791. // user_name = "xxx"
  36792. //} else {
  36793. // user_name = role.UserName
  36794. //}
  36795. psn_record, _ := service.GetPsnNCDSRecordById(id)
  36796. if psn_record.ID == 0 {
  36797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36798. return
  36799. }
  36800. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36801. var res ResultTwo
  36802. var res10265 ResultTwo10265
  36803. if miConfig.Code == "H15049901371" {
  36804. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36805. utils.ErrorLog("解析失败:%v", err)
  36806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36807. return
  36808. }
  36809. res.ErrMsg = res10265.ErrMsg
  36810. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36811. res.Infcode = infocode
  36812. res.Output = res10265.Output
  36813. res.InfRefmsgid = res10265.InfRefmsgid
  36814. } else {
  36815. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36816. utils.ErrorLog("解析失败:%v", err)
  36817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36818. return
  36819. }
  36820. }
  36821. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36822. infoStr := string(Iinfos)
  36823. var rf []*ResultFive
  36824. json.Unmarshal([]byte(infoStr), &rf)
  36825. var insuplc_admdvs string
  36826. var insutype string
  36827. var is390 int = 0
  36828. var is310 int = 0
  36829. var insutypes []*ResultFive
  36830. for _, item := range rf {
  36831. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36832. insutypes = append(insutypes, item)
  36833. }
  36834. }
  36835. if len(insutypes) == 1 {
  36836. insutype = insutypes[0].Insutype
  36837. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36838. } else {
  36839. for _, i := range insutypes {
  36840. if i.Insutype == "390" {
  36841. is390 = 1
  36842. }
  36843. if i.Insutype == "310" {
  36844. is310 = 1
  36845. }
  36846. }
  36847. }
  36848. if is390 == 1 {
  36849. insutype = "390"
  36850. }
  36851. if is310 == 1 {
  36852. insutype = "310"
  36853. }
  36854. if len(insutypes) == 0 {
  36855. insutype = "310"
  36856. }
  36857. insutype = psn_record.Insutype
  36858. for _, item := range rf {
  36859. if item.Insutype == insutype {
  36860. insuplc_admdvs = item.InsuplcAdmdvs
  36861. }
  36862. }
  36863. if config.IsOpen == 1 {
  36864. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36865. var dat map[string]interface{}
  36866. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36867. fmt.Println(dat)
  36868. } else {
  36869. fmt.Println(err)
  36870. }
  36871. userJSONBytes, _ := json.Marshal(dat)
  36872. var res ResultFourteen
  36873. var res10265 ResultFourteen10265
  36874. if miConfig.Code == "H15049901371" {
  36875. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36876. utils.ErrorLog("解析失败:%v", err)
  36877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36878. return
  36879. }
  36880. res.ErrMsg = res10265.ErrMsg
  36881. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36882. res.Infcode = infocode
  36883. res.Output = res10265.Output
  36884. res.InfRefmsgid = res10265.InfRefmsgid
  36885. } else {
  36886. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36887. utils.ErrorLog("解析失败:%v", err)
  36888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36889. return
  36890. }
  36891. }
  36892. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36893. // utils.ErrorLog("解析失败:%v", err)
  36894. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36895. // return
  36896. //}
  36897. if res.Infcode == 0 {
  36898. psn_record.IsCancel = 2
  36899. service.CreatePsnNCDSRecord(&psn_record)
  36900. c.ServeSuccessJSON(map[string]interface{}{
  36901. "failed_code": 0,
  36902. "msg": "撤销备案成功",
  36903. })
  36904. } else {
  36905. c.ServeSuccessJSON(map[string]interface{}{
  36906. "failed_code": -10,
  36907. "msg": res.ErrMsg,
  36908. })
  36909. return
  36910. }
  36911. }
  36912. }
  36913. func (c *HisApiController) TestTest() {
  36914. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  36915. fmt.Println(patient.Iinfo)
  36916. }
  36917. type CustomData struct {
  36918. MsgId string
  36919. PsnNo string
  36920. Info string
  36921. }
  36922. func (c *HisApiController) ReversalData() {
  36923. var customData []*CustomData
  36924. custom := &CustomData{
  36925. MsgId: "H44022900158202103301714472004",
  36926. PsnNo: "44020000001101329945",
  36927. Info: "2207",
  36928. }
  36929. customData = append(customData, custom)
  36930. custom1 := &CustomData{
  36931. MsgId: "H4402290015820210330172057803",
  36932. PsnNo: "44020000001101161813",
  36933. Info: "2207",
  36934. }
  36935. customData = append(customData, custom1)
  36936. custom2 := &CustomData{
  36937. MsgId: "H44022900158202103301705198813",
  36938. PsnNo: "44190000133097375417",
  36939. Info: "2207",
  36940. }
  36941. customData = append(customData, custom2)
  36942. custom3 := &CustomData{
  36943. MsgId: "H44022900158202103301715524756",
  36944. PsnNo: "44020000001100187221",
  36945. Info: "2207",
  36946. }
  36947. customData = append(customData, custom3)
  36948. custom4 := &CustomData{
  36949. MsgId: "H44022900158202103301730376224",
  36950. PsnNo: "44020000001101959155",
  36951. Info: "2207",
  36952. }
  36953. customData = append(customData, custom4)
  36954. custom5 := &CustomData{
  36955. MsgId: "H44022900158202103301748008725",
  36956. PsnNo: "44020000001104246641",
  36957. Info: "2207",
  36958. }
  36959. customData = append(customData, custom5)
  36960. custom6 := &CustomData{
  36961. MsgId: "H44022900158202103301718096755",
  36962. PsnNo: "44020000001102211860",
  36963. Info: "2207",
  36964. }
  36965. customData = append(customData, custom6)
  36966. custom7 := &CustomData{
  36967. MsgId: "H44022900158202103301736551640",
  36968. PsnNo: "44020000001102687718",
  36969. Info: "2207",
  36970. }
  36971. customData = append(customData, custom7)
  36972. custom8 := &CustomData{
  36973. MsgId: "H44022900158202103301743097676",
  36974. PsnNo: "44020000001102127785",
  36975. Info: "2207",
  36976. }
  36977. customData = append(customData, custom8)
  36978. custom9 := &CustomData{
  36979. MsgId: "H44022900158202103301712304203",
  36980. PsnNo: "44020000001101518097",
  36981. Info: "2207",
  36982. }
  36983. customData = append(customData, custom9)
  36984. custom10 := &CustomData{
  36985. MsgId: "H44022900158202103301738448785",
  36986. PsnNo: "44020000001100500813",
  36987. Info: "2207",
  36988. }
  36989. customData = append(customData, custom10)
  36990. custom11 := &CustomData{
  36991. MsgId: "H44022900158202103301732455843",
  36992. PsnNo: "44020000001102690557",
  36993. Info: "2207",
  36994. }
  36995. customData = append(customData, custom11)
  36996. custom12 := &CustomData{
  36997. MsgId: "H44022900158202103301745421708",
  36998. PsnNo: "44020000001102211928",
  36999. Info: "2207",
  37000. }
  37001. customData = append(customData, custom12)
  37002. custom1212 := &CustomData{
  37003. MsgId: "H440229001582021033017351627",
  37004. PsnNo: "44020000001102481733",
  37005. Info: "2207",
  37006. }
  37007. customData = append(customData, custom1212)
  37008. custom13 := &CustomData{
  37009. MsgId: "H44022900158202103301740327951",
  37010. PsnNo: "44020000001103174866",
  37011. Info: "2207",
  37012. }
  37013. customData = append(customData, custom13)
  37014. custom14 := &CustomData{
  37015. MsgId: "H4402290015820210330174922668",
  37016. PsnNo: "44020000001102927272",
  37017. Info: "2207",
  37018. }
  37019. customData = append(customData, custom14)
  37020. custom15 := &CustomData{
  37021. MsgId: "H44022900158202103301752362273",
  37022. PsnNo: "44020000001102942890",
  37023. Info: "2207",
  37024. }
  37025. customData = append(customData, custom15)
  37026. custom16 := &CustomData{
  37027. MsgId: "H44022900158202103301751082917",
  37028. PsnNo: "44020000001101662162",
  37029. Info: "2207",
  37030. }
  37031. customData = append(customData, custom16)
  37032. custom17 := &CustomData{
  37033. MsgId: "H44022900158202103301754147728",
  37034. PsnNo: "44020000000229014511",
  37035. Info: "2207",
  37036. }
  37037. customData = append(customData, custom17)
  37038. adminUser := c.GetAdminUserInfo()
  37039. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37040. for _, item := range customData {
  37041. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  37042. fmt.Println(result)
  37043. }
  37044. }
  37045. func (c *HisApiController) GetAllopatry() {
  37046. year := c.GetString("year")
  37047. month := c.GetString("month")
  37048. admin_user_id, _ := c.GetInt64("admin_user_id")
  37049. adminUser := c.GetAdminUserInfo()
  37050. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37051. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37052. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37053. var dat map[string]interface{}
  37054. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37055. fmt.Println(dat)
  37056. } else {
  37057. fmt.Println(err)
  37058. }
  37059. userJSONBytes, _ := json.Marshal(dat)
  37060. var res models.Result9001
  37061. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37062. utils.ErrorLog("解析失败:%v", err)
  37063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37064. return
  37065. }
  37066. fmt.Println(res.Output.Signinoutb)
  37067. fmt.Println(res.Output.Signinoutb.SignNo)
  37068. fmt.Println(string(userJSONBytes))
  37069. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  37070. var dat3 map[string]interface{}
  37071. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  37072. fmt.Println(dat3)
  37073. } else {
  37074. fmt.Println(err)
  37075. }
  37076. userJSONBytes3, _ := json.Marshal(dat3)
  37077. var res3 models.Result3260
  37078. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  37079. utils.ErrorLog("解析失败:%v", err)
  37080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37081. return
  37082. }
  37083. var curpage int
  37084. var pagesize int = 100
  37085. var start int = 1
  37086. //var stop int
  37087. //pagecount := 10
  37088. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  37089. var res22 []models.Result3260
  37090. for curpage = 1; curpage <= pagecount; curpage++ {
  37091. if curpage == 1 {
  37092. start = 0
  37093. } else {
  37094. start = (curpage-1)*pagesize + 1
  37095. }
  37096. fmt.Println(start)
  37097. //stop = curpage * pagesize
  37098. //if stop > int(res3.Output.Totalrow) {
  37099. // stop =int(res3.Output.Totalrow)
  37100. //}
  37101. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  37102. var dat2 map[string]interface{}
  37103. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37104. fmt.Println(dat)
  37105. } else {
  37106. fmt.Println(err)
  37107. }
  37108. userJSONBytes2, _ := json.Marshal(dat2)
  37109. var res2 models.Result3260
  37110. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37111. utils.ErrorLog("解析失败:%v", err)
  37112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37113. return
  37114. }
  37115. if res2.Infcode == 0 {
  37116. res22 = append(res22, res2)
  37117. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37118. //var dat2 map[string]interface{}
  37119. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  37120. // fmt.Println(dat)
  37121. //} else {
  37122. // fmt.Println(err)
  37123. //}
  37124. //c.ServeSuccessJSON(map[string]interface{}{
  37125. // "list": res2.Output.Data,
  37126. //})
  37127. //continue
  37128. }
  37129. }
  37130. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  37131. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  37132. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  37133. //var dat2 map[string]interface{}
  37134. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37135. // fmt.Println(dat)
  37136. //} else {
  37137. // fmt.Println(err)
  37138. //}
  37139. //userJSONBytes2, _ := json.Marshal(dat2)
  37140. //var res2 models.Result3260
  37141. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37142. // utils.ErrorLog("解析失败:%v", err)
  37143. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37144. // return
  37145. //}
  37146. //if res2.Infcode == 0 {
  37147. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37148. // var dat2 map[string]interface{}
  37149. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  37150. // fmt.Println(dat)
  37151. // } else {
  37152. // fmt.Println(err)
  37153. // }
  37154. // c.ServeSuccessJSON(map[string]interface{}{
  37155. // "list": res2.Output.Data,
  37156. // })
  37157. //}
  37158. }
  37159. func (c *HisApiController) ComfirmAllopatry() {
  37160. year := c.GetString("year")
  37161. month := c.GetString("month")
  37162. admin_user_id, _ := c.GetInt64("admin_user_id")
  37163. adminUser := c.GetAdminUserInfo()
  37164. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37165. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37166. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37167. var dat map[string]interface{}
  37168. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37169. fmt.Println(dat)
  37170. } else {
  37171. fmt.Println(err)
  37172. }
  37173. userJSONBytes, _ := json.Marshal(dat)
  37174. var res models.Result9001
  37175. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37176. utils.ErrorLog("解析失败:%v", err)
  37177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37178. return
  37179. }
  37180. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  37181. var dat2 map[string]interface{}
  37182. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37183. fmt.Println(dat)
  37184. } else {
  37185. fmt.Println(err)
  37186. }
  37187. userJSONBytes2, _ := json.Marshal(dat2)
  37188. var res2 models.Result3260
  37189. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37190. utils.ErrorLog("解析失败:%v", err)
  37191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37192. return
  37193. }
  37194. //if res2.Infcode == 0 {
  37195. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37196. // var dat map[string]interface{}
  37197. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37198. // fmt.Println(dat)
  37199. // } else {
  37200. // fmt.Println(err)
  37201. // }
  37202. // userJSONBytes, _ := json.Marshal(dat)
  37203. // var res3 models.Result3261
  37204. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  37205. // utils.ErrorLog("解析失败:%v", err)
  37206. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37207. // return
  37208. // }
  37209. //
  37210. // if res3.Infcode == 0 {
  37211. // record := &models.HisYidiClearRecord{
  37212. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37213. // Ctime: time.Now().Unix(),
  37214. // Mtime: time.Now().Unix(),
  37215. // Status: 1,
  37216. // MsgId: msgId,
  37217. // }
  37218. // service.SaveClearRecord(record)
  37219. // c.ServeSuccessJSON(map[string]interface{}{
  37220. // "msg": "提取成功",
  37221. // })
  37222. // }
  37223. //}
  37224. }
  37225. func (c *HisApiController) RefundAllopatry() {
  37226. year := c.GetString("year")
  37227. month := c.GetString("month")
  37228. //id, _ := c.GetInt64("id")
  37229. admin_user_id, _ := c.GetInt64("admin_user_id")
  37230. adminUser := c.GetAdminUserInfo()
  37231. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37232. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37233. //record, _ := service.GetClearRecordById(id)
  37234. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37235. var dat map[string]interface{}
  37236. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  37237. fmt.Println(dat)
  37238. } else {
  37239. fmt.Println(err)
  37240. }
  37241. userJSONBytes, _ := json.Marshal(dat)
  37242. var res models.Result9001
  37243. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37244. utils.ErrorLog("解析失败:%v", err)
  37245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37246. return
  37247. }
  37248. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  37249. var dat2 map[string]interface{}
  37250. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  37251. fmt.Println(dat)
  37252. } else {
  37253. fmt.Println(err)
  37254. }
  37255. userJSONBytes2, _ := json.Marshal(dat2)
  37256. var empty ResultFourteen
  37257. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  37258. utils.ErrorLog("解析失败:%v", err)
  37259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37260. return
  37261. }
  37262. if empty.Infcode == 0 {
  37263. c.ServeSuccessJSON(map[string]interface{}{
  37264. "msg": "撤销成功",
  37265. })
  37266. return
  37267. }
  37268. }
  37269. func (c *HisApiController) ReversalOtherData() {
  37270. var customData []*CustomData
  37271. custom := &CustomData{
  37272. MsgId: "H44022900158202103301714472004",
  37273. PsnNo: "44020000001101329945",
  37274. Info: "2208",
  37275. }
  37276. customData = append(customData, custom)
  37277. custom1 := &CustomData{
  37278. MsgId: "H4402290015820210330172057803",
  37279. PsnNo: "44020000001101161813",
  37280. Info: "2208",
  37281. }
  37282. customData = append(customData, custom1)
  37283. custom2 := &CustomData{
  37284. MsgId: "H44022900158202103301705198813",
  37285. PsnNo: "44190000133097375417",
  37286. Info: "2208",
  37287. }
  37288. customData = append(customData, custom2)
  37289. custom3 := &CustomData{
  37290. MsgId: "H44022900158202103301715524756",
  37291. PsnNo: "44020000001100187221",
  37292. Info: "2208",
  37293. }
  37294. customData = append(customData, custom3)
  37295. custom4 := &CustomData{
  37296. MsgId: "H44022900158202103301730376224",
  37297. PsnNo: "44020000001101959155",
  37298. Info: "2208",
  37299. }
  37300. customData = append(customData, custom4)
  37301. custom5 := &CustomData{
  37302. MsgId: "H44022900158202103301748008725",
  37303. PsnNo: "44020000001104246641",
  37304. Info: "2208",
  37305. }
  37306. customData = append(customData, custom5)
  37307. custom6 := &CustomData{
  37308. MsgId: "H44022900158202103301718096755",
  37309. PsnNo: "44020000001102211860",
  37310. Info: "2208",
  37311. }
  37312. customData = append(customData, custom6)
  37313. custom7 := &CustomData{
  37314. MsgId: "H44022900158202103301736551640",
  37315. PsnNo: "44020000001102687718",
  37316. Info: "2208",
  37317. }
  37318. customData = append(customData, custom7)
  37319. custom8 := &CustomData{
  37320. MsgId: "H44022900158202103301743097676",
  37321. PsnNo: "44020000001102127785",
  37322. Info: "2208",
  37323. }
  37324. customData = append(customData, custom8)
  37325. custom9 := &CustomData{
  37326. MsgId: "H44022900158202103301712304203",
  37327. PsnNo: "44020000001101518097",
  37328. Info: "2208",
  37329. }
  37330. customData = append(customData, custom9)
  37331. custom10 := &CustomData{
  37332. MsgId: "H44022900158202103301738448785",
  37333. PsnNo: "44020000001100500813",
  37334. Info: "2208",
  37335. }
  37336. customData = append(customData, custom10)
  37337. custom11 := &CustomData{
  37338. MsgId: "H44022900158202103301732455843",
  37339. PsnNo: "44020000001102690557",
  37340. Info: "2208",
  37341. }
  37342. customData = append(customData, custom11)
  37343. custom12 := &CustomData{
  37344. MsgId: "H44022900158202103301745421708",
  37345. PsnNo: "44020000001102211928",
  37346. Info: "2208",
  37347. }
  37348. customData = append(customData, custom12)
  37349. custom1212 := &CustomData{
  37350. MsgId: "H440229001582021033017351627",
  37351. PsnNo: "44020000001102481733",
  37352. Info: "2208",
  37353. }
  37354. customData = append(customData, custom1212)
  37355. custom13 := &CustomData{
  37356. MsgId: "H44022900158202103301740327951",
  37357. PsnNo: "44020000001103174866",
  37358. Info: "2208",
  37359. }
  37360. customData = append(customData, custom13)
  37361. custom14 := &CustomData{
  37362. MsgId: "H4402290015820210330174922668",
  37363. PsnNo: "44020000001102927272",
  37364. Info: "2208",
  37365. }
  37366. customData = append(customData, custom14)
  37367. custom15 := &CustomData{
  37368. MsgId: "H44022900158202103301752362273",
  37369. PsnNo: "44020000001102942890",
  37370. Info: "2208",
  37371. }
  37372. customData = append(customData, custom15)
  37373. custom16 := &CustomData{
  37374. MsgId: "H44022900158202103301751082917",
  37375. PsnNo: "44020000001101662162",
  37376. Info: "2208",
  37377. }
  37378. customData = append(customData, custom16)
  37379. custom17 := &CustomData{
  37380. MsgId: "H44022900158202103301754147728",
  37381. PsnNo: "44020000000229014511",
  37382. Info: "2208",
  37383. }
  37384. customData = append(customData, custom17)
  37385. adminUser := c.GetAdminUserInfo()
  37386. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37387. for _, item := range customData {
  37388. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  37389. fmt.Println(result)
  37390. }
  37391. }
  37392. func PathExists(path string) (bool, error) {
  37393. _, err := os.Stat(path)
  37394. if err == nil {
  37395. return true, nil
  37396. }
  37397. if os.IsNotExist(err) {
  37398. return false, nil
  37399. }
  37400. return false, err
  37401. }
  37402. // 创建文件夹
  37403. func Mkdir(dir string) {
  37404. // 创建文件夹
  37405. exist, err := PathExists(dir)
  37406. if err != nil {
  37407. fmt.Println(err.Error())
  37408. } else {
  37409. if exist {
  37410. fmt.Println(dir + "文件夹已存在!")
  37411. } else {
  37412. // 文件夹名称,权限
  37413. err := os.Mkdir(dir, os.ModePerm)
  37414. if err != nil {
  37415. fmt.Println(dir+"文件夹创建失败:", err.Error())
  37416. } else {
  37417. fmt.Println(dir + "文件夹创建成功!")
  37418. }
  37419. }
  37420. }
  37421. }
  37422. // 压缩文件
  37423. func Zip(srcFile string, destZip string) error {
  37424. zipfile, err := os.Create(destZip)
  37425. if err != nil {
  37426. return err
  37427. }
  37428. defer zipfile.Close()
  37429. archive := zip.NewWriter(zipfile)
  37430. defer archive.Close()
  37431. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  37432. if err != nil {
  37433. return err
  37434. }
  37435. header, err := zip.FileInfoHeader(info)
  37436. if err != nil {
  37437. return err
  37438. }
  37439. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  37440. // header.Name = path
  37441. if info.IsDir() {
  37442. header.Name += "/"
  37443. } else {
  37444. header.Method = zip.Deflate
  37445. }
  37446. writer, err := archive.CreateHeader(header)
  37447. if err != nil {
  37448. return err
  37449. }
  37450. if !info.IsDir() {
  37451. file, err := os.Open(path)
  37452. if err != nil {
  37453. return err
  37454. }
  37455. defer file.Close()
  37456. _, err = io.Copy(writer, file)
  37457. }
  37458. return err
  37459. })
  37460. return err
  37461. }
  37462. func ReadFile(filePath string) []byte {
  37463. f, err := os.Open(filePath)
  37464. if err != nil {
  37465. fmt.Println("read file fail", err)
  37466. return nil
  37467. }
  37468. defer f.Close()
  37469. fd, err := ioutil.ReadAll(f)
  37470. if err != nil {
  37471. fmt.Println("read to fd fail", err)
  37472. return nil
  37473. }
  37474. return fd
  37475. }
  37476. func saveLogq(result string, request string, infno string, desc string) {
  37477. dir := "日志"
  37478. utils.Mkdir(dir)
  37479. month := time.Unix(1557042972, 0).Format("1")
  37480. year := time.Now().Format("2006")
  37481. month = time.Now().Format("01")
  37482. day := time.Now().Format("02")
  37483. hour := time.Now().Format("15")
  37484. min := time.Now().Format("04")
  37485. sec := time.Now().Format("05")
  37486. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37487. file := year + month + day + "_log"
  37488. file_name := file + ".txt"
  37489. file_path := "日志" + "/" + file_name
  37490. exist, _ := utils.PathExists(file_path)
  37491. if exist { //存在
  37492. fmt.Println("存在")
  37493. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37494. if err != nil {
  37495. fmt.Println("read fail")
  37496. }
  37497. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37498. n, _ := f.Seek(0, 2)
  37499. _, err = f.WriteAt([]byte(content), n)
  37500. } else { //不存在
  37501. fmt.Println("文件不存在,创建文件")
  37502. f, err := os.Create("日志" + "/" + file_name)
  37503. defer f.Close()
  37504. if err != nil {
  37505. } else {
  37506. _, err = f.Write([]byte("记录日志"))
  37507. }
  37508. }
  37509. }
  37510. func saveLog(result string, request string, infno string, desc string) {
  37511. org_id, _ := beego.AppConfig.Int64("org_id")
  37512. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37513. dir := miConfig.OrgName + "日志"
  37514. utils.Mkdir(dir)
  37515. month := time.Unix(1557042972, 0).Format("1")
  37516. year := time.Now().Format("2006")
  37517. month = time.Now().Format("01")
  37518. day := time.Now().Format("02")
  37519. hour := time.Now().Format("15")
  37520. min := time.Now().Format("04")
  37521. sec := time.Now().Format("05")
  37522. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37523. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  37524. file_name := file + ".txt"
  37525. file_path := miConfig.OrgName + "日志" + "/" + file_name
  37526. exist, _ := utils.PathExists(file_path)
  37527. if exist { //存在
  37528. fmt.Println("存在")
  37529. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37530. if err != nil {
  37531. fmt.Println("read fail")
  37532. }
  37533. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37534. n, _ := f.Seek(0, 2)
  37535. _, err = f.WriteAt([]byte(content), n)
  37536. } else { //不存在
  37537. fmt.Println("文件不存在,创建文件")
  37538. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  37539. defer f.Close()
  37540. if err != nil {
  37541. } else {
  37542. _, err = f.Write([]byte("记录日志"))
  37543. }
  37544. }
  37545. }
  37546. type Charset string
  37547. const (
  37548. UTF8 = Charset("UTF-8")
  37549. GB18030 = Charset("GB18030")
  37550. )
  37551. func ConvertToString(src string, srcCode string, tagCode string) string {
  37552. srcCoder := mahonia.NewDecoder(srcCode)
  37553. srcResult := srcCoder.ConvertString(src)
  37554. tagCoder := mahonia.NewDecoder(tagCode)
  37555. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  37556. result := string(cdata)
  37557. return result
  37558. }
  37559. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  37560. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37561. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37562. var token string
  37563. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37564. var api string
  37565. if miConfig.MdtrtareaAdmvs == "320921" {
  37566. 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 +
  37567. "&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
  37568. fmt.Println(api)
  37569. } else {
  37570. 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 +
  37571. "&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
  37572. }
  37573. resp, requestErr := http.Get(api)
  37574. if requestErr != nil {
  37575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37576. return ""
  37577. }
  37578. body, ioErr := ioutil.ReadAll(resp.Body)
  37579. if ioErr != nil {
  37580. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37582. return ""
  37583. }
  37584. var respJSON map[string]interface{}
  37585. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37586. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37588. return ""
  37589. }
  37590. var status string
  37591. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37592. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37593. var res ResultTwo //1101结果
  37594. var res10265 ResultTwo10265 //1101结果
  37595. if status == "0" { //读卡成功
  37596. var card_info string //卡信息
  37597. var busi_card_info string
  37598. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37599. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37600. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37601. fmt.Println(card_info)
  37602. fmt.Println(busi_card_info)
  37603. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37604. result, _ := json.Marshal(respJSON)
  37605. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37606. utils.ErrorLog("解析失败:%v", err)
  37607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37608. return ""
  37609. }
  37610. res.ErrMsg = res10265.ErrMsg
  37611. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37612. res.Infcode = infocode
  37613. res.Output = res10265.Output
  37614. res.InfRefmsgid = res10265.InfRefmsgid
  37615. if res.Infcode == 0 {
  37616. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37617. if err == gorm.ErrRecordNotFound {
  37618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37619. return ""
  37620. } else if err != nil {
  37621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37622. return ""
  37623. } else {
  37624. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37625. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37626. infoStr := string(Iinfos)
  37627. idetinfoStr := string(Idetinfos)
  37628. psn := &models.HisPsn{
  37629. PsnNo: res.Output.Baseinfo.PsnNo,
  37630. PatientId: patient.ID,
  37631. Certno: res.Output.Baseinfo.Certno,
  37632. Gend: res.Output.Baseinfo.Gend,
  37633. Naty: res.Output.Baseinfo.Naty,
  37634. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37635. PsnName: res.Output.Baseinfo.PsnName,
  37636. Idetinfo: idetinfoStr,
  37637. Insuinfo: infoStr,
  37638. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37639. CardInfo: card_info,
  37640. VerifyNumber: token,
  37641. }
  37642. service.CreateHisPsn(psn)
  37643. return token
  37644. }
  37645. }
  37646. } else {
  37647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37648. return ""
  37649. }
  37650. } else { //读卡失败
  37651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37652. return ""
  37653. }
  37654. return token
  37655. }
  37656. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  37657. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37658. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37659. var token string
  37660. var api string
  37661. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  37662. "&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
  37663. fmt.Println(api)
  37664. resp, requestErr := http.Get(api)
  37665. if requestErr != nil {
  37666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37667. return ""
  37668. }
  37669. body, ioErr := ioutil.ReadAll(resp.Body)
  37670. if ioErr != nil {
  37671. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37673. return ""
  37674. }
  37675. var respJSON map[string]interface{}
  37676. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37677. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37679. return ""
  37680. }
  37681. var status string
  37682. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37683. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37684. var res ResultTwo //1101结果
  37685. if status == "1" { //读卡成功
  37686. var card_info string //卡信息
  37687. var busi_card_info string
  37688. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37689. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37690. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37691. fmt.Println(card_info)
  37692. fmt.Println(busi_card_info)
  37693. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37694. result, _ := json.Marshal(respJSON)
  37695. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37696. utils.ErrorLog("解析失败:%v", err)
  37697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37698. return ""
  37699. }
  37700. if res.Infcode == 0 {
  37701. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37702. if err == gorm.ErrRecordNotFound {
  37703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37704. return ""
  37705. } else if err != nil {
  37706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37707. return ""
  37708. } else {
  37709. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37710. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37711. infoStr := string(Iinfos)
  37712. idetinfoStr := string(Idetinfos)
  37713. psn := &models.HisPsn{
  37714. PsnNo: res.Output.Baseinfo.PsnNo,
  37715. PatientId: patient.ID,
  37716. Certno: res.Output.Baseinfo.Certno,
  37717. Gend: res.Output.Baseinfo.Gend,
  37718. Naty: res.Output.Baseinfo.Naty,
  37719. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37720. PsnName: res.Output.Baseinfo.PsnName,
  37721. Idetinfo: idetinfoStr,
  37722. Insuinfo: infoStr,
  37723. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37724. CardInfo: card_info,
  37725. VerifyNumber: token,
  37726. }
  37727. service.CreateHisPsn(psn)
  37728. return token
  37729. }
  37730. }
  37731. } else {
  37732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37733. return ""
  37734. }
  37735. return token
  37736. }
  37737. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  37738. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37739. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37740. var token string
  37741. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37742. var api string
  37743. if miConfig.MdtrtareaAdmvs == "320921" {
  37744. 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 +
  37745. "&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
  37746. fmt.Println(api)
  37747. } else {
  37748. 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 +
  37749. "&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
  37750. }
  37751. resp, requestErr := http.Get(api)
  37752. if requestErr != nil {
  37753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37754. return ""
  37755. }
  37756. body, ioErr := ioutil.ReadAll(resp.Body)
  37757. if ioErr != nil {
  37758. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37760. return ""
  37761. }
  37762. var respJSON map[string]interface{}
  37763. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37764. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37766. return ""
  37767. }
  37768. var status string
  37769. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37770. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37771. var res ResultTwo //1101结果
  37772. var res10265 ResultTwo10265 //1101结果
  37773. if status == "0" { //读卡成功
  37774. var card_info string //卡信息
  37775. var busi_card_info string
  37776. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37777. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37778. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37779. fmt.Println(card_info)
  37780. fmt.Println(busi_card_info)
  37781. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37782. result, _ := json.Marshal(respJSON)
  37783. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37784. utils.ErrorLog("解析失败:%v", err)
  37785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37786. return ""
  37787. }
  37788. res.ErrMsg = res10265.ErrMsg
  37789. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37790. res.Infcode = infocode
  37791. res.Output = res10265.Output
  37792. res.InfRefmsgid = res10265.InfRefmsgid
  37793. if res.Infcode == 0 {
  37794. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37795. if err == gorm.ErrRecordNotFound {
  37796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37797. return ""
  37798. } else if err != nil {
  37799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37800. return ""
  37801. } else {
  37802. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37803. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37804. infoStr := string(Iinfos)
  37805. idetinfoStr := string(Idetinfos)
  37806. psn := &models.HisPsn{
  37807. PsnNo: res.Output.Baseinfo.PsnNo,
  37808. PatientId: patient.ID,
  37809. Certno: res.Output.Baseinfo.Certno,
  37810. Gend: res.Output.Baseinfo.Gend,
  37811. Naty: res.Output.Baseinfo.Naty,
  37812. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37813. PsnName: res.Output.Baseinfo.PsnName,
  37814. Idetinfo: idetinfoStr,
  37815. Insuinfo: infoStr,
  37816. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37817. CardInfo: card_info,
  37818. VerifyNumber: token,
  37819. }
  37820. service.CreateHisPsn(psn)
  37821. return token
  37822. }
  37823. }
  37824. } else {
  37825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37826. return ""
  37827. }
  37828. } else { //读卡失败
  37829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37830. return ""
  37831. }
  37832. return token
  37833. }
  37834. func DeleteExtraSpaceTwo(s string) string {
  37835. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37836. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37837. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37838. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37839. s2 := make([]byte, len(s1)) //定义字符数组切片
  37840. copy(s2, s1) //将字符串复制到切片
  37841. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37842. for len(spc_index) > 0 { //找到适配项
  37843. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37844. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37845. }
  37846. return string(s2)
  37847. }
  37848. func Remove0000(s string) string {
  37849. str := make([]rune, 0, len(s))
  37850. for _, v := range []rune(s) {
  37851. if v == 0 {
  37852. continue
  37853. }
  37854. str = append(str, v)
  37855. }
  37856. return string(str)
  37857. }
  37858. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  37859. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  37860. readCard := DllDef.MustFindProc("EcQuery")
  37861. pCardInfo := make([]byte, 8192)
  37862. pBusiCardInfo := make([]byte, 8192)
  37863. data := make(map[string]interface{})
  37864. //pData := make(map[string]interface{})
  37865. inputData := make(map[string]interface{})
  37866. inputData["orgId"] = code
  37867. inputData["businessType"] = "01101"
  37868. inputData["operatorId"] = operator_id
  37869. inputData["operatorName"] = operator_name
  37870. inputData["officeId"] = "001"
  37871. inputData["officeName"] = "血透室"
  37872. //
  37873. data["data"] = inputData
  37874. data["transType"] = "ec.query"
  37875. data["orgId"] = code
  37876. bytesData, _ := json.Marshal(data)
  37877. pCardInfo = bytesData
  37878. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  37879. fmt.Println(ret2)
  37880. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  37881. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  37882. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  37883. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  37884. if ret2 != 0 {
  37885. return "", ""
  37886. }
  37887. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  37888. }
  37889. func DeleteExtraSpace(s string) string {
  37890. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37891. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37892. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37893. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37894. s2 := make([]byte, len(s1)) //定义字符数组切片
  37895. copy(s2, s1) //将字符串复制到切片
  37896. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37897. for len(spc_index) > 0 { //找到适配项
  37898. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37899. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37900. }
  37901. return string(s2)
  37902. }
  37903. // 对账
  37904. func (c *HisApiController) Post3202() {
  37905. start_time := c.GetString("start_time")
  37906. end_time := c.GetString("end_time")
  37907. //insutype := c.GetString("insutype")
  37908. clr_type := c.GetString("clr_type")
  37909. clr_org := c.GetString("clr_optins")
  37910. admin_user_id, _ := c.GetInt64("admin_user_id")
  37911. adminUser := c.GetAdminUserInfo()
  37912. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37913. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37914. if len(clr_org) == 0 {
  37915. clr_org = miConfig.MdtrtareaAdmvs
  37916. }
  37917. timeLayout := "2006-01-02"
  37918. loc, _ := time.LoadLocation("Local")
  37919. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37920. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37921. var orders []*models.HisOrder
  37922. if clr_org == "421300" {
  37923. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37924. } else if clr_org == "420902" {
  37925. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37926. } else {
  37927. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37928. }
  37929. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37930. //fixmedins_setl_cnt := int64(len(orders))
  37931. var medfee_sumamt float64
  37932. var acct_pay float64
  37933. var fund_pay_sumamt float64
  37934. for _, item := range orders {
  37935. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37936. acct_pay = acct_pay + item.AcctPay
  37937. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37938. }
  37939. //var medfee_sumamt_two float64
  37940. //var acct_pay_two float64
  37941. //var fund_pay_sumamt_two float64
  37942. //for _, item := range orders_two {
  37943. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37944. // acct_pay_two = acct_pay_two + item.AcctPay
  37945. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37946. //}
  37947. //var user_name string
  37948. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37949. //if role.ID == 0 {
  37950. // user_name = "xxx"
  37951. //} else {
  37952. // user_name = role.UserName
  37953. //}
  37954. var res ResultSix
  37955. if config.IsOpen == 1 {
  37956. var bps []*models.BusinessParamsTwo
  37957. var bp models.BusinessParamsTwo
  37958. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37959. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  37960. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  37961. bp.MedfeeSumamt = medfee_sumamt_str
  37962. bp.AcctPay = acct_pay_str
  37963. bp.FundPaySumamt = fund_pay_sumamt_str
  37964. bp.Insutype = ""
  37965. bp.StmtBegndate = start_time
  37966. bp.ClrType = clr_type
  37967. bp.SetlOptins = clr_org
  37968. bp.StmtEnddate = end_time
  37969. bps = append(bps, &bp)
  37970. data := make(map[string]interface{})
  37971. data["bps"] = bps
  37972. data["org_name"] = miConfig.OrgName
  37973. data["doctor"] = role.UserName
  37974. data["fixmedins_code"] = miConfig.Code
  37975. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37976. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37977. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37978. if miConfig.MdtrtareaAdmvs == "421300" {
  37979. client := &http.Client{}
  37980. bytesData, _ := json.Marshal(data)
  37981. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37982. resp, _ := client.Do(req)
  37983. defer resp.Body.Close()
  37984. body, ioErr := ioutil.ReadAll(resp.Body)
  37985. if ioErr != nil {
  37986. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37988. return
  37989. }
  37990. var respJSON map[string]interface{}
  37991. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37992. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37994. return
  37995. }
  37996. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37997. userJSONBytes, _ := json.Marshal(respJSON)
  37998. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37999. utils.ErrorLog("解析失败:%v", err)
  38000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38001. return
  38002. }
  38003. }
  38004. if miConfig.MdtrtareaAdmvs == "420200" {
  38005. client := &http.Client{}
  38006. bytesData, _ := json.Marshal(data)
  38007. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  38008. resp, _ := client.Do(req)
  38009. defer resp.Body.Close()
  38010. body, ioErr := ioutil.ReadAll(resp.Body)
  38011. if ioErr != nil {
  38012. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38014. return
  38015. }
  38016. var respJSON map[string]interface{}
  38017. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38018. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38020. return
  38021. }
  38022. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38023. userJSONBytes, _ := json.Marshal(respJSON)
  38024. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38025. utils.ErrorLog("解析失败:%v", err)
  38026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38027. return
  38028. }
  38029. }
  38030. if miConfig.MdtrtareaAdmvs == "421182" {
  38031. client := &http.Client{}
  38032. bytesData, _ := json.Marshal(data)
  38033. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  38034. resp, _ := client.Do(req)
  38035. defer resp.Body.Close()
  38036. body, ioErr := ioutil.ReadAll(resp.Body)
  38037. if ioErr != nil {
  38038. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38040. return
  38041. }
  38042. var respJSON map[string]interface{}
  38043. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38046. return
  38047. }
  38048. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38049. userJSONBytes, _ := json.Marshal(respJSON)
  38050. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38051. utils.ErrorLog("解析失败:%v", err)
  38052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38053. return
  38054. }
  38055. }
  38056. if miConfig.MdtrtareaAdmvs == "420902" {
  38057. client := &http.Client{}
  38058. bytesData, _ := json.Marshal(data)
  38059. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  38060. resp, _ := client.Do(req)
  38061. defer resp.Body.Close()
  38062. body, ioErr := ioutil.ReadAll(resp.Body)
  38063. if ioErr != nil {
  38064. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38066. return
  38067. }
  38068. var respJSON map[string]interface{}
  38069. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38070. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38072. return
  38073. }
  38074. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38075. userJSONBytes, _ := json.Marshal(respJSON)
  38076. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38077. utils.ErrorLog("解析失败:%v", err)
  38078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38079. return
  38080. }
  38081. }
  38082. if res.Infcode == 0 {
  38083. c.ServeSuccessJSON(map[string]interface{}{
  38084. "msg": "发起成功",
  38085. })
  38086. } else {
  38087. c.ServeSuccessJSON(map[string]interface{}{
  38088. "failed_code": -10,
  38089. "msg": res.ErrMsg,
  38090. })
  38091. }
  38092. }
  38093. }
  38094. func (c *HisApiController) Post3204a() {
  38095. start_time := c.GetString("start_time")
  38096. end_time := c.GetString("end_time")
  38097. //insutype := c.GetString("insutype")
  38098. clr_type := c.GetString("clr_type")
  38099. clr_org := c.GetString("clr_optins")
  38100. admin_user_id, _ := c.GetInt64("admin_user_id")
  38101. adminUser := c.GetAdminUserInfo()
  38102. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38103. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38104. if len(clr_org) == 0 {
  38105. clr_org = miConfig.MdtrtareaAdmvs
  38106. }
  38107. timeLayout := "2006-01-02"
  38108. loc, _ := time.LoadLocation("Local")
  38109. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38110. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38111. var orders []*models.HisOrder
  38112. if clr_org == "421300" {
  38113. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38114. } else if clr_org == "420902" {
  38115. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38116. } else {
  38117. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38118. }
  38119. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38120. //fixmedins_setl_cnt := int64(len(orders))
  38121. var medfee_sumamt float64
  38122. var acct_pay float64
  38123. var fund_pay_sumamt float64
  38124. for _, item := range orders {
  38125. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38126. acct_pay = acct_pay + item.AcctPay
  38127. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38128. }
  38129. //var medfee_sumamt_two float64
  38130. //var acct_pay_two float64
  38131. //var fund_pay_sumamt_two float64
  38132. //for _, item := range orders_two {
  38133. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38134. // acct_pay_two = acct_pay_two + item.AcctPay
  38135. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38136. //}
  38137. //var user_name string
  38138. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38139. //if role.ID == 0 {
  38140. // user_name = "xxx"
  38141. //} else {
  38142. // user_name = role.UserName
  38143. //}
  38144. var res ResultSix
  38145. if config.IsOpen == 1 {
  38146. var bps []*models.BusinessParamsTwo
  38147. var bp models.BusinessParamsTwo
  38148. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38149. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38150. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38151. bp.MedfeeSumamt = medfee_sumamt_str
  38152. bp.AcctPay = acct_pay_str
  38153. bp.FundPaySumamt = fund_pay_sumamt_str
  38154. bp.Insutype = ""
  38155. bp.StmtBegndate = start_time
  38156. bp.ClrType = clr_type
  38157. bp.SetlOptins = clr_org
  38158. bp.StmtEnddate = end_time
  38159. bps = append(bps, &bp)
  38160. data := make(map[string]interface{})
  38161. data["bps"] = bps
  38162. data["org_name"] = miConfig.OrgName
  38163. data["doctor"] = role.UserName
  38164. data["fixmedins_code"] = miConfig.Code
  38165. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38166. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38167. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38168. if miConfig.MdtrtareaAdmvs == "421300" {
  38169. client := &http.Client{}
  38170. bytesData, _ := json.Marshal(data)
  38171. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38172. resp, _ := client.Do(req)
  38173. defer resp.Body.Close()
  38174. body, ioErr := ioutil.ReadAll(resp.Body)
  38175. if ioErr != nil {
  38176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38178. return
  38179. }
  38180. var respJSON map[string]interface{}
  38181. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38184. return
  38185. }
  38186. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38187. userJSONBytes, _ := json.Marshal(respJSON)
  38188. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38189. utils.ErrorLog("解析失败:%v", err)
  38190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38191. return
  38192. }
  38193. }
  38194. if miConfig.MdtrtareaAdmvs == "420200" {
  38195. client := &http.Client{}
  38196. bytesData, _ := json.Marshal(data)
  38197. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38198. resp, _ := client.Do(req)
  38199. defer resp.Body.Close()
  38200. body, ioErr := ioutil.ReadAll(resp.Body)
  38201. if ioErr != nil {
  38202. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38204. return
  38205. }
  38206. var respJSON map[string]interface{}
  38207. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38208. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38210. return
  38211. }
  38212. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38213. userJSONBytes, _ := json.Marshal(respJSON)
  38214. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38215. utils.ErrorLog("解析失败:%v", err)
  38216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38217. return
  38218. }
  38219. }
  38220. if miConfig.MdtrtareaAdmvs == "421182" {
  38221. client := &http.Client{}
  38222. bytesData, _ := json.Marshal(data)
  38223. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38224. resp, _ := client.Do(req)
  38225. defer resp.Body.Close()
  38226. body, ioErr := ioutil.ReadAll(resp.Body)
  38227. if ioErr != nil {
  38228. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38230. return
  38231. }
  38232. var respJSON map[string]interface{}
  38233. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38234. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38236. return
  38237. }
  38238. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38239. userJSONBytes, _ := json.Marshal(respJSON)
  38240. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38241. utils.ErrorLog("解析失败:%v", err)
  38242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38243. return
  38244. }
  38245. }
  38246. if miConfig.MdtrtareaAdmvs == "420902" {
  38247. client := &http.Client{}
  38248. bytesData, _ := json.Marshal(data)
  38249. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38250. resp, _ := client.Do(req)
  38251. defer resp.Body.Close()
  38252. body, ioErr := ioutil.ReadAll(resp.Body)
  38253. if ioErr != nil {
  38254. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38256. return
  38257. }
  38258. var respJSON map[string]interface{}
  38259. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38260. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38262. return
  38263. }
  38264. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38265. userJSONBytes, _ := json.Marshal(respJSON)
  38266. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38267. utils.ErrorLog("解析失败:%v", err)
  38268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38269. return
  38270. }
  38271. }
  38272. if res.Infcode == 0 {
  38273. c.ServeSuccessJSON(map[string]interface{}{
  38274. "msg": "撤销成功",
  38275. })
  38276. } else {
  38277. c.ServeSuccessJSON(map[string]interface{}{
  38278. "failed_code": -10,
  38279. "msg": res.ErrMsg,
  38280. })
  38281. }
  38282. }
  38283. }
  38284. func (c *HisApiController) Post3204() {
  38285. admin_user_id, _ := c.GetInt64("admin_user_id")
  38286. id := c.GetString("id")
  38287. adminUser := c.GetAdminUserInfo()
  38288. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38289. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38290. //clr_org := miConfig.MdtrtareaAdmvs
  38291. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38292. var res ResultSix
  38293. if config.IsOpen == 1 {
  38294. data := make(map[string]interface{})
  38295. data["id"] = id
  38296. data["org_name"] = miConfig.OrgName
  38297. data["doctor"] = role.UserName
  38298. data["fixmedins_code"] = miConfig.Code
  38299. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38300. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38301. client := &http.Client{}
  38302. bytesData, _ := json.Marshal(data)
  38303. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  38304. resp, _ := client.Do(req)
  38305. defer resp.Body.Close()
  38306. body, ioErr := ioutil.ReadAll(resp.Body)
  38307. if ioErr != nil {
  38308. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38310. return
  38311. }
  38312. var respJSON map[string]interface{}
  38313. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38314. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38316. return
  38317. }
  38318. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38319. userJSONBytes, _ := json.Marshal(respJSON)
  38320. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38321. utils.ErrorLog("解析失败:%v", err)
  38322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38323. return
  38324. }
  38325. if res.Infcode == 0 {
  38326. c.ServeSuccessJSON(map[string]interface{}{
  38327. "msg": "发起成功",
  38328. })
  38329. } else {
  38330. c.ServeSuccessJSON(map[string]interface{}{
  38331. "failed_code": -10,
  38332. "msg": res.ErrMsg,
  38333. })
  38334. }
  38335. }
  38336. }
  38337. func (c *HisApiController) Post8404() {
  38338. admin_user_id, _ := c.GetInt64("admin_user_id")
  38339. month := c.GetString("month")
  38340. adminUser := c.GetAdminUserInfo()
  38341. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38342. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38343. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38344. var res ResultSix
  38345. if config.IsOpen == 1 {
  38346. data := make(map[string]interface{})
  38347. data["month"] = month
  38348. data["org_name"] = miConfig.OrgName
  38349. data["doctor"] = role.UserName
  38350. data["fixmedins_code"] = miConfig.Code
  38351. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38352. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38353. client := &http.Client{}
  38354. bytesData, _ := json.Marshal(data)
  38355. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  38356. resp, _ := client.Do(req)
  38357. defer resp.Body.Close()
  38358. body, ioErr := ioutil.ReadAll(resp.Body)
  38359. if ioErr != nil {
  38360. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38362. return
  38363. }
  38364. var respJSON map[string]interface{}
  38365. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38368. return
  38369. }
  38370. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38371. userJSONBytes, _ := json.Marshal(respJSON)
  38372. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38373. utils.ErrorLog("解析失败:%v", err)
  38374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38375. return
  38376. }
  38377. if res.Infcode == 0 {
  38378. c.ServeSuccessJSON(map[string]interface{}{
  38379. "msg": "查询成功",
  38380. })
  38381. } else {
  38382. c.ServeSuccessJSON(map[string]interface{}{
  38383. "failed_code": -10,
  38384. "msg": res.ErrMsg,
  38385. })
  38386. }
  38387. }
  38388. }
  38389. func (c *HisApiController) Post3202b() {
  38390. start_time := c.GetString("start_time")
  38391. end_time := c.GetString("end_time")
  38392. //insutype := c.GetString("insutype")
  38393. clr_type := c.GetString("clr_type")
  38394. clr_org := c.GetString("clr_optins")
  38395. admin_user_id, _ := c.GetInt64("admin_user_id")
  38396. adminUser := c.GetAdminUserInfo()
  38397. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38398. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38399. if len(clr_org) == 0 {
  38400. clr_org = miConfig.MdtrtareaAdmvs
  38401. }
  38402. timeLayout := "2006-01-02"
  38403. loc, _ := time.LoadLocation("Local")
  38404. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38405. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38406. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38407. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38408. //fixmedins_setl_cnt := int64(len(orders))
  38409. var medfee_sumamt float64
  38410. var acct_pay float64
  38411. var fund_pay_sumamt float64
  38412. for _, item := range orders {
  38413. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38414. acct_pay = acct_pay + item.AcctPay
  38415. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38416. }
  38417. //var medfee_sumamt_two float64
  38418. //var acct_pay_two float64
  38419. //var fund_pay_sumamt_two float64
  38420. //for _, item := range orders_two {
  38421. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38422. // acct_pay_two = acct_pay_two + item.AcctPay
  38423. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38424. //}
  38425. //var user_name string
  38426. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38427. //if role.ID == 0 {
  38428. // user_name = "xxx"
  38429. //} else {
  38430. // user_name = role.UserName
  38431. //}
  38432. var res ResultSix
  38433. if config.IsOpen == 1 {
  38434. var bps []*models.BusinessParamsTwo
  38435. var bp models.BusinessParamsTwo
  38436. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38437. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38438. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38439. bp.MedfeeSumamt = medfee_sumamt_str
  38440. bp.AcctPay = acct_pay_str
  38441. bp.FundPaySumamt = fund_pay_sumamt_str
  38442. bp.Insutype = "390"
  38443. bp.StmtBegndate = start_time
  38444. bp.ClrType = clr_type
  38445. bp.SetlOptins = clr_org
  38446. bp.StmtEnddate = end_time
  38447. bps = append(bps, &bp)
  38448. data := make(map[string]interface{})
  38449. data["bps"] = bps
  38450. data["org_name"] = miConfig.OrgName
  38451. data["doctor"] = role.UserName
  38452. data["fixmedins_code"] = miConfig.Code
  38453. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38454. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38455. if miConfig.MdtrtareaAdmvs == "421300" {
  38456. client := &http.Client{}
  38457. bytesData, _ := json.Marshal(data)
  38458. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38459. resp, _ := client.Do(req)
  38460. defer resp.Body.Close()
  38461. body, ioErr := ioutil.ReadAll(resp.Body)
  38462. if ioErr != nil {
  38463. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38465. return
  38466. }
  38467. var respJSON map[string]interface{}
  38468. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38469. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38471. return
  38472. }
  38473. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38474. userJSONBytes, _ := json.Marshal(respJSON)
  38475. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38476. utils.ErrorLog("解析失败:%v", err)
  38477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38478. return
  38479. }
  38480. }
  38481. if miConfig.MdtrtareaAdmvs == "420200" {
  38482. client := &http.Client{}
  38483. bytesData, _ := json.Marshal(data)
  38484. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38485. resp, _ := client.Do(req)
  38486. defer resp.Body.Close()
  38487. body, ioErr := ioutil.ReadAll(resp.Body)
  38488. if ioErr != nil {
  38489. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38491. return
  38492. }
  38493. var respJSON map[string]interface{}
  38494. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38495. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38497. return
  38498. }
  38499. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38500. userJSONBytes, _ := json.Marshal(respJSON)
  38501. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38502. utils.ErrorLog("解析失败:%v", err)
  38503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38504. return
  38505. }
  38506. }
  38507. if miConfig.MdtrtareaAdmvs == "421182" {
  38508. client := &http.Client{}
  38509. bytesData, _ := json.Marshal(data)
  38510. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  38511. resp, _ := client.Do(req)
  38512. defer resp.Body.Close()
  38513. body, ioErr := ioutil.ReadAll(resp.Body)
  38514. if ioErr != nil {
  38515. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38517. return
  38518. }
  38519. var respJSON map[string]interface{}
  38520. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38521. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38523. return
  38524. }
  38525. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38526. userJSONBytes, _ := json.Marshal(respJSON)
  38527. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38528. utils.ErrorLog("解析失败:%v", err)
  38529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38530. return
  38531. }
  38532. }
  38533. if res.Infcode == 0 {
  38534. c.ServeSuccessJSON(map[string]interface{}{
  38535. "msg": "发起成功",
  38536. })
  38537. } else {
  38538. c.ServeSuccessJSON(map[string]interface{}{
  38539. "failed_code": -10,
  38540. "msg": res.ErrMsg,
  38541. })
  38542. }
  38543. }
  38544. }
  38545. func (c *HisApiController) Post1608() {
  38546. start_time := c.GetString("start_time")
  38547. end_time := c.GetString("end_time")
  38548. admin_user_id, _ := c.GetInt64("admin_user_id")
  38549. adminUser := c.GetAdminUserInfo()
  38550. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38551. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38552. timeLayout := "2006-01-02"
  38553. loc, _ := time.LoadLocation("Local")
  38554. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38555. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38556. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38557. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38558. fixmedins_setl_cnt := int64(len(orders))
  38559. var medfee_sumamt float64
  38560. var func_smamt float64
  38561. for _, item := range orders {
  38562. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38563. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  38564. }
  38565. times := strings.Split(start_time, "-")
  38566. time_tows := strings.Split(end_time, "-")
  38567. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38568. var res ResultSix
  38569. if config.IsOpen == 1 {
  38570. //var bps []*models.BusinessParamsTwo
  38571. //var bp models.BusinessParamsTwo
  38572. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38573. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  38574. data := make(map[string]interface{})
  38575. data["org_name"] = miConfig.OrgName
  38576. data["doctor"] = role.UserName
  38577. data["func_smamt"] = func_smamt_str
  38578. data["fixmedins_code"] = miConfig.Code
  38579. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38580. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38581. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  38582. data["medfee_sumamt"] = medfee_sumamt_str
  38583. data["start_time"] = times[0] + times[1] + times[2]
  38584. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  38585. if miConfig.MdtrtareaAdmvs == "421300" {
  38586. client := &http.Client{}
  38587. bytesData, _ := json.Marshal(data)
  38588. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38589. resp, _ := client.Do(req)
  38590. defer resp.Body.Close()
  38591. body, ioErr := ioutil.ReadAll(resp.Body)
  38592. if ioErr != nil {
  38593. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38595. return
  38596. }
  38597. var respJSON map[string]interface{}
  38598. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38599. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38601. return
  38602. }
  38603. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38604. userJSONBytes, _ := json.Marshal(respJSON)
  38605. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38606. utils.ErrorLog("解析失败:%v", err)
  38607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38608. return
  38609. }
  38610. }
  38611. if miConfig.MdtrtareaAdmvs == "420200" {
  38612. client := &http.Client{}
  38613. bytesData, _ := json.Marshal(data)
  38614. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38615. resp, _ := client.Do(req)
  38616. defer resp.Body.Close()
  38617. body, ioErr := ioutil.ReadAll(resp.Body)
  38618. if ioErr != nil {
  38619. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38621. return
  38622. }
  38623. var respJSON map[string]interface{}
  38624. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38625. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38627. return
  38628. }
  38629. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38630. userJSONBytes, _ := json.Marshal(respJSON)
  38631. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38632. utils.ErrorLog("解析失败:%v", err)
  38633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38634. return
  38635. }
  38636. }
  38637. if miConfig.MdtrtareaAdmvs == "421182" {
  38638. client := &http.Client{}
  38639. bytesData, _ := json.Marshal(data)
  38640. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  38641. resp, _ := client.Do(req)
  38642. defer resp.Body.Close()
  38643. body, ioErr := ioutil.ReadAll(resp.Body)
  38644. if ioErr != nil {
  38645. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38647. return
  38648. }
  38649. var respJSON map[string]interface{}
  38650. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38651. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38653. return
  38654. }
  38655. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38656. userJSONBytes, _ := json.Marshal(respJSON)
  38657. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38658. utils.ErrorLog("解析失败:%v", err)
  38659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38660. return
  38661. }
  38662. }
  38663. if res.Infcode == 0 {
  38664. c.ServeSuccessJSON(map[string]interface{}{
  38665. "msg": "发起成功",
  38666. })
  38667. } else {
  38668. c.ServeSuccessJSON(map[string]interface{}{
  38669. "failed_code": -10,
  38670. "msg": res.ErrMsg,
  38671. })
  38672. }
  38673. }
  38674. }
  38675. // 5.11.1.1【5262】结算信息按时间段查询
  38676. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38677. admin_user_id, _ := c.GetInt64("admin_user_id")
  38678. adminUser := c.GetAdminUserInfo()
  38679. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38680. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38681. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38682. var res Result5262
  38683. if config.IsOpen == 1 {
  38684. if miConfig.MdtrtareaAdmvs == "421300" {
  38685. data := make(map[string]interface{})
  38686. data["bps"] = bp
  38687. data["org_name"] = miConfig.OrgName
  38688. data["doctor"] = role.UserName
  38689. data["fixmedins_code"] = miConfig.Code
  38690. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38691. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38692. data["page"] = strconv.FormatInt(page, 10)
  38693. data["limit"] = strconv.FormatInt(limit, 10)
  38694. fmt.Println(data)
  38695. client := &http.Client{}
  38696. bytesData, _ := json.Marshal(data)
  38697. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38698. resp, _ := client.Do(req)
  38699. defer resp.Body.Close()
  38700. body, ioErr := ioutil.ReadAll(resp.Body)
  38701. if ioErr != nil {
  38702. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38704. return
  38705. }
  38706. var respJSON map[string]interface{}
  38707. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38708. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38710. return
  38711. }
  38712. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38713. userJSONBytes, _ := json.Marshal(respJSON)
  38714. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38715. utils.ErrorLog("解析失败:%v", err)
  38716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38717. return
  38718. }
  38719. }
  38720. if miConfig.MdtrtareaAdmvs == "420200" {
  38721. data := make(map[string]interface{})
  38722. data["bps"] = bp
  38723. data["org_name"] = miConfig.OrgName
  38724. data["doctor"] = role.UserName
  38725. data["fixmedins_code"] = miConfig.Code
  38726. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38727. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38728. data["page"] = strconv.FormatInt(page, 10)
  38729. data["limit"] = strconv.FormatInt(limit, 10)
  38730. fmt.Println(data)
  38731. client := &http.Client{}
  38732. bytesData, _ := json.Marshal(data)
  38733. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38734. resp, _ := client.Do(req)
  38735. defer resp.Body.Close()
  38736. body, ioErr := ioutil.ReadAll(resp.Body)
  38737. if ioErr != nil {
  38738. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38740. return
  38741. }
  38742. var respJSON map[string]interface{}
  38743. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38744. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38746. return
  38747. }
  38748. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38749. userJSONBytes, _ := json.Marshal(respJSON)
  38750. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38751. utils.ErrorLog("解析失败:%v", err)
  38752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38753. return
  38754. }
  38755. }
  38756. if miConfig.MdtrtareaAdmvs == "421182" {
  38757. data := make(map[string]interface{})
  38758. data["bps"] = bp
  38759. data["org_name"] = miConfig.OrgName
  38760. data["doctor"] = role.UserName
  38761. data["fixmedins_code"] = miConfig.Code
  38762. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38763. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38764. data["page"] = strconv.FormatInt(page, 10)
  38765. data["limit"] = strconv.FormatInt(limit, 10)
  38766. fmt.Println(data)
  38767. client := &http.Client{}
  38768. bytesData, _ := json.Marshal(data)
  38769. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38770. resp, _ := client.Do(req)
  38771. defer resp.Body.Close()
  38772. body, ioErr := ioutil.ReadAll(resp.Body)
  38773. if ioErr != nil {
  38774. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38776. return
  38777. }
  38778. var respJSON map[string]interface{}
  38779. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38780. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38782. return
  38783. }
  38784. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38785. userJSONBytes, _ := json.Marshal(respJSON)
  38786. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38787. utils.ErrorLog("解析失败:%v", err)
  38788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38789. return
  38790. }
  38791. }
  38792. if miConfig.MdtrtareaAdmvs == "420902" {
  38793. data := make(map[string]interface{})
  38794. data["bps"] = bp
  38795. data["org_name"] = miConfig.OrgName
  38796. data["doctor"] = role.UserName
  38797. data["fixmedins_code"] = miConfig.Code
  38798. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38799. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38800. data["page"] = strconv.FormatInt(page, 10)
  38801. data["limit"] = strconv.FormatInt(limit, 10)
  38802. fmt.Println(data)
  38803. client := &http.Client{}
  38804. bytesData, _ := json.Marshal(data)
  38805. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38806. resp, _ := client.Do(req)
  38807. defer resp.Body.Close()
  38808. body, ioErr := ioutil.ReadAll(resp.Body)
  38809. if ioErr != nil {
  38810. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38812. return
  38813. }
  38814. var respJSON map[string]interface{}
  38815. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38816. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38818. return
  38819. }
  38820. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38821. userJSONBytes, _ := json.Marshal(respJSON)
  38822. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38823. utils.ErrorLog("解析失败:%v", err)
  38824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38825. return
  38826. }
  38827. }
  38828. if res.Infcode == 0 {
  38829. c.ServeSuccessJSON(map[string]interface{}{
  38830. "order": res.Output.Result,
  38831. "total": res.Output.PageInfo.RecordCounts,
  38832. })
  38833. } else {
  38834. c.ServeSuccessJSON(map[string]interface{}{
  38835. "failed_code": -10,
  38836. "msg": res.ErrMsg,
  38837. })
  38838. }
  38839. }
  38840. }
  38841. // 5.11.1.2【5267】异地结算信息时间段查询
  38842. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38843. admin_user_id, _ := c.GetInt64("admin_user_id")
  38844. adminUser := c.GetAdminUserInfo()
  38845. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38846. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38847. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38848. var res Result5267
  38849. if config.IsOpen == 1 {
  38850. if miConfig.MdtrtareaAdmvs == "421300" {
  38851. data := make(map[string]interface{})
  38852. data["bps"] = bp
  38853. data["org_name"] = miConfig.OrgName
  38854. data["doctor"] = role.UserName
  38855. data["fixmedins_code"] = miConfig.Code
  38856. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38857. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38858. data["page"] = page
  38859. data["limit"] = limit
  38860. fmt.Println(data)
  38861. client := &http.Client{}
  38862. bytesData, _ := json.Marshal(data)
  38863. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38864. resp, _ := client.Do(req)
  38865. defer resp.Body.Close()
  38866. body, ioErr := ioutil.ReadAll(resp.Body)
  38867. if ioErr != nil {
  38868. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38870. return
  38871. }
  38872. var respJSON map[string]interface{}
  38873. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38874. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38876. return
  38877. }
  38878. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38879. userJSONBytes, _ := json.Marshal(respJSON)
  38880. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38881. utils.ErrorLog("解析失败:%v", err)
  38882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38883. return
  38884. }
  38885. }
  38886. if miConfig.MdtrtareaAdmvs == "420200" {
  38887. data := make(map[string]interface{})
  38888. data["bps"] = bp
  38889. data["org_name"] = miConfig.OrgName
  38890. data["doctor"] = role.UserName
  38891. data["fixmedins_code"] = miConfig.Code
  38892. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38893. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38894. data["page"] = page
  38895. data["limit"] = limit
  38896. fmt.Println(data)
  38897. client := &http.Client{}
  38898. bytesData, _ := json.Marshal(data)
  38899. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38900. resp, _ := client.Do(req)
  38901. defer resp.Body.Close()
  38902. body, ioErr := ioutil.ReadAll(resp.Body)
  38903. if ioErr != nil {
  38904. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38906. return
  38907. }
  38908. var respJSON map[string]interface{}
  38909. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38910. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38912. return
  38913. }
  38914. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38915. userJSONBytes, _ := json.Marshal(respJSON)
  38916. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38917. utils.ErrorLog("解析失败:%v", err)
  38918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38919. return
  38920. }
  38921. }
  38922. if miConfig.MdtrtareaAdmvs == "421182" {
  38923. data := make(map[string]interface{})
  38924. data["bps"] = bp
  38925. data["org_name"] = miConfig.OrgName
  38926. data["doctor"] = role.UserName
  38927. data["fixmedins_code"] = miConfig.Code
  38928. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38929. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38930. data["page"] = page
  38931. data["limit"] = limit
  38932. fmt.Println(data)
  38933. client := &http.Client{}
  38934. bytesData, _ := json.Marshal(data)
  38935. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  38936. resp, _ := client.Do(req)
  38937. defer resp.Body.Close()
  38938. body, ioErr := ioutil.ReadAll(resp.Body)
  38939. if ioErr != nil {
  38940. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38942. return
  38943. }
  38944. var respJSON map[string]interface{}
  38945. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38946. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38948. return
  38949. }
  38950. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38951. userJSONBytes, _ := json.Marshal(respJSON)
  38952. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38953. utils.ErrorLog("解析失败:%v", err)
  38954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38955. return
  38956. }
  38957. }
  38958. if res.Infcode == 0 {
  38959. c.ServeSuccessJSON(map[string]interface{}{
  38960. "order": res.Output.Result,
  38961. "total": res.Output.PageInfo.RecordCounts,
  38962. })
  38963. } else {
  38964. c.ServeSuccessJSON(map[string]interface{}{
  38965. "failed_code": -10,
  38966. "msg": res.ErrMsg,
  38967. })
  38968. }
  38969. }
  38970. }
  38971. func (c *HisApiController) Post3501() {
  38972. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38973. data := make(map[string]interface{})
  38974. var struct3501s []models.Struct3501
  38975. var struct3501 models.Struct3501
  38976. struct3501.OrgName = miConfig.OrgName
  38977. struct3501.AccessKey = miConfig.AccessKey
  38978. struct3501.RequestUrl = miConfig.Url
  38979. struct3501.SecretKey = miConfig.SecretKey
  38980. struct3501.ManuDate = "2022-08-17"
  38981. struct3501.FixmedinsBchno = ""
  38982. struct3501.ManuLotnum = ""
  38983. struct3501.RxFlag = "0"
  38984. struct3501.ExpyEnd = "2022-08-17"
  38985. struct3501.Invdate = "2022-08-17"
  38986. struct3501.InvCnt = "20.25"
  38987. struct3501.Memo = ""
  38988. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38989. struct3501.FixmedinsHilistId = miConfig.Code
  38990. struct3501.FixmedinsHilistName = miConfig.OrgName
  38991. struct3501s = append(struct3501s, struct3501)
  38992. data["struct_3501s"] = struct3501s
  38993. client := &http.Client{}
  38994. bytesData, _ := json.Marshal(data)
  38995. var req *http.Request
  38996. if miConfig.MdtrtareaAdmvs == "320921" {
  38997. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38998. } else {
  38999. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39000. }
  39001. resp, _ := client.Do(req)
  39002. defer resp.Body.Close()
  39003. body, ioErr := ioutil.ReadAll(resp.Body)
  39004. if ioErr != nil {
  39005. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39007. return
  39008. }
  39009. var respJSON map[string]interface{}
  39010. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39011. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39013. return
  39014. }
  39015. var res ResultSix
  39016. var resSix10265 ResultSix10265 //1101结果
  39017. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39018. result, _ := json.Marshal(respJSON)
  39019. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39020. utils.ErrorLog("解析失败:%v", err)
  39021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39022. return
  39023. }
  39024. res.InfRefmsgid = resSix10265.InfRefmsgid
  39025. res.Output = resSix10265.Output
  39026. res.ErrMsg = resSix10265.ErrMsg
  39027. res.Cainfo = resSix10265.Cainfo
  39028. res.WarnMsg = resSix10265.WarnMsg
  39029. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39030. res.Infcode = infocode
  39031. if infocode == 0 {
  39032. c.ServeSuccessJSON(map[string]interface{}{
  39033. "msg": "上传成功",
  39034. })
  39035. return
  39036. } else {
  39037. c.ServeSuccessJSON(map[string]interface{}{
  39038. "failed_code": -10,
  39039. "msg": res.ErrMsg,
  39040. })
  39041. return
  39042. }
  39043. }
  39044. func (c *HisApiController) Post3502() {
  39045. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39046. data := make(map[string]interface{})
  39047. var struct3502s []models.Struct3502
  39048. var struct3502 models.Struct3502
  39049. struct3502.OrgName = miConfig.OrgName
  39050. struct3502.AccessKey = miConfig.AccessKey
  39051. struct3502.RequestUrl = miConfig.Url
  39052. struct3502.SecretKey = miConfig.SecretKey
  39053. struct3502.ManuDate = "2022-08-15"
  39054. struct3502.FixmedinsBchno = ""
  39055. struct3502.ManuLotnum = ""
  39056. struct3502.RxFlag = "0"
  39057. struct3502.ExpyEnd = "2022-08-15"
  39058. struct3502.Invdate = "2022-08-15"
  39059. struct3502.InvCnt = "20.25"
  39060. struct3502.Memo = ""
  39061. struct3502.MedListCodg = "XB01ABD056B002020200517"
  39062. struct3502.FixmedinsHilistId = miConfig.Code
  39063. struct3502.FixmedinsHilistName = miConfig.OrgName
  39064. struct3502s = append(struct3502s, struct3502)
  39065. data["struct_3502s"] = struct3502s
  39066. client := &http.Client{}
  39067. bytesData, _ := json.Marshal(data)
  39068. var req *http.Request
  39069. if miConfig.MdtrtareaAdmvs == "320921" {
  39070. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39071. } else {
  39072. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39073. }
  39074. resp, _ := client.Do(req)
  39075. defer resp.Body.Close()
  39076. body, ioErr := ioutil.ReadAll(resp.Body)
  39077. if ioErr != nil {
  39078. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39080. return
  39081. }
  39082. var respJSON map[string]interface{}
  39083. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39084. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39086. return
  39087. }
  39088. var res ResultSix
  39089. var resSix10265 ResultSix10265 //1101结果
  39090. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39091. result, _ := json.Marshal(respJSON)
  39092. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39093. utils.ErrorLog("解析失败:%v", err)
  39094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39095. return
  39096. }
  39097. res.InfRefmsgid = resSix10265.InfRefmsgid
  39098. res.Output = resSix10265.Output
  39099. res.ErrMsg = resSix10265.ErrMsg
  39100. res.Cainfo = resSix10265.Cainfo
  39101. res.WarnMsg = resSix10265.WarnMsg
  39102. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39103. res.Infcode = infocode
  39104. if infocode == 0 {
  39105. c.ServeSuccessJSON(map[string]interface{}{
  39106. "msg": "上传成功",
  39107. })
  39108. return
  39109. } else {
  39110. c.ServeSuccessJSON(map[string]interface{}{
  39111. "failed_code": -10,
  39112. "msg": res.ErrMsg,
  39113. })
  39114. return
  39115. }
  39116. }
  39117. func (c *HisApiController) Post3503() {
  39118. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39119. data := make(map[string]interface{})
  39120. var struct3501s []models.Struct3501
  39121. var struct3501 models.Struct3501
  39122. struct3501.OrgName = miConfig.OrgName
  39123. struct3501.AccessKey = miConfig.AccessKey
  39124. struct3501.RequestUrl = miConfig.Url
  39125. struct3501.SecretKey = miConfig.SecretKey
  39126. struct3501.ManuDate = "2022-08-15"
  39127. struct3501.FixmedinsBchno = ""
  39128. struct3501.ManuLotnum = ""
  39129. struct3501.RxFlag = "0"
  39130. struct3501.ExpyEnd = "2022-08-15"
  39131. struct3501.Invdate = "2022-08-15"
  39132. struct3501.InvCnt = "20.25"
  39133. struct3501.Memo = ""
  39134. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39135. struct3501.FixmedinsHilistId = miConfig.Code
  39136. struct3501.FixmedinsHilistName = miConfig.OrgName
  39137. struct3501s = append(struct3501s, struct3501)
  39138. data["struct_3501s"] = struct3501s
  39139. client := &http.Client{}
  39140. bytesData, _ := json.Marshal(data)
  39141. var req *http.Request
  39142. if miConfig.MdtrtareaAdmvs == "320921" {
  39143. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39144. } else {
  39145. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39146. }
  39147. resp, _ := client.Do(req)
  39148. defer resp.Body.Close()
  39149. body, ioErr := ioutil.ReadAll(resp.Body)
  39150. if ioErr != nil {
  39151. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39153. return
  39154. }
  39155. var respJSON map[string]interface{}
  39156. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39159. return
  39160. }
  39161. var res ResultSix
  39162. var resSix10265 ResultSix10265 //1101结果
  39163. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39164. result, _ := json.Marshal(respJSON)
  39165. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39166. utils.ErrorLog("解析失败:%v", err)
  39167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39168. return
  39169. }
  39170. res.InfRefmsgid = resSix10265.InfRefmsgid
  39171. res.Output = resSix10265.Output
  39172. res.ErrMsg = resSix10265.ErrMsg
  39173. res.Cainfo = resSix10265.Cainfo
  39174. res.WarnMsg = resSix10265.WarnMsg
  39175. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39176. res.Infcode = infocode
  39177. if infocode == 0 {
  39178. c.ServeSuccessJSON(map[string]interface{}{
  39179. "msg": "上传成功",
  39180. })
  39181. return
  39182. } else {
  39183. c.ServeSuccessJSON(map[string]interface{}{
  39184. "failed_code": -10,
  39185. "msg": res.ErrMsg,
  39186. })
  39187. return
  39188. }
  39189. }
  39190. func (c *HisApiController) Post3504() {
  39191. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39192. data := make(map[string]interface{})
  39193. var struct3501s []models.Struct3501
  39194. var struct3501 models.Struct3501
  39195. struct3501.OrgName = miConfig.OrgName
  39196. struct3501.AccessKey = miConfig.AccessKey
  39197. struct3501.RequestUrl = miConfig.Url
  39198. struct3501.SecretKey = miConfig.SecretKey
  39199. struct3501.ManuDate = "2022-08-15"
  39200. struct3501.FixmedinsBchno = ""
  39201. struct3501.ManuLotnum = ""
  39202. struct3501.RxFlag = "0"
  39203. struct3501.ExpyEnd = "2022-08-15"
  39204. struct3501.Invdate = "2022-08-15"
  39205. struct3501.InvCnt = "20.25"
  39206. struct3501.Memo = ""
  39207. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39208. struct3501.FixmedinsHilistId = miConfig.Code
  39209. struct3501.FixmedinsHilistName = miConfig.OrgName
  39210. struct3501s = append(struct3501s, struct3501)
  39211. data["struct_3501s"] = struct3501s
  39212. client := &http.Client{}
  39213. bytesData, _ := json.Marshal(data)
  39214. var req *http.Request
  39215. if miConfig.MdtrtareaAdmvs == "320921" {
  39216. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39217. } else {
  39218. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39219. }
  39220. resp, _ := client.Do(req)
  39221. defer resp.Body.Close()
  39222. body, ioErr := ioutil.ReadAll(resp.Body)
  39223. if ioErr != nil {
  39224. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39226. return
  39227. }
  39228. var respJSON map[string]interface{}
  39229. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39230. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39232. return
  39233. }
  39234. var res ResultSix
  39235. var resSix10265 ResultSix10265 //1101结果
  39236. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39237. result, _ := json.Marshal(respJSON)
  39238. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39239. utils.ErrorLog("解析失败:%v", err)
  39240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39241. return
  39242. }
  39243. res.InfRefmsgid = resSix10265.InfRefmsgid
  39244. res.Output = resSix10265.Output
  39245. res.ErrMsg = resSix10265.ErrMsg
  39246. res.Cainfo = resSix10265.Cainfo
  39247. res.WarnMsg = resSix10265.WarnMsg
  39248. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39249. res.Infcode = infocode
  39250. if infocode == 0 {
  39251. c.ServeSuccessJSON(map[string]interface{}{
  39252. "msg": "上传成功",
  39253. })
  39254. return
  39255. } else {
  39256. c.ServeSuccessJSON(map[string]interface{}{
  39257. "failed_code": -10,
  39258. "msg": res.ErrMsg,
  39259. })
  39260. return
  39261. }
  39262. }
  39263. func (c *HisApiController) Post3505() {
  39264. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39265. data := make(map[string]interface{})
  39266. var struct3501s []models.Struct3501
  39267. var struct3501 models.Struct3501
  39268. struct3501.OrgName = miConfig.OrgName
  39269. struct3501.AccessKey = miConfig.AccessKey
  39270. struct3501.RequestUrl = miConfig.Url
  39271. struct3501.SecretKey = miConfig.SecretKey
  39272. struct3501.ManuDate = "2022-08-15"
  39273. struct3501.FixmedinsBchno = ""
  39274. struct3501.ManuLotnum = ""
  39275. struct3501.RxFlag = "0"
  39276. struct3501.ExpyEnd = "2022-08-15"
  39277. struct3501.Invdate = "2022-08-15"
  39278. struct3501.InvCnt = "20.25"
  39279. struct3501.Memo = ""
  39280. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39281. struct3501.FixmedinsHilistId = miConfig.Code
  39282. struct3501.FixmedinsHilistName = miConfig.OrgName
  39283. struct3501s = append(struct3501s, struct3501)
  39284. data["struct_3501s"] = struct3501s
  39285. client := &http.Client{}
  39286. bytesData, _ := json.Marshal(data)
  39287. var req *http.Request
  39288. if miConfig.MdtrtareaAdmvs == "320921" {
  39289. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39290. } else {
  39291. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39292. }
  39293. resp, _ := client.Do(req)
  39294. defer resp.Body.Close()
  39295. body, ioErr := ioutil.ReadAll(resp.Body)
  39296. if ioErr != nil {
  39297. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39299. return
  39300. }
  39301. var respJSON map[string]interface{}
  39302. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39305. return
  39306. }
  39307. var res ResultSix
  39308. var resSix10265 ResultSix10265 //1101结果
  39309. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39310. result, _ := json.Marshal(respJSON)
  39311. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39312. utils.ErrorLog("解析失败:%v", err)
  39313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39314. return
  39315. }
  39316. res.InfRefmsgid = resSix10265.InfRefmsgid
  39317. res.Output = resSix10265.Output
  39318. res.ErrMsg = resSix10265.ErrMsg
  39319. res.Cainfo = resSix10265.Cainfo
  39320. res.WarnMsg = resSix10265.WarnMsg
  39321. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39322. res.Infcode = infocode
  39323. if infocode == 0 {
  39324. c.ServeSuccessJSON(map[string]interface{}{
  39325. "msg": "上传成功",
  39326. })
  39327. return
  39328. } else {
  39329. c.ServeSuccessJSON(map[string]interface{}{
  39330. "failed_code": -10,
  39331. "msg": res.ErrMsg,
  39332. })
  39333. return
  39334. }
  39335. }
  39336. func (c *HisApiController) Post3506() {
  39337. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39338. data := make(map[string]interface{})
  39339. var struct3501s []models.Struct3501
  39340. var struct3501 models.Struct3501
  39341. struct3501.OrgName = miConfig.OrgName
  39342. struct3501.AccessKey = miConfig.AccessKey
  39343. struct3501.RequestUrl = miConfig.Url
  39344. struct3501.SecretKey = miConfig.SecretKey
  39345. struct3501.ManuDate = "2022-08-15"
  39346. struct3501.FixmedinsBchno = ""
  39347. struct3501.ManuLotnum = ""
  39348. struct3501.RxFlag = "0"
  39349. struct3501.ExpyEnd = "2022-08-15"
  39350. struct3501.Invdate = "2022-08-15"
  39351. struct3501.InvCnt = "20.25"
  39352. struct3501.Memo = ""
  39353. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39354. struct3501.FixmedinsHilistId = miConfig.Code
  39355. struct3501.FixmedinsHilistName = miConfig.OrgName
  39356. struct3501s = append(struct3501s, struct3501)
  39357. data["struct_3501s"] = struct3501s
  39358. client := &http.Client{}
  39359. bytesData, _ := json.Marshal(data)
  39360. var req *http.Request
  39361. if miConfig.MdtrtareaAdmvs == "320921" {
  39362. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39363. } else {
  39364. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39365. }
  39366. resp, _ := client.Do(req)
  39367. defer resp.Body.Close()
  39368. body, ioErr := ioutil.ReadAll(resp.Body)
  39369. if ioErr != nil {
  39370. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39372. return
  39373. }
  39374. var respJSON map[string]interface{}
  39375. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39376. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39378. return
  39379. }
  39380. var res ResultSix
  39381. var resSix10265 ResultSix10265 //1101结果
  39382. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39383. result, _ := json.Marshal(respJSON)
  39384. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39385. utils.ErrorLog("解析失败:%v", err)
  39386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39387. return
  39388. }
  39389. res.InfRefmsgid = resSix10265.InfRefmsgid
  39390. res.Output = resSix10265.Output
  39391. res.ErrMsg = resSix10265.ErrMsg
  39392. res.Cainfo = resSix10265.Cainfo
  39393. res.WarnMsg = resSix10265.WarnMsg
  39394. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39395. res.Infcode = infocode
  39396. if infocode == 0 {
  39397. c.ServeSuccessJSON(map[string]interface{}{
  39398. "msg": "上传成功",
  39399. })
  39400. return
  39401. } else {
  39402. c.ServeSuccessJSON(map[string]interface{}{
  39403. "failed_code": -10,
  39404. "msg": res.ErrMsg,
  39405. })
  39406. return
  39407. }
  39408. }
  39409. func (c *HisApiController) Post3507() {
  39410. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39411. data := make(map[string]interface{})
  39412. var struct3501s []models.Struct3501
  39413. var struct3501 models.Struct3501
  39414. struct3501.OrgName = miConfig.OrgName
  39415. struct3501.AccessKey = miConfig.AccessKey
  39416. struct3501.RequestUrl = miConfig.Url
  39417. struct3501.SecretKey = miConfig.SecretKey
  39418. struct3501.ManuDate = "2022-08-15"
  39419. struct3501.FixmedinsBchno = ""
  39420. struct3501.ManuLotnum = ""
  39421. struct3501.RxFlag = "0"
  39422. struct3501.ExpyEnd = "2022-08-15"
  39423. struct3501.Invdate = "2022-08-15"
  39424. struct3501.InvCnt = "20.25"
  39425. struct3501.Memo = ""
  39426. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39427. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  39428. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  39429. struct3501s = append(struct3501s, struct3501)
  39430. data["struct_3501s"] = struct3501s
  39431. client := &http.Client{}
  39432. bytesData, _ := json.Marshal(data)
  39433. var req *http.Request
  39434. if miConfig.MdtrtareaAdmvs == "320921" {
  39435. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39436. } else {
  39437. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39438. }
  39439. resp, _ := client.Do(req)
  39440. defer resp.Body.Close()
  39441. body, ioErr := ioutil.ReadAll(resp.Body)
  39442. if ioErr != nil {
  39443. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39445. return
  39446. }
  39447. var respJSON map[string]interface{}
  39448. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39449. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39451. return
  39452. }
  39453. var res ResultSix
  39454. var resSix10265 ResultSix10265 //1101结果
  39455. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39456. result, _ := json.Marshal(respJSON)
  39457. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39458. utils.ErrorLog("解析失败:%v", err)
  39459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39460. return
  39461. }
  39462. res.InfRefmsgid = resSix10265.InfRefmsgid
  39463. res.Output = resSix10265.Output
  39464. res.ErrMsg = resSix10265.ErrMsg
  39465. res.Cainfo = resSix10265.Cainfo
  39466. res.WarnMsg = resSix10265.WarnMsg
  39467. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39468. res.Infcode = infocode
  39469. if infocode == 0 {
  39470. c.ServeSuccessJSON(map[string]interface{}{
  39471. "msg": "上传成功",
  39472. })
  39473. return
  39474. } else {
  39475. c.ServeSuccessJSON(map[string]interface{}{
  39476. "failed_code": -10,
  39477. "msg": res.ErrMsg,
  39478. })
  39479. return
  39480. }
  39481. }
  39482. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39483. // WebSocket服务器地址
  39484. serverURL := "ws://127.0.0.1:8899"
  39485. // 解析WebSocket服务器地址
  39486. u, err := url.Parse(serverURL)
  39487. if err != nil {
  39488. }
  39489. // 建立WebSocket连接
  39490. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39491. if err != nil {
  39492. }
  39493. defer conn.Close()
  39494. input2 := make(map[string]interface{})
  39495. input := make(map[string]interface{})
  39496. inputData := make(map[string]interface{})
  39497. inputData["orgId"] = code
  39498. inputData["businessType"] = "01101"
  39499. inputData["operatorId"] = operator_id
  39500. inputData["operatorName"] = operator_name
  39501. inputData["officeId"] = "001"
  39502. inputData["officeName"] = "血透室"
  39503. inputData["deviceType"] = ""
  39504. input["data"] = inputData
  39505. input["orgId"] = code
  39506. input["transType"] = "ec.query"
  39507. //if md == ""
  39508. if md[:4] == "4403" {
  39509. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39510. } else if md[:4] == "4401" {
  39511. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39512. } else {
  39513. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39514. }
  39515. input2["indata"] = input
  39516. fmt.Println(input2)
  39517. bytesData, _ := json.Marshal(input2)
  39518. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39519. if err != nil {
  39520. fmt.Println(err)
  39521. }
  39522. // 接收消息
  39523. _, receivedMessage, err := conn.ReadMessage()
  39524. if err != nil {
  39525. fmt.Println(err)
  39526. }
  39527. return "", string(receivedMessage)
  39528. }
  39529. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  39530. // WebSocket服务器地址
  39531. serverURL := "ws://127.0.0.1:8899"
  39532. // 解析WebSocket服务器地址
  39533. u, err := url.Parse(serverURL)
  39534. if err != nil {
  39535. }
  39536. // 建立WebSocket连接
  39537. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39538. if err != nil {
  39539. }
  39540. defer conn.Close()
  39541. input2 := make(map[string]interface{})
  39542. input := make(map[string]interface{})
  39543. inputData := make(map[string]interface{})
  39544. inputData["orgId"] = code
  39545. inputData["businessType"] = "01101"
  39546. inputData["operatorId"] = operator_id
  39547. inputData["operatorName"] = operator_name
  39548. inputData["officeId"] = "001"
  39549. inputData["officeName"] = "血透室"
  39550. inputData["deviceType"] = ""
  39551. input["data"] = inputData
  39552. input["orgId"] = code
  39553. input["transType"] = "ec.query"
  39554. //if md == ""
  39555. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39556. input2["indata"] = input
  39557. fmt.Println(input2)
  39558. bytesData, _ := json.Marshal(input2)
  39559. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39560. if err != nil {
  39561. fmt.Println(err)
  39562. }
  39563. // 接收消息
  39564. _, receivedMessage, err := conn.ReadMessage()
  39565. if err != nil {
  39566. fmt.Println(err)
  39567. }
  39568. return "", string(receivedMessage)
  39569. }
  39570. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  39571. // WebSocket服务器地址
  39572. serverURL := "ws://127.0.0.1:8899"
  39573. // 解析WebSocket服务器地址
  39574. u, err := url.Parse(serverURL)
  39575. if err != nil {
  39576. }
  39577. // 建立WebSocket连接
  39578. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39579. if err != nil {
  39580. }
  39581. defer conn.Close()
  39582. input2 := make(map[string]interface{})
  39583. input := make(map[string]interface{})
  39584. inputData := make(map[string]interface{})
  39585. inputData["orgId"] = code
  39586. inputData["businessType"] = "01301"
  39587. inputData["operatorId"] = operator_id
  39588. inputData["operatorName"] = operator_name
  39589. inputData["officeId"] = "001"
  39590. inputData["officeName"] = "血透室"
  39591. inputData["deviceType"] = ""
  39592. input["data"] = inputData
  39593. input["orgId"] = code
  39594. input["transType"] = "ec.query"
  39595. //if md == ""
  39596. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39597. input2["indata"] = input
  39598. fmt.Println(input2)
  39599. bytesData, _ := json.Marshal(input2)
  39600. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39601. if err != nil {
  39602. fmt.Println(err)
  39603. }
  39604. // 接收消息
  39605. _, receivedMessage, err := conn.ReadMessage()
  39606. if err != nil {
  39607. fmt.Println(err)
  39608. }
  39609. return "", string(receivedMessage)
  39610. }
  39611. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  39612. // WebSocket服务器地址
  39613. serverURL := "ws://127.0.0.1:8899"
  39614. // 解析WebSocket服务器地址
  39615. u, err := url.Parse(serverURL)
  39616. if err != nil {
  39617. }
  39618. // 建立WebSocket连接
  39619. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39620. if err != nil {
  39621. }
  39622. defer conn.Close()
  39623. input2 := make(map[string]interface{})
  39624. input := make(map[string]interface{})
  39625. inputData := make(map[string]interface{})
  39626. inputData["orgId"] = code
  39627. inputData["businessType"] = "01103"
  39628. inputData["operatorId"] = operator_id
  39629. inputData["operatorName"] = operator_name
  39630. inputData["officeId"] = "001"
  39631. inputData["officeName"] = "血透室"
  39632. inputData["deviceType"] = ""
  39633. input["data"] = inputData
  39634. input["orgId"] = code
  39635. input["transType"] = "ec.query"
  39636. //if md ==
  39637. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  39638. input2["indata"] = input
  39639. fmt.Println(input2)
  39640. bytesData, _ := json.Marshal(input2)
  39641. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39642. if err != nil {
  39643. fmt.Println(err)
  39644. }
  39645. // 接收消息
  39646. _, receivedMessage, err := conn.ReadMessage()
  39647. if err != nil {
  39648. fmt.Println(err)
  39649. }
  39650. return "", string(receivedMessage)
  39651. }
  39652. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39653. // WebSocket服务器地址
  39654. serverURL := "ws://127.0.0.1:8899"
  39655. // 解析WebSocket服务器地址
  39656. u, err := url.Parse(serverURL)
  39657. if err != nil {
  39658. }
  39659. // 建立WebSocket连接
  39660. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39661. if err != nil {
  39662. }
  39663. defer conn.Close()
  39664. input2 := make(map[string]interface{})
  39665. input := make(map[string]interface{})
  39666. inputData := make(map[string]interface{})
  39667. inputData["orgId"] = code
  39668. inputData["businessType"] = "01101"
  39669. inputData["operatorId"] = operator_id
  39670. inputData["operatorName"] = operator_name
  39671. inputData["officeId"] = "001"
  39672. inputData["officeName"] = "血透室"
  39673. inputData["deviceType"] = ""
  39674. input["data"] = inputData
  39675. input["orgId"] = code
  39676. input["transType"] = "ec.query"
  39677. //if md == ""
  39678. if md[:4] == "4403" {
  39679. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39680. } else if md[:4] == "4401" {
  39681. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39682. } else {
  39683. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39684. }
  39685. input2["indata"] = input
  39686. fmt.Println(input2)
  39687. bytesData, _ := json.Marshal(input2)
  39688. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39689. if err != nil {
  39690. fmt.Println(err)
  39691. }
  39692. // 接收消息
  39693. _, receivedMessage, err := conn.ReadMessage()
  39694. if err != nil {
  39695. fmt.Println(err)
  39696. }
  39697. return "", string(receivedMessage)
  39698. }
  39699. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  39700. // WebSocket服务器地址
  39701. serverURL := "ws://127.0.0.1:8899"
  39702. // 解析WebSocket服务器地址
  39703. u, err := url.Parse(serverURL)
  39704. if err != nil {
  39705. }
  39706. // 建立WebSocket连接
  39707. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39708. if err != nil {
  39709. }
  39710. defer conn.Close()
  39711. input2 := make(map[string]interface{})
  39712. input := make(map[string]interface{})
  39713. inputData := make(map[string]interface{})
  39714. inputData["orgId"] = code
  39715. inputData["businessType"] = "01301"
  39716. inputData["operatorId"] = operator_id
  39717. inputData["operatorName"] = operator_name
  39718. inputData["officeId"] = "001"
  39719. inputData["officeName"] = "血透室"
  39720. inputData["deviceType"] = ""
  39721. input["data"] = inputData
  39722. input["orgId"] = code
  39723. input["transType"] = "ec.query"
  39724. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39725. input2["indata"] = input
  39726. bytesData, _ := json.Marshal(input2)
  39727. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39728. if err != nil {
  39729. fmt.Println(err)
  39730. }
  39731. // 接收消息
  39732. _, receivedMessage, err := conn.ReadMessage()
  39733. if err != nil {
  39734. fmt.Println(err)
  39735. }
  39736. return "", string(receivedMessage)
  39737. }
  39738. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  39739. newArr = make([]string, 0)
  39740. for i := 0; i < len(arr); i++ {
  39741. repeat := false
  39742. for j := i + 1; j < len(arr); j++ {
  39743. if arr[i] == arr[j] {
  39744. repeat = true
  39745. break
  39746. }
  39747. }
  39748. if !repeat {
  39749. newArr = append(newArr, arr[i])
  39750. }
  39751. }
  39752. return
  39753. }
  39754. func getBirthdateAndAge(idNumber string) (string, int, error) {
  39755. if len(idNumber) != 18 {
  39756. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  39757. }
  39758. // 提取出生日期
  39759. year, err := strconv.Atoi(idNumber[6:10])
  39760. if err != nil {
  39761. return "", 0, err
  39762. }
  39763. month, err := strconv.Atoi(idNumber[10:12])
  39764. if err != nil {
  39765. return "", 0, err
  39766. }
  39767. day, err := strconv.Atoi(idNumber[12:14])
  39768. if err != nil {
  39769. return "", 0, err
  39770. }
  39771. // 格式化生日字符串
  39772. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  39773. birthdateFormatted := birthdate.Format("2006-01-02")
  39774. // 计算年龄
  39775. today := time.Now()
  39776. age := today.Year() - birthdate.Year()
  39777. if today.YearDay() < birthdate.YearDay() {
  39778. age--
  39779. }
  39780. return birthdateFormatted, age, nil
  39781. }
  39782. // 从身份证号码中提取出生年月日
  39783. func getBirthDateFromIDCard(idCard string) (string, error) {
  39784. // 身份证号码长度应为18位
  39785. if len(idCard) != 18 {
  39786. return "", fmt.Errorf("身份证号码长度应为18位")
  39787. }
  39788. // 提取出生日期部分 (YYYYMMDD)
  39789. birthDateStr := idCard[6:14]
  39790. // 解析出生日期
  39791. birthDate, err := time.Parse("20060102", birthDateStr)
  39792. if err != nil {
  39793. return "", fmt.Errorf("解析出生日期失败: %v", err)
  39794. }
  39795. // 格式化出生日期为 YYYY-MM-DD
  39796. formattedDate := birthDate.Format("2006-01-02")
  39797. return formattedDate, nil
  39798. }